From 8eba05ed4a20b6c17e89875cfaa73bfc51835b74 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 20 Feb 2017 20:09:20 +0800 Subject: [PATCH] Potentially fix Samsung crash and change colors --- .../main/java/com/topjohnwu/magisk/MagiskManager.java | 1 + app/src/main/java/com/topjohnwu/magisk/MainActivity.java | 8 +++----- .../main/java/com/topjohnwu/magisk/SettingsActivity.java | 3 +-- .../main/java/com/topjohnwu/magisk/SplashActivity.java | 9 ++++++--- .../java/com/topjohnwu/magisk/asyncs/CheckUpdates.java | 4 ++-- app/src/main/res/values/colors.xml | 2 +- app/src/main/res/values/styles.xml | 2 -- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java index 53c3fcbf6..7a1d5b064 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java @@ -25,6 +25,7 @@ public class MagiskManager extends Application { public static final String MAGISK_HIDE_PATH = "/magisk/.core/magiskhide/"; public static final String TMP_FOLDER_PATH = "/dev/tmp"; public static final String MAGISK_PATH = "/magisk"; + public static final String INTENT_SECTION = "section"; // Events public final CallbackEvent blockDetectionDone = new CallbackEvent<>(); diff --git a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java index 04b3bff60..2e9cfcc4c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java @@ -29,8 +29,6 @@ import butterknife.ButterKnife; public class MainActivity extends Activity implements NavigationView.OnNavigationItemSelectedListener, CallbackEvent.Listener { - public static final String SECTION = "section"; - private final Handler mDrawerHandler = new Handler(); private SharedPreferences prefs; private int mDrawerItem; @@ -79,7 +77,7 @@ public class MainActivity extends Activity toggle.syncState(); if (savedInstanceState == null) - navigate(getIntent().getStringExtra(SECTION)); + navigate(getIntent().getStringExtra(MagiskManager.INTENT_SECTION)); navigationView.setNavigationItemSelectedListener(this); getApplicationContext().reloadMainActivity.register(this); @@ -95,13 +93,13 @@ public class MainActivity extends Activity @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); - navigate(savedInstanceState.getInt(SECTION, R.id.status)); + navigate(savedInstanceState.getInt(MagiskManager.INTENT_SECTION, R.id.status)); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - outState.putInt(SECTION, mDrawerItem); + outState.putInt(MagiskManager.INTENT_SECTION, mDrawerItem); } @Override diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java index 76f30d022..42d1246de 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java @@ -146,9 +146,8 @@ public class SettingsActivity extends Activity { enabled = prefs.getBoolean("dark_theme", false); if (getApplication().isDarkTheme != enabled) { getApplication().isDarkTheme = enabled; - getApplication().reloadMainActivity.trigger(); getActivity().finish(); - getActivity().recreate(); + getApplication().reloadMainActivity.trigger(); } break; case "disable": diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index 4d3978d3c..b83e1e062 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -31,7 +31,7 @@ public class SplashActivity extends Activity{ magiskManager.init(); // Initialize the update check service, notify every 3 hours - if (!"install".equals(getIntent().getStringExtra(MainActivity.SECTION))) { + if (!"install".equals(getIntent().getStringExtra(MagiskManager.INTENT_SECTION))) { ComponentName service = new ComponentName(magiskManager, UpdateCheckService.class); JobInfo jobInfo = new JobInfo.Builder(UPDATE_SERVICE_ID, service) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) @@ -60,8 +60,11 @@ public class SplashActivity extends Activity{ @Override protected void onPostExecute(Void v) { super.onPostExecute(v); - Intent intent = getIntent().setClass(magiskManager, MainActivity.class) - .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + String section = getIntent().getStringExtra(MagiskManager.INTENT_SECTION); + Intent intent = new Intent(magiskManager, MainActivity.class); + if (section != null) { + intent.putExtra(MagiskManager.INTENT_SECTION, section); + } startActivity(intent); finish(); } diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java index 0762833b8..6e11782a8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/CheckUpdates.java @@ -7,7 +7,7 @@ import android.content.Intent; import android.support.v4.app.TaskStackBuilder; import android.support.v7.app.NotificationCompat; -import com.topjohnwu.magisk.MainActivity; +import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.SplashActivity; import com.topjohnwu.magisk.utils.Utils; @@ -56,7 +56,7 @@ public class CheckUpdates extends ParallelTask { .setVibrate(new long[]{0, 100, 100, 100}) .setAutoCancel(true); Intent intent = new Intent(magiskManager, SplashActivity.class); - intent.putExtra(MainActivity.SECTION, "install"); + intent.putExtra(MagiskManager.INTENT_SECTION, "install"); TaskStackBuilder stackBuilder = TaskStackBuilder.create(magiskManager); stackBuilder.addParentStack(SplashActivity.class); stackBuilder.addNextIntent(intent); diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index d77969e30..4388aaf60 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -13,7 +13,7 @@ #2196F3 #FFC107 - #1a237e + #bf360c #000000 #dedede diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 65fa4466a..9fc445db5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -15,8 +15,6 @@