From 1e22764695e076c5db63f7ff984aae62089d8bb5 Mon Sep 17 00:00:00 2001 From: tehcneko <7764726+tehcneko@users.noreply.github.com> Date: Fri, 12 Feb 2021 21:34:13 +0800 Subject: [PATCH] [app] Nuke non-md2 themes --- .../manager/ui/activity/AppListActivity.java | 7 +- .../manager/ui/activity/BaseActivity.java | 39 +- .../manager/ui/activity/ModulesActivity.java | 9 +- .../manager/ui/activity/RepoActivity.java | 7 +- .../manager/ui/activity/RepoItemActivity.java | 5 - .../manager/ui/activity/SettingsActivity.java | 51 - .../github/lsposed/manager/util/NavUtil.java | 2 +- ...background_md2.xml => item_background.xml} | 2 +- .../res/drawable/item_background_round.xml | 17 - app/src/main/res/layout/activity_about.xml | 1 - app/src/main/res/layout/activity_app_list.xml | 1 - app/src/main/res/layout/activity_list.xml | 1 - app/src/main/res/layout/activity_logs.xml | 3 +- .../res/layout/activity_module_detail.xml | 3 +- app/src/main/res/layout/activity_settings.xml | 1 - app/src/main/res/values-night/colors.xml | 1 + app/src/main/res/values-night/colors_md2.xml | 4 - app/src/main/res/values-night/styles.xml | 17 +- app/src/main/res/values/attrs.xml | 1 - app/src/main/res/values/colors.xml | 10 +- app/src/main/res/values/colors_md2.xml | 9 - app/src/main/res/values/styles.xml | 80 +- .../main/res/values/themes_custom_colorab.xml | 1724 ----------------- app/src/main/res/xml/prefs.xml | 13 - 24 files changed, 80 insertions(+), 1928 deletions(-) rename app/src/main/res/drawable/{item_background_md2.xml => item_background.xml} (85%) delete mode 100644 app/src/main/res/drawable/item_background_round.xml delete mode 100644 app/src/main/res/values-night/colors_md2.xml delete mode 100644 app/src/main/res/values/colors_md2.xml delete mode 100644 app/src/main/res/values/themes_custom_colorab.xml diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/AppListActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/AppListActivity.java index e1a59ebb..61759ac4 100644 --- a/app/src/main/java/io/github/lsposed/manager/ui/activity/AppListActivity.java +++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/AppListActivity.java @@ -16,7 +16,6 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.SearchView; -import androidx.recyclerview.widget.DividerItemDecoration; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; @@ -59,12 +58,8 @@ public class AppListActivity extends BaseActivity { binding.recyclerView.setAdapter(scopeAdapter); binding.recyclerView.setHasFixedSize(true); binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this)); + RecyclerViewKt.addFastScroller(binding.recyclerView, binding.recyclerView); RecyclerViewKt.fixEdgeEffect(binding.recyclerView, false, true); - if (!preferences.getBoolean("md2", true)) { - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, - DividerItemDecoration.VERTICAL); - binding.recyclerView.addItemDecoration(dividerItemDecoration); - } searchListener = new SearchView.OnQueryTextListener() { @Override diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/BaseActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/BaseActivity.java index 9a85eb24..99735ee0 100644 --- a/app/src/main/java/io/github/lsposed/manager/ui/activity/BaseActivity.java +++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/BaseActivity.java @@ -5,7 +5,10 @@ import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.Color; +import android.os.Build; import android.os.Bundle; +import android.view.Window; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -67,8 +70,7 @@ public class BaseActivity extends MaterialActivity { @StyleRes private int getCustomTheme() { - String baseThemeName = preferences.getBoolean("colorized_action_bar", false) && !preferences.getBoolean("md2", true) ? - "ThemeOverlay.ActionBarPrimaryColor" : "ThemeOverlay"; + String baseThemeName = "ThemeOverlay"; String customThemeName; String primaryColorEntryName = "colorPrimary"; for (CustomThemeColor color : CustomThemeColors.Primary.values()) { @@ -91,7 +93,7 @@ public class BaseActivity extends MaterialActivity { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - theme = getTheme(this) + getCustomTheme() + preferences.getBoolean("md2", true); + theme = getTheme(this) + getCustomTheme(); // make sure the versions are consistent String coreVersionStr = Constants.getXposedVersion(); @@ -121,8 +123,7 @@ public class BaseActivity extends MaterialActivity { @Override protected void onResume() { super.onResume(); - getWindow().setStatusBarColor(0); - if (!Objects.equals(theme, getTheme(this) + getCustomTheme() + preferences.getBoolean("md2", true))) { + if (!Objects.equals(theme, getTheme(this) + getCustomTheme())) { recreate(); } } @@ -141,14 +142,30 @@ public class BaseActivity extends MaterialActivity { theme.applyStyle(resid, false); } theme.applyStyle(getCustomTheme(), true); - if (preferences.getBoolean("md2", true) && !(this instanceof MainActivity)) { - theme.applyStyle(R.style.ThemeOverlay_Md2, true); - } - if (this instanceof MainActivity) { - theme.applyStyle(R.style.ThemeOverlay_ActivityMain, true); - } theme.applyStyle(getThemeStyleRes(this), true); // only pass theme style to super, so styled theme will not be overwritten super.onApplyThemeResource(theme, R.style.ThemeOverlay, first); } + + @Override + public void onApplyTranslucentSystemBars() { + super.onApplyTranslucentSystemBars(); + Window window = getWindow(); + window.setStatusBarColor(Color.TRANSPARENT); + + window.getDecorView().post(() -> { + if (window.getDecorView().getRootWindowInsets().getSystemWindowInsetBottom() >= Resources.getSystem().getDisplayMetrics().density * 40) { + window.setNavigationBarColor(getThemedColor(android.R.attr.navigationBarColor) & 0x00ffffff | -0x20000000); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + window.setNavigationBarContrastEnforced(false); + } + } else { + window.setNavigationBarColor(Color.TRANSPARENT); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + window.setNavigationBarContrastEnforced(true); + } + } + }); + + } } diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/ModulesActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/ModulesActivity.java index 36ee6a3f..3e31be0f 100644 --- a/app/src/main/java/io/github/lsposed/manager/ui/activity/ModulesActivity.java +++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/ModulesActivity.java @@ -29,7 +29,6 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.SearchView; import androidx.core.content.ContextCompat; -import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.request.target.CustomTarget; @@ -83,14 +82,8 @@ public class ModulesActivity extends BaseActivity implements ModuleUtil.ModuleLi binding.recyclerView.setAdapter(adapter); binding.recyclerView.setHasFixedSize(true); binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this)); - //RecyclerViewKt.addFastScroller(binding.recyclerView, binding.swipeRefreshLayout); + RecyclerViewKt.addFastScroller(binding.recyclerView, binding.recyclerView); RecyclerViewKt.fixEdgeEffect(binding.recyclerView, false, true); - if (!preferences.getBoolean("md2", true)) { - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, - DividerItemDecoration.VERTICAL); - binding.recyclerView.addItemDecoration(dividerItemDecoration); - } - //binding.swipeRefreshLayout.setOnRefreshListener(() -> adapter.refresh(true)); mSearchListener = new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/RepoActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/RepoActivity.java index bcc57fdd..73901dc5 100644 --- a/app/src/main/java/io/github/lsposed/manager/ui/activity/RepoActivity.java +++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/RepoActivity.java @@ -36,7 +36,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.SearchView; -import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; @@ -76,12 +75,8 @@ public class RepoActivity extends BaseActivity implements RepoLoader.Listener { binding.recyclerView.setAdapter(adapter); binding.recyclerView.setHasFixedSize(true); binding.recyclerView.setLayoutManager(new LinearLayoutManagerFix(this)); + RecyclerViewKt.addFastScroller(binding.recyclerView, binding.recyclerView); RecyclerViewKt.fixEdgeEffect(binding.recyclerView, false, true); - if (!preferences.getBoolean("md2", true)) { - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, - DividerItemDecoration.VERTICAL); - binding.recyclerView.addItemDecoration(dividerItemDecoration); - } repoLoader.addListener(this); searchListener = new SearchView.OnQueryTextListener() { @Override diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/RepoItemActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/RepoItemActivity.java index 5d1c1868..8b550ed0 100644 --- a/app/src/main/java/io/github/lsposed/manager/ui/activity/RepoItemActivity.java +++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/RepoItemActivity.java @@ -35,7 +35,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; -import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager2.widget.ViewPager2; @@ -317,10 +316,6 @@ public class RepoItemActivity extends BaseActivity { case 2: holder.recyclerView.setAdapter(position == 1 ? new ReleaseAdapter(module.getReleases()) : new InformationAdapter(module)); holder.recyclerView.setLayoutManager(new LinearLayoutManagerFix(RepoItemActivity.this)); - if (!preferences.getBoolean("md2", true)) { - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(RepoItemActivity.this, DividerItemDecoration.VERTICAL); - holder.recyclerView.addItemDecoration(dividerItemDecoration); - } holder.recyclerView.getBorderViewDelegate().setBorderVisibilityChangedListener((top, oldTop, bottom, oldBottom) -> binding.appBar.setRaised(!top)); RecyclerViewKt.fixEdgeEffect(holder.recyclerView, false, true); RecyclerViewKt.addFastScroller(holder.recyclerView, holder.itemView); diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/SettingsActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/SettingsActivity.java index 8fac51dc..ff5a18ad 100644 --- a/app/src/main/java/io/github/lsposed/manager/ui/activity/SettingsActivity.java +++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/SettingsActivity.java @@ -262,22 +262,6 @@ public class SettingsActivity extends BaseActivity { }); } - SwitchPreference transparent = findPreference("transparent_status_bar"); - if (transparent != null) { - transparent.setOnPreferenceChangeListener((preference, newValue) -> { - boolean enabled = (Boolean) newValue; - SettingsActivity activity = (SettingsActivity) getActivity(); - if (activity != null) { - if (enabled) { - activity.getWindow().setStatusBarColor(activity.getThemedColor(R.attr.colorActionBar)); - } else { - activity.getWindow().setStatusBarColor(activity.getThemedColor(R.attr.colorPrimaryDark)); - } - } - return true; - }); - } - IntegerListPreference theme = findPreference("theme"); if (theme != null) { theme.setOnPreferenceChangeListener((preference, newValue) -> { @@ -324,41 +308,6 @@ public class SettingsActivity extends BaseActivity { return true; }); } - - Preference colorized_action_bar = findPreference("colorized_action_bar"); - if (colorized_action_bar != null) { - colorized_action_bar.setOnPreferenceChangeListener((preference, newValue) -> { - SettingsActivity activity = (SettingsActivity) getActivity(); - if (activity != null && !(isBlackNightTheme() && isNightMode(getResources().getConfiguration()))) { - activity.restart(); - } - return true; - }); - } - - SwitchPreference md2 = findPreference("md2"); - if (md2 != null) { - md2.setOnPreferenceChangeListener((preference, newValue) -> { - SettingsActivity activity = (SettingsActivity) getActivity(); - if (activity != null) { - updatePreference(!md2.isChecked()); - activity.restart(); - } - return true; - }); - updatePreference(!md2.isChecked()); - } - } - - private void updatePreference(boolean show) { - Preference transparent_status_bar = findPreference("transparent_status_bar"); - if (transparent_status_bar != null) { - transparent_status_bar.setVisible(show); - } - Preference colorized_action_bar = findPreference("colorized_action_bar"); - if (colorized_action_bar != null) { - colorized_action_bar.setVisible(show); - } } private class OnFlagChangeListener implements Preference.OnPreferenceChangeListener { diff --git a/app/src/main/java/io/github/lsposed/manager/util/NavUtil.java b/app/src/main/java/io/github/lsposed/manager/util/NavUtil.java index 1857862f..29b3915a 100644 --- a/app/src/main/java/io/github/lsposed/manager/util/NavUtil.java +++ b/app/src/main/java/io/github/lsposed/manager/util/NavUtil.java @@ -14,7 +14,7 @@ public final class NavUtil { CustomTabsIntent.Builder customTabsIntent = new CustomTabsIntent.Builder(); customTabsIntent.setShowTitle(true); CustomTabColorSchemeParams params = new CustomTabColorSchemeParams.Builder() - .setToolbarColor(activity.getThemedColor(R.attr.colorActionBar)) + .setToolbarColor(activity.getThemedColor(R.attr.toolbarColor)) .setNavigationBarColor(activity.getThemedColor(android.R.attr.navigationBarColor)) .setNavigationBarDividerColor(0) .build(); diff --git a/app/src/main/res/drawable/item_background_md2.xml b/app/src/main/res/drawable/item_background.xml similarity index 85% rename from app/src/main/res/drawable/item_background_md2.xml rename to app/src/main/res/drawable/item_background.xml index fc19ef5b..34a5a418 100644 --- a/app/src/main/res/drawable/item_background_md2.xml +++ b/app/src/main/res/drawable/item_background.xml @@ -10,7 +10,7 @@ android:left="8dp" android:top="4dp"> - + diff --git a/app/src/main/res/drawable/item_background_round.xml b/app/src/main/res/drawable/item_background_round.xml deleted file mode 100644 index 70f4df8c..00000000 --- a/app/src/main/res/drawable/item_background_round.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 66418af3..54a5a2c4 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -19,7 +19,6 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:background="?colorActionBar" app:popupTheme="?actionBarPopupTheme" /> diff --git a/app/src/main/res/layout/activity_app_list.xml b/app/src/main/res/layout/activity_app_list.xml index 4d7c2c1a..b8cb6c41 100644 --- a/app/src/main/res/layout/activity_app_list.xml +++ b/app/src/main/res/layout/activity_app_list.xml @@ -39,7 +39,6 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:background="?colorActionBar" app:subtitleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle" app:titleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Title" app:popupTheme="?actionBarPopupTheme" /> diff --git a/app/src/main/res/layout/activity_list.xml b/app/src/main/res/layout/activity_list.xml index 90fe4dd2..be1a89d2 100644 --- a/app/src/main/res/layout/activity_list.xml +++ b/app/src/main/res/layout/activity_list.xml @@ -38,7 +38,6 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:background="?colorActionBar" app:subtitleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle" app:titleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Title" app:popupTheme="?actionBarPopupTheme" /> diff --git a/app/src/main/res/layout/activity_logs.xml b/app/src/main/res/layout/activity_logs.xml index e819b2cc..a448273f 100644 --- a/app/src/main/res/layout/activity_logs.xml +++ b/app/src/main/res/layout/activity_logs.xml @@ -24,7 +24,6 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?actionBarSize" - android:background="?colorActionBar" app:subtitleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle" app:titleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Title" app:popupTheme="?actionBarPopupTheme" /> @@ -33,7 +32,7 @@ android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="@dimen/tab_layout_height" - android:background="?colorActionBar" + android:background="@android:color/transparent" app:tabMode="fixed" style="?tabLayoutTheme"> diff --git a/app/src/main/res/layout/activity_module_detail.xml b/app/src/main/res/layout/activity_module_detail.xml index 84ef42b1..aaf41e6f 100644 --- a/app/src/main/res/layout/activity_module_detail.xml +++ b/app/src/main/res/layout/activity_module_detail.xml @@ -42,7 +42,6 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?actionBarSize" - android:background="?colorActionBar" app:subtitleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle" app:titleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Title" app:popupTheme="?actionBarPopupTheme" /> @@ -51,7 +50,7 @@ android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="@dimen/tab_layout_height" - android:background="?colorActionBar" + android:background="@android:color/transparent" style="?tabLayoutTheme" /> diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 48278a3a..e311dbfc 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -19,7 +19,6 @@ android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:background="?colorActionBar" app:subtitleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle" app:titleTextAppearance="@android:style/TextAppearance.Material.Widget.Toolbar.Title" app:popupTheme="?actionBarPopupTheme" /> diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 24558a19..03bf4c23 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -4,6 +4,7 @@ #303030 #2E2E2E #383838 + #cbffffff #B3000000 @color/material_red_700 @color/material_green_700 diff --git a/app/src/main/res/values-night/colors_md2.xml b/app/src/main/res/values-night/colors_md2.xml deleted file mode 100644 index df56bec6..00000000 --- a/app/src/main/res/values-night/colors_md2.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #cbffffff - diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index 77160443..5770f131 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -1,18 +1,3 @@ - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/xml/prefs.xml b/app/src/main/res/xml/prefs.xml index 6efde4c7..4694d45d 100644 --- a/app/src/main/res/xml/prefs.xml +++ b/app/src/main/res/xml/prefs.xml @@ -38,19 +38,6 @@ android:summary="%s" android:title="@string/settings_theme" app:iconSpaceReserved="false" /> - - -