porting_android.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. Minetest
  3. Copyright (C) 2014 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #ifndef __ANDROID__
  18. #error this include has to be included on android port only!
  19. #endif
  20. #include <jni.h>
  21. #include <android_native_app_glue.h>
  22. #include <android/log.h>
  23. #include <string>
  24. namespace porting {
  25. /** java app **/
  26. extern android_app *app_global;
  27. /** java <-> c++ interaction interface **/
  28. extern JNIEnv *jnienv;
  29. /**
  30. * do initialization required on android only
  31. */
  32. void initAndroid();
  33. void cleanupAndroid();
  34. /**
  35. * Initializes path_* variables for Android
  36. * @param env Android JNI environment
  37. */
  38. void initializePathsAndroid();
  39. /**
  40. * use java function to copy media from assets to external storage
  41. */
  42. void copyAssets();
  43. /**
  44. * show text input dialog in java
  45. * @param acceptButton text to display on accept button
  46. * @param hint hint to show
  47. * @param current initial value to display
  48. * @param editType type of texfield
  49. * (1==multiline text input; 2==single line text input; 3=password field)
  50. */
  51. void showInputDialog(const std::string& acceptButton,
  52. const std::string& hint, const std::string& current, int editType);
  53. /**
  54. * WORKAROUND for not working callbacks from java -> c++
  55. * get current state of input dialog
  56. */
  57. int getInputDialogState();
  58. /**
  59. * WORKAROUND for not working callbacks from java -> c++
  60. * get text in current input dialog
  61. */
  62. std::string getInputDialogValue();
  63. #ifndef SERVER
  64. float getDisplayDensity();
  65. v2u32 getDisplaySize();
  66. #endif
  67. }