Commit ae187ac6 authored by fallenstardust's avatar fallenstardust

优化清除

parent 6715374a
...@@ -200,7 +200,9 @@ E_DEVICE_TYPE CIrrDeviceAndroid::getType() const ...@@ -200,7 +200,9 @@ E_DEVICE_TYPE CIrrDeviceAndroid::getType() const
void CIrrDeviceAndroid::handleAndroidCommand(ANDROID_APP app, int32_t cmd) void CIrrDeviceAndroid::handleAndroidCommand(ANDROID_APP app, int32_t cmd)
{ {
CIrrDeviceAndroid* device = (CIrrDeviceAndroid*)app->userData; CIrrDeviceAndroid* device = (CIrrDeviceAndroid*)app->userData;
if(device->onAppCmd != nullptr){
device->onAppCmd(app, cmd);
}
switch (cmd) switch (cmd)
{ {
case APP_CMD_SAVE_STATE: case APP_CMD_SAVE_STATE:
......
...@@ -58,6 +58,19 @@ namespace irr ...@@ -58,6 +58,19 @@ namespace irr
core::array<EKEY_CODE> KeyMap; core::array<EKEY_CODE> KeyMap;
bool isPaused(){
return Paused;
}
bool isFocused(){
return Focused;
}
bool isDestroy(){
return !Initialized;
}
void (*onAppCmd)(struct android_app* app, int32_t cmd) = nullptr;
private: private:
static void handleAndroidCommand(ANDROID_APP app, int32_t cmd); static void handleAndroidCommand(ANDROID_APP app, int32_t cmd);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <android_native_app_glue.h> #include <android_native_app_glue.h>
#include <signal.h> #include <signal.h>
#include <android/log.h> #include <android/log.h>
#include <Android/CIrrDeviceAndroid.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "ygomobile-native", __VA_ARGS__)) #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "ygomobile-native", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "ygomobile-native", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "ygomobile-native", __VA_ARGS__))
......
...@@ -297,7 +297,7 @@ static void* join_game_thread(void* param) { ...@@ -297,7 +297,7 @@ static void* join_game_thread(void* param) {
JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInputFix( JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInputFix(
JNIEnv* env, jclass clazz, jlong handle, jint x, jint y) { JNIEnv* env, jclass clazz, jlong handle, jint x, jint y) {
if(ygo::mainGame) { if(ygo::mainGame) {
__android_log_print(ANDROID_LOG_INFO, "ygo", "setInputFix posX=%d, posY=%d", x, y); ALOGD("setInputFix posX=%d, posY=%d", x, y);
ygo::mainGame->setPositionFix(core::position2di(x, y)); ygo::mainGame->setPositionFix(core::position2di(x, y));
} }
} }
......
...@@ -9,9 +9,7 @@ ...@@ -9,9 +9,7 @@
<application> <application>
<activity <activity
android:name="cn.garymb.ygomobile.YGOMobileActivity" android:name="cn.garymb.ygomobile.YGOMobileActivity"
android:clearTaskOnLaunch="true"
android:configChanges="orientation|keyboardHidden|screenSize" android:configChanges="orientation|keyboardHidden|screenSize"
android:excludeFromRecents="true"
android:exported="true" android:exported="true"
android:label="YGOMobile" android:label="YGOMobile"
android:process=":game" android:process=":game"
......
...@@ -60,9 +60,6 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -60,9 +60,6 @@ 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
...@@ -80,6 +77,8 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -80,6 +77,8 @@ 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;
...@@ -87,12 +86,11 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -87,12 +86,11 @@ 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;
private boolean onGameExiting;
// 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) {
...@@ -138,6 +136,10 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -138,6 +136,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();
...@@ -547,17 +549,26 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -547,17 +549,26 @@ public class YGOMobileActivity extends NativeActivity implements
@Override @Override
public void onGameExit() { public void onGameExit() {
if(onGameExiting){
return;
}
onGameExiting = true;
Log.e("ygomobile", "game exit"); Log.e("ygomobile", "game exit");
Intent intent = new Intent("ygomobile.intent.action.GAME"); final Intent intent = new Intent("ygomobile.intent.action.GAME");
intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.putExtra("game_exit_time", System.currentTimeMillis());
intent.setPackage(getPackageName()); intent.setPackage(getPackageName());
runOnUiThread(new Runnable() {
@Override
public void run() {
try { try {
startActivity(intent); startActivity(intent);
} catch (Throwable ignore) { } catch (Throwable ignore) {}
finishAndRemoveTask();
}
Process.killProcess(Process.myPid()); Process.killProcess(Process.myPid());
} }
});
}
} }
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
android:extractNativeLibs="true" android:extractNativeLibs="true"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:taskAffinity="cn.garymb.ygomobile.task"
tools:replace="android:allowBackup,android:supportsRtl" tools:replace="android:allowBackup,android:supportsRtl"
tools:targetApi="m"> tools:targetApi="m">
<activity <activity
android:name="cn.garymb.ygomobile.ui.activities.LogoActivity" android:name="cn.garymb.ygomobile.ui.activities.LogoActivity"
android:excludeFromRecents="false" android:excludeFromRecents="false"
android:taskAffinity="cn.garymb.logo"
android:theme="@style/TranslucentTheme"> android:theme="@style/TranslucentTheme">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
...@@ -33,14 +33,18 @@ ...@@ -33,14 +33,18 @@
</activity> </activity>
<activity
android:name="com.tencent.bugly.beta.ui.BetaActivity"
android:launchMode="singleTop"
android:configChanges="keyboardHidden|orientation|screenSize|locale"
android:excludeFromRecents="true"/>
<activity <activity
android:name="cn.garymb.ygomobile.ui.home.MainActivity" android:name="cn.garymb.ygomobile.ui.home.MainActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize" android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:excludeFromRecents="false"
android:exported="true" android:exported="true"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:launchMode="singleTop" android:launchMode="singleTop"
android:stateNotNeeded="true"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"> android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
<intent-filter> <intent-filter>
...@@ -119,6 +123,11 @@ ...@@ -119,6 +123,11 @@
android:name="cn.garymb.ygomobile.YGOMobileActivity" android:name="cn.garymb.ygomobile.YGOMobileActivity"
android:theme="@style/AppTheme.Game" android:theme="@style/AppTheme.Game"
tools:replace="android:theme" /> tools:replace="android:theme" />
<receiver
android:name="cn.garymb.ygomobile.GameReceiver"
android:enabled="false" />
<activity <activity
android:name="cn.garymb.ygomobile.ui.preference.SettingsActivity" android:name="cn.garymb.ygomobile.ui.preference.SettingsActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize" android:configChanges="orientation|keyboardHidden|navigation|screenSize"
...@@ -187,11 +196,6 @@ ...@@ -187,11 +196,6 @@
<activity <activity
android:name="cn.garymb.ygomobile.ui.activities.PermissionsActivity" android:name="cn.garymb.ygomobile.ui.activities.PermissionsActivity"
android:theme="@style/TranslucentTheme"/> android:theme="@style/TranslucentTheme"/>
<activity
android:name="com.tencent.bugly.beta.ui.BetaActivity"
android:configChanges="keyboardHidden|orientation|screenSize|locale"
android:theme="@android:style/Theme.Translucent" />
<meta-data <meta-data
android:name="BUGLY_APPID" android:name="BUGLY_APPID"
android:value="${APP_ID}" /> android:value="${APP_ID}" />
......
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