mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 10:35:26 +00:00
Seperate Configs
This commit is contained in:
parent
ad16a6fc1b
commit
bcc695234c
@ -46,7 +46,7 @@ public class AboutActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
||||
Logger.dev("AboutActivity: Theme is " + theme);
|
||||
if (Utils.isDarkTheme) {
|
||||
if (Global.Configs.isDarkTheme) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
setContentView(R.layout.activity_about);
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.topjohnwu.magisk.module.Module;
|
||||
import com.topjohnwu.magisk.module.Repo;
|
||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||
import com.topjohnwu.magisk.utils.ValueSortedMap;
|
||||
@ -21,7 +26,7 @@ public class Global {
|
||||
}
|
||||
public static class Data {
|
||||
public static ValueSortedMap<String, Repo> repoMap = new ValueSortedMap<>();
|
||||
public static ValueSortedMap<String, com.topjohnwu.magisk.module.Module> moduleMap = new ValueSortedMap<>();
|
||||
public static ValueSortedMap<String, Module> moduleMap = new ValueSortedMap<>();
|
||||
public static List<String> blockList;
|
||||
}
|
||||
public static class Events {
|
||||
@ -33,5 +38,17 @@ public class Global {
|
||||
public static final CallbackHandler.Event updateCheckDone = new CallbackHandler.Event();
|
||||
public static final CallbackHandler.Event safetyNetDone = new CallbackHandler.Event();
|
||||
}
|
||||
public static class Configs {
|
||||
public static boolean isDarkTheme;
|
||||
public static boolean shellLogging;
|
||||
public static boolean devLogging;
|
||||
|
||||
public static void init(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
isDarkTheme = prefs.getString("theme", context.getString(R.string.theme_default_value)).equalsIgnoreCase(context.getString(R.string.theme_dark_value));
|
||||
devLogging = prefs.getBoolean("developer_logging", false);
|
||||
shellLogging = prefs.getBoolean("shell_logging", false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import android.view.View;
|
||||
|
||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@ -48,7 +47,7 @@ public class MainActivity extends AppCompatActivity
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
|
||||
if (Utils.isDarkTheme) {
|
||||
if (Global.Configs.isDarkTheme) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -16,10 +16,10 @@ import android.widget.TextView;
|
||||
import com.github.clans.fab.FloatingActionButton;
|
||||
import com.topjohnwu.magisk.adapters.ModulesAdapter;
|
||||
import com.topjohnwu.magisk.module.Module;
|
||||
import com.topjohnwu.magisk.module.ModuleHelper;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.module.ModuleHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -16,11 +16,11 @@ import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.adapters.ReposAdapter;
|
||||
import com.topjohnwu.magisk.adapters.SimpleSectionedRecyclerViewAdapter;
|
||||
import com.topjohnwu.magisk.module.ModuleHelper;
|
||||
import com.topjohnwu.magisk.module.Repo;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.module.ModuleHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -32,7 +32,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
String theme = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("theme", "");
|
||||
Logger.dev("AboutActivity: Theme is " + theme);
|
||||
if (Utils.isDarkTheme) {
|
||||
if (Global.Configs.isDarkTheme) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
return true;
|
||||
});
|
||||
|
||||
if (Utils.isDarkTheme) {
|
||||
if (Global.Configs.isDarkTheme) {
|
||||
themePreference.setSummary(R.string.theme_dark);
|
||||
} else {
|
||||
themePreference.setSummary(R.string.theme_default);
|
||||
@ -143,8 +143,8 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
switch (key) {
|
||||
case "theme":
|
||||
String theme = prefs.getString("theme", getString(R.string.theme_default_value));
|
||||
if (Utils.isDarkTheme != theme.equalsIgnoreCase(getString(R.string.theme_dark_value))) {
|
||||
Utils.isDarkTheme = !Utils.isDarkTheme;
|
||||
if (Global.Configs.isDarkTheme != theme.equalsIgnoreCase(getString(R.string.theme_dark_value))) {
|
||||
Global.Configs.isDarkTheme = !Global.Configs.isDarkTheme;
|
||||
getActivity().recreate();
|
||||
Global.Events.reloadMainActivity.trigger();
|
||||
}
|
||||
@ -200,10 +200,10 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
}.exec();
|
||||
break;
|
||||
case "developer_logging":
|
||||
Logger.devLog = prefs.getBoolean("developer_logging", false);
|
||||
Global.Configs.devLogging = prefs.getBoolean("developer_logging", false);
|
||||
break;
|
||||
case "shell_logging":
|
||||
Logger.logShell = prefs.getBoolean("shell_logging", false);
|
||||
Global.Configs.shellLogging = prefs.getBoolean("shell_logging", false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
@ -16,18 +15,14 @@ public class SplashActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
|
||||
String theme = prefs.getString("theme", getString(R.string.theme_default_value));
|
||||
Utils.isDarkTheme = theme.equalsIgnoreCase(getString(R.string.theme_dark_value));
|
||||
Global.Configs.init(getApplicationContext());
|
||||
|
||||
if (Utils.isDarkTheme) {
|
||||
if (Global.Configs.isDarkTheme) {
|
||||
setTheme(R.style.AppTheme_dh);
|
||||
}
|
||||
|
||||
Logger.devLog = prefs.getBoolean("developer_logging", false);
|
||||
Logger.logShell = prefs.getBoolean("shell_logging", false);
|
||||
|
||||
// Initialize prefs
|
||||
prefs.edit()
|
||||
.putBoolean("magiskhide", Utils.itemExist(false, "/magisk/.core/magiskhide/enable"))
|
||||
|
@ -5,8 +5,8 @@ import android.content.SharedPreferences;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
import com.topjohnwu.magisk.utils.ValueSortedMap;
|
||||
|
@ -2,8 +2,8 @@ package com.topjohnwu.magisk.receivers;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Shell;
|
||||
import com.topjohnwu.magisk.utils.ZipUtils;
|
||||
|
@ -3,7 +3,6 @@ package com.topjohnwu.magisk.superuser;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -2,20 +2,20 @@ package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.topjohnwu.magisk.Global;
|
||||
|
||||
public class Logger {
|
||||
|
||||
public static final String TAG = "Magisk";
|
||||
public static final String DEV_TAG = "Magisk: DEV";
|
||||
public static final String DEBUG_TAG = "Magisk: DEBUG";
|
||||
|
||||
public static boolean logShell, devLog;
|
||||
|
||||
public static void debug(String msg) {
|
||||
Log.d(DEBUG_TAG, msg);
|
||||
}
|
||||
|
||||
public static void dev(String msg, Object... args) {
|
||||
if (devLog) {
|
||||
if (Global.Configs.devLogging) {
|
||||
if (args.length == 1 && args[0] instanceof Throwable) {
|
||||
Log.d(DEV_TAG, msg, (Throwable) args[0]);
|
||||
} else {
|
||||
@ -25,13 +25,13 @@ public class Logger {
|
||||
}
|
||||
|
||||
public static void dev(String msg) {
|
||||
if (devLog) {
|
||||
if (Global.Configs.devLogging) {
|
||||
Log.d(DEV_TAG, msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void shell(boolean root, String msg) {
|
||||
if (logShell) {
|
||||
if (Global.Configs.shellLogging) {
|
||||
Log.d(root ? "SU" : "SH", msg);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import android.support.v4.app.ActivityCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.Global;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||
|
||||
@ -23,7 +24,6 @@ import java.util.List;
|
||||
public class Utils {
|
||||
|
||||
public static boolean isDownloading = false;
|
||||
public static boolean isDarkTheme;
|
||||
|
||||
public static boolean itemExist(String path) {
|
||||
return itemExist(true, path);
|
||||
@ -125,7 +125,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static AlertDialog.Builder getAlertDialogBuilder(Context context) {
|
||||
if (isDarkTheme) {
|
||||
if (Global.Configs.isDarkTheme) {
|
||||
return new AlertDialog.Builder(context, R.style.AlertDialog_dh);
|
||||
} else {
|
||||
return new AlertDialog.Builder(context);
|
||||
|
Loading…
Reference in New Issue
Block a user