From 0e009fabeb9bdf2ec8ff9815f9b96360b40e60e7 Mon Sep 17 00:00:00 2001 From: NekoInverter <42698724+NekoInverter@users.noreply.github.com> Date: Sun, 15 Mar 2020 12:25:35 +0800 Subject: [PATCH] Fixes --- app/src/main/AndroidManifest.xml | 1 + .../edxposed/manager/BaseActivity.java | 29 ++++++++++++++----- .../item_background_round_nopadding.xml | 12 ++++++++ app/src/main/res/layout/activity_main.xml | 23 ++++++++------- app/src/main/res/values-night/colors_md2.xml | 10 ------- app/src/main/res/values/styles.xml | 4 ++- 6 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 app/src/main/res/drawable/item_background_round_nopadding.xml delete mode 100644 app/src/main/res/values-night/colors_md2.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8a37e9f9..0016b94f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,6 +43,7 @@ android:label="@string/Downloads" /> diff --git a/app/src/main/java/org/meowcat/edxposed/manager/BaseActivity.java b/app/src/main/java/org/meowcat/edxposed/manager/BaseActivity.java index 576ca0d6..16178361 100644 --- a/app/src/main/java/org/meowcat/edxposed/manager/BaseActivity.java +++ b/app/src/main/java/org/meowcat/edxposed/manager/BaseActivity.java @@ -9,8 +9,11 @@ import android.content.res.TypedArray; import android.os.Bundle; import android.os.Looper; import android.text.TextUtils; +import android.util.DisplayMetrics; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; import android.widget.Toast; import androidx.annotation.NonNull; @@ -37,10 +40,10 @@ public class BaseActivity extends AppCompatActivity { private static final String THEME_DEFAULT = "DEFAULT"; private static final String THEME_BLACK = "BLACK"; - private String mTheme; + private String theme; public static boolean isBlackNightTheme() { - return XposedApp.getPreferences().getBoolean("black_dark_theme", false); + return XposedApp.getPreferences().getBoolean("black_dark_theme", false) || XposedApp.getPreferences().getBoolean("md2", false); } public static String getTheme(Context context) { @@ -55,6 +58,19 @@ public class BaseActivity extends AppCompatActivity { return (configuration.uiMode & Configuration.UI_MODE_NIGHT_YES) > 0; } + @Override + public void setContentView(View view) { + FrameLayout frameLayout = new FrameLayout(this); + frameLayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); + if (displayMetrics.widthPixels > displayMetrics.heightPixels) { + int padding = (displayMetrics.widthPixels - displayMetrics.heightPixels) / 2; + frameLayout.setPadding(padding, 0, padding, 0); + } + frameLayout.addView(view); + super.setContentView(frameLayout); + } + @StyleRes public int getThemeStyleRes(Context context) { switch (getTheme(context)) { @@ -104,7 +120,7 @@ public class BaseActivity extends AppCompatActivity { public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppCompatDelegate.setDefaultNightMode(XposedApp.getPreferences().getInt("theme", 0)); - mTheme = getTheme(this); + theme = getTheme(this) + getCustomTheme() + XposedApp.getPreferences().getBoolean("md2", false); } public int getThemedColor(int id) { @@ -124,7 +140,7 @@ public class BaseActivity extends AppCompatActivity { getWindow().setStatusBarColor(getThemedColor(R.attr.colorPrimaryDark)); } } - if (!Objects.equals(mTheme, getTheme(this))) { + if (!Objects.equals(theme, getTheme(this) + getCustomTheme() + XposedApp.getPreferences().getBoolean("md2", false))) { recreate(); } } @@ -143,12 +159,9 @@ public class BaseActivity extends AppCompatActivity { theme.applyStyle(resid, false); } theme.applyStyle(getCustomTheme(), true); - if (XposedApp.getPreferences().getBoolean("md2", false)) { + if (XposedApp.getPreferences().getBoolean("md2", false) && !(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); diff --git a/app/src/main/res/drawable/item_background_round_nopadding.xml b/app/src/main/res/drawable/item_background_round_nopadding.xml new file mode 100644 index 00000000..d52cfb1d --- /dev/null +++ b/app/src/main/res/drawable/item_background_round_nopadding.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 16fbc1e5..ab70d387 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -12,7 +12,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false" - android:clipToPadding="false"> + android:clipToPadding="false" + android:scrollbars="none"> + app:srcCompat="@drawable/ic_check_circle" + app:tint="@android:color/white" /> - - @color/material_blue_700 - #000 - #000 - @color/material_blue_700 - #000 - #ea000000 - #eaffffff - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 448c9d62..75b910b0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -54,9 +54,11 @@ @style/Widget.MaterialComponents.TabLayout.Colored -