From 9fbe5895b7b879ec3a3123c27e825d07f76b671f Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 2 Feb 2019 04:22:25 -0500 Subject: [PATCH] Use Intent rather than global variable --- app-core/src/main/java/com/topjohnwu/magisk/App.java | 1 - app-core/src/main/java/com/topjohnwu/magisk/Const.java | 1 + app/src/full/java/com/topjohnwu/magisk/MainActivity.java | 2 +- app/src/full/java/com/topjohnwu/magisk/SplashActivity.java | 3 +-- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app-core/src/main/java/com/topjohnwu/magisk/App.java b/app-core/src/main/java/com/topjohnwu/magisk/App.java index 43de3d1bb..2ae8bb53b 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/App.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/App.java @@ -20,7 +20,6 @@ import java.util.concurrent.ThreadPoolExecutor; public class App extends ContainerApp { public static App self; - public boolean init = false; public static ThreadPoolExecutor THREAD_POOL; // Global resources diff --git a/app-core/src/main/java/com/topjohnwu/magisk/Const.java b/app-core/src/main/java/com/topjohnwu/magisk/Const.java index 71f2ab34b..dd0be4ddb 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/Const.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/Const.java @@ -84,6 +84,7 @@ public class Const { public static final String LINK_KEY = "Link"; public static final String IF_NONE_MATCH = "If-None-Match"; // intents + public static final String FROM_SPLASH = "splash"; public static final String OPEN_SECTION = "section"; public static final String INTENT_SET_NAME = "filename"; public static final String INTENT_SET_LINK = "link"; diff --git a/app/src/full/java/com/topjohnwu/magisk/MainActivity.java b/app/src/full/java/com/topjohnwu/magisk/MainActivity.java index c76b1f678..6514cddd4 100644 --- a/app/src/full/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/MainActivity.java @@ -50,7 +50,7 @@ public class MainActivity extends BaseActivity @Override protected void onCreate(final Bundle savedInstanceState) { - if (!app.init) { + if (!getIntent().getBooleanExtra(Const.Key.FROM_SPLASH, false)) { startActivity(new Intent(this, ClassMap.get(SplashActivity.class))); finish(); } diff --git a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java index 8f6d68e2d..0710e4bec 100644 --- a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java @@ -58,10 +58,9 @@ public class SplashActivity extends BaseActivity { new UpdateRepos().exec(); } - app.init = true; - Intent intent = new Intent(this, ClassMap.get(MainActivity.class)); intent.putExtra(Const.Key.OPEN_SECTION, getIntent().getStringExtra(Const.Key.OPEN_SECTION)); + intent.putExtra(Const.Key.FROM_SPLASH, true); intent.putExtra(BaseActivity.INTENT_PERM, getIntent().getStringExtra(BaseActivity.INTENT_PERM)); startActivity(intent); finish();