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