Commit 786c3215 authored by fallenstardust's avatar fallenstardust

open yrp

parent 4523dd9d
...@@ -63,7 +63,7 @@ irr::io::path getExternalStorageDir(ANDROID_APP app) { ...@@ -63,7 +63,7 @@ irr::io::path getExternalStorageDir(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -95,7 +95,7 @@ irr::io::path getExternalFilesDir(ANDROID_APP app) { ...@@ -95,7 +95,7 @@ irr::io::path getExternalFilesDir(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -125,7 +125,7 @@ float getScreenHeight(ANDROID_APP app) { ...@@ -125,7 +125,7 @@ float getScreenHeight(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -150,7 +150,7 @@ float getScreenWidth(ANDROID_APP app) { ...@@ -150,7 +150,7 @@ float getScreenWidth(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -175,7 +175,7 @@ irr::io::path getDBDir(ANDROID_APP app) { ...@@ -175,7 +175,7 @@ irr::io::path getDBDir(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -204,7 +204,7 @@ irr::io::path getCardImagePath(ANDROID_APP app) { ...@@ -204,7 +204,7 @@ irr::io::path getCardImagePath(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -233,7 +233,7 @@ irr::io::path getCoreConfigVersion(ANDROID_APP app) { ...@@ -233,7 +233,7 @@ irr::io::path getCoreConfigVersion(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -261,7 +261,7 @@ int getOpenglVersion(ANDROID_APP app) { ...@@ -261,7 +261,7 @@ int getOpenglVersion(ANDROID_APP app) {
int ret = 1; int ret = 1;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -285,7 +285,7 @@ int getCardQuality(ANDROID_APP app) { ...@@ -285,7 +285,7 @@ int getCardQuality(ANDROID_APP app) {
int ret = 1; int ret = 1;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -310,7 +310,7 @@ irr::io::path getFontPath(ANDROID_APP app) { ...@@ -310,7 +310,7 @@ irr::io::path getFontPath(ANDROID_APP app) {
irr::io::path ret; irr::io::path ret;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -338,7 +338,7 @@ irr::io::path getResourcePath(ANDROID_APP app) { ...@@ -338,7 +338,7 @@ irr::io::path getResourcePath(ANDROID_APP app) {
irr::io::path ret; irr::io::path ret;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -366,7 +366,7 @@ float getXScale(ANDROID_APP app){ ...@@ -366,7 +366,7 @@ float getXScale(ANDROID_APP app){
float ret = 1; float ret = 1;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -390,7 +390,7 @@ float getYScale(ANDROID_APP app){ ...@@ -390,7 +390,7 @@ float getYScale(ANDROID_APP app){
float ret = 1; float ret = 1;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -424,7 +424,7 @@ irr::io::path getSetting(ANDROID_APP app, const char* key) { ...@@ -424,7 +424,7 @@ irr::io::path getSetting(ANDROID_APP app, const char* key) {
irr::io::path ret; irr::io::path ret;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -468,7 +468,7 @@ void setLastCategory(ANDROID_APP app, const char* catename) { ...@@ -468,7 +468,7 @@ void setLastCategory(ANDROID_APP app, const char* catename) {
int getIntSetting(ANDROID_APP app, const char* key,int defvalue){ int getIntSetting(ANDROID_APP app, const char* key,int defvalue){
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return defvalue; return defvalue;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return defvalue; return defvalue;
...@@ -496,7 +496,7 @@ int getIntSetting(ANDROID_APP app, const char* key,int defvalue){ ...@@ -496,7 +496,7 @@ int getIntSetting(ANDROID_APP app, const char* key,int defvalue){
void saveIntSetting(ANDROID_APP app, const char* key, int value) { void saveIntSetting(ANDROID_APP app, const char* key, int value) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return; return;
...@@ -522,7 +522,7 @@ void saveIntSetting(ANDROID_APP app, const char* key, int value) { ...@@ -522,7 +522,7 @@ void saveIntSetting(ANDROID_APP app, const char* key, int value) {
void saveSetting(ANDROID_APP app, const char* key, const char* value) { void saveSetting(ANDROID_APP app, const char* key, const char* value) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return; return;
...@@ -553,7 +553,7 @@ bool perfromTrick(ANDROID_APP app) { ...@@ -553,7 +553,7 @@ bool perfromTrick(ANDROID_APP app) {
bool ret = true; bool ret = true;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return false; return false;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return false; return false;
...@@ -582,7 +582,7 @@ bool getFontAntiAlias(ANDROID_APP app) { ...@@ -582,7 +582,7 @@ bool getFontAntiAlias(ANDROID_APP app) {
bool ret = true; bool ret = true;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return true; return true;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return true; return true;
...@@ -611,7 +611,7 @@ bool getFontAntiAlias(ANDROID_APP app) { ...@@ -611,7 +611,7 @@ bool getFontAntiAlias(ANDROID_APP app) {
void perfromHapticFeedback(ANDROID_APP app) { void perfromHapticFeedback(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return; return;
...@@ -629,7 +629,7 @@ irr::io::path getCacheDir(ANDROID_APP app) { ...@@ -629,7 +629,7 @@ irr::io::path getCacheDir(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return ret; return ret;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return ret; return ret;
...@@ -662,7 +662,7 @@ irr::io::path getCacheDir(ANDROID_APP app) { ...@@ -662,7 +662,7 @@ irr::io::path getCacheDir(ANDROID_APP app) {
void toggleIME(ANDROID_APP app, bool pShow, const char* hint) { void toggleIME(ANDROID_APP app, bool pShow, const char* hint) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
// Retrieves NativeActivity. // Retrieves NativeActivity.
jobject lNativeActivity = app->activity->clazz; jobject lNativeActivity = app->activity->clazz;
...@@ -686,7 +686,7 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) { ...@@ -686,7 +686,7 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
jint lFlags = 2; jint lFlags = 2;
...@@ -752,7 +752,7 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) { ...@@ -752,7 +752,7 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
core::position2di initJavaBridge(ANDROID_APP app, void* handle) { core::position2di initJavaBridge(ANDROID_APP app, void* handle) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return core::position2di(0, 0); return core::position2di(0, 0);
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
jobject lNativeActivity = app->activity->clazz; jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity); jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
...@@ -777,7 +777,7 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) { ...@@ -777,7 +777,7 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) {
InitOptions* getInitOptions(ANDROID_APP app) { InitOptions* getInitOptions(ANDROID_APP app) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return NULL; return NULL;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
jobject lNativeActivity = app->activity->clazz; jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity); jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
...@@ -795,7 +795,7 @@ int getLocalAddr(ANDROID_APP app) { ...@@ -795,7 +795,7 @@ int getLocalAddr(ANDROID_APP app) {
int addr = -1; int addr = -1;
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return addr; return addr;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
jobject lNativeActivity = app->activity->clazz; jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity); jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
...@@ -807,11 +807,29 @@ int getLocalAddr(ANDROID_APP app) { ...@@ -807,11 +807,29 @@ int getLocalAddr(ANDROID_APP app) {
return addr; return addr;
} }
void OnShareFile(ANDROID_APP app, char* title, char* path){
if (!app || !app->activity || !app->activity->vm)
return;
JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, nullptr);
jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
jmethodID MethodGetAddr = jni->GetMethodID(ClassNativeActivity,
"shareFile", "(Ljava/lang/String;Ljava/lang/String;)V");
jstring s_title = jni->NewStringUTF(title);
jstring s_path = jni->NewStringUTF(path);
jni->CallVoidMethod(lNativeActivity, MethodGetAddr, s_title, s_path);
jni->ReleaseStringUTFChars(s_title, title);
jni->ReleaseStringUTFChars(s_path, path);
jni->DeleteLocalRef(ClassNativeActivity);
app->activity->vm->DetachCurrentThread();
}
void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow, char** pContents, void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow, char** pContents,
int count, int mode) { int count, int mode) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
jobject lNativeActivity = app->activity->clazz; jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity); jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
...@@ -834,7 +852,7 @@ void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow, char** pContents, ...@@ -834,7 +852,7 @@ void showAndroidComboBoxCompat(ANDROID_APP app, bool pShow, char** pContents,
void toggleOverlayView(ANDROID_APP app, bool pShow) { void toggleOverlayView(ANDROID_APP app, bool pShow) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
jobject lNativeActivity = app->activity->clazz; jobject lNativeActivity = app->activity->clazz;
jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity); jclass ClassNativeActivity = jni->GetObjectClass(lNativeActivity);
...@@ -956,7 +974,7 @@ bool android_deck_delete(const char* deck_name) { ...@@ -956,7 +974,7 @@ bool android_deck_delete(const char* deck_name) {
void runWindbot(ANDROID_APP app, const char* args) { void runWindbot(ANDROID_APP app, const char* args) {
if (!app || !app->activity || !app->activity->vm) if (!app || !app->activity || !app->activity->vm)
return; return;
JNIEnv* jni = 0; JNIEnv* jni = nullptr;
app->activity->vm->AttachCurrentThread(&jni, NULL); app->activity->vm->AttachCurrentThread(&jni, NULL);
if (!jni) if (!jni)
return; return;
......
...@@ -98,6 +98,8 @@ extern float getScreenWidth(ANDROID_APP app); ...@@ -98,6 +98,8 @@ extern float getScreenWidth(ANDROID_APP app);
extern float getScreenHeight(ANDROID_APP app); extern float getScreenHeight(ANDROID_APP app);
extern void OnShareFile(ANDROID_APP app, char* title, char* path);
// Get SDCard path. // Get SDCard path.
extern irr::io::path getExternalStorageDir(ANDROID_APP app); extern irr::io::path getExternalStorageDir(ANDROID_APP app);
......
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
*/ */
package cn.garymb.ygomobile; package cn.garymb.ygomobile;
import android.app.AlertDialog;
import android.app.NativeActivity; import android.app.NativeActivity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.res.Resources; import android.content.res.Resources;
...@@ -58,6 +60,9 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -58,6 +60,9 @@ public class YGOMobileActivity extends NativeActivity implements
private static final int CHAIN_CONTROL_PANEL_X_POSITION_LEFT_EDGE = 205; private static final int CHAIN_CONTROL_PANEL_X_POSITION_LEFT_EDGE = 205;
private static final int CHAIN_CONTROL_PANEL_Y_REVERT_POSITION = 100; private static final int CHAIN_CONTROL_PANEL_Y_REVERT_POSITION = 100;
private static final int MAX_REFRESH = 30 * 1000; private static final int MAX_REFRESH = 30 * 1000;
private static int sChainControlXPostion = -1;
private static int sChainControlYPostion = -1;
private static boolean USE_SURFACE = true;
protected final int windowsFlags = protected final int windowsFlags =
Build.VERSION.SDK_INT >= 19 ? ( Build.VERSION.SDK_INT >= 19 ? (
View.SYSTEM_UI_FLAG_LAYOUT_STABLE View.SYSTEM_UI_FLAG_LAYOUT_STABLE
...@@ -66,7 +71,6 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -66,7 +71,6 @@ public class YGOMobileActivity extends NativeActivity implements
| View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) : | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) :
View.SYSTEM_UI_FLAG_LOW_PROFILE; View.SYSTEM_UI_FLAG_LOW_PROFILE;
protected View mContentView; protected View mContentView;
protected ComboBoxCompat mGlobalComboBox; protected ComboBoxCompat mGlobalComboBox;
protected EditWindowCompat mGlobalEditText; protected EditWindowCompat mGlobalEditText;
...@@ -76,8 +80,6 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -76,8 +80,6 @@ public class YGOMobileActivity extends NativeActivity implements
private NetworkController mNetController; private NetworkController mNetController;
private volatile boolean mOverlayShowRequest = false; private volatile boolean mOverlayShowRequest = false;
private volatile int mCompatGUIMode; private volatile int mCompatGUIMode;
private static int sChainControlXPostion = -1;
private static int sChainControlYPostion = -1;
private GameApplication mApp; private GameApplication mApp;
private Handler handler = new Handler(); private Handler handler = new Handler();
private FullScreenUtils mFullScreenUtils; private FullScreenUtils mFullScreenUtils;
...@@ -85,10 +87,12 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -85,10 +87,12 @@ public class YGOMobileActivity extends NativeActivity implements
private FrameLayout mLayout; private FrameLayout mLayout;
private SurfaceView mSurfaceView; private SurfaceView mSurfaceView;
private boolean replaced = false; private boolean replaced = false;
private static boolean USE_SURFACE = true;
private String[] mArgV; private String[] mArgV;
// public static int notchHeight; // public static int notchHeight;
//电池管理
private PowerManager mPM;
private PowerManager.WakeLock mLock;
private GameApplication app() { private GameApplication app() {
if (mApp == null) { if (mApp == null) {
...@@ -108,14 +112,14 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -108,14 +112,14 @@ public class YGOMobileActivity extends NativeActivity implements
@SuppressWarnings("WrongConstant") @SuppressWarnings("WrongConstant")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
if(USE_SURFACE) { if (USE_SURFACE) {
mSurfaceView = new SurfaceView(this); mSurfaceView = new SurfaceView(this);
} }
mFullScreenUtils = new FullScreenUtils(this, app().isImmerSiveMode()); mFullScreenUtils = new FullScreenUtils(this, app().isImmerSiveMode());
mFullScreenUtils.fullscreen(); mFullScreenUtils.fullscreen();
mFullScreenUtils.onCreate(); mFullScreenUtils.onCreate();
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Log.e("YGOStarter","跳转完成"+System.currentTimeMillis()); Log.e("YGOStarter", "跳转完成" + System.currentTimeMillis());
if (sChainControlXPostion < 0) { if (sChainControlXPostion < 0) {
initPostion(); initPostion();
} }
...@@ -131,14 +135,10 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -131,14 +135,10 @@ public class YGOMobileActivity extends NativeActivity implements
.setPackage(getPackageName())); .setPackage(getPackageName()));
} }
//电池管理
private PowerManager mPM;
private PowerManager.WakeLock mLock;
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
Log.e("YGOStarter","ygo显示"+System.currentTimeMillis()); Log.e("YGOStarter", "ygo显示" + System.currentTimeMillis());
if (mLock == null) { if (mLock == null) {
if (mPM == null) { if (mPM == null) {
mPM = (PowerManager) getSystemService(POWER_SERVICE); mPM = (PowerManager) getSystemService(POWER_SERVICE);
...@@ -232,7 +232,7 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -232,7 +232,7 @@ public class YGOMobileActivity extends NativeActivity implements
} }
} }
private int[] getGameSize(){ private int[] getGameSize() {
//调整padding //调整padding
float xScale = app().getXScale(); float xScale = app().getXScale();
float yScale = app().getYScale(); float yScale = app().getYScale();
...@@ -282,7 +282,7 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -282,7 +282,7 @@ public class YGOMobileActivity extends NativeActivity implements
} }
} }
private void changeGameSize(){ private void changeGameSize() {
//游戏大小 //游戏大小
int[] size = getGameSize(); int[] size = getGameSize();
int w = (int) app().getScreenHeight(); int w = (int) app().getScreenHeight();
...@@ -485,7 +485,7 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -485,7 +485,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override @Override
public void surfaceCreated(SurfaceHolder holder) { public void surfaceCreated(SurfaceHolder holder) {
if(USE_SURFACE) { if (USE_SURFACE) {
if (!replaced) { if (!replaced) {
return; return;
} }
...@@ -495,7 +495,7 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -495,7 +495,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if(USE_SURFACE) { if (USE_SURFACE) {
if (!replaced) { if (!replaced) {
return; return;
} }
...@@ -505,7 +505,7 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -505,7 +505,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override @Override
public void surfaceDestroyed(SurfaceHolder holder) { public void surfaceDestroyed(SurfaceHolder holder) {
if(USE_SURFACE) { if (USE_SURFACE) {
if (!replaced) { if (!replaced) {
return; return;
} }
...@@ -515,11 +515,31 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -515,11 +515,31 @@ public class YGOMobileActivity extends NativeActivity implements
@Override @Override
public void surfaceRedrawNeeded(SurfaceHolder holder) { public void surfaceRedrawNeeded(SurfaceHolder holder) {
if(USE_SURFACE) { if (USE_SURFACE) {
if (!replaced) { if (!replaced) {
return; return;
} }
} }
super.surfaceRedrawNeeded(holder); super.surfaceRedrawNeeded(holder);
} }
@Override
public void shareFile(final String title, final String path) {
//TODO 分享文件
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(YGOMobileActivity.this);
builder.setTitle(title);
builder.setMessage(path);
builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.show();
}
});
}
} }
...@@ -195,6 +195,8 @@ public final class IrrlichtBridge { ...@@ -195,6 +195,8 @@ public final class IrrlichtBridge {
void toggleIME(String hint, boolean isShow); void toggleIME(String hint, boolean isShow);
void shareFile(String title, String path);
void showComboBoxCompat(String[] items, boolean isShow, int mode); void showComboBoxCompat(String[] items, boolean isShow, int mode);
void performHapticFeedback(); void performHapticFeedback();
......
...@@ -134,7 +134,7 @@ public class GameUriManager { ...@@ -134,7 +134,7 @@ public class GameUriManager {
} }
activity.startActivity(startdeck); activity.startActivity(startdeck);
} else if (file.getName().toLowerCase(Locale.US).endsWith(".ypk")) { } else if (file.getName().toLowerCase(Locale.US).endsWith(".ypk")) {
File ypk = new File(AppsSettings.get().getExpansionsPath() + "/" + file.getName().toLowerCase(Locale.US)); File ypk = new File(AppsSettings.get().getExpansionsPath() + "/" + file.getName());
if (ypk.exists() && file.lastModified() == ypk.lastModified()) { if (ypk.exists() && file.lastModified() == ypk.lastModified()) {
Toast.makeText(activity, activity.getString(R.string.file_exist), Toast.LENGTH_LONG).show(); Toast.makeText(activity, activity.getString(R.string.file_exist), Toast.LENGTH_LONG).show();
} else { } else {
...@@ -152,7 +152,7 @@ public class GameUriManager { ...@@ -152,7 +152,7 @@ public class GameUriManager {
Toast.makeText(activity, R.string.ypk_installed, Toast.LENGTH_LONG).show(); Toast.makeText(activity, R.string.ypk_installed, Toast.LENGTH_LONG).show();
} }
} else if (file.getName().toLowerCase(Locale.US).endsWith(".yrp")) { } else if (file.getName().toLowerCase(Locale.US).endsWith(".yrp")) {
File yrp = new File(AppsSettings.get().getResourcePath() + "/" + CORE_REPLAY_PATH + "/" + file.getName().toLowerCase(Locale.US)); File yrp = new File(AppsSettings.get().getResourcePath() + "/" + CORE_REPLAY_PATH + "/" + file.getName());
if (yrp.exists()) { if (yrp.exists()) {
YGOStarter.startGame(getActivity(), null, "-r" + yrp.getName()); YGOStarter.startGame(getActivity(), null, "-r" + yrp.getName());
Toast.makeText(activity, activity.getString(R.string.file_exist), Toast.LENGTH_LONG).show(); Toast.makeText(activity, activity.getString(R.string.file_exist), Toast.LENGTH_LONG).show();
...@@ -164,7 +164,7 @@ public class GameUriManager { ...@@ -164,7 +164,7 @@ public class GameUriManager {
} }
if (!ComponentUtils.isActivityRunning(getActivity(), new ComponentName(getActivity(), YGOMobileActivity.class))) { if (!ComponentUtils.isActivityRunning(getActivity(), new ComponentName(getActivity(), YGOMobileActivity.class))) {
YGOStarter.startGame(getActivity(), null, "-r" + yrp.getName()); YGOStarter.startGame(getActivity(), null, "-r" + yrp.getName());
Toast.makeText(activity, ""+yrp.getName(), Toast.LENGTH_LONG).show(); Toast.makeText(activity, "" + yrp.getName(), Toast.LENGTH_LONG).show();
} }
} }
} }
...@@ -194,7 +194,7 @@ public class GameUriManager { ...@@ -194,7 +194,7 @@ public class GameUriManager {
} }
} else if (urifile.getName().toLowerCase(Locale.US).endsWith(".ypk")) { } else if (urifile.getName().toLowerCase(Locale.US).endsWith(".ypk")) {
try { try {
File ypk = new File(AppsSettings.get().getExpansionsPath() + "/" + urifile.getName().toLowerCase(Locale.US)); File ypk = new File(AppsSettings.get().getExpansionsPath() + "/" + urifile.getName());
ParcelFileDescriptor pfd = getActivity().getContentResolver().openFileDescriptor(uri, "r"); ParcelFileDescriptor pfd = getActivity().getContentResolver().openFileDescriptor(uri, "r");
if (ypk.exists() && urifile.lastModified() == ypk.lastModified()) { if (ypk.exists() && urifile.lastModified() == ypk.lastModified()) {
Toast.makeText(activity, activity.getString(R.string.file_exist), Toast.LENGTH_SHORT).show(); Toast.makeText(activity, activity.getString(R.string.file_exist), Toast.LENGTH_SHORT).show();
...@@ -222,8 +222,8 @@ public class GameUriManager { ...@@ -222,8 +222,8 @@ public class GameUriManager {
Toast.makeText(activity, R.string.ypk_installed, Toast.LENGTH_LONG).show(); Toast.makeText(activity, R.string.ypk_installed, Toast.LENGTH_LONG).show();
} }
} else if (urifile.getName().toLowerCase(Locale.US).endsWith(".yrp")) { } else if (urifile.getName().toLowerCase(Locale.US).endsWith(".yrp")) {
File yrp = new File(AppsSettings.get().getResourcePath() + "/" + CORE_REPLAY_PATH + "/" + urifile.getName());
try { try {
File yrp = new File(AppsSettings.get().getResourcePath() + "/" + CORE_REPLAY_PATH + "/" + urifile.getName().toLowerCase(Locale.US));
ParcelFileDescriptor pfd = getActivity().getContentResolver().openFileDescriptor(uri, "r"); ParcelFileDescriptor pfd = getActivity().getContentResolver().openFileDescriptor(uri, "r");
if (yrp.exists()) { if (yrp.exists()) {
YGOStarter.startGame(getActivity(), null, "-r " + urifile.getName()); YGOStarter.startGame(getActivity(), null, "-r " + urifile.getName());
...@@ -245,7 +245,7 @@ public class GameUriManager { ...@@ -245,7 +245,7 @@ public class GameUriManager {
e.printStackTrace(); e.printStackTrace();
} }
if (!ComponentUtils.isActivityRunning(activity, new ComponentName(activity, YGOMobileActivity.class))) { if (!ComponentUtils.isActivityRunning(activity, new ComponentName(activity, YGOMobileActivity.class))) {
YGOStarter.startGame(activity, null,"-r " + urifile.getName()); YGOStarter.startGame(activity, null, "-r " + urifile.getName());
Toast.makeText(activity, activity.getString(R.string.yrp_installed), Toast.LENGTH_LONG).show(); Toast.makeText(activity, activity.getString(R.string.yrp_installed), Toast.LENGTH_LONG).show();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment