Some cleanups

This commit is contained in:
topjohnwu 2018-08-01 03:09:44 +08:00
parent 863b9a410f
commit e90c555c18
6 changed files with 13 additions and 15 deletions

View File

@ -52,9 +52,7 @@ public class Data {
public static int suResponseType;
public static int suNotificationType;
public static int suNamespaceMode;
public static String localeConfig;
public static int updateChannel;
public static String bootFormat;
public static int repoOrder;
public static void loadMagiskInfo() {
@ -154,8 +152,7 @@ public class Data {
// config
isDarkTheme = mm.prefs.getBoolean(Const.Key.DARK_THEME, false);
updateChannel = Utils.getPrefsInt(mm.prefs, Const.Key.UPDATE_CHANNEL, Const.Value.STABLE_CHANNEL);
bootFormat = mm.prefs.getString(Const.Key.BOOT_FORMAT, ".img");
repoOrder = mm.prefs.getInt(Const.Key.REPO_ORDER, Const.Value.ORDER_NAME);
repoOrder = mm.prefs.getInt(Const.Key.REPO_ORDER, Const.Value.ORDER_DATE);
}
public static void writeConfig() {
@ -171,8 +168,6 @@ public class Data {
.putString(Const.Key.SU_MULTIUSER_MODE, String.valueOf(multiuserMode))
.putString(Const.Key.SU_MNT_NS, String.valueOf(suNamespaceMode))
.putString(Const.Key.UPDATE_CHANNEL, String.valueOf(updateChannel))
.putString(Const.Key.LOCALE, localeConfig)
.putString(Const.Key.BOOT_FORMAT, bootFormat)
.putInt(Const.Key.UPDATE_SERVICE_VER, Const.UPDATE_SERVICE_VER)
.putInt(Const.Key.REPO_ORDER, repoOrder)
.apply();

View File

@ -44,7 +44,6 @@ public class MagiskManager extends ContainerApp {
prefs = PreferenceManager.getDefaultSharedPreferences(this);
mDB = MagiskDatabaseHelper.getInstance(this);
LocaleManager.locale = LocaleManager.defaultLocale = Locale.getDefault();
String pkg = mDB.getStrings(Const.Key.SU_MANAGER, null);
if (pkg != null && getPackageName().equals(Const.ORIG_PKG_NAME)) {

View File

@ -231,10 +231,11 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
private void outputBoot(File patched) throws IOException {
switch (mode) {
case PATCH_MODE:
File dest = new File(Download.EXTERNAL_PATH, "patched_boot" + Data.bootFormat);
String fmt = mm.prefs.getString(Const.Key.BOOT_FORMAT, ".img");
File dest = new File(Download.EXTERNAL_PATH, "patched_boot" + fmt);
dest.getParentFile().mkdirs();
OutputStream out;
switch (Data.bootFormat) {
switch (fmt) {
case ".img.tar":
out = new TarOutputStream(new BufferedOutputStream(new FileOutputStream(dest)));
((TarOutputStream) out).putNextEntry(new TarEntry(patched, "boot.img"));

View File

@ -17,20 +17,20 @@ import java.util.List;
import java.util.Locale;
public class LocaleManager {
public static Locale locale;
public static Locale defaultLocale;
public static Locale locale = Locale.getDefault();
public final static Locale defaultLocale = Locale.getDefault();
public static List<Locale> locales;
public static void setLocale() {
MagiskManager mm = Data.MM();
Data.localeConfig = mm.prefs.getString(Const.Key.LOCALE, "");
if (Data.localeConfig.isEmpty()) {
String localeConfig = mm.prefs.getString(Const.Key.LOCALE, "");
if (localeConfig.isEmpty()) {
locale = defaultLocale;
} else {
locale = Locale.forLanguageTag(Data.localeConfig);
locale = Locale.forLanguageTag(localeConfig);
}
Resources res = mm.getResources();
Configuration config = new Configuration(res.getConfiguration());
Configuration config = res.getConfiguration();
config.setLocale(locale);
res.updateConfiguration(config, res.getDisplayMetrics());
}

View File

@ -12,6 +12,7 @@
<ListPreference
android:key="locale"
android:defaultValue="@string/empty"
android:title="@string/language"/>
<Preference
@ -52,6 +53,7 @@
android:title="@string/settings_boot_format_title"
android:entries="@array/boot_formats"
android:entryValues="@array/boot_formats"
android:defaultValue=".img"
android:summary="@string/settings_boot_format_summary"/>
</PreferenceCategory>

View File

@ -5,6 +5,7 @@
<string name="app_name" translatable="false">Magisk Manager</string>
<string name="magisk" translatable="false">Magisk</string>
<string name="magiskhide" translatable="false">Magisk Hide</string>
<string name="empty" translatable="false"/>
<!--Used in both stub and full app-->
<string name="download_file_error">Error downloading file</string>