2014-04-21 14:10:59 +02:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
2017-08-17 22:19:39 +02:00
|
|
|
|
|
|
|
#pragma once
|
2014-04-21 14:10:59 +02:00
|
|
|
|
|
|
|
#ifndef __ANDROID__
|
2024-01-07 13:00:04 +01:00
|
|
|
#error This header has to be included on Android port only!
|
2014-04-21 14:10:59 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
#include <android_native_app_glue.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
|
2024-01-11 10:37:13 +01:00
|
|
|
#include "irrlichttypes_bloated.h"
|
|
|
|
|
2014-04-21 14:10:59 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace porting {
|
2024-01-07 13:00:04 +01:00
|
|
|
// Java app
|
2014-04-21 14:10:59 +02:00
|
|
|
extern android_app *app_global;
|
|
|
|
|
2024-01-07 13:00:04 +01:00
|
|
|
// Java <-> C++ interaction interface
|
2014-04-21 14:10:59 +02:00
|
|
|
extern JNIEnv *jnienv;
|
|
|
|
|
|
|
|
/**
|
2024-01-07 13:00:04 +01:00
|
|
|
* 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)
|
2014-04-21 14:10:59 +02:00
|
|
|
*/
|
2024-01-07 13:00:04 +01:00
|
|
|
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);
|
2014-04-21 14:10:59 +02:00
|
|
|
|
2022-06-05 18:42:09 +02:00
|
|
|
/**
|
|
|
|
* Opens a share intent to the file at path
|
|
|
|
*
|
|
|
|
* @param path
|
|
|
|
*/
|
|
|
|
void shareFileAndroid(const std::string &path);
|
|
|
|
|
2024-01-07 13:00:04 +01:00
|
|
|
/*
|
|
|
|
* Types of Android input dialog:
|
|
|
|
* 1. Text input (single/multi-line text and password field)
|
|
|
|
* 2. Selection input (combo box)
|
2014-04-21 14:10:59 +02:00
|
|
|
*/
|
2024-01-07 13:00:04 +01:00
|
|
|
enum AndroidDialogType { TEXT_INPUT, SELECTION_INPUT };
|
2014-04-21 14:10:59 +02:00
|
|
|
|
2024-01-07 13:00:04 +01:00
|
|
|
/*
|
|
|
|
* 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.
|
2014-04-21 14:10:59 +02:00
|
|
|
*/
|
2024-01-07 13:00:04 +01:00
|
|
|
int getInputDialogSelection();
|
2014-04-21 14:10:59 +02:00
|
|
|
|
2017-12-06 21:36:29 +01:00
|
|
|
#ifndef SERVER
|
|
|
|
float getDisplayDensity();
|
|
|
|
v2u32 getDisplaySize();
|
|
|
|
#endif
|
2023-06-05 12:02:10 +02:00
|
|
|
|
2014-04-21 14:10:59 +02:00
|
|
|
}
|