Enable md2 by default

This commit is contained in:
tehcneko 2021-01-29 11:49:39 +08:00
parent 9eadc2ad24
commit 3b7502ca5a
4 changed files with 20 additions and 21 deletions

View File

@ -25,7 +25,6 @@ import io.github.lsposed.manager.adapters.BlackListAdapter;
import io.github.lsposed.manager.adapters.ScopeAdapter; import io.github.lsposed.manager.adapters.ScopeAdapter;
import io.github.lsposed.manager.databinding.ActivityScopeListBinding; import io.github.lsposed.manager.databinding.ActivityScopeListBinding;
import io.github.lsposed.manager.util.LinearLayoutManagerFix; import io.github.lsposed.manager.util.LinearLayoutManagerFix;
import me.zhanghai.android.fastscroll.FastScrollerBuilder; import me.zhanghai.android.fastscroll.FastScrollerBuilder;
public class AppListActivity extends BaseActivity { public class AppListActivity extends BaseActivity {
@ -67,7 +66,7 @@ public class AppListActivity extends BaseActivity {
binding.recyclerView.setAdapter(appAdapter); binding.recyclerView.setAdapter(appAdapter);
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this)); binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView); FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView);
if (!preferences.getBoolean("md2", false)) { if (!preferences.getBoolean("md2", true)) {
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this,
DividerItemDecoration.VERTICAL); DividerItemDecoration.VERTICAL);
binding.recyclerView.addItemDecoration(dividerItemDecoration); binding.recyclerView.addItemDecoration(dividerItemDecoration);

View File

@ -18,6 +18,8 @@ import androidx.core.content.ContextCompat;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import java.util.Objects;
import io.github.lsposed.manager.App; import io.github.lsposed.manager.App;
import io.github.lsposed.manager.R; import io.github.lsposed.manager.R;
import io.github.lsposed.manager.util.CompileUtil; import io.github.lsposed.manager.util.CompileUtil;
@ -25,8 +27,6 @@ import io.github.lsposed.manager.util.CustomThemeColor;
import io.github.lsposed.manager.util.CustomThemeColors; import io.github.lsposed.manager.util.CustomThemeColors;
import io.github.lsposed.manager.util.RebootUtil; import io.github.lsposed.manager.util.RebootUtil;
import java.util.Objects;
public class BaseActivity extends AppCompatActivity { public class BaseActivity extends AppCompatActivity {
private static final String THEME_DEFAULT = "DEFAULT"; private static final String THEME_DEFAULT = "DEFAULT";
@ -39,7 +39,7 @@ public class BaseActivity extends AppCompatActivity {
} }
public static boolean isBlackNightTheme() { public static boolean isBlackNightTheme() {
return preferences.getBoolean("black_dark_theme", false) || preferences.getBoolean("md2", false); return preferences.getBoolean("black_dark_theme", false) || preferences.getBoolean("md2", true);
} }
public static String getTheme(Context context) { public static String getTheme(Context context) {
@ -67,7 +67,7 @@ public class BaseActivity extends AppCompatActivity {
@StyleRes @StyleRes
private int getCustomTheme() { private int getCustomTheme() {
String baseThemeName = preferences.getBoolean("colorized_action_bar", false) && !preferences.getBoolean("md2", false) ? String baseThemeName = preferences.getBoolean("colorized_action_bar", false) && !preferences.getBoolean("md2", true) ?
"ThemeOverlay.ActionBarPrimaryColor" : "ThemeOverlay"; "ThemeOverlay.ActionBarPrimaryColor" : "ThemeOverlay";
String customThemeName; String customThemeName;
String primaryColorEntryName = "colorPrimary"; String primaryColorEntryName = "colorPrimary";
@ -92,7 +92,7 @@ public class BaseActivity extends AppCompatActivity {
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
AppCompatDelegate.setDefaultNightMode(preferences.getInt("theme", -1)); AppCompatDelegate.setDefaultNightMode(preferences.getInt("theme", -1));
theme = getTheme(this) + getCustomTheme() + preferences.getBoolean("md2", false); theme = getTheme(this) + getCustomTheme() + preferences.getBoolean("md2", true);
} }
public int getThemedColor(int id) { public int getThemedColor(int id) {
@ -112,7 +112,7 @@ public class BaseActivity extends AppCompatActivity {
getWindow().setStatusBarColor(getThemedColor(R.attr.colorPrimaryDark)); getWindow().setStatusBarColor(getThemedColor(R.attr.colorPrimaryDark));
} }
} }
if (!Objects.equals(theme, getTheme(this) + getCustomTheme() + preferences.getBoolean("md2", false))) { if (!Objects.equals(theme, getTheme(this) + getCustomTheme() + preferences.getBoolean("md2", true))) {
recreate(); recreate();
} }
} }
@ -131,7 +131,7 @@ public class BaseActivity extends AppCompatActivity {
theme.applyStyle(resid, false); theme.applyStyle(resid, false);
} }
theme.applyStyle(getCustomTheme(), true); theme.applyStyle(getCustomTheme(), true);
if (preferences.getBoolean("md2", false) && !(this instanceof MainActivity)) { if (preferences.getBoolean("md2", true) && !(this instanceof MainActivity)) {
theme.applyStyle(R.style.ThemeOverlay_Md2, true); theme.applyStyle(R.style.ThemeOverlay_Md2, true);
} }
if (this instanceof MainActivity) { if (this instanceof MainActivity) {

View File

@ -27,17 +27,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import io.github.lsposed.manager.App;
import io.github.lsposed.manager.BuildConfig;
import io.github.lsposed.manager.Constants;
import io.github.lsposed.manager.R;
import io.github.lsposed.manager.adapters.AppAdapter;
import io.github.lsposed.manager.databinding.ActivityModulesBinding;
import io.github.lsposed.manager.util.GlideApp;
import io.github.lsposed.manager.util.LinearLayoutManagerFix;
import io.github.lsposed.manager.util.ModuleUtil;
import io.github.lsposed.manager.util.NavUtil;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -54,6 +43,16 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import io.github.lsposed.manager.App;
import io.github.lsposed.manager.BuildConfig;
import io.github.lsposed.manager.Constants;
import io.github.lsposed.manager.R;
import io.github.lsposed.manager.adapters.AppAdapter;
import io.github.lsposed.manager.databinding.ActivityModulesBinding;
import io.github.lsposed.manager.util.GlideApp;
import io.github.lsposed.manager.util.LinearLayoutManagerFix;
import io.github.lsposed.manager.util.ModuleUtil;
import io.github.lsposed.manager.util.NavUtil;
import me.zhanghai.android.fastscroll.FastScrollerBuilder; import me.zhanghai.android.fastscroll.FastScrollerBuilder;
import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS; import static android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
@ -197,7 +196,7 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi
binding.recyclerView.setAdapter(adapter); binding.recyclerView.setAdapter(adapter);
binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this)); binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this));
FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView); FastScrollerBuilder fastScrollerBuilder = new FastScrollerBuilder(binding.recyclerView);
if (!preferences.getBoolean("md2", false)) { if (!preferences.getBoolean("md2", true)) {
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this,
DividerItemDecoration.VERTICAL); DividerItemDecoration.VERTICAL);
binding.recyclerView.addItemDecoration(dividerItemDecoration); binding.recyclerView.addItemDecoration(dividerItemDecoration);

View File

@ -45,6 +45,7 @@
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:key="md2" android:key="md2"
android:title="@string/material_design_2" android:title="@string/material_design_2"
android:defaultValue="true"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:key="colorized_action_bar" android:key="colorized_action_bar"