Potentially fix Samsung crash and change colors

This commit is contained in:
topjohnwu 2017-02-20 20:09:20 +08:00
parent 2f78155723
commit 8eba05ed4a
7 changed files with 14 additions and 15 deletions

View File

@ -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<Void> blockDetectionDone = new CallbackEvent<>();

View File

@ -29,8 +29,6 @@ import butterknife.ButterKnife;
public class MainActivity extends Activity
implements NavigationView.OnNavigationItemSelectedListener, CallbackEvent.Listener<Void> {
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

View File

@ -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":

View File

@ -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();
}

View File

@ -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<Void, Void, Void> {
.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);

View File

@ -13,7 +13,7 @@
<color name="blue500">#2196F3</color>
<color name="yellow500">#FFC107</color>
<color name="dark_primary">#1a237e</color>
<color name="dark_primary">#bf360c</color>
<color name="dark_primary_dark">#000000</color>
<color name="dark_secondary_text">#dedede</color>

View File

@ -15,8 +15,6 @@
</style>
<style name="AppTheme.Dark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/dark_primary</item>
<item name="colorPrimaryDark">@color/dark_primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="colorAccentFallback">@color/accentFallback</item>
<item name="windowActionModeOverlay">true</item>