#pragma once
#include <jni.h>
#include "ofConstants.h"
#include "ofEvent.h"
enum ofxAndroidPermission{
OFX_ANDROID_PERMISSION_READ_CALENDAR = 0,
OFX_ANDROID_PERMISSION_WRITE_CALENDAR,
OFX_ANDROID_PERMISSION_CAMERA,
OFX_ANDROID_PERMISSION_READ_CONTACTS,
OFX_ANDROID_PERMISSION_WRITE_CONTACTS,
OFX_ANDROID_PERMISSION_GET_ACCOUNTS,
OFX_ANDROID_PERMISSION_ACCESS_FINE_LOCATION,
OFX_ANDROID_PERMISSION_ACCESS_COARSE_LOCATION,
OFX_ANDROID_PERMISSION_RECORD_AUDIO,
OFX_ANDROID_PERMISSION_READ_PHONE_STATE,
OFX_ANDROID_PERMISSION_CALL_PHONE,
OFX_ANDROID_PERMISSION_READ_CALL_LOG,
OFX_ANDROID_PERMISSION_WRITE_CALL_LOG,
OFX_ANDROID_PERMISSION_ADD_VOICEMAIL,
OFX_ANDROID_PERMISSION_USE_SIP,
OFX_ANDROID_PERMISSION_PROCESS_OUTGOING_CALLS,
OFX_ANDROID_PERMISSION_BODY_SENSORS,
OFX_ANDROID_PERMISSION_SEND_SMS,
OFX_ANDROID_PERMISSION_RECEIVE_SMS,
OFX_ANDROID_PERMISSION_READ_SMS,
OFX_ANDROID_PERMISSION_RECEIVE_WAP_PUSH,
OFX_ANDROID_PERMISSION_RECEIVE_MMS,
OFX_ANDROID_PERMISSION_READ_EXTERNAL_STORAGE,
OFX_ANDROID_PERMISSION_WRITE_EXTERNAL_STORAGE
};
enum ofOrientation: short;
JavaVM * ofGetJavaVMPtr();
JNIEnv * ofGetJNIEnv();
jclass ofGetJavaOFAndroid();
jobject ofGetOFActivityObject();
jmethodID ofxJavaGetMethodID(jclass classID, std::string methodName, std::string methodSignature);
jmethodID ofxJavaGetStaticMethodID(jclass classID, std::string methodName, std::string methodSignature);
std::string ofxJavaGetClassName(jclass classID);
jclass ofxJavaGetClassID(std::string className);
jfieldID ofxJavaGetStaticFieldID(jclass classID, std::string fieldName, std::string fieldType);
void ofxJavaGetJString(const std::string& str, jstring &jstr);
void ofxJstringToString(JNIEnv * env, jstring jstr, std::string &str);
jobject ofxJavaGetStaticObjectField(jclass classID, std::string fieldName, std::string fieldType);
jobject ofxJavaGetStaticObjectField(std::string className, std::string fieldName, std::string fieldType);
void ofxJavaCallVoidMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, va_list args);
void ofxJavaCallVoidMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, ...);
void ofxJavaCallVoidMethod(jobject object, std::string className, std::string methodName, std::string methodSignature, ...);
jobject ofxJavaCallStaticObjectMethod(jclass classID, std::string methodName, std::string methodSignature, va_list args);
jobject ofxJavaCallStaticObjectMethod(jclass classID, std::string methodName, std::string methodSignature, ...);
jobject ofxJavaCallStaticObjectMethod(std::string className, std::string methodName, std::string methodSignature, ...);
jobject ofxJavaCallObjectMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, va_list args);
jobject ofxJavaCallObjectMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, ...);
jobject ofxJavaCallObjectMethod(jobject object, std::string className, std::string methodName, std::string methodSignature, ...);
void ofxJavaCallStaticVoidMethod(jclass classID, std::string methodName, std::string methodSignature, va_list args);
void ofxJavaCallStaticVoidMethod(jclass classID, std::string methodName, std::string methodSignature, ...);
void ofxJavaCallStaticVoidMethod(std::string className, std::string methodName, std::string methodSignature, ...);
float ofxJavaCallFloatMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, va_list args);
float ofxJavaCallFloatMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, ...);
float ofxJavaCallFloatMethod(jobject object, std::string className, std::string methodName, std::string methodSignature, ...);
int ofxJavaCallIntMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, va_list args);
int ofxJavaCallIntMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, ...);
int ofxJavaCallIntMethod(jobject object, std::string className, std::string methodName, std::string methodSignature, ...);
int64_t ofxJavaCallLongMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, va_list args);
int64_t ofxJavaCallLongMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, ...);
int64_t ofxJavaCallLongMethod(jobject object, std::string className, std::string methodName, std::string methodSignature, ...);
bool ofxJavaCallBoolMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, va_list args);
bool ofxJavaCallBoolMethod(jobject object, jclass classID, std::string methodName, std::string methodSignature, ...);
bool ofxJavaCallBoolMethod(jobject object, std::string className, std::string methodName, std::string methodSignature, ...);
void ofxAndroidPauseApp();
void ofxAndroidAlertBox(std::string msg);
int ofxAndroidProgressBox(std::string msg);
void ofxAndroidDismissProgressBox(int id);
void ofxAndroidOkCancelBox(std::string msg);
void ofxAndroidYesNoBox(std::string msg);
void ofxAndroidAlertTextBox(std::string question, std::string text);
std::string ofxAndroidGetTextBoxResult();
bool ofxAndroidAlertListBox(std::string title, const std::vector<std::string> & list);
void ofxAndroidToast(std::string msg);
void ofxAndroidLockScreenSleep();
void ofxAndroidUnlockScreenSleep();
bool ofxAndroidIsOnline();
bool ofxAndroidIsWifiOnline();
bool ofxAndroidIsMobileOnline();
void ofxAndroidRequestPermission(ofxAndroidPermission permission);
bool ofxAndroidCheckPermission(ofxAndroidPermission permission);
std::string ofxAndroidGetStringRes(std::string id);
std::string ofxAndroidRandomUUID();
void ofxAndroidMonitorNetworkState();
void ofxAndroidLaunchBrowser(std::string url);
void ofxAndroidNotifyLoadPercent(float percent);
bool ofxAndroidCheckSDCardMounted();
void ofxAndroidEnableMulticast();
void ofxAndroidDisableMulticast();
void ofxAndroidSetViewItemChecked(std::string item_name, bool checked);
enum ofxAndroidSwipeDir{
OFX_ANDROID_SWIPE_UP = 1,
OFX_ANDROID_SWIPE_DOWN = 2,
OFX_ANDROID_SWIPE_LEFT = 3,
OFX_ANDROID_SWIPE_RIGHT = 4
};
struct ofxAndroidSwipeEventArgs{
ofxAndroidSwipeDir dir;
int id;
};
class ofxAndroidScaleEventArgs{
public:
ofxAndroidScaleEventArgs(jobject detector);
float getCurrentSpan();
float getCurrentSpanX();
float getCurrentSpanY();
int64_t getEventTime();
float getFocusX();
float getFocusY();
float getPreviousSpan();
float getPreviousSpanX();
float getPreviousSpanY();
float getScaleFactor();
int64_t getTimeDelta();
private:
jobject detector;
};
class ofxAndroidEventsClass{
public:
ofEvent<void> okPressed;
ofEvent<void> cancelPressed;
ofEvent<void> backPressed;
ofEvent<bool> networkConnected;
ofEvent<ofOrientation> deviceOrientationChanged;
ofEvent<void> start;
ofEvent<void> stop;
ofEvent<void> resume;
ofEvent<void> pause;
ofEvent<void> unloadGL;
ofEvent<void> reloadGL;
ofEvent<ofxAndroidSwipeEventArgs> swipe;
ofEvent<ofxAndroidScaleEventArgs> scale;
ofEvent<ofxAndroidScaleEventArgs> scaleBegin;
ofEvent<ofxAndroidScaleEventArgs> scaleEnd;
ofEvent<std::string> menuItemSelected;
ofEvent<std::string> menuItemChecked;
};
ofxAndroidEventsClass & ofxAndroidEvents();
enum ofxAndroidKeyCode{
KEYCODE_SOFT_LEFT = 1,
KEYCODE_SOFT_RIGHT = 2,
KEYCODE_HOME = 3,
KEYCODE_BACK = 4,
KEYCODE_CALL = 5,
KEYCODE_ENDCALL = 6,
KEYCODE_DPAD_UP = 19,
KEYCODE_DPAD_DOWN = 20,
KEYCODE_DPAD_LEFT = 21,
KEYCODE_DPAD_RIGHT = 22,
KEYCODE_DPAD_CENTER = 23,
KEYCODE_VOLUME_UP = 24,
KEYCODE_VOLUME_DOWN = 25,
KEYCODE_POWER = 26,
KEYCODE_CAMERA = 27,
KEYCODE_CLEAR = 28,
};
Comments