-
Notifications
You must be signed in to change notification settings - Fork 2k
/
porting_android.h
113 lines (92 loc) · 3.13 KB
/
porting_android.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
Minetest
Copyright (C) 2014 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#ifndef __ANDROID__
#error This header has to be included on Android port only!
#endif
#include <jni.h>
#include <android_native_app_glue.h>
#include <android/log.h>
#include "irrlichttypes_bloated.h"
#include <string>
namespace porting {
// Java app
extern android_app *app_global;
// Java <-> C++ interaction interface
extern JNIEnv *jnienv;
/**
* Show a text input dialog in Java
* @param hint Hint to be shown
* @param current Initial value to be displayed
* @param editType Type of the text field
* (1 = multi-line text input; 2 = single-line text input; 3 = password field)
*/
void showTextInputDialog(const std::string &hint, const std::string ¤t, int editType);
/**
* Show a selection dialog in Java
* @param optionList The list of options
* @param listSize Size of the list
* @param selectedIdx Selected index
*/
void showComboBoxDialog(const std::string optionList[], s32 listSize, s32 selectedIdx);
/**
* Opens a share intent to the file at path
*
* @param path
*/
void shareFileAndroid(const std::string &path);
/*
* Types of Android input dialog:
* 1. Text input (single/multi-line text and password field)
* 2. Selection input (combo box)
*/
enum AndroidDialogType { TEXT_INPUT, SELECTION_INPUT };
/*
* WORKAROUND for not working callbacks from Java -> C++
* Get the type of the last input dialog
*/
AndroidDialogType getLastInputDialogType();
/*
* States of Android input dialog:
* 1. The dialog is currently shown.
* 2. The dialog has its input sent.
* 3. The dialog is canceled/dismissed.
*/
enum AndroidDialogState { DIALOG_SHOWN, DIALOG_INPUTTED, DIALOG_CANCELED };
/*
* WORKAROUND for not working callbacks from Java -> C++
* Get the state of the input dialog
*/
AndroidDialogState getInputDialogState();
/*
* WORKAROUND for not working callbacks from Java -> C++
* Get the text in the current/last input dialog
* This function clears the dialog state (set to canceled). Make sure to save
* the dialog state before calling this function.
*/
std::string getInputDialogMessage();
/*
* WORKAROUND for not working callbacks from Java -> C++
* Get the selection in the current/last input dialog
* This function clears the dialog state (set to canceled). Make sure to save
* the dialog state before calling this function.
*/
int getInputDialogSelection();
#ifndef SERVER
float getDisplayDensity();
v2u32 getDisplaySize();
#endif
}