porting_android.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 header has to be included on Android port only!
  19. #endif
  20. #include "irrlichttypes_bloated.h"
  21. #include <string>
  22. namespace porting {
  23. /**
  24. * Show a text input dialog in Java
  25. * @param hint Hint to be shown
  26. * @param current Initial value to be displayed
  27. * @param editType Type of the text field
  28. * (1 = multi-line text input; 2 = single-line text input; 3 = password field)
  29. */
  30. void showTextInputDialog(const std::string &hint, const std::string &current, int editType);
  31. /**
  32. * Show a selection dialog in Java
  33. * @param optionList The list of options
  34. * @param listSize Size of the list
  35. * @param selectedIdx Selected index
  36. */
  37. void showComboBoxDialog(const std::string optionList[], s32 listSize, s32 selectedIdx);
  38. /**
  39. * Opens a share intent to the file at path
  40. *
  41. * @param path
  42. */
  43. void shareFileAndroid(const std::string &path);
  44. /*
  45. * Types of Android input dialog:
  46. * 1. Text input (single/multi-line text and password field)
  47. * 2. Selection input (combo box)
  48. */
  49. enum AndroidDialogType { TEXT_INPUT, SELECTION_INPUT };
  50. /*
  51. * WORKAROUND for not working callbacks from Java -> C++
  52. * Get the type of the last input dialog
  53. */
  54. AndroidDialogType getLastInputDialogType();
  55. /*
  56. * States of Android input dialog:
  57. * 1. The dialog is currently shown.
  58. * 2. The dialog has its input sent.
  59. * 3. The dialog is canceled/dismissed.
  60. */
  61. enum AndroidDialogState { DIALOG_SHOWN, DIALOG_INPUTTED, DIALOG_CANCELED };
  62. /*
  63. * WORKAROUND for not working callbacks from Java -> C++
  64. * Get the state of the input dialog
  65. */
  66. AndroidDialogState getInputDialogState();
  67. /*
  68. * WORKAROUND for not working callbacks from Java -> C++
  69. * Get the text in the current/last input dialog
  70. * This function clears the dialog state (set to canceled). Make sure to save
  71. * the dialog state before calling this function.
  72. */
  73. std::string getInputDialogMessage();
  74. /*
  75. * WORKAROUND for not working callbacks from Java -> C++
  76. * Get the selection in the current/last input dialog
  77. * This function clears the dialog state (set to canceled). Make sure to save
  78. * the dialog state before calling this function.
  79. */
  80. int getInputDialogSelection();
  81. bool hasPhysicalKeyboardAndroid();
  82. #ifndef SERVER
  83. float getDisplayDensity();
  84. v2u32 getDisplaySize();
  85. #endif
  86. }