1 /*************************************************************************/
2 /*  java_godot_io_wrapper.h                                              */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md).   */
10 /*                                                                       */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the       */
13 /* "Software"), to deal in the Software without restriction, including   */
14 /* without limitation the rights to use, copy, modify, merge, publish,   */
15 /* distribute, sublicense, and/or sell copies of the Software, and to    */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions:                                             */
18 /*                                                                       */
19 /* The above copyright notice and this permission notice shall be        */
20 /* included in all copies or substantial portions of the Software.       */
21 /*                                                                       */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
29 /*************************************************************************/
30 
31 // note, swapped java and godot around in the file name so all the java
32 // wrappers are together
33 
34 #ifndef JAVA_GODOT_IO_WRAPPER_H
35 #define JAVA_GODOT_IO_WRAPPER_H
36 
37 #include <android/log.h>
38 #include <jni.h>
39 
40 #include "string_android.h"
41 
42 // Class that makes functions in java/src/org/godotengine/godot/GodotIO.java callable from C++
43 class GodotIOJavaWrapper {
44 private:
45 	jobject godot_io_instance;
46 	jclass cls;
47 
48 	jmethodID _open_URI = 0;
49 	jmethodID _get_data_dir = 0;
50 	jmethodID _get_locale = 0;
51 	jmethodID _get_model = 0;
52 	jmethodID _get_screen_DPI = 0;
53 	jmethodID _get_unique_id = 0;
54 	jmethodID _show_keyboard = 0;
55 	jmethodID _hide_keyboard = 0;
56 	jmethodID _set_screen_orientation = 0;
57 	jmethodID _get_system_dir = 0;
58 	jmethodID _play_video = 0;
59 	jmethodID _is_video_playing = 0;
60 	jmethodID _pause_video = 0;
61 	jmethodID _stop_video = 0;
62 
63 public:
64 	GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instance);
65 	~GodotIOJavaWrapper();
66 
67 	jobject get_instance();
68 
69 	Error open_uri(const String &p_uri);
70 	String get_user_data_dir();
71 	String get_locale();
72 	String get_model();
73 	int get_screen_dpi();
74 	String get_unique_id();
75 	bool has_vk();
76 	void show_vk(const String &p_existing, bool p_multiline, int p_max_input_length, int p_cursor_start, int p_cursor_end);
77 	void hide_vk();
78 	int get_vk_height();
79 	void set_vk_height(int p_height);
80 	void set_screen_orientation(int p_orient);
81 	String get_system_dir(int p_dir);
82 	void play_video(const String &p_path);
83 	bool is_video_playing();
84 	void pause_video();
85 	void stop_video();
86 };
87 
88 #endif /* !JAVA_GODOT_IO_WRAPPER_H */
89