The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2163 lines
108KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. // This byte-code is generated from native/java/com/rmsl/juce/ComponentPeerView.java with min sdk version 16
  21. // See juce_core/native/java/README.txt on how to generate this byte-code.
  22. static const uint8 javaComponentPeerView[] =
  23. {31,139,8,8,212,138,183,97,0,3,74,97,118,97,68,101,120,66,121,116,101,67,111,100,101,46,100,101,120,0,165,155,11,120,84,213,181,
  24. 199,215,62,231,204,76,50,153,36,147,73,72,2,36,100,18,2,132,144,48,147,132,231,77,144,71,0,77,8,15,73,64,9,180,50,73,38,201,
  25. 192,228,204,48,51,121,160,237,173,40,21,172,214,71,11,62,177,190,253,188,109,109,109,171,94,63,31,183,180,246,179,253,20,253,
  26. 192,226,163,214,182,86,189,214,7,229,34,31,90,175,181,114,255,107,159,61,147,9,143,210,246,134,239,55,107,157,181,223,123,175,
  27. 189,246,62,19,210,19,28,113,250,27,102,211,219,117,91,222,126,241,223,63,156,100,111,184,247,80,238,157,199,91,61,254,101,3,
  28. 151,60,183,166,252,189,89,68,81,34,26,89,63,203,67,234,167,18,182,50,97,217,231,129,35,6,81,51,228,1,27,81,49,228,177,12,162,
  29. 203,32,31,206,36,66,18,237,206,38,122,115,42,81,70,14,209,75,165,68,135,193,171,224,117,240,22,120,23,124,1,196,36,34,27,200,0,
  30. 46,224,6,249,160,8,204,1,171,193,90,176,30,116,130,47,131,110,208,15,6,192,215,193,147,224,21,240,17,215,81,70,84,3,218,192,48,
  31. 184,17,124,23,252,20,188,12,142,2,167,151,104,54,104,5,61,96,31,120,26,28,3,149,229,68,155,192,181,224,39,224,15,32,167,2,253,
  32. 0,55,131,151,192,199,96,252,100,162,249,96,19,184,12,236,5,15,130,3,224,56,112,84,18,85,131,243,192,151,192,54,112,23,120,10,
  33. 252,26,188,3,62,1,159,3,231,20,162,108,144,7,138,65,9,168,4,213,160,14,204,5,77,96,17,88,6,90,193,106,176,14,108,0,1,208,3,66,
  34. 32,2,18,224,50,176,3,124,29,124,3,124,11,220,10,238,0,119,131,71,193,115,224,21,240,22,56,10,62,3,118,172,153,7,76,2,213,96,14,
  35. 104,6,107,65,63,136,130,175,130,93,224,30,240,16,120,24,60,3,158,7,191,6,191,5,239,128,15,193,167,192,54,141,104,28,168,4,181,
  36. 96,22,184,16,92,4,58,65,0,92,9,174,3,123,193,189,224,97,240,2,248,16,124,2,178,171,48,47,96,42,168,7,139,192,10,176,25,12,130,
  37. 43,193,117,224,78,240,16,120,12,252,20,28,0,191,7,71,129,62,29,99,3,21,96,17,88,14,218,192,106,176,25,196,192,78,240,109,112,
  38. 23,120,12,252,18,188,6,254,4,78,128,204,106,248,39,168,1,115,64,19,88,8,86,128,53,32,0,162,96,7,184,22,220,6,238,3,223,7,143,
  39. 131,159,131,223,129,247,192,71,192,57,3,190,4,188,192,7,102,131,5,96,25,184,0,172,2,23,129,0,136,128,97,240,85,112,37,184,9,
  40. 124,15,60,13,14,130,63,3,170,65,255,64,13,152,5,154,65,59,8,128,48,184,12,236,4,215,129,59,192,247,192,79,192,83,224,89,240,2,
  41. 248,13,120,15,252,15,200,169,133,95,130,9,224,60,176,9,116,131,126,48,2,174,2,119,130,31,130,167,193,171,224,40,200,154,9,95,6,
  42. 211,64,3,104,6,23,130,205,32,10,190,6,110,5,119,130,251,193,67,224,81,240,36,216,15,158,5,7,193,175,193,235,224,109,240,62,248,
  43. 12,216,124,136,15,96,42,168,7,179,193,60,208,4,22,129,165,224,2,208,6,236,152,18,132,38,202,2,133,160,136,172,120,53,30,76,0,
  44. 19,65,9,64,40,34,132,15,66,120,32,132,1,194,182,39,108,115,154,204,177,15,96,107,16,92,153,224,138,4,87,34,184,2,97,249,72,77,
  45. 57,97,200,132,174,17,154,36,63,168,3,245,160,1,32,116,210,108,48,7,204,85,241,115,62,248,55,208,8,154,192,2,112,30,88,8,22,129,
  46. 197,96,9,89,49,118,25,184,0,92,12,186,64,55,232,1,65,178,198,151,252,113,40,89,83,98,141,89,168,103,167,210,217,206,243,160,41,
  47. 187,75,233,179,96,207,77,171,203,163,230,172,73,217,115,148,61,87,165,37,245,113,74,119,171,121,229,250,243,149,190,84,149,45,
  48. 78,171,147,231,186,173,196,210,121,142,59,84,158,169,105,245,76,87,245,228,41,125,19,244,2,165,247,148,88,109,242,156,135,85,
  49. 61,172,39,84,61,181,170,158,113,106,29,190,162,250,195,107,177,179,196,154,195,122,149,167,69,233,220,86,171,210,175,133,190,
  50. 66,233,220,110,155,210,111,129,190,82,233,15,66,95,165,244,71,160,175,86,250,126,232,107,148,126,0,250,133,74,63,12,189,93,233,
  51. 111,164,217,223,73,211,143,64,95,167,244,19,105,118,118,202,164,158,145,166,187,75,71,235,44,78,179,123,161,119,40,189,42,205,
  52. 94,146,86,39,207,249,90,165,247,164,245,205,159,150,159,231,115,189,210,231,193,126,145,210,23,165,229,89,147,166,95,92,106,
  53. 249,102,131,154,219,13,74,223,12,123,167,210,251,211,244,4,244,141,74,191,28,250,38,165,239,134,254,37,165,239,129,126,137,210,
  54. 239,130,254,101,165,63,152,102,103,31,219,172,244,135,97,15,40,125,127,90,254,3,165,236,231,130,182,147,37,179,4,239,251,41,20,
  55. 39,75,62,42,165,160,199,149,124,66,201,39,149,124,74,201,167,85,254,95,201,101,241,82,134,176,100,158,224,184,209,64,191,36,
  56. 150,101,148,41,56,134,88,233,101,42,189,12,41,5,130,125,190,144,182,241,58,97,215,61,38,101,25,61,43,101,41,29,146,178,129,254,
  57. 36,101,22,125,32,125,126,42,45,135,180,33,2,125,68,188,63,237,116,131,148,227,232,78,200,76,68,49,93,202,89,116,130,120,159,87,
  58. 201,231,44,101,207,66,68,248,88,142,219,122,206,69,187,215,75,89,72,55,170,231,91,148,188,139,253,74,165,187,113,131,219,163,
  59. 158,111,147,82,167,219,201,218,159,251,148,188,67,74,65,247,43,249,0,241,126,212,104,175,148,211,233,62,226,189,55,69,182,155,
  60. 143,72,247,71,41,231,211,91,82,78,164,255,38,222,167,181,52,168,228,113,226,248,60,135,158,33,142,31,46,122,73,202,241,116,140,
  61. 125,92,245,127,60,34,45,203,18,68,203,71,164,172,166,79,165,92,72,154,92,15,191,76,47,197,200,119,74,89,76,187,213,243,213,82,
  62. 206,163,35,114,157,102,202,124,147,80,227,31,136,215,199,42,87,6,123,175,146,125,82,230,82,191,148,104,95,88,210,144,235,56,85,
  63. 230,247,98,101,66,82,250,104,139,148,139,105,171,148,249,20,86,114,64,202,69,100,74,57,158,70,148,252,170,148,115,105,135,148,
  64. 229,116,141,148,30,250,166,148,217,116,157,148,118,250,182,242,151,189,42,253,38,41,103,211,205,82,102,210,119,164,116,210,221,
  65. 42,223,61,82,102,208,189,82,90,235,224,197,12,61,168,228,127,40,249,93,229,127,223,147,114,18,125,95,217,31,82,254,248,3,37,
  66. 127,168,228,195,82,122,233,71,82,54,210,143,165,156,67,63,87,242,23,82,78,166,151,165,172,160,87,148,124,85,201,215,84,250,111,
  67. 212,243,235,74,254,86,202,28,122,67,202,105,244,59,41,107,232,247,82,158,71,111,74,105,249,143,87,249,15,63,191,173,246,203,59,
  68. 82,90,254,196,249,223,149,178,137,142,74,89,79,159,40,249,23,41,103,208,103,82,78,160,207,165,172,163,191,169,231,47,84,190,
  69. 147,74,146,176,210,133,176,230,197,35,248,156,42,162,91,137,229,18,250,153,220,159,26,253,84,202,60,114,11,62,139,44,63,157,
  70. 129,29,241,45,226,243,72,167,127,151,82,163,231,137,207,164,2,218,79,124,63,24,175,252,212,218,75,201,51,18,175,82,116,24,135,
  71. 228,7,234,144,154,164,236,124,198,113,12,231,244,35,72,207,84,129,182,76,149,159,145,86,254,115,164,151,168,116,47,89,231,40,
  72. 159,129,149,170,188,11,114,169,74,231,179,127,47,218,218,103,13,151,30,168,183,108,79,66,254,28,232,42,253,0,120,69,229,249,
  73. 131,180,235,82,95,237,179,238,9,27,133,147,162,110,110,109,163,150,133,181,204,64,45,220,86,167,207,186,43,121,68,71,151,147,
  74. 182,185,27,96,207,210,10,241,122,88,167,105,198,124,205,32,135,59,143,58,186,178,104,155,119,18,197,176,235,57,95,71,183,149,
  75. 87,167,44,99,219,154,217,180,100,208,169,205,215,254,124,210,116,243,120,29,238,170,63,25,170,253,168,186,223,85,96,70,163,238,
  76. 75,229,104,185,109,238,247,165,62,235,206,117,182,182,117,68,102,143,167,97,218,248,211,219,244,207,161,37,54,23,98,197,49,180,
  77. 201,231,132,83,152,222,169,136,78,46,81,245,238,233,185,231,202,220,85,239,115,188,53,100,127,110,240,89,107,215,17,181,242,
  78. 113,74,161,38,239,33,218,124,228,241,32,174,116,108,115,166,167,107,98,167,216,235,120,96,216,62,15,35,67,28,63,166,163,191,60,
  79. 198,125,62,142,239,152,89,79,54,198,56,8,155,135,54,185,93,242,78,150,129,39,30,235,253,62,235,108,205,183,23,80,133,230,66,62,
  80. 158,133,142,120,54,117,52,228,144,233,110,70,46,151,152,47,154,70,109,222,243,177,23,71,115,44,66,14,167,190,22,23,221,181,83,
  81. 4,253,168,227,70,210,141,217,155,39,208,186,56,230,65,47,36,143,190,9,90,50,127,71,34,27,253,246,97,36,46,131,251,111,200,121,
  82. 152,69,205,54,206,63,95,119,208,220,205,54,242,228,115,25,110,171,16,241,205,116,143,227,145,157,210,70,213,139,188,150,236,
  83. 115,7,125,214,29,110,163,39,71,141,179,2,115,24,245,86,195,195,55,186,65,126,174,28,179,144,255,136,222,244,89,223,51,68,221,
  84. 124,219,206,73,217,223,75,217,235,164,93,83,183,224,99,62,203,159,59,220,185,114,79,176,7,113,187,159,250,172,123,112,135,55,
  85. 23,125,92,202,59,132,58,202,221,232,245,68,180,156,147,202,119,242,172,249,74,100,190,28,120,60,143,196,142,238,28,96,191,115,
  86. 120,10,163,222,34,196,219,10,35,11,189,177,163,87,27,247,20,226,169,140,162,254,26,218,147,185,113,79,62,158,74,241,52,69,62,
  87. 21,160,222,133,88,107,151,49,193,22,69,189,88,65,232,101,70,33,202,229,81,137,97,131,45,134,120,238,52,230,25,95,162,50,39,63,
  88. 227,253,146,58,247,121,160,153,184,225,108,186,125,28,180,62,156,73,166,183,95,126,134,16,175,42,80,103,212,45,207,97,163,128,
  89. 38,47,158,69,83,5,223,0,77,175,129,158,119,112,159,108,216,191,94,27,113,141,14,180,234,209,77,247,144,234,201,255,146,103,234,
  90. 228,222,57,24,79,87,70,17,173,204,176,59,60,69,37,25,89,82,51,253,219,168,195,238,210,231,233,5,228,209,60,149,147,151,206,37,
  91. 143,109,155,59,129,121,112,217,87,218,13,155,103,156,71,74,211,191,157,190,109,176,167,177,119,243,168,172,222,239,161,170,187,
  92. 179,141,170,19,224,56,56,6,94,7,124,88,232,134,188,247,143,254,92,190,144,254,169,231,83,127,172,116,190,59,22,98,63,114,180,
  93. 224,123,139,166,87,221,42,166,221,44,102,238,21,90,205,29,162,250,118,65,42,186,224,158,234,183,124,166,221,235,145,113,214,
  94. 144,145,15,239,208,126,229,99,254,149,84,174,231,96,207,219,100,188,219,233,183,98,108,116,93,47,149,55,59,165,63,39,203,220,
  95. 152,76,243,47,70,25,151,244,193,100,218,109,169,180,5,169,52,135,188,237,17,221,171,210,134,236,107,101,100,224,58,109,106,223,
  96. 255,216,111,237,153,246,69,158,180,248,162,195,23,217,18,245,183,226,182,82,245,217,232,120,158,80,117,241,123,112,39,198,148,
  97. 163,250,192,63,251,253,86,236,247,184,115,83,123,230,57,127,114,207,20,200,62,37,237,7,149,125,29,246,116,174,178,115,202,43,
  98. 126,235,93,211,116,47,147,125,149,177,14,245,121,168,234,11,93,181,243,134,223,58,71,114,100,57,235,77,244,157,52,155,93,197,
  99. 239,15,207,49,182,11,212,216,146,249,79,156,35,127,75,106,46,172,126,252,237,12,253,176,213,157,110,115,165,217,12,213,86,126,
  100. 157,245,253,128,71,240,55,8,27,253,26,89,82,167,13,117,136,123,199,54,248,29,180,193,111,87,214,76,248,49,86,210,189,193,111,
  101. 32,61,3,251,113,60,250,83,78,94,145,167,198,203,107,82,81,103,157,213,103,238,127,199,146,66,138,174,189,144,140,11,171,62,101,
  102. 223,208,165,255,85,159,181,76,195,178,147,39,229,184,23,53,145,17,224,50,46,180,195,103,245,92,100,226,187,170,103,188,135,218,
  103. 239,65,57,62,17,133,102,204,195,25,222,113,119,30,214,174,148,215,14,167,133,78,28,233,178,177,87,156,25,166,59,7,50,203,254,
  104. 242,142,147,52,67,240,119,19,85,199,219,239,230,184,227,230,116,196,139,60,150,134,233,246,176,180,57,238,26,202,224,55,99,113,
  105. 67,213,239,207,149,111,149,149,239,185,115,229,91,99,229,227,23,39,97,200,239,58,120,14,120,61,248,254,196,223,193,56,241,196,
  106. 123,166,187,206,250,174,197,227,110,143,141,142,112,190,176,78,222,26,126,149,38,78,49,113,142,102,162,118,211,157,197,210,238,
  107. 216,38,118,14,217,87,96,252,85,127,142,248,139,105,87,38,78,226,247,76,247,124,180,86,197,23,77,205,154,247,228,247,71,44,243,
  108. 21,46,117,246,239,168,179,222,59,49,187,87,160,109,187,108,219,110,205,230,252,204,76,180,153,201,35,18,158,138,250,114,7,69,
  109. 22,141,167,91,158,64,43,199,77,183,19,118,151,152,39,248,166,99,233,166,119,152,215,194,198,53,113,31,179,184,143,59,196,30,
  110. 171,143,30,119,213,171,150,47,176,255,220,89,103,125,239,49,214,23,172,17,179,141,199,106,39,167,22,93,219,6,47,66,217,143,73,
  111. 69,24,162,135,210,124,60,83,197,178,39,149,111,69,46,158,64,29,67,233,181,206,67,155,214,158,138,98,79,113,153,92,229,91,7,144,
  112. 92,130,138,218,15,33,183,206,35,23,186,156,117,145,43,216,147,114,200,153,201,158,4,95,114,188,124,35,123,210,39,114,23,85,125,
  113. 212,254,146,7,146,87,127,146,92,245,60,206,107,227,213,207,225,49,31,98,47,193,136,243,170,222,56,119,206,53,86,206,95,158,59,
  114. 231,106,228,52,221,124,175,112,102,121,242,230,78,172,38,79,249,228,146,217,240,194,37,244,2,121,38,204,126,162,156,184,22,174,
  115. 227,7,92,135,55,159,165,240,216,150,218,92,182,43,214,61,59,206,244,22,88,150,194,165,118,151,253,138,222,103,11,147,245,190,
  116. 230,116,138,170,55,209,143,43,241,230,143,151,138,71,111,252,163,83,100,204,119,22,211,63,58,130,233,212,123,50,189,63,255,74,
  117. 79,184,166,170,223,254,243,61,88,165,122,48,229,255,221,131,85,178,7,188,103,173,111,39,217,183,56,46,250,148,228,253,203,239,
  118. 242,113,233,123,154,188,67,53,215,91,223,165,162,143,184,135,56,200,165,77,208,255,74,158,130,201,75,113,15,177,117,217,113,15,
  119. 145,119,138,109,84,111,240,189,214,129,126,103,227,140,1,159,123,60,147,43,112,11,209,249,22,146,129,155,198,74,67,211,249,246,
  120. 177,77,171,58,154,173,85,29,1,31,128,247,216,223,243,208,183,137,114,239,34,10,107,53,133,213,197,122,85,213,180,154,153,213,
  121. 105,241,63,82,63,186,55,116,101,29,174,183,238,228,243,52,7,241,140,132,145,35,135,60,139,170,254,202,227,179,206,136,203,235,
  122. 173,56,192,119,58,190,125,79,208,254,75,222,233,202,209,90,25,222,39,231,33,122,152,238,17,236,80,167,88,32,242,49,219,166,191,
  123. 146,252,24,241,114,153,223,244,79,38,183,209,81,151,143,155,118,173,172,63,153,226,209,76,127,5,185,53,43,109,38,207,239,113,
  124. 235,247,108,252,147,252,206,151,191,167,46,128,173,36,249,229,173,250,169,58,229,121,222,41,207,92,190,128,172,187,64,30,122,
  125. 39,148,141,241,42,153,161,210,61,234,220,159,160,236,101,74,106,10,175,154,175,25,52,87,218,107,149,189,22,209,217,146,66,198,
  126. 83,161,254,217,104,244,142,161,41,223,72,222,45,140,148,46,148,221,145,250,46,91,195,76,139,84,126,150,217,169,50,44,237,42,
  127. 205,78,13,50,157,109,14,37,51,149,76,126,23,158,35,123,69,234,190,195,99,108,80,99,241,74,123,131,242,225,134,84,175,173,242,
  128. 179,148,156,173,202,37,251,201,50,91,181,207,122,110,42,61,55,109,76,217,169,177,22,165,250,97,213,237,86,237,121,83,57,173,
  129. 113,121,85,110,65,214,251,191,168,34,188,223,217,155,66,102,40,113,30,105,231,53,82,97,115,100,32,26,49,131,102,98,77,48,24,91,
  130. 31,10,14,207,220,18,24,10,144,88,78,218,242,22,18,45,164,181,76,7,80,91,73,107,109,163,210,214,193,238,224,226,238,238,96,60,
  131. 30,234,10,133,67,137,237,171,34,61,193,53,177,200,80,168,39,24,163,162,21,193,237,93,145,64,172,103,105,40,62,16,138,199,219,
  132. 66,241,68,208,68,130,104,35,173,13,181,181,161,154,182,54,210,219,240,128,143,86,254,104,163,194,182,128,217,19,139,132,122,
  133. 124,129,104,212,183,184,59,17,26,66,205,141,52,107,172,61,26,13,135,186,3,137,80,196,172,76,230,105,11,245,6,187,183,119,135,
  134. 131,205,129,112,184,43,208,189,53,222,72,227,207,86,42,61,169,59,98,162,103,9,95,51,203,145,68,122,82,95,44,16,237,15,117,199,
  135. 125,205,1,115,40,128,10,39,157,33,41,18,142,196,150,135,194,137,96,236,236,233,43,3,137,88,104,164,145,166,255,221,244,49,85,
  136. 21,159,158,117,77,32,100,162,127,69,167,167,172,13,118,35,33,63,149,16,137,251,150,12,154,61,225,96,35,21,164,27,91,150,132,
  137. 204,30,174,125,180,142,33,44,181,15,139,181,108,40,200,149,79,24,155,176,50,194,211,165,210,166,143,77,99,39,169,92,109,46,143,
  138. 116,15,198,155,251,3,102,95,48,185,200,233,93,73,101,77,31,82,202,120,126,44,50,24,109,164,57,167,167,116,196,130,193,213,93,
  139. 241,96,108,40,24,67,43,231,135,35,93,129,112,91,96,123,100,48,49,218,76,217,223,47,215,72,117,99,51,4,210,253,213,55,198,123,
  140. 87,6,204,64,31,23,169,255,135,139,176,195,183,152,189,145,211,250,127,142,50,201,77,210,72,51,199,150,11,153,209,193,196,64,48,
  141. 209,31,233,241,45,9,196,81,57,158,225,151,38,150,87,122,237,148,179,231,95,214,19,74,68,98,86,119,170,207,158,237,180,42,107,
  142. 207,145,119,165,212,83,179,179,176,173,59,50,224,139,13,196,195,190,45,8,0,190,211,194,70,229,223,141,11,141,180,252,156,21,
  143. 156,37,114,84,142,93,217,249,255,106,61,141,84,126,174,162,141,84,209,214,19,8,15,133,182,250,2,166,25,73,200,152,225,91,102,
  144. 118,135,35,241,144,217,215,28,14,196,101,48,56,61,79,11,38,54,166,210,203,207,144,190,50,56,208,165,50,4,145,165,244,12,89,218,
  145. 67,125,102,32,49,24,11,242,134,225,24,236,11,99,111,249,176,195,98,237,193,109,131,65,179,27,41,121,233,41,86,115,21,105,166,
  146. 150,112,56,216,23,8,91,203,176,108,164,59,24,181,22,187,242,12,121,98,125,131,3,24,123,90,174,252,244,92,8,138,125,214,164,141,
  147. 26,87,69,218,7,187,251,45,207,72,43,231,73,203,178,186,107,139,140,73,165,105,182,246,96,247,96,12,14,113,150,34,237,136,129,
  148. 102,31,123,228,168,45,22,236,13,163,30,116,99,40,98,133,238,142,64,172,47,152,222,219,9,103,200,110,117,173,145,198,89,105,131,
  149. 137,80,216,183,56,22,11,108,103,39,104,164,220,52,51,91,200,125,138,161,145,140,142,13,107,150,145,43,221,231,72,172,39,109,
  150. 125,11,217,214,183,224,7,106,43,217,215,183,182,44,95,222,74,6,36,39,180,114,2,30,248,96,91,223,218,137,60,172,240,225,182,94,
  151. 154,218,58,145,218,214,137,163,111,125,39,10,119,202,138,68,39,233,157,92,14,31,109,172,182,145,173,179,149,117,3,2,199,101,39,
  152. 91,113,76,218,59,219,164,217,198,18,246,141,56,155,55,182,144,103,227,233,206,144,191,241,12,107,225,180,226,82,165,223,239,79,
  153. 233,117,105,122,125,154,222,144,166,207,74,211,103,167,233,115,210,244,185,105,250,60,232,89,150,190,60,28,232,139,83,246,152,
  154. 128,72,5,129,51,4,94,178,7,100,68,226,146,44,219,2,93,193,48,101,4,212,241,78,227,3,61,61,103,62,6,40,51,160,124,56,78,162,139,
  155. 242,248,240,95,50,152,72,68,204,53,49,52,19,236,33,123,87,4,143,3,144,242,80,36,123,183,60,207,201,209,45,143,173,30,178,225,
  156. 222,16,136,81,86,55,135,170,8,78,217,197,9,126,72,157,204,148,35,31,58,98,1,51,222,27,137,13,80,54,223,26,112,28,199,101,110,
  157. 84,100,93,30,80,81,100,16,207,19,187,99,193,64,226,244,48,200,225,153,140,158,80,111,47,137,32,217,130,124,174,146,183,23,135,
  158. 242,25,179,198,151,108,239,224,90,51,57,135,60,103,201,214,43,133,171,119,244,212,237,161,44,249,196,145,171,165,135,38,98,123,
  159. 140,169,109,121,90,98,201,169,137,99,46,109,153,50,85,174,194,56,86,71,47,76,234,114,68,217,48,115,36,194,178,4,99,113,202,224,
  160. 71,246,56,114,178,166,50,185,120,131,242,208,58,66,3,65,89,233,5,193,80,95,127,130,242,161,202,67,37,189,75,108,108,83,155,123,
  161. 181,217,142,153,11,154,178,10,108,226,64,59,130,162,85,133,181,165,41,23,170,156,115,68,81,57,213,174,81,3,42,115,224,105,109,
  162. 96,248,226,164,178,129,178,88,137,68,18,220,26,185,241,208,190,29,110,51,208,142,45,29,234,14,82,14,44,235,204,16,47,60,143,75,
  163. 246,230,212,107,132,28,245,250,80,202,127,185,204,69,88,145,200,112,71,100,43,58,91,146,122,150,153,194,65,156,56,209,112,96,
  164. 251,242,88,0,227,55,144,122,177,252,220,64,162,159,114,177,102,240,65,204,237,154,192,32,59,167,59,101,88,27,140,195,141,83,
  165. 150,37,41,63,166,108,203,130,19,109,105,100,24,91,36,245,184,46,74,5,169,7,121,218,93,16,234,233,65,159,84,51,43,35,104,67,150,
  166. 25,99,136,5,250,146,117,74,3,170,81,117,202,59,38,229,171,135,96,140,189,93,185,68,70,127,32,110,57,97,81,63,220,165,61,210,
  167. 171,22,51,22,25,176,134,143,44,40,45,93,214,232,143,32,174,138,16,57,225,3,171,101,168,142,147,30,26,24,160,92,126,233,8,5,194,
  168. 205,129,104,124,37,166,157,178,149,161,61,24,94,102,246,164,210,241,136,213,143,193,251,229,157,164,99,123,52,72,46,169,94,98,
  169. 221,79,40,3,141,173,15,132,7,177,161,67,56,31,182,6,209,88,188,197,140,39,2,56,35,145,26,95,29,13,224,192,164,241,161,120,71,4,
  170. 7,214,178,145,40,54,177,116,180,101,102,0,235,212,131,186,227,106,205,200,177,53,184,189,153,251,83,180,245,44,175,46,217,201,
  171. 132,246,126,158,81,91,88,134,168,108,172,116,48,198,221,91,133,75,4,25,225,96,111,130,236,225,160,217,151,232,39,187,234,170,
  172. 48,201,48,217,27,28,102,112,120,21,43,25,102,50,30,184,204,244,61,104,143,116,113,96,33,35,18,238,233,151,159,195,148,23,49,
  173. 147,175,57,205,50,176,96,215,140,154,150,6,227,137,88,100,59,59,206,168,81,57,87,90,201,164,119,77,28,53,181,7,134,130,201,249,
  174. 178,118,90,90,126,57,249,99,171,104,79,68,162,81,152,138,16,16,100,63,78,185,77,162,243,38,124,107,152,178,35,233,175,5,148,19,
  175. 25,19,184,201,21,49,47,136,96,99,201,32,65,153,17,51,233,216,217,82,93,57,24,78,132,162,188,36,242,17,206,153,193,231,129,44,
  176. 138,28,237,161,75,131,201,200,135,154,172,165,149,53,217,35,214,130,59,44,121,9,202,13,34,148,39,16,169,108,81,233,216,206,104,
  177. 32,134,156,50,24,100,71,199,184,183,45,42,67,121,105,52,18,29,12,159,53,120,139,24,57,98,214,139,38,85,196,130,125,236,27,177,
  178. 179,191,131,82,73,44,56,128,161,90,195,95,109,158,114,114,217,98,50,46,234,241,96,130,114,226,28,65,83,111,128,228,194,179,156,
  179. 68,246,84,42,74,127,106,177,6,45,119,15,23,75,187,168,203,98,109,73,143,164,98,60,157,241,21,141,198,197,147,161,112,93,40,45,
  180. 182,77,60,163,153,111,200,1,28,137,113,43,56,74,7,206,142,143,9,138,206,228,99,216,234,211,69,161,112,120,85,36,33,221,193,21,
  181. 199,134,73,6,40,20,196,83,42,122,32,51,59,154,213,47,220,255,144,12,47,27,125,44,142,91,189,105,25,109,75,141,212,144,135,141,
  182. 145,232,15,197,201,206,159,149,126,37,235,96,229,163,71,71,77,80,121,34,50,6,19,189,243,100,132,23,67,100,27,146,81,195,33,197,
  183. 234,94,50,248,213,135,114,249,51,221,185,50,217,208,17,89,23,15,146,123,232,180,51,97,40,20,75,12,6,194,234,20,115,14,141,78,
  184. 133,24,38,49,66,218,136,31,212,129,122,208,0,102,145,216,78,143,25,26,237,209,28,57,157,181,244,180,33,110,210,28,165,90,214,
  185. 33,109,164,116,139,78,135,68,241,91,43,232,69,67,219,165,193,158,67,135,13,113,141,112,148,62,175,93,90,122,92,167,111,138,234,
  186. 218,111,217,136,222,54,244,155,180,248,176,35,231,153,50,58,161,9,66,85,77,244,87,141,28,53,27,117,237,152,200,190,90,23,71,68,
  187. 254,204,145,191,232,116,149,208,182,52,137,188,188,80,147,22,47,181,81,147,200,178,163,188,102,117,64,155,179,65,91,49,92,75,
  188. 111,106,226,54,110,237,84,249,62,170,204,121,132,142,90,162,73,191,82,188,47,254,83,56,106,180,67,212,168,93,175,13,107,7,197,
  189. 240,136,118,232,178,55,119,11,205,230,92,92,219,52,179,169,233,188,141,58,93,46,156,95,209,197,14,49,187,233,129,114,93,127,65,
  190. 248,69,209,56,255,36,93,123,78,104,34,175,200,166,105,23,162,43,54,97,211,237,78,109,198,125,54,167,157,236,194,174,217,245,
  191. 234,106,109,168,198,166,85,107,241,26,154,107,117,97,174,118,155,118,187,84,12,86,246,105,119,140,181,166,20,91,50,249,59,252,
  192. 184,143,187,252,141,18,26,130,88,65,31,235,218,173,218,157,108,63,110,192,64,187,121,202,232,67,157,63,111,55,180,193,203,32,
  193. 247,26,98,16,226,164,206,2,37,31,144,207,215,148,208,245,42,195,221,86,134,171,45,113,143,46,62,192,194,172,88,81,219,185,162,
  194. 115,38,125,77,124,69,150,250,153,142,121,121,68,160,224,196,90,122,87,136,221,60,91,197,95,104,91,75,87,232,25,113,173,77,183,
  195. 95,163,233,90,86,191,200,207,213,134,75,241,233,101,109,164,148,238,215,180,103,57,119,233,46,109,92,169,54,80,170,229,54,206,
  196. 92,17,212,6,91,55,105,219,91,233,121,77,127,86,236,148,233,90,222,85,90,172,244,166,141,91,118,235,182,235,52,205,23,92,72,63,
  197. 83,101,115,118,121,75,110,162,39,116,219,87,159,23,215,106,39,196,165,232,231,143,116,227,22,237,65,241,178,56,140,244,5,187,
  198. 58,233,102,97,101,213,126,69,165,218,19,95,67,191,50,185,95,14,238,215,51,180,65,91,84,131,30,249,45,220,109,122,214,139,66,91,
  199. 208,164,187,142,138,57,11,132,208,157,143,11,173,86,148,100,47,180,57,109,174,58,91,214,22,187,115,166,200,47,212,46,107,108,
  200. 178,187,22,136,210,113,108,31,107,212,150,139,210,28,58,168,139,155,177,0,94,93,92,165,249,133,167,80,115,213,96,148,101,58,
  201. 237,18,181,147,108,36,149,25,147,109,244,71,127,53,29,208,197,65,116,145,142,233,98,196,145,19,42,161,171,53,241,77,20,254,133,
  202. 78,79,136,210,153,91,86,140,108,30,191,139,180,114,113,189,86,236,213,42,180,136,225,121,81,20,101,107,149,48,148,56,138,68,
  203. 209,162,162,204,162,165,69,90,81,117,145,97,229,42,147,185,52,228,58,63,149,63,71,155,204,249,69,241,36,75,209,138,75,139,203,
  204. 72,19,134,243,6,175,240,76,217,113,185,177,191,100,170,120,179,68,136,253,165,66,188,1,94,155,132,100,225,210,196,13,222,234,
  205. 203,47,55,238,43,155,33,126,85,70,186,157,114,184,132,240,212,160,204,181,229,98,183,247,41,254,56,204,31,71,202,133,182,179,
  206. 66,104,223,175,32,123,209,196,60,15,54,128,199,250,87,143,204,135,43,144,229,174,169,248,120,156,63,14,242,199,17,254,216,61,
  207. 13,31,247,77,51,174,208,72,0,150,14,165,255,35,20,0,39,152,47,246,79,19,226,24,184,182,74,23,119,85,141,19,143,87,9,113,16,156,
  208. 0,187,167,11,177,15,28,0,159,131,27,170,133,184,15,60,14,174,157,129,97,131,19,224,181,90,33,14,207,68,62,159,48,118,251,133,
  209. 177,207,143,58,252,54,113,203,108,228,159,163,137,199,193,27,115,220,105,191,15,72,202,228,223,255,240,247,211,201,191,1,226,
  210. 239,173,147,127,7,148,252,221,40,255,45,16,127,103,157,252,123,32,59,141,254,77,144,238,182,210,248,247,21,194,107,253,30,104,
  211. 17,116,187,215,202,195,255,255,77,184,45,59,255,159,55,205,107,181,203,127,67,164,171,252,252,255,206,12,175,245,123,136,189,
  212. 245,214,47,38,184,172,252,127,115,110,171,175,252,247,74,255,7,252,145,236,168,232,52,0,0,0,0};
  213. //==============================================================================
  214. #if JUCE_PUSH_NOTIFICATIONS && JUCE_MODULE_AVAILABLE_juce_gui_extra
  215. extern bool juce_handleNotificationIntent (void*);
  216. extern void juce_firebaseDeviceNotificationsTokenRefreshed (void*);
  217. extern void juce_firebaseRemoteNotificationReceived (void*);
  218. extern void juce_firebaseRemoteMessagesDeleted();
  219. extern void juce_firebaseRemoteMessageSent(void*);
  220. extern void juce_firebaseRemoteMessageSendError (void*, void*);
  221. #endif
  222. //==============================================================================
  223. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  224. METHOD (create, "<init>", "(II)V")
  225. DECLARE_JNI_CLASS (AndroidLayoutParams, "android/view/ViewGroup$LayoutParams")
  226. #undef JNI_CLASS_MEMBERS
  227. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  228. METHOD (addView, "addView", "(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V") \
  229. METHOD (removeView, "removeView", "(Landroid/view/View;)V") \
  230. METHOD (updateViewLayout, "updateViewLayout", "(Landroid/view/View;Landroid/view/ViewGroup$LayoutParams;)V")
  231. DECLARE_JNI_CLASS (AndroidViewManager, "android/view/ViewManager")
  232. #undef JNI_CLASS_MEMBERS
  233. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  234. METHOD (create, "<init>", "(IIIIIII)V") \
  235. FIELD (gravity, "gravity", "I") \
  236. FIELD (windowAnimations, "windowAnimations", "I")
  237. DECLARE_JNI_CLASS (AndroidWindowManagerLayoutParams, "android/view/WindowManager$LayoutParams")
  238. #undef JNI_CLASS_MEMBERS
  239. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  240. METHOD (getDisplayCutout, "getDisplayCutout", "()Landroid/view/DisplayCutout;")
  241. DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidWindowInsets, "android/view/WindowInsets", 28)
  242. #undef JNI_CLASS_MEMBERS
  243. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  244. METHOD (getSafeInsetBottom, "getSafeInsetBottom", "()I") \
  245. METHOD (getSafeInsetLeft, "getSafeInsetLeft", "()I") \
  246. METHOD (getSafeInsetRight, "getSafeInsetRight", "()I") \
  247. METHOD (getSafeInsetTop, "getSafeInsetTop", "()I")
  248. DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidDisplayCutout, "android/view/DisplayCutout", 28)
  249. #undef JNI_CLASS_MEMBERS
  250. //==============================================================================
  251. namespace
  252. {
  253. enum
  254. {
  255. SYSTEM_UI_FLAG_VISIBLE = 0,
  256. SYSTEM_UI_FLAG_LOW_PROFILE = 1,
  257. SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2,
  258. SYSTEM_UI_FLAG_FULLSCREEN = 4,
  259. SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512,
  260. SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024,
  261. SYSTEM_UI_FLAG_IMMERSIVE = 2048,
  262. SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 4096
  263. };
  264. constexpr int fullScreenFlags = SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
  265. constexpr int FLAG_NOT_FOCUSABLE = 0x8;
  266. }
  267. //==============================================================================
  268. static bool supportsDisplayCutout()
  269. {
  270. return getAndroidSDKVersion() >= 28;
  271. }
  272. static BorderSize<int> androidDisplayCutoutToBorderSize (LocalRef<jobject> displayCutout, double displayScale)
  273. {
  274. if (displayCutout.get() == nullptr)
  275. return {};
  276. auto* env = getEnv();
  277. auto getInset = [&] (jmethodID methodID)
  278. {
  279. return roundToInt (env->CallIntMethod (displayCutout.get(), methodID) / displayScale);
  280. };
  281. return { getInset (AndroidDisplayCutout.getSafeInsetTop),
  282. getInset (AndroidDisplayCutout.getSafeInsetLeft),
  283. getInset (AndroidDisplayCutout.getSafeInsetBottom),
  284. getInset (AndroidDisplayCutout.getSafeInsetRight) };
  285. }
  286. /* The usage of the KeyPress class relies on its keyCode member having the standard ASCII values
  287. represent ASCII keycodes. However in the native Android keycodes the values for special keys
  288. e.g. RETURN, F1-F12 overlap with the ASCII range. Hence we need to translate them.
  289. */
  290. static constexpr int translateAndroidKeyCode (int keyCode) noexcept
  291. {
  292. switch (keyCode)
  293. {
  294. case 7: return '0';
  295. case 8: return '1';
  296. case 9: return '2';
  297. case 10: return '3';
  298. case 11: return '4';
  299. case 12: return '5';
  300. case 13: return '6';
  301. case 14: return '7';
  302. case 15: return '8';
  303. case 16: return '9';
  304. case 17: return '*';
  305. case 18: return '#';
  306. case 19: return KeyPress::upKey; // KEYCODE_DPAD_UP
  307. case 20: return KeyPress::downKey; // KEYCODE_DPAD_DOWN
  308. case 21: return KeyPress::leftKey; // KEYCODE_DPAD_LEFT
  309. case 22: return KeyPress::rightKey; // KEYCODE_DPAD_RIGHT
  310. case 29: return 'A';
  311. case 30: return 'B';
  312. case 31: return 'C';
  313. case 32: return 'D';
  314. case 33: return 'E';
  315. case 34: return 'F';
  316. case 35: return 'G';
  317. case 36: return 'H';
  318. case 37: return 'I';
  319. case 38: return 'J';
  320. case 39: return 'K';
  321. case 40: return 'L';
  322. case 41: return 'M';
  323. case 42: return 'N';
  324. case 43: return 'O';
  325. case 44: return 'P';
  326. case 45: return 'Q';
  327. case 46: return 'R';
  328. case 47: return 'S';
  329. case 48: return 'T';
  330. case 49: return 'U';
  331. case 50: return 'V';
  332. case 51: return 'W';
  333. case 52: return 'X';
  334. case 53: return 'Y';
  335. case 54: return 'Z';
  336. case 55: return ',';
  337. case 56: return '.';
  338. case 61: return KeyPress::tabKey; // KEYCODE_TAB
  339. case 62: return KeyPress::spaceKey; // KEYCODE_SPACE
  340. case 66: return KeyPress::returnKey; // KEYCODE_ENTER
  341. case 67: return KeyPress::backspaceKey; // KEYCODE_DEL
  342. case 68: return '`';
  343. case 69: return '-';
  344. case 70: return '=';
  345. case 71: return '[';
  346. case 72: return ']';
  347. case 73: return '\\';
  348. case 74: return ';';
  349. case 75: return '\'';
  350. case 76: return '/';
  351. case 77: return '@';
  352. case 81: return '+';
  353. case 85: return KeyPress::playKey; // KEYCODE_MEDIA_PLAY_PAUSE
  354. case 86: return KeyPress::stopKey; // KEYCODE_MEDIA_STOP
  355. case 87: return KeyPress::fastForwardKey; // KEYCODE_MEDIA_NEXT
  356. case 88: return KeyPress::rewindKey; // KEYCODE_MEDIA_PREVIOUS
  357. case 92: return KeyPress::pageUpKey; // KEYCODE_PAGE_UP
  358. case 93: return KeyPress::pageDownKey; // KEYCODE_PAGE_DOWN
  359. case 111: return KeyPress::escapeKey; // KEYCODE_ESCAPE
  360. case 112: return KeyPress::deleteKey; // KEYCODE_FORWARD_DEL
  361. case 122: return KeyPress::homeKey; // KEYCODE_MOVE_HOME
  362. case 123: return KeyPress::endKey; // KEYCODE_MOVE_END
  363. case 124: return KeyPress::insertKey; // KEYCODE_INSERT
  364. case 131: return KeyPress::F1Key; // KEYCODE_F1
  365. case 132: return KeyPress::F2Key; // KEYCODE_F2
  366. case 133: return KeyPress::F3Key; // KEYCODE_F3
  367. case 134: return KeyPress::F4Key; // KEYCODE_F4
  368. case 135: return KeyPress::F5Key; // KEYCODE_F5
  369. case 136: return KeyPress::F6Key; // KEYCODE_F6
  370. case 137: return KeyPress::F7Key; // KEYCODE_F7
  371. case 138: return KeyPress::F8Key; // KEYCODE_F8
  372. case 139: return KeyPress::F9Key; // KEYCODE_F9
  373. case 140: return KeyPress::F10Key; // KEYCODE_F10
  374. case 141: return KeyPress::F11Key; // KEYCODE_F11
  375. case 142: return KeyPress::F12Key; // KEYCODE_F12
  376. case 144: return '0';
  377. case 145: return '1';
  378. case 146: return '2';
  379. case 147: return '3';
  380. case 148: return '4';
  381. case 149: return '5';
  382. case 150: return '6';
  383. case 151: return '7';
  384. case 152: return '8';
  385. case 153: return '9';
  386. case 154: return '/';
  387. case 155: return '*';
  388. case 156: return '-';
  389. case 157: return '+';
  390. case 158: return '.';
  391. case 159: return ',';
  392. case 161: return '=';
  393. case 162: return '(';
  394. case 163: return ')';
  395. default: return 0;
  396. }
  397. }
  398. static constexpr int translateAndroidKeyboardFlags (int javaFlags) noexcept
  399. {
  400. constexpr int metaShiftOn = 0x1;
  401. constexpr int metaAltOn = 0x02;
  402. constexpr int metaCtrlOn = 0x1000;
  403. int flags = 0;
  404. if ((javaFlags & metaShiftOn) != 0) flags |= ModifierKeys::shiftModifier;
  405. if ((javaFlags & metaAltOn) != 0) flags |= ModifierKeys::altModifier;
  406. if ((javaFlags & metaCtrlOn) != 0) flags |= ModifierKeys::ctrlModifier;
  407. return flags;
  408. }
  409. //==============================================================================
  410. class AndroidComponentPeer : public ComponentPeer,
  411. private Timer
  412. {
  413. public:
  414. AndroidComponentPeer (Component& comp, int windowStyleFlags, void* nativeViewHandle)
  415. : ComponentPeer (comp, windowStyleFlags)
  416. {
  417. auto* env = getEnv();
  418. // NB: must not put this in the initialiser list, as it invokes a callback,
  419. // which will fail if the peer is only half-constructed.
  420. view = GlobalRef (LocalRef<jobject> (env->NewObject (ComponentPeerView, ComponentPeerView.create,
  421. getAppContext().get(), (jboolean) component.isOpaque(),
  422. (jlong) this)));
  423. if (nativeViewHandle != nullptr)
  424. {
  425. viewGroupIsWindow = false;
  426. // we don't know if the user is holding on to a local ref to this, so
  427. // explicitly create a new one
  428. auto nativeView = LocalRef<jobject> (env->NewLocalRef (static_cast<jobject> (nativeViewHandle)));
  429. if (env->IsInstanceOf (nativeView.get(), AndroidActivity))
  430. {
  431. viewGroup = GlobalRef (nativeView);
  432. env->CallVoidMethod (viewGroup.get(), AndroidActivity.setContentView, view.get());
  433. }
  434. else if (env->IsInstanceOf (nativeView.get(), AndroidViewGroup))
  435. {
  436. viewGroup = GlobalRef (nativeView);
  437. LocalRef<jobject> layoutParams (env->NewObject (AndroidLayoutParams, AndroidLayoutParams.create, -2, -2));
  438. env->CallVoidMethod (view.get(), AndroidView.setLayoutParams, layoutParams.get());
  439. env->CallVoidMethod ((jobject) viewGroup.get(), AndroidViewGroup.addView, view.get());
  440. }
  441. else
  442. {
  443. // the native handle you passed as a second argument to Component::addToDesktop must
  444. // either be an Activity or a ViewGroup
  445. jassertfalse;
  446. }
  447. }
  448. else
  449. {
  450. viewGroupIsWindow = true;
  451. LocalRef<jobject> viewLayoutParams (env->NewObject (AndroidLayoutParams, AndroidLayoutParams.create, -2, -2));
  452. env->CallVoidMethod (view.get(), AndroidView.setLayoutParams, viewLayoutParams.get());
  453. auto physicalBounds = (comp.getBoundsInParent().toFloat() * scale).toNearestInt();
  454. view.callVoidMethod (AndroidView.layout,
  455. physicalBounds.getX(), physicalBounds.getY(), physicalBounds.getRight(), physicalBounds.getBottom());
  456. LocalRef<jobject> windowLayoutParams (env->NewObject (AndroidWindowManagerLayoutParams, AndroidWindowManagerLayoutParams.create,
  457. physicalBounds.getWidth(), physicalBounds.getHeight(),
  458. physicalBounds.getX(), physicalBounds.getY(),
  459. TYPE_APPLICATION, FLAG_NOT_TOUCH_MODAL | FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_NO_LIMITS | FLAG_NOT_FOCUSABLE,
  460. component.isOpaque() ? PIXEL_FORMAT_OPAQUE : PIXEL_FORMAT_TRANSPARENT));
  461. env->SetIntField (windowLayoutParams.get(), AndroidWindowManagerLayoutParams.gravity, GRAVITY_LEFT | GRAVITY_TOP);
  462. env->SetIntField (windowLayoutParams.get(), AndroidWindowManagerLayoutParams.windowAnimations, 0x01030000 /* android.R.style.Animation */);
  463. if (supportsDisplayCutout())
  464. {
  465. jfieldID layoutInDisplayCutoutModeFieldId = env->GetFieldID (AndroidWindowManagerLayoutParams,
  466. "layoutInDisplayCutoutMode",
  467. "I");
  468. if (layoutInDisplayCutoutModeFieldId != nullptr)
  469. env->SetIntField (windowLayoutParams.get(),
  470. layoutInDisplayCutoutModeFieldId,
  471. LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS);
  472. }
  473. if (Desktop::getInstance().getKioskModeComponent() != nullptr)
  474. setNavBarsHidden (true);
  475. LocalRef<jobject> activity (getCurrentActivity());
  476. if (activity == nullptr)
  477. activity = getMainActivity();
  478. viewGroup = GlobalRef (LocalRef<jobject> (env->CallObjectMethod (activity.get(), AndroidContext.getSystemService, javaString ("window").get())));
  479. env->CallVoidMethod (viewGroup.get(), AndroidViewManager.addView, view.get(), windowLayoutParams.get());
  480. }
  481. if (supportsDisplayCutout())
  482. {
  483. jmethodID setOnApplyWindowInsetsListenerMethodId = env->GetMethodID (AndroidView,
  484. "setOnApplyWindowInsetsListener",
  485. "(Landroid/view/View$OnApplyWindowInsetsListener;)V");
  486. if (setOnApplyWindowInsetsListenerMethodId != nullptr)
  487. env->CallVoidMethod (view.get(), setOnApplyWindowInsetsListenerMethodId,
  488. CreateJavaInterface (new ViewWindowInsetsListener,
  489. "android/view/View$OnApplyWindowInsetsListener").get());
  490. }
  491. if (isFocused())
  492. handleFocusGain();
  493. }
  494. ~AndroidComponentPeer() override
  495. {
  496. stopTimer();
  497. auto* env = getEnv();
  498. env->CallVoidMethod (view, ComponentPeerView.clear);
  499. frontWindow = nullptr;
  500. GlobalRef localView (view);
  501. GlobalRef localViewGroup (viewGroup);
  502. callOnMessageThread ([env, localView, localViewGroup]
  503. {
  504. if (env->IsInstanceOf (localViewGroup.get(), AndroidActivity))
  505. env->CallVoidMethod (localViewGroup.get(), AndroidActivity.setContentView, nullptr);
  506. else
  507. env->CallVoidMethod (localViewGroup.get(), AndroidViewManager.removeView, localView.get());
  508. });
  509. }
  510. void* getNativeHandle() const override
  511. {
  512. return (void*) view.get();
  513. }
  514. void setVisible (bool shouldBeVisible) override
  515. {
  516. GlobalRef localView (view);
  517. callOnMessageThread ([localView, shouldBeVisible]
  518. {
  519. localView.callVoidMethod (ComponentPeerView.setVisible, shouldBeVisible);
  520. });
  521. }
  522. void setTitle (const String& title) override
  523. {
  524. view.callVoidMethod (ComponentPeerView.setViewName, javaString (title).get());
  525. }
  526. void setBounds (const Rectangle<int>& userRect, bool isNowFullScreen) override
  527. {
  528. auto bounds = (userRect.toFloat() * scale).toNearestInt();
  529. if (MessageManager::getInstance()->isThisTheMessageThread())
  530. {
  531. fullScreen = isNowFullScreen;
  532. view.callVoidMethod (AndroidView.layout,
  533. bounds.getX(), bounds.getY(), bounds.getRight(), bounds.getBottom());
  534. if (viewGroup != nullptr && viewGroupIsWindow)
  535. {
  536. auto* env = getEnv();
  537. LocalRef<jobject> windowLayoutParams (env->NewObject (AndroidWindowManagerLayoutParams, AndroidWindowManagerLayoutParams.create,
  538. bounds.getWidth(), bounds.getHeight(), bounds.getX(), bounds.getY(),
  539. TYPE_APPLICATION, FLAG_NOT_TOUCH_MODAL | FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_NO_LIMITS,
  540. component.isOpaque() ? PIXEL_FORMAT_OPAQUE : PIXEL_FORMAT_TRANSPARENT));
  541. env->SetIntField (windowLayoutParams.get(), AndroidWindowManagerLayoutParams.gravity, GRAVITY_LEFT | GRAVITY_TOP);
  542. env->CallVoidMethod (viewGroup.get(), AndroidViewManager.updateViewLayout, view.get(), windowLayoutParams.get());
  543. }
  544. }
  545. else
  546. {
  547. GlobalRef localView (view);
  548. MessageManager::callAsync ([localView, bounds]
  549. {
  550. localView.callVoidMethod (AndroidView.layout,
  551. bounds.getX(), bounds.getY(), bounds.getRight(), bounds.getBottom());
  552. });
  553. }
  554. }
  555. Rectangle<int> getBounds() const override
  556. {
  557. Rectangle<int> bounds (view.callIntMethod (AndroidView.getLeft),
  558. view.callIntMethod (AndroidView.getTop),
  559. view.callIntMethod (AndroidView.getWidth),
  560. view.callIntMethod (AndroidView.getHeight));
  561. return (bounds.toFloat() / scale).toNearestInt();
  562. }
  563. void handleScreenSizeChange() override
  564. {
  565. ComponentPeer::handleScreenSizeChange();
  566. if (isFullScreen())
  567. setFullScreen (true);
  568. }
  569. Point<int> getScreenPosition() const
  570. {
  571. auto* env = getEnv();
  572. LocalRef<jintArray> position (env->NewIntArray (2));
  573. env->CallVoidMethod (view.get(), AndroidView.getLocationOnScreen, position.get());
  574. jint* const screenPosition = env->GetIntArrayElements (position.get(), nullptr);
  575. Point<int> pos (screenPosition[0], screenPosition[1]);
  576. env->ReleaseIntArrayElements (position.get(), screenPosition, 0);
  577. return pos;
  578. }
  579. Point<float> localToGlobal (Point<float> relativePosition) override
  580. {
  581. return relativePosition + (getScreenPosition().toFloat() / scale);
  582. }
  583. using ComponentPeer::localToGlobal;
  584. Point<float> globalToLocal (Point<float> screenPosition) override
  585. {
  586. return screenPosition - (getScreenPosition().toFloat() / scale);
  587. }
  588. using ComponentPeer::globalToLocal;
  589. void setMinimised (bool /*shouldBeMinimised*/) override
  590. {
  591. // n/a
  592. }
  593. bool isMinimised() const override
  594. {
  595. return false;
  596. }
  597. void setFullScreen (bool shouldBeFullScreen) override
  598. {
  599. if (shouldNavBarsBeHidden (shouldBeFullScreen))
  600. {
  601. if (isTimerRunning())
  602. return;
  603. startTimer (500);
  604. }
  605. else
  606. {
  607. setNavBarsHidden (false);
  608. }
  609. auto newBounds = [&]
  610. {
  611. if (navBarsHidden || shouldBeFullScreen)
  612. if (auto* display = Desktop::getInstance().getDisplays().getPrimaryDisplay())
  613. return navBarsHidden ? display->totalArea
  614. : display->userArea;
  615. return lastNonFullscreenBounds.isEmpty() ? getBounds() : lastNonFullscreenBounds;
  616. }();
  617. if (! newBounds.isEmpty())
  618. setBounds (newBounds, shouldBeFullScreen);
  619. component.repaint();
  620. }
  621. bool isFullScreen() const override
  622. {
  623. return fullScreen;
  624. }
  625. void setIcon (const Image& /*newIcon*/) override
  626. {
  627. // n/a
  628. }
  629. bool contains (Point<int> localPos, bool trueIfInAChildWindow) const override
  630. {
  631. return isPositiveAndBelow (localPos.x, component.getWidth())
  632. && isPositiveAndBelow (localPos.y, component.getHeight())
  633. && ((! trueIfInAChildWindow) || view.callBooleanMethod (ComponentPeerView.containsPoint,
  634. (float) localPos.x * scale,
  635. (float) localPos.y * scale));
  636. }
  637. BorderSize<int> getFrameSize() const override
  638. {
  639. // TODO
  640. return {};
  641. }
  642. bool setAlwaysOnTop (bool /*alwaysOnTop*/) override
  643. {
  644. // TODO
  645. return false;
  646. }
  647. void toFront (bool makeActive) override
  648. {
  649. // Avoid calling bringToFront excessively: it's very slow
  650. if (frontWindow != this)
  651. {
  652. view.callVoidMethod (AndroidView.bringToFront);
  653. frontWindow = this;
  654. }
  655. if (makeActive)
  656. grabFocus();
  657. handleBroughtToFront();
  658. }
  659. void toBehind (ComponentPeer*) override
  660. {
  661. // TODO
  662. }
  663. //==============================================================================
  664. void handleMouseDownCallback (int index, Point<float> sysPos, int64 time)
  665. {
  666. lastMousePos = sysPos / scale;
  667. auto pos = globalToLocal (lastMousePos);
  668. // this forces a mouse-enter/up event, in case for some reason we didn't get a mouse-up before.
  669. handleMouseEvent (MouseInputSource::InputSourceType::touch,
  670. pos,
  671. ModifierKeys::currentModifiers.withoutMouseButtons(),
  672. MouseInputSource::invalidPressure,
  673. MouseInputSource::invalidOrientation,
  674. time,
  675. {},
  676. index);
  677. if (isValidPeer (this))
  678. handleMouseDragCallback (index, sysPos, time);
  679. }
  680. void handleMouseDragCallback (int index, Point<float> sysPos, int64 time)
  681. {
  682. lastMousePos = sysPos / scale;
  683. auto pos = globalToLocal (lastMousePos);
  684. jassert (index < 64);
  685. touchesDown = (touchesDown | (1 << (index & 63)));
  686. ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier);
  687. handleMouseEvent (MouseInputSource::InputSourceType::touch,
  688. pos,
  689. ModifierKeys::currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier),
  690. MouseInputSource::invalidPressure,
  691. MouseInputSource::invalidOrientation,
  692. time,
  693. {},
  694. index);
  695. }
  696. void handleMouseUpCallback (int index, Point<float> sysPos, int64 time)
  697. {
  698. lastMousePos = sysPos / scale;
  699. auto pos = globalToLocal (lastMousePos);
  700. jassert (index < 64);
  701. touchesDown = (touchesDown & ~(1 << (index & 63)));
  702. if (touchesDown == 0)
  703. ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons();
  704. handleMouseEvent (MouseInputSource::InputSourceType::touch,
  705. pos,
  706. ModifierKeys::currentModifiers.withoutMouseButtons(),
  707. MouseInputSource::invalidPressure,
  708. MouseInputSource::invalidOrientation,
  709. time,
  710. {},
  711. index);
  712. }
  713. void handleKeyDownCallback (int k, int kc, int kbFlags)
  714. {
  715. ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withOnlyMouseButtons()
  716. .withFlags (translateAndroidKeyboardFlags (kbFlags));
  717. handleKeyPress (translateAndroidKeyCode (k), static_cast<juce_wchar> (kc));
  718. }
  719. void handleKeyUpCallback (int /*k*/, int /*kc*/)
  720. {
  721. }
  722. void handleBackButtonCallback()
  723. {
  724. bool handled = false;
  725. if (auto* app = JUCEApplicationBase::getInstance())
  726. handled = app->backButtonPressed();
  727. if (isKioskModeComponent())
  728. setNavBarsHidden (navBarsHidden);
  729. if (! handled)
  730. {
  731. auto* env = getEnv();
  732. LocalRef<jobject> activity (getCurrentActivity());
  733. if (activity != nullptr)
  734. {
  735. jmethodID finishMethod = env->GetMethodID (AndroidActivity, "finish", "()V");
  736. if (finishMethod != nullptr)
  737. env->CallVoidMethod (activity.get(), finishMethod);
  738. }
  739. }
  740. }
  741. void handleKeyboardHiddenCallback()
  742. {
  743. Component::unfocusAllComponents();
  744. }
  745. void handleAppPausedCallback() {}
  746. void handleAppResumedCallback()
  747. {
  748. if (isKioskModeComponent())
  749. setNavBarsHidden (navBarsHidden);
  750. }
  751. //==============================================================================
  752. AccessibilityNativeHandle* getNativeHandleForViewId (jint virtualViewId) const
  753. {
  754. if (auto* handler = (virtualViewId == HOST_VIEW_ID
  755. ? component.getAccessibilityHandler()
  756. : AccessibilityNativeHandle::getAccessibilityHandlerForVirtualViewId (virtualViewId)))
  757. {
  758. return handler->getNativeImplementation();
  759. }
  760. return nullptr;
  761. }
  762. jboolean populateAccessibilityNodeInfoCallback (jint virtualViewId, jobject info) const
  763. {
  764. if (auto* handle = getNativeHandleForViewId (virtualViewId))
  765. {
  766. handle->populateNodeInfo (info);
  767. return true;
  768. }
  769. return false;
  770. }
  771. jboolean handlePerformActionCallback (jint virtualViewId, jint action, jobject arguments) const
  772. {
  773. if (auto* handle = getNativeHandleForViewId (virtualViewId))
  774. return handle->performAction (action, arguments);
  775. return false;
  776. }
  777. static jobject getFocusViewIdForHandler (const AccessibilityHandler* handler)
  778. {
  779. if (handler != nullptr)
  780. return getEnv()->NewObject (JavaInteger,
  781. JavaInteger.constructor,
  782. handler->getNativeImplementation()->getVirtualViewId());
  783. return nullptr;
  784. }
  785. jobject getInputFocusViewIdCallback()
  786. {
  787. if (auto* comp = dynamic_cast<Component*> (findCurrentTextInputTarget()))
  788. return getFocusViewIdForHandler (comp->getAccessibilityHandler());
  789. return nullptr;
  790. }
  791. jobject getAccessibilityFocusViewIdCallback() const
  792. {
  793. if (auto* handler = component.getAccessibilityHandler())
  794. {
  795. if (auto* modal = Component::getCurrentlyModalComponent())
  796. {
  797. if (! component.isParentOf (modal)
  798. && component.isCurrentlyBlockedByAnotherModalComponent())
  799. {
  800. if (auto* modalHandler = modal->getAccessibilityHandler())
  801. {
  802. if (auto* focusChild = modalHandler->getChildFocus())
  803. return getFocusViewIdForHandler (focusChild);
  804. return getFocusViewIdForHandler (modalHandler);
  805. }
  806. }
  807. }
  808. if (auto* focusChild = handler->getChildFocus())
  809. return getFocusViewIdForHandler (focusChild);
  810. }
  811. return nullptr;
  812. }
  813. //==============================================================================
  814. bool isFocused() const override
  815. {
  816. if (view != nullptr)
  817. return view.callBooleanMethod (AndroidView.hasFocus);
  818. return false;
  819. }
  820. void grabFocus() override
  821. {
  822. if (view != nullptr)
  823. view.callBooleanMethod (AndroidView.requestFocus);
  824. }
  825. void handleFocusChangeCallback (bool hasFocus)
  826. {
  827. if (isFullScreen())
  828. setFullScreen (true);
  829. if (hasFocus)
  830. handleFocusGain();
  831. else
  832. handleFocusLoss();
  833. }
  834. static const char* getVirtualKeyboardType (TextInputTarget::VirtualKeyboardType type) noexcept
  835. {
  836. switch (type)
  837. {
  838. case TextInputTarget::textKeyboard: return "text";
  839. case TextInputTarget::numericKeyboard: return "number";
  840. case TextInputTarget::decimalKeyboard: return "numberDecimal";
  841. case TextInputTarget::urlKeyboard: return "textUri";
  842. case TextInputTarget::emailAddressKeyboard: return "textEmailAddress";
  843. case TextInputTarget::phoneNumberKeyboard: return "phone";
  844. default: jassertfalse; break;
  845. }
  846. return "text";
  847. }
  848. void textInputRequired (Point<int>, TextInputTarget& target) override
  849. {
  850. view.callVoidMethod (ComponentPeerView.showKeyboard,
  851. javaString (getVirtualKeyboardType (target.getKeyboardType())).get());
  852. }
  853. void dismissPendingTextInput() override
  854. {
  855. view.callVoidMethod (ComponentPeerView.showKeyboard, javaString ("").get());
  856. if (! isTimerRunning())
  857. startTimer (500);
  858. }
  859. //==============================================================================
  860. void handlePaintCallback (jobject canvas, jobject paint)
  861. {
  862. auto* env = getEnv();
  863. jobject rect = env->CallObjectMethod (canvas, AndroidCanvas.getClipBounds);
  864. auto left = env->GetIntField (rect, AndroidRect.left);
  865. auto top = env->GetIntField (rect, AndroidRect.top);
  866. auto right = env->GetIntField (rect, AndroidRect.right);
  867. auto bottom = env->GetIntField (rect, AndroidRect.bottom);
  868. env->DeleteLocalRef (rect);
  869. auto clip = Rectangle<int>::leftTopRightBottom (left, top, right, bottom);
  870. if (clip.isEmpty())
  871. return;
  872. auto sizeNeeded = clip.getWidth() * clip.getHeight();
  873. if (sizeAllocated < sizeNeeded)
  874. {
  875. buffer.clear();
  876. sizeAllocated = sizeNeeded;
  877. buffer = GlobalRef (LocalRef<jobject> ((jobject) env->NewIntArray (sizeNeeded)));
  878. }
  879. if (jint* dest = env->GetIntArrayElements ((jintArray) buffer.get(), nullptr))
  880. {
  881. {
  882. Image temp (new PreallocatedImage (clip.getWidth(), clip.getHeight(),
  883. dest, ! component.isOpaque()));
  884. {
  885. LowLevelGraphicsSoftwareRenderer g (temp);
  886. g.setOrigin (-clip.getPosition());
  887. g.addTransform (AffineTransform::scale (scale));
  888. handlePaint (g);
  889. }
  890. }
  891. env->ReleaseIntArrayElements ((jintArray) buffer.get(), dest, 0);
  892. env->CallVoidMethod (canvas, AndroidCanvas.drawBitmap, (jintArray) buffer.get(), 0, clip.getWidth(),
  893. (jfloat) clip.getX(), (jfloat) clip.getY(),
  894. clip.getWidth(), clip.getHeight(), true, paint);
  895. }
  896. }
  897. void repaint (const Rectangle<int>& userArea) override
  898. {
  899. auto area = (userArea.toFloat() * scale).toNearestInt();
  900. GlobalRef localView (view);
  901. callOnMessageThread ([area, localView]
  902. {
  903. localView.callVoidMethod (AndroidView.invalidate,
  904. area.getX(), area.getY(), area.getRight(), area.getBottom());
  905. });
  906. }
  907. void performAnyPendingRepaintsNow() override
  908. {
  909. // TODO
  910. }
  911. void setAlpha (float /*newAlpha*/) override
  912. {
  913. // TODO
  914. }
  915. StringArray getAvailableRenderingEngines() override
  916. {
  917. return StringArray ("Software Renderer");
  918. }
  919. //==============================================================================
  920. static Point<float> lastMousePos;
  921. static int64 touchesDown;
  922. //==============================================================================
  923. struct StartupActivityCallbackListener : public ActivityLifecycleCallbacks
  924. {
  925. void onActivityStarted (jobject /*activity*/) override
  926. {
  927. auto* env = getEnv();
  928. LocalRef<jobject> appContext (getAppContext());
  929. if (appContext.get() != nullptr)
  930. {
  931. env->CallVoidMethod (appContext.get(),
  932. AndroidApplication.unregisterActivityLifecycleCallbacks,
  933. activityCallbackListener.get());
  934. clear();
  935. activityCallbackListener.clear();
  936. forceDisplayUpdate();
  937. }
  938. }
  939. };
  940. private:
  941. //==============================================================================
  942. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  943. METHOD (create, "<init>", "(Landroid/content/Context;ZJ)V") \
  944. METHOD (clear, "clear", "()V") \
  945. METHOD (setViewName, "setViewName", "(Ljava/lang/String;)V") \
  946. METHOD (setVisible, "setVisible", "(Z)V") \
  947. METHOD (isVisible, "isVisible", "()Z") \
  948. METHOD (containsPoint, "containsPoint", "(II)Z") \
  949. METHOD (showKeyboard, "showKeyboard", "(Ljava/lang/String;)V") \
  950. METHOD (setSystemUiVisibilityCompat, "setSystemUiVisibilityCompat", "(I)V") \
  951. CALLBACK (handlePaintJni, "handlePaint", "(JLandroid/graphics/Canvas;Landroid/graphics/Paint;)V") \
  952. CALLBACK (handleMouseDownJni, "handleMouseDown", "(JIFFJ)V") \
  953. CALLBACK (handleMouseDragJni, "handleMouseDrag", "(JIFFJ)V") \
  954. CALLBACK (handleMouseUpJni, "handleMouseUp", "(JIFFJ)V") \
  955. CALLBACK (handleKeyDownJni, "handleKeyDown", "(JIII)V") \
  956. CALLBACK (handleKeyUpJni, "handleKeyUp", "(JII)V") \
  957. CALLBACK (handleBackButtonJni, "handleBackButton", "(J)V") \
  958. CALLBACK (handleKeyboardHiddenJni, "handleKeyboardHidden", "(J)V") \
  959. CALLBACK (viewSizeChangedJni, "viewSizeChanged", "(J)V") \
  960. CALLBACK (focusChangedJni, "focusChanged", "(JZ)V") \
  961. CALLBACK (handleAppPausedJni, "handleAppPaused", "(J)V") \
  962. CALLBACK (handleAppResumedJni, "handleAppResumed", "(J)V") \
  963. CALLBACK (populateAccessibilityNodeInfoJni, "populateAccessibilityNodeInfo", "(JILandroid/view/accessibility/AccessibilityNodeInfo;)Z") \
  964. CALLBACK (handlePerformActionJni, "handlePerformAction", "(JIILandroid/os/Bundle;)Z") \
  965. CALLBACK (getInputFocusViewIdJni, "getInputFocusViewId", "(J)Ljava/lang/Integer;") \
  966. CALLBACK (getAccessibilityFocusViewIdJni, "getAccessibilityFocusViewId", "(J)Ljava/lang/Integer;") \
  967. DECLARE_JNI_CLASS_WITH_BYTECODE (ComponentPeerView, "com/rmsl/juce/ComponentPeerView", 16, javaComponentPeerView, sizeof (javaComponentPeerView))
  968. #undef JNI_CLASS_MEMBERS
  969. static void JNICALL handlePaintJni (JNIEnv*, jobject /*view*/, jlong host, jobject canvas, jobject paint) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handlePaintCallback (canvas, paint); }
  970. static void JNICALL handleMouseDownJni (JNIEnv*, jobject /*view*/, jlong host, jint i, jfloat x, jfloat y, jlong time) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleMouseDownCallback (i, Point<float> ((float) x, (float) y), (int64) time); }
  971. static void JNICALL handleMouseDragJni (JNIEnv*, jobject /*view*/, jlong host, jint i, jfloat x, jfloat y, jlong time) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleMouseDragCallback (i, Point<float> ((float) x, (float) y), (int64) time); }
  972. static void JNICALL handleMouseUpJni (JNIEnv*, jobject /*view*/, jlong host, jint i, jfloat x, jfloat y, jlong time) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleMouseUpCallback (i, Point<float> ((float) x, (float) y), (int64) time); }
  973. static void JNICALL viewSizeChangedJni (JNIEnv*, jobject /*view*/, jlong host) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleMovedOrResized(); }
  974. static void JNICALL focusChangedJni (JNIEnv*, jobject /*view*/, jlong host, jboolean hasFocus) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleFocusChangeCallback (hasFocus); }
  975. static void JNICALL handleKeyDownJni (JNIEnv*, jobject /*view*/, jlong host, jint k, jint kc, jint kbFlags) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleKeyDownCallback ((int) k, (int) kc, (int) kbFlags); }
  976. static void JNICALL handleKeyUpJni (JNIEnv*, jobject /*view*/, jlong host, jint k, jint kc) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleKeyUpCallback ((int) k, (int) kc); }
  977. static void JNICALL handleBackButtonJni (JNIEnv*, jobject /*view*/, jlong host) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleBackButtonCallback(); }
  978. static void JNICALL handleKeyboardHiddenJni (JNIEnv*, jobject /*view*/, jlong host) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleKeyboardHiddenCallback(); }
  979. static void JNICALL handleAppPausedJni (JNIEnv*, jobject /*view*/, jlong host) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleAppPausedCallback(); }
  980. static void JNICALL handleAppResumedJni (JNIEnv*, jobject /*view*/, jlong host) { if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host)) myself->handleAppResumedCallback(); }
  981. static jboolean JNICALL populateAccessibilityNodeInfoJni (JNIEnv*, jobject /*view*/, jlong host, jint virtualViewId, jobject info)
  982. {
  983. if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host))
  984. return myself->populateAccessibilityNodeInfoCallback (virtualViewId, info);
  985. return false;
  986. }
  987. static jboolean JNICALL handlePerformActionJni (JNIEnv*, jobject /*view*/, jlong host, jint virtualViewId, jint action, jobject arguments)
  988. {
  989. if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host))
  990. return myself->handlePerformActionCallback (virtualViewId, action, arguments);
  991. return false;
  992. }
  993. static jobject JNICALL getInputFocusViewIdJni (JNIEnv*, jobject /*view*/, jlong host)
  994. {
  995. if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host))
  996. return myself->getInputFocusViewIdCallback();
  997. return nullptr;
  998. }
  999. static jobject JNICALL getAccessibilityFocusViewIdJni (JNIEnv*, jobject /*view*/, jlong host)
  1000. {
  1001. if (auto* myself = reinterpret_cast<AndroidComponentPeer*> (host))
  1002. return myself->getAccessibilityFocusViewIdCallback();
  1003. return nullptr;
  1004. }
  1005. //==============================================================================
  1006. struct ViewWindowInsetsListener : public juce::AndroidInterfaceImplementer
  1007. {
  1008. jobject onApplyWindowInsets (LocalRef<jobject> v, LocalRef<jobject> insets)
  1009. {
  1010. auto* env = getEnv();
  1011. LocalRef<jobject> displayCutout (env->CallObjectMethod (insets.get(), AndroidWindowInsets.getDisplayCutout));
  1012. if (displayCutout != nullptr)
  1013. {
  1014. const auto& mainDisplay = *Desktop::getInstance().getDisplays().getPrimaryDisplay();
  1015. auto newSafeAreaInsets = androidDisplayCutoutToBorderSize (displayCutout, mainDisplay.scale);
  1016. if (newSafeAreaInsets != mainDisplay.safeAreaInsets)
  1017. forceDisplayUpdate();
  1018. auto* fieldId = env->GetStaticFieldID (AndroidWindowInsets, "CONSUMED", "Landroid/view/WindowInsets");
  1019. jassert (fieldId != nullptr);
  1020. return env->GetStaticObjectField (AndroidWindowInsets, fieldId);
  1021. }
  1022. jmethodID onApplyWindowInsetsMethodId = env->GetMethodID (AndroidView,
  1023. "onApplyWindowInsets",
  1024. "(Landroid/view/WindowInsets;)Landroid/view/WindowInsets;");
  1025. jassert (onApplyWindowInsetsMethodId != nullptr);
  1026. return env->CallObjectMethod (v.get(), onApplyWindowInsetsMethodId, insets.get());
  1027. }
  1028. private:
  1029. jobject invoke (jobject proxy, jobject method, jobjectArray args) override
  1030. {
  1031. auto* env = getEnv();
  1032. auto methodName = juce::juceString ((jstring) env->CallObjectMethod (method, JavaMethod.getName));
  1033. if (methodName == "onApplyWindowInsets")
  1034. {
  1035. jassert (env->GetArrayLength (args) == 2);
  1036. LocalRef<jobject> windowView (env->GetObjectArrayElement (args, 0));
  1037. LocalRef<jobject> insets (env->GetObjectArrayElement (args, 1));
  1038. return onApplyWindowInsets (std::move (windowView), std::move (insets));
  1039. }
  1040. // invoke base class
  1041. return AndroidInterfaceImplementer::invoke (proxy, method, args);
  1042. }
  1043. };
  1044. //==============================================================================
  1045. struct PreallocatedImage : public ImagePixelData
  1046. {
  1047. PreallocatedImage (int width_, int height_, jint* data_, bool hasAlpha_)
  1048. : ImagePixelData (Image::ARGB, width_, height_), data (data_), hasAlpha (hasAlpha_)
  1049. {
  1050. if (hasAlpha_)
  1051. zeromem (data_, static_cast<size_t> (width * height) * sizeof (jint));
  1052. }
  1053. ~PreallocatedImage() override
  1054. {
  1055. if (hasAlpha)
  1056. {
  1057. auto pix = (PixelARGB*) data;
  1058. for (int i = width * height; --i >= 0;)
  1059. {
  1060. pix->unpremultiply();
  1061. ++pix;
  1062. }
  1063. }
  1064. }
  1065. std::unique_ptr<ImageType> createType() const override
  1066. {
  1067. return std::make_unique<SoftwareImageType>();
  1068. }
  1069. std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
  1070. {
  1071. return std::make_unique<LowLevelGraphicsSoftwareRenderer> (Image (this));
  1072. }
  1073. void initialiseBitmapData (Image::BitmapData& bm, int x, int y, Image::BitmapData::ReadWriteMode /*mode*/) override
  1074. {
  1075. bm.lineStride = width * static_cast<int> (sizeof (jint));
  1076. bm.pixelStride = static_cast<int> (sizeof (jint));
  1077. bm.pixelFormat = Image::ARGB;
  1078. bm.data = (uint8*) (data + x + y * width);
  1079. }
  1080. ImagePixelData::Ptr clone() override
  1081. {
  1082. auto s = new PreallocatedImage (width, height, nullptr, hasAlpha);
  1083. s->allocatedData.malloc (sizeof (jint) * static_cast<size_t> (width * height));
  1084. s->data = s->allocatedData;
  1085. memcpy (s->data, data, sizeof (jint) * static_cast<size_t> (width * height));
  1086. return s;
  1087. }
  1088. private:
  1089. jint* data;
  1090. HeapBlock<jint> allocatedData;
  1091. bool hasAlpha;
  1092. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PreallocatedImage)
  1093. };
  1094. //==============================================================================
  1095. void timerCallback() override
  1096. {
  1097. setNavBarsHidden (shouldNavBarsBeHidden (fullScreen));
  1098. setFullScreen (fullScreen);
  1099. stopTimer();
  1100. }
  1101. bool isKioskModeComponent() const
  1102. {
  1103. if (auto* kiosk = Desktop::getInstance().getKioskModeComponent())
  1104. return kiosk->getPeer() == this;
  1105. return false;
  1106. }
  1107. bool shouldNavBarsBeHidden (bool shouldBeFullScreen) const
  1108. {
  1109. return (shouldBeFullScreen && isKioskModeComponent());
  1110. }
  1111. void setNavBarsHidden (bool hidden)
  1112. {
  1113. if (navBarsHidden != hidden)
  1114. {
  1115. navBarsHidden = hidden;
  1116. view.callVoidMethod (ComponentPeerView.setSystemUiVisibilityCompat,
  1117. (navBarsHidden ? (jint) (fullScreenFlags) : (jint) (SYSTEM_UI_FLAG_VISIBLE)));
  1118. }
  1119. }
  1120. template <typename Callback>
  1121. static void callOnMessageThread (Callback&& callback)
  1122. {
  1123. if (MessageManager::getInstance()->isThisTheMessageThread())
  1124. callback();
  1125. else
  1126. MessageManager::callAsync (std::forward<Callback> (callback));
  1127. }
  1128. //==============================================================================
  1129. friend class Displays;
  1130. static AndroidComponentPeer* frontWindow;
  1131. static GlobalRef activityCallbackListener;
  1132. static constexpr int GRAVITY_LEFT = 0x3, GRAVITY_TOP = 0x30;
  1133. static constexpr int TYPE_APPLICATION = 0x2;
  1134. static constexpr int FLAG_NOT_TOUCH_MODAL = 0x20, FLAG_LAYOUT_IN_SCREEN = 0x100, FLAG_LAYOUT_NO_LIMITS = 0x200;
  1135. static constexpr int PIXEL_FORMAT_OPAQUE = -1, PIXEL_FORMAT_TRANSPARENT = -2;
  1136. static constexpr int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 0x3;
  1137. GlobalRef view, viewGroup, buffer;
  1138. bool viewGroupIsWindow = false, fullScreen = false, navBarsHidden = false;
  1139. int sizeAllocated = 0;
  1140. float scale = (float) Desktop::getInstance().getDisplays().getPrimaryDisplay()->scale;
  1141. //==============================================================================
  1142. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AndroidComponentPeer)
  1143. };
  1144. Point<float> AndroidComponentPeer::lastMousePos;
  1145. int64 AndroidComponentPeer::touchesDown = 0;
  1146. AndroidComponentPeer* AndroidComponentPeer::frontWindow = nullptr;
  1147. GlobalRef AndroidComponentPeer::activityCallbackListener;
  1148. AndroidComponentPeer::ComponentPeerView_Class AndroidComponentPeer::ComponentPeerView;
  1149. //==============================================================================
  1150. ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindow)
  1151. {
  1152. return new AndroidComponentPeer (*this, styleFlags, nativeWindow);
  1153. }
  1154. //==============================================================================
  1155. bool Desktop::canUseSemiTransparentWindows() noexcept
  1156. {
  1157. return true;
  1158. }
  1159. class Desktop::NativeDarkModeChangeDetectorImpl : public ActivityLifecycleCallbacks
  1160. {
  1161. public:
  1162. NativeDarkModeChangeDetectorImpl()
  1163. {
  1164. LocalRef<jobject> appContext (getAppContext());
  1165. if (appContext != nullptr)
  1166. {
  1167. auto* env = getEnv();
  1168. myself = GlobalRef (CreateJavaInterface (this, "android/app/Application$ActivityLifecycleCallbacks"));
  1169. env->CallVoidMethod (appContext.get(), AndroidApplication.registerActivityLifecycleCallbacks, myself.get());
  1170. }
  1171. }
  1172. ~NativeDarkModeChangeDetectorImpl() override
  1173. {
  1174. LocalRef<jobject> appContext (getAppContext());
  1175. if (appContext != nullptr && myself != nullptr)
  1176. {
  1177. auto* env = getEnv();
  1178. env->CallVoidMethod (appContext.get(),
  1179. AndroidApplication.unregisterActivityLifecycleCallbacks,
  1180. myself.get());
  1181. clear();
  1182. myself.clear();
  1183. }
  1184. }
  1185. bool isDarkModeEnabled() const noexcept { return darkModeEnabled; }
  1186. void onActivityStarted (jobject /*activity*/) override
  1187. {
  1188. const auto isEnabled = getDarkModeSetting();
  1189. if (darkModeEnabled != isEnabled)
  1190. {
  1191. darkModeEnabled = isEnabled;
  1192. Desktop::getInstance().darkModeChanged();
  1193. }
  1194. }
  1195. private:
  1196. static bool getDarkModeSetting()
  1197. {
  1198. auto* env = getEnv();
  1199. const LocalRef<jobject> resources (env->CallObjectMethod (getAppContext().get(), AndroidContext.getResources));
  1200. const LocalRef<jobject> configuration (env->CallObjectMethod (resources, AndroidResources.getConfiguration));
  1201. const auto uiMode = env->GetIntField (configuration, AndroidConfiguration.uiMode);
  1202. return ((uiMode & UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES);
  1203. }
  1204. static constexpr int UI_MODE_NIGHT_MASK = 0x00000030,
  1205. UI_MODE_NIGHT_NO = 0x00000010,
  1206. UI_MODE_NIGHT_UNDEFINED = 0x00000000,
  1207. UI_MODE_NIGHT_YES = 0x00000020;
  1208. GlobalRef myself;
  1209. bool darkModeEnabled = getDarkModeSetting();
  1210. //==============================================================================
  1211. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NativeDarkModeChangeDetectorImpl)
  1212. };
  1213. std::unique_ptr<Desktop::NativeDarkModeChangeDetectorImpl> Desktop::createNativeDarkModeChangeDetectorImpl()
  1214. {
  1215. return std::make_unique<NativeDarkModeChangeDetectorImpl>();
  1216. }
  1217. bool Desktop::isDarkModeActive() const
  1218. {
  1219. return nativeDarkModeChangeDetectorImpl->isDarkModeEnabled();
  1220. }
  1221. double Desktop::getDefaultMasterScale()
  1222. {
  1223. return 1.0;
  1224. }
  1225. Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
  1226. {
  1227. enum
  1228. {
  1229. ROTATION_0 = 0,
  1230. ROTATION_90 = 1,
  1231. ROTATION_180 = 2,
  1232. ROTATION_270 = 3
  1233. };
  1234. JNIEnv* env = getEnv();
  1235. LocalRef<jstring> windowServiceString (javaString ("window"));
  1236. LocalRef<jobject> windowManager = LocalRef<jobject> (env->CallObjectMethod (getAppContext().get(), AndroidContext.getSystemService, windowServiceString.get()));
  1237. if (windowManager.get() != nullptr)
  1238. {
  1239. LocalRef<jobject> display = LocalRef<jobject> (env->CallObjectMethod (windowManager, AndroidWindowManager.getDefaultDisplay));
  1240. if (display.get() != nullptr)
  1241. {
  1242. int rotation = env->CallIntMethod (display, AndroidDisplay.getRotation);
  1243. switch (rotation)
  1244. {
  1245. case ROTATION_0: return upright;
  1246. case ROTATION_90: return rotatedAntiClockwise;
  1247. case ROTATION_180: return upsideDown;
  1248. case ROTATION_270: return rotatedClockwise;
  1249. }
  1250. }
  1251. }
  1252. jassertfalse;
  1253. return upright;
  1254. }
  1255. bool MouseInputSource::SourceList::addSource()
  1256. {
  1257. addSource (sources.size(), MouseInputSource::InputSourceType::touch);
  1258. return true;
  1259. }
  1260. bool MouseInputSource::SourceList::canUseTouch()
  1261. {
  1262. return true;
  1263. }
  1264. Point<float> MouseInputSource::getCurrentRawMousePosition()
  1265. {
  1266. return AndroidComponentPeer::lastMousePos;
  1267. }
  1268. void MouseInputSource::setRawMousePosition (Point<float>)
  1269. {
  1270. // not needed
  1271. }
  1272. //==============================================================================
  1273. bool KeyPress::isKeyCurrentlyDown (int /*keyCode*/)
  1274. {
  1275. // TODO
  1276. return false;
  1277. }
  1278. JUCE_API void JUCE_CALLTYPE Process::hide()
  1279. {
  1280. auto* env = getEnv();
  1281. LocalRef<jobject> currentActivity (getCurrentActivity().get());
  1282. if (env->CallBooleanMethod (currentActivity.get(), AndroidActivity.moveTaskToBack, true) == 0)
  1283. {
  1284. GlobalRef intent (LocalRef<jobject> (env->NewObject (AndroidIntent, AndroidIntent.constructor)));
  1285. env->CallObjectMethod (intent, AndroidIntent.setAction, javaString ("android.intent.action.MAIN") .get());
  1286. env->CallObjectMethod (intent, AndroidIntent.addCategory, javaString ("android.intent.category.HOME").get());
  1287. env->CallVoidMethod (currentActivity.get(), AndroidContext.startActivity, intent.get());
  1288. }
  1289. }
  1290. //==============================================================================
  1291. // TODO
  1292. JUCE_API bool JUCE_CALLTYPE Process::isForegroundProcess() { return true; }
  1293. JUCE_API void JUCE_CALLTYPE Process::makeForegroundProcess() {}
  1294. //==============================================================================
  1295. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  1296. METHOD (show, "show", "()V") \
  1297. METHOD (getWindow, "getWindow", "()Landroid/view/Window;")
  1298. DECLARE_JNI_CLASS (AndroidDialog, "android/app/Dialog")
  1299. #undef JNI_CLASS_MEMBERS
  1300. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  1301. METHOD (construct, "<init>", "(Landroid/content/Context;)V") \
  1302. METHOD (create, "create", "()Landroid/app/AlertDialog;") \
  1303. METHOD (setTitle, "setTitle", "(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;") \
  1304. METHOD (setMessage, "setMessage", "(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;") \
  1305. METHOD (setCancelable, "setCancelable", "(Z)Landroid/app/AlertDialog$Builder;") \
  1306. METHOD (setOnCancelListener, "setOnCancelListener", "(Landroid/content/DialogInterface$OnCancelListener;)Landroid/app/AlertDialog$Builder;") \
  1307. METHOD (setPositiveButton, "setPositiveButton", "(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;") \
  1308. METHOD (setNegativeButton, "setNegativeButton", "(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;") \
  1309. METHOD (setNeutralButton, "setNeutralButton", "(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;")
  1310. DECLARE_JNI_CLASS (AndroidAlertDialogBuilder, "android/app/AlertDialog$Builder")
  1311. #undef JNI_CLASS_MEMBERS
  1312. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  1313. METHOD (dismiss, "dismiss", "()V")
  1314. DECLARE_JNI_CLASS (AndroidDialogInterface, "android/content/DialogInterface")
  1315. #undef JNI_CLASS_MEMBERS
  1316. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  1317. DECLARE_JNI_CLASS (AndroidDialogOnClickListener, "android/content/DialogInterface$OnClickListener")
  1318. #undef JNI_CLASS_MEMBERS
  1319. //==============================================================================
  1320. class DialogListener : public juce::AndroidInterfaceImplementer
  1321. {
  1322. public:
  1323. DialogListener (std::shared_ptr<ModalComponentManager::Callback> callbackToUse, int resultToUse)
  1324. : callback (std::move (callbackToUse)), result (resultToUse)
  1325. {}
  1326. void onResult (jobject dialog)
  1327. {
  1328. auto* env = getEnv();
  1329. env->CallVoidMethod (dialog, AndroidDialogInterface.dismiss);
  1330. if (callback != nullptr)
  1331. callback->modalStateFinished (result);
  1332. callback = nullptr;
  1333. }
  1334. private:
  1335. jobject invoke (jobject proxy, jobject method, jobjectArray args) override
  1336. {
  1337. auto* env = getEnv();
  1338. auto methodName = juce::juceString ((jstring) env->CallObjectMethod (method, JavaMethod.getName));
  1339. if (methodName == "onCancel" || methodName == "onClick")
  1340. {
  1341. onResult (env->GetObjectArrayElement (args, 0));
  1342. return nullptr;
  1343. }
  1344. // invoke base class
  1345. return AndroidInterfaceImplementer::invoke (proxy, method, args);
  1346. }
  1347. std::shared_ptr<ModalComponentManager::Callback> callback;
  1348. int result;
  1349. };
  1350. //==============================================================================
  1351. static void createAndroidDialog (const MessageBoxOptions& opts,
  1352. ModalComponentManager::Callback* callbackIn,
  1353. AlertWindowMappings::MapFn mapFn)
  1354. {
  1355. auto* env = getEnv();
  1356. LocalRef<jobject> builder (env->NewObject (AndroidAlertDialogBuilder, AndroidAlertDialogBuilder.construct, getMainActivity().get()));
  1357. builder = LocalRef<jobject> (env->CallObjectMethod (builder.get(), AndroidAlertDialogBuilder.setTitle, javaString (opts.getTitle()).get()));
  1358. builder = LocalRef<jobject> (env->CallObjectMethod (builder.get(), AndroidAlertDialogBuilder.setMessage, javaString (opts.getMessage()).get()));
  1359. builder = LocalRef<jobject> (env->CallObjectMethod (builder.get(), AndroidAlertDialogBuilder.setCancelable, true));
  1360. std::shared_ptr<ModalComponentManager::Callback> sharedCallback (AlertWindowMappings::getWrappedCallback (callbackIn, mapFn));
  1361. builder = LocalRef<jobject> (env->CallObjectMethod (builder.get(), AndroidAlertDialogBuilder.setOnCancelListener,
  1362. CreateJavaInterface (new DialogListener (sharedCallback, 0),
  1363. "android/content/DialogInterface$OnCancelListener").get()));
  1364. builder = LocalRef<jobject> (env->CallObjectMethod (builder.get(), AndroidAlertDialogBuilder.setPositiveButton,
  1365. javaString (opts.getButtonText (0)).get(),
  1366. CreateJavaInterface (new DialogListener (sharedCallback, 0),
  1367. "android/content/DialogInterface$OnClickListener").get()));
  1368. if (opts.getButtonText (1).isNotEmpty())
  1369. builder = LocalRef<jobject> (env->CallObjectMethod (builder.get(), AndroidAlertDialogBuilder.setNegativeButton,
  1370. javaString (opts.getButtonText (1)).get(),
  1371. CreateJavaInterface (new DialogListener (sharedCallback, 1),
  1372. "android/content/DialogInterface$OnClickListener").get()));
  1373. if (opts.getButtonText (2).isNotEmpty())
  1374. builder = LocalRef<jobject> (env->CallObjectMethod (builder.get(), AndroidAlertDialogBuilder.setNeutralButton,
  1375. javaString (opts.getButtonText (2)).get(),
  1376. CreateJavaInterface (new DialogListener (sharedCallback, 2),
  1377. "android/content/DialogInterface$OnClickListener").get()));
  1378. LocalRef<jobject> dialog (env->CallObjectMethod (builder.get(), AndroidAlertDialogBuilder.create));
  1379. LocalRef<jobject> window (env->CallObjectMethod (dialog.get(), AndroidDialog.getWindow));
  1380. if (Desktop::getInstance().getKioskModeComponent() != nullptr)
  1381. {
  1382. env->CallVoidMethod (window.get(), AndroidWindow.setFlags, FLAG_NOT_FOCUSABLE, FLAG_NOT_FOCUSABLE);
  1383. LocalRef<jobject> decorView (env->CallObjectMethod (window.get(), AndroidWindow.getDecorView));
  1384. env->CallVoidMethod (decorView.get(), AndroidView.setSystemUiVisibility, fullScreenFlags);
  1385. }
  1386. env->CallVoidMethod (dialog.get(), AndroidDialog.show);
  1387. if (Desktop::getInstance().getKioskModeComponent() != nullptr)
  1388. env->CallVoidMethod (window.get(), AndroidWindow.clearFlags, FLAG_NOT_FOCUSABLE);
  1389. }
  1390. void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (MessageBoxIconType /*iconType*/,
  1391. const String& title, const String& message,
  1392. Component* /*associatedComponent*/,
  1393. ModalComponentManager::Callback* callback)
  1394. {
  1395. createAndroidDialog (MessageBoxOptions()
  1396. .withTitle (title)
  1397. .withMessage (message)
  1398. .withButton (TRANS("OK")),
  1399. callback, AlertWindowMappings::messageBox);
  1400. }
  1401. bool JUCE_CALLTYPE NativeMessageBox::showOkCancelBox (MessageBoxIconType /*iconType*/,
  1402. const String& title, const String& message,
  1403. Component* /*associatedComponent*/,
  1404. ModalComponentManager::Callback* callback)
  1405. {
  1406. createAndroidDialog (MessageBoxOptions()
  1407. .withTitle (title)
  1408. .withMessage (message)
  1409. .withButton (TRANS("OK"))
  1410. .withButton (TRANS("Cancel")),
  1411. callback, AlertWindowMappings::okCancel);
  1412. return false;
  1413. }
  1414. int JUCE_CALLTYPE NativeMessageBox::showYesNoCancelBox (MessageBoxIconType /*iconType*/,
  1415. const String& title, const String& message,
  1416. Component* /*associatedComponent*/,
  1417. ModalComponentManager::Callback* callback)
  1418. {
  1419. createAndroidDialog (MessageBoxOptions()
  1420. .withTitle (title)
  1421. .withMessage (message)
  1422. .withButton (TRANS("Yes"))
  1423. .withButton (TRANS("No"))
  1424. .withButton (TRANS("Cancel")),
  1425. callback, AlertWindowMappings::yesNoCancel);
  1426. return 0;
  1427. }
  1428. int JUCE_CALLTYPE NativeMessageBox::showYesNoBox (MessageBoxIconType /*iconType*/,
  1429. const String& title, const String& message,
  1430. Component* /*associatedComponent*/,
  1431. ModalComponentManager::Callback* callback)
  1432. {
  1433. createAndroidDialog (MessageBoxOptions()
  1434. .withTitle (title)
  1435. .withMessage (message)
  1436. .withButton (TRANS("Yes"))
  1437. .withButton (TRANS("No")),
  1438. callback, AlertWindowMappings::okCancel);
  1439. return 0;
  1440. }
  1441. void JUCE_CALLTYPE NativeMessageBox::showAsync (const MessageBoxOptions& options,
  1442. ModalComponentManager::Callback* callback)
  1443. {
  1444. createAndroidDialog (options, callback, AlertWindowMappings::noMapping);
  1445. }
  1446. void JUCE_CALLTYPE NativeMessageBox::showAsync (const MessageBoxOptions& options,
  1447. std::function<void (int)> callback)
  1448. {
  1449. showAsync (options, ModalCallbackFunction::create (callback));
  1450. }
  1451. //==============================================================================
  1452. static bool androidScreenSaverEnabled = true;
  1453. void Desktop::setScreenSaverEnabled (bool shouldEnable)
  1454. {
  1455. constexpr auto FLAG_KEEP_SCREEN_ON = 0x80;
  1456. if (shouldEnable != androidScreenSaverEnabled)
  1457. {
  1458. LocalRef<jobject> activity (getMainActivity());
  1459. if (activity != nullptr)
  1460. {
  1461. auto* env = getEnv();
  1462. LocalRef<jobject> mainWindow (env->CallObjectMethod (activity.get(), AndroidActivity.getWindow));
  1463. env->CallVoidMethod (mainWindow.get(), AndroidWindow.setFlags, shouldEnable ? 0 : FLAG_KEEP_SCREEN_ON, FLAG_KEEP_SCREEN_ON);
  1464. }
  1465. androidScreenSaverEnabled = shouldEnable;
  1466. }
  1467. }
  1468. bool Desktop::isScreenSaverEnabled()
  1469. {
  1470. return androidScreenSaverEnabled;
  1471. }
  1472. //==============================================================================
  1473. void Desktop::setKioskComponent (Component* kioskComp, bool enableOrDisable, bool allowMenusAndBars)
  1474. {
  1475. ignoreUnused (allowMenusAndBars);
  1476. if (AndroidComponentPeer* peer = dynamic_cast<AndroidComponentPeer*> (kioskComp->getPeer()))
  1477. peer->setFullScreen (enableOrDisable);
  1478. else
  1479. jassertfalse; // (this should have been checked by the caller)
  1480. }
  1481. //==============================================================================
  1482. static jint getAndroidOrientationFlag (int orientations) noexcept
  1483. {
  1484. enum
  1485. {
  1486. SCREEN_ORIENTATION_LANDSCAPE = 0,
  1487. SCREEN_ORIENTATION_PORTRAIT = 1,
  1488. SCREEN_ORIENTATION_USER = 2,
  1489. SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8,
  1490. SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9,
  1491. SCREEN_ORIENTATION_USER_LANDSCAPE = 11,
  1492. SCREEN_ORIENTATION_USER_PORTRAIT = 12,
  1493. };
  1494. switch (orientations)
  1495. {
  1496. case Desktop::upright: return (jint) SCREEN_ORIENTATION_PORTRAIT;
  1497. case Desktop::upsideDown: return (jint) SCREEN_ORIENTATION_REVERSE_PORTRAIT;
  1498. case Desktop::upright + Desktop::upsideDown: return (jint) SCREEN_ORIENTATION_USER_PORTRAIT;
  1499. case Desktop::rotatedAntiClockwise: return (jint) SCREEN_ORIENTATION_LANDSCAPE;
  1500. case Desktop::rotatedClockwise: return (jint) SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
  1501. case Desktop::rotatedClockwise + Desktop::rotatedAntiClockwise: return (jint) SCREEN_ORIENTATION_USER_LANDSCAPE;
  1502. default: return (jint) SCREEN_ORIENTATION_USER;
  1503. }
  1504. }
  1505. void Desktop::allowedOrientationsChanged()
  1506. {
  1507. LocalRef<jobject> activity (getMainActivity());
  1508. if (activity != nullptr)
  1509. getEnv()->CallVoidMethod (activity.get(), AndroidActivity.setRequestedOrientation, getAndroidOrientationFlag (allowedOrientations));
  1510. }
  1511. //==============================================================================
  1512. bool juce_areThereAnyAlwaysOnTopWindows()
  1513. {
  1514. return false;
  1515. }
  1516. //==============================================================================
  1517. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  1518. METHOD (create, "<init>", "()V") \
  1519. FIELD (density, "density", "F") \
  1520. FIELD (widthPixels, "widthPixels", "I") \
  1521. FIELD (heightPixels, "heightPixels", "I")
  1522. DECLARE_JNI_CLASS (AndroidDisplayMetrics, "android/util/DisplayMetrics")
  1523. #undef JNI_CLASS_MEMBERS
  1524. //==============================================================================
  1525. class LayoutChangeListener : public juce::AndroidInterfaceImplementer
  1526. {
  1527. public:
  1528. virtual void onLayoutChange (LocalRef<jobject> view, int left, int top, int right, int bottom,
  1529. int oldLeft, int oldTop, int oldRight, int oldBottom) = 0;
  1530. private:
  1531. jobject invoke (jobject proxy, jobject method, jobjectArray args) override
  1532. {
  1533. auto* env = getEnv();
  1534. auto methodName = juce::juceString ((jstring) env->CallObjectMethod (method, JavaMethod.getName));
  1535. if (methodName == "onLayoutChange")
  1536. {
  1537. jassert (env->GetArrayLength (args) == 9);
  1538. LocalRef<jobject> view (env->GetObjectArrayElement (args, 0));
  1539. int dims[8];
  1540. for (int i = 1; i < 9; ++i)
  1541. {
  1542. LocalRef<jobject> integer (env->GetObjectArrayElement (args, i));
  1543. dims[i - 1] = env->CallIntMethod (integer.get(), JavaInteger.intValue);
  1544. }
  1545. onLayoutChange (std::move (view), dims[0], dims[1], dims[2], dims[3],
  1546. dims[4], dims[5], dims[6], dims[7]);
  1547. return nullptr;
  1548. }
  1549. // invoke base class
  1550. return AndroidInterfaceImplementer::invoke (proxy, method, args);
  1551. }
  1552. std::unique_ptr<ModalComponentManager::Callback> callback;
  1553. };
  1554. //==============================================================================
  1555. struct MainActivityWindowLayoutListener : public LayoutChangeListener
  1556. {
  1557. MainActivityWindowLayoutListener (std::function<void()>&& updateDisplaysCb)
  1558. : forceDisplayUpdate (std::move (updateDisplaysCb))
  1559. {
  1560. }
  1561. void onLayoutChange (LocalRef<jobject> /*view*/, int left, int top, int right, int bottom,
  1562. int oldLeft, int oldTop, int oldRight, int oldBottom) override
  1563. {
  1564. auto newBounds = Rectangle<int>::leftTopRightBottom (left, top, right, bottom);
  1565. auto oldBounds = Rectangle<int>::leftTopRightBottom (oldLeft, oldTop, oldRight, oldBottom);
  1566. if (newBounds != oldBounds)
  1567. {
  1568. const auto& mainDisplay = *Desktop::getInstance().getDisplays().getPrimaryDisplay();
  1569. auto userArea = (newBounds.toFloat() / mainDisplay.scale).toNearestInt();
  1570. if (userArea != mainDisplay.userArea)
  1571. forceDisplayUpdate();
  1572. }
  1573. }
  1574. std::function<void()> forceDisplayUpdate;
  1575. };
  1576. //==============================================================================
  1577. void Displays::findDisplays (float masterScale)
  1578. {
  1579. auto* env = getEnv();
  1580. LocalRef<jobject> usableSize (env->NewObject (AndroidPoint, AndroidPoint.create, 0, 0));
  1581. LocalRef<jstring> windowServiceString (javaString ("window"));
  1582. LocalRef<jobject> displayMetrics (env->NewObject (AndroidDisplayMetrics, AndroidDisplayMetrics.create));
  1583. LocalRef<jobject> windowManager (env->CallObjectMethod (getAppContext().get(), AndroidContext.getSystemService, windowServiceString.get()));
  1584. LocalRef <jobject> display (env->CallObjectMethod (windowManager, AndroidWindowManager.getDefaultDisplay));
  1585. jmethodID getRealMetricsMethod = env->GetMethodID (AndroidDisplay, "getRealMetrics", "(Landroid/util/DisplayMetrics;)V");
  1586. if (getRealMetricsMethod != nullptr)
  1587. env->CallVoidMethod (display.get(), getRealMetricsMethod, displayMetrics.get());
  1588. else
  1589. env->CallVoidMethod (display.get(), AndroidDisplay.getMetrics, displayMetrics.get());
  1590. env->CallVoidMethod (display.get(), AndroidDisplay.getSize, usableSize.get());
  1591. Display d;
  1592. d.isMain = true;
  1593. d.scale = env->GetFloatField (displayMetrics.get(), AndroidDisplayMetrics.density);
  1594. d.dpi = (d.scale * 160.f);
  1595. d.scale *= masterScale;
  1596. d.totalArea = Rectangle<int> (env->GetIntField (displayMetrics.get(), AndroidDisplayMetrics.widthPixels),
  1597. env->GetIntField (displayMetrics.get(), AndroidDisplayMetrics.heightPixels)) / d.scale;
  1598. d.userArea = Rectangle<int> (env->GetIntField (usableSize.get(), AndroidPoint.x),
  1599. env->GetIntField (usableSize.get(), AndroidPoint.y)) / d.scale;
  1600. // unfortunately usableSize still contains the nav bar
  1601. // the best workaround is to try to get the size of the top-level view of
  1602. // the main activity
  1603. LocalRef<jobject> activity (getMainActivity());
  1604. if (activity != nullptr)
  1605. {
  1606. LocalRef<jobject> mainWindow (env->CallObjectMethod (activity.get(), AndroidActivity.getWindow));
  1607. LocalRef<jobject> decorView (env->CallObjectMethod (mainWindow.get(), AndroidWindow.getDecorView));
  1608. LocalRef<jobject> contentView (env->CallObjectMethod (decorView.get(), AndroidView.findViewById, 0x01020002 /* android.R.id.content */));
  1609. if (contentView != nullptr)
  1610. {
  1611. Rectangle<int> activityArea (env->CallIntMethod (contentView.get(), AndroidView.getLeft),
  1612. env->CallIntMethod (contentView.get(), AndroidView.getTop),
  1613. env->CallIntMethod (contentView.get(), AndroidView.getWidth),
  1614. env->CallIntMethod (contentView.get(), AndroidView.getHeight));
  1615. if (! activityArea.isEmpty())
  1616. d.userArea = activityArea / d.scale;
  1617. if (supportsDisplayCutout())
  1618. {
  1619. jmethodID getRootWindowInsetsMethodId = env->GetMethodID (AndroidView,
  1620. "getRootWindowInsets",
  1621. "()Landroid/view/WindowInsets;");
  1622. if (getRootWindowInsetsMethodId != nullptr)
  1623. {
  1624. LocalRef<jobject> insets (env->CallObjectMethod (contentView.get(), getRootWindowInsetsMethodId));
  1625. if (insets != nullptr)
  1626. {
  1627. LocalRef<jobject> displayCutout (env->CallObjectMethod (insets.get(), AndroidWindowInsets.getDisplayCutout));
  1628. if (displayCutout.get() != nullptr)
  1629. d.safeAreaInsets = androidDisplayCutoutToBorderSize (displayCutout, d.scale);
  1630. }
  1631. }
  1632. }
  1633. static bool hasAddedMainActivityListener = false;
  1634. if (! hasAddedMainActivityListener)
  1635. {
  1636. hasAddedMainActivityListener = true;
  1637. env->CallVoidMethod (contentView.get(), AndroidView.addOnLayoutChangeListener,
  1638. CreateJavaInterface (new MainActivityWindowLayoutListener ([this] { refresh(); }),
  1639. "android/view/View$OnLayoutChangeListener").get());
  1640. }
  1641. }
  1642. }
  1643. else
  1644. {
  1645. // the main activity may have not started yet so add an activity listener
  1646. if (AndroidComponentPeer::activityCallbackListener == nullptr)
  1647. {
  1648. LocalRef<jobject> appContext (getAppContext());
  1649. if (appContext.get() != nullptr)
  1650. {
  1651. AndroidComponentPeer::activityCallbackListener = GlobalRef (CreateJavaInterface (
  1652. new AndroidComponentPeer::StartupActivityCallbackListener,
  1653. "android/app/Application$ActivityLifecycleCallbacks"));
  1654. env->CallVoidMethod (appContext.get(),
  1655. AndroidApplication.registerActivityLifecycleCallbacks,
  1656. AndroidComponentPeer::activityCallbackListener.get());
  1657. }
  1658. }
  1659. }
  1660. displays.add (d);
  1661. }
  1662. //==============================================================================
  1663. Image juce_createIconForFile (const File& /*file*/)
  1664. {
  1665. return Image();
  1666. }
  1667. //==============================================================================
  1668. class MouseCursor::PlatformSpecificHandle
  1669. {
  1670. public:
  1671. PlatformSpecificHandle (const MouseCursor::StandardCursorType) {}
  1672. PlatformSpecificHandle (const CustomMouseCursorInfo&) {}
  1673. static void showInWindow (PlatformSpecificHandle*, ComponentPeer*) {}
  1674. };
  1675. //==============================================================================
  1676. bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& /*files*/, bool /*canMove*/,
  1677. Component* /*srcComp*/, std::function<void()> /*callback*/)
  1678. {
  1679. jassertfalse; // no such thing on Android!
  1680. return false;
  1681. }
  1682. bool DragAndDropContainer::performExternalDragDropOfText (const String& /*text*/, Component* /*srcComp*/,
  1683. std::function<void()> /*callback*/)
  1684. {
  1685. jassertfalse; // no such thing on Android!
  1686. return false;
  1687. }
  1688. //==============================================================================
  1689. void LookAndFeel::playAlertSound()
  1690. {
  1691. }
  1692. //==============================================================================
  1693. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  1694. METHOD (getText, "getText", "()Ljava/lang/CharSequence;") \
  1695. METHOD (setText, "setText", "(Ljava/lang/CharSequence;)V")
  1696. DECLARE_JNI_CLASS (AndroidClipboardManager, "android/content/ClipboardManager")
  1697. #undef JNI_CLASS_MEMBERS
  1698. //==============================================================================
  1699. void SystemClipboard::copyTextToClipboard (const String& text)
  1700. {
  1701. auto* env = getEnv();
  1702. LocalRef<jobject> clipboardManager (env->CallObjectMethod (getAppContext().get(), AndroidContext.getSystemService, javaString ("clipboard").get()));
  1703. env->CallVoidMethod (clipboardManager.get(), AndroidClipboardManager.setText, javaString(text).get());
  1704. }
  1705. String SystemClipboard::getTextFromClipboard()
  1706. {
  1707. auto* env = getEnv();
  1708. LocalRef<jobject> clipboardManager (env->CallObjectMethod (getAppContext().get(), AndroidContext.getSystemService, javaString ("clipboard").get()));
  1709. LocalRef<jobject> charSequence (env->CallObjectMethod (clipboardManager.get(), AndroidClipboardManager.getText));
  1710. if (charSequence == nullptr)
  1711. return {};
  1712. return juceString(LocalRef<jstring> ((jstring) env->CallObjectMethod(charSequence.get(), JavaCharSequence.toString)));
  1713. }
  1714. //==============================================================================
  1715. constexpr int extendedKeyModifier = 0x10000;
  1716. const int KeyPress::spaceKey = ' ';
  1717. const int KeyPress::returnKey = extendedKeyModifier + 2;
  1718. const int KeyPress::escapeKey = extendedKeyModifier + 3;
  1719. const int KeyPress::backspaceKey = extendedKeyModifier + 4;
  1720. const int KeyPress::leftKey = extendedKeyModifier + 5;
  1721. const int KeyPress::rightKey = extendedKeyModifier + 6;
  1722. const int KeyPress::upKey = extendedKeyModifier + 7;
  1723. const int KeyPress::downKey = extendedKeyModifier + 8;
  1724. const int KeyPress::pageUpKey = extendedKeyModifier + 9;
  1725. const int KeyPress::pageDownKey = extendedKeyModifier + 10;
  1726. const int KeyPress::endKey = extendedKeyModifier + 11;
  1727. const int KeyPress::homeKey = extendedKeyModifier + 12;
  1728. const int KeyPress::deleteKey = extendedKeyModifier + 13;
  1729. const int KeyPress::insertKey = extendedKeyModifier + 14;
  1730. const int KeyPress::tabKey = extendedKeyModifier + 15;
  1731. const int KeyPress::F1Key = extendedKeyModifier + 16;
  1732. const int KeyPress::F2Key = extendedKeyModifier + 17;
  1733. const int KeyPress::F3Key = extendedKeyModifier + 18;
  1734. const int KeyPress::F4Key = extendedKeyModifier + 19;
  1735. const int KeyPress::F5Key = extendedKeyModifier + 20;
  1736. const int KeyPress::F6Key = extendedKeyModifier + 21;
  1737. const int KeyPress::F7Key = extendedKeyModifier + 22;
  1738. const int KeyPress::F8Key = extendedKeyModifier + 23;
  1739. const int KeyPress::F9Key = extendedKeyModifier + 24;
  1740. const int KeyPress::F10Key = extendedKeyModifier + 25;
  1741. const int KeyPress::F11Key = extendedKeyModifier + 26;
  1742. const int KeyPress::F12Key = extendedKeyModifier + 27;
  1743. const int KeyPress::F13Key = extendedKeyModifier + 28;
  1744. const int KeyPress::F14Key = extendedKeyModifier + 29;
  1745. const int KeyPress::F15Key = extendedKeyModifier + 30;
  1746. const int KeyPress::F16Key = extendedKeyModifier + 31;
  1747. const int KeyPress::F17Key = extendedKeyModifier + 32;
  1748. const int KeyPress::F18Key = extendedKeyModifier + 33;
  1749. const int KeyPress::F19Key = extendedKeyModifier + 34;
  1750. const int KeyPress::F20Key = extendedKeyModifier + 35;
  1751. const int KeyPress::F21Key = extendedKeyModifier + 36;
  1752. const int KeyPress::F22Key = extendedKeyModifier + 37;
  1753. const int KeyPress::F23Key = extendedKeyModifier + 38;
  1754. const int KeyPress::F24Key = extendedKeyModifier + 39;
  1755. const int KeyPress::F25Key = extendedKeyModifier + 40;
  1756. const int KeyPress::F26Key = extendedKeyModifier + 41;
  1757. const int KeyPress::F27Key = extendedKeyModifier + 42;
  1758. const int KeyPress::F28Key = extendedKeyModifier + 43;
  1759. const int KeyPress::F29Key = extendedKeyModifier + 44;
  1760. const int KeyPress::F30Key = extendedKeyModifier + 45;
  1761. const int KeyPress::F31Key = extendedKeyModifier + 46;
  1762. const int KeyPress::F32Key = extendedKeyModifier + 47;
  1763. const int KeyPress::F33Key = extendedKeyModifier + 48;
  1764. const int KeyPress::F34Key = extendedKeyModifier + 49;
  1765. const int KeyPress::F35Key = extendedKeyModifier + 50;
  1766. const int KeyPress::numberPad0 = extendedKeyModifier + 51;
  1767. const int KeyPress::numberPad1 = extendedKeyModifier + 52;
  1768. const int KeyPress::numberPad2 = extendedKeyModifier + 53;
  1769. const int KeyPress::numberPad3 = extendedKeyModifier + 54;
  1770. const int KeyPress::numberPad4 = extendedKeyModifier + 55;
  1771. const int KeyPress::numberPad5 = extendedKeyModifier + 56;
  1772. const int KeyPress::numberPad6 = extendedKeyModifier + 57;
  1773. const int KeyPress::numberPad7 = extendedKeyModifier + 58;
  1774. const int KeyPress::numberPad8 = extendedKeyModifier + 59;
  1775. const int KeyPress::numberPad9 = extendedKeyModifier + 60;
  1776. const int KeyPress::numberPadAdd = extendedKeyModifier + 61;
  1777. const int KeyPress::numberPadSubtract = extendedKeyModifier + 62;
  1778. const int KeyPress::numberPadMultiply = extendedKeyModifier + 63;
  1779. const int KeyPress::numberPadDivide = extendedKeyModifier + 64;
  1780. const int KeyPress::numberPadSeparator = extendedKeyModifier + 65;
  1781. const int KeyPress::numberPadDecimalPoint = extendedKeyModifier + 66;
  1782. const int KeyPress::numberPadEquals = extendedKeyModifier + 67;
  1783. const int KeyPress::numberPadDelete = extendedKeyModifier + 68;
  1784. const int KeyPress::playKey = extendedKeyModifier + 69;
  1785. const int KeyPress::stopKey = extendedKeyModifier + 70;
  1786. const int KeyPress::fastForwardKey = extendedKeyModifier + 71;
  1787. const int KeyPress::rewindKey = extendedKeyModifier + 72;
  1788. //==============================================================================
  1789. #ifdef JUCE_PUSH_NOTIFICATIONS_ACTIVITY
  1790. struct JuceActivityNewIntentListener
  1791. {
  1792. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
  1793. CALLBACK (appNewIntent, "appNewIntent", "(Landroid/content/Intent;)V")
  1794. DECLARE_JNI_CLASS (JavaActivity, JUCE_PUSH_NOTIFICATIONS_ACTIVITY)
  1795. #undef JNI_CLASS_MEMBERS
  1796. static void JNICALL appNewIntent (JNIEnv*, jobject /*activity*/, jobject intentData)
  1797. {
  1798. juce_handleNotificationIntent (static_cast<void*> (intentData));
  1799. }
  1800. };
  1801. JuceActivityNewIntentListener::JavaActivity_Class JuceActivityNewIntentListener::JavaActivity;
  1802. #endif
  1803. } // namespace juce