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.

2121 lines
110KB

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