porting_android.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef __PORTING_ANDROID_H__
  17. #define __PORTING_ANDROID_H__
  18. #ifndef __ANDROID__
  19. #error this include has to be included on android port only!
  20. #endif
  21. #include <jni.h>
  22. #include <android_native_app_glue.h>
  23. #include <android/log.h>
  24. #include <string>
  25. namespace porting {
  26. /** java app **/
  27. extern android_app *app_global;
  28. /** java <-> c++ interaction interface **/
  29. extern JNIEnv *jnienv;
  30. /**
  31. * do initialization required on android only
  32. */
  33. void initAndroid();
  34. void cleanupAndroid();
  35. /**
  36. * set storage dir on external sdcard#
  37. * @param lJNIEnv environment from android
  38. */
  39. void setExternalStorageDir(JNIEnv* lJNIEnv);
  40. /**
  41. * use java function to copy media from assets to external storage
  42. */
  43. void copyAssets();
  44. /**
  45. * show text input dialog in java
  46. * @param acceptButton text to display on accept button
  47. * @param hint hint to show
  48. * @param current initial value to display
  49. * @param editType type of texfield
  50. * (1==multiline text input; 2==single line text input; 3=password field)
  51. */
  52. void showInputDialog(const std::string& acceptButton,
  53. const std::string& hint, const std::string& current, int editType);
  54. /**
  55. * WORKAROUND for not working callbacks from java -> c++
  56. * get current state of input dialog
  57. */
  58. int getInputDialogState();
  59. /**
  60. * WORKAROUND for not working callbacks from java -> c++
  61. * get text in current input dialog
  62. */
  63. std::string getInputDialogValue();
  64. }
  65. #endif