Fixes
This commit is contained in:
parent
f1250d1044
commit
0e009fabeb
|
|
@ -43,6 +43,7 @@
|
|||
android:label="@string/Downloads" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:theme="@style/AppTheme.ActivityMain"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:color="?colorControlHighlight"
|
||||
tools:ignore="PrivateResource">
|
||||
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@android:color/white" />
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
||||
|
|
@ -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">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -96,8 +97,8 @@
|
|||
android:layout_height="28dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:contentDescription="@string/Activated"
|
||||
android:tint="@android:color/white"
|
||||
app:srcCompat="@drawable/ic_check_circle" />
|
||||
app:srcCompat="@drawable/ic_check_circle"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/status_title"
|
||||
|
|
@ -132,6 +133,7 @@
|
|||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<RelativeLayout
|
||||
|
|
@ -182,6 +184,7 @@
|
|||
android:focusable="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardPreventCornerOverlap="false">
|
||||
|
||||
<RelativeLayout
|
||||
|
|
@ -229,7 +232,7 @@
|
|||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="?roundBackground"
|
||||
android:background="@drawable/item_background_round_nopadding"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
|
|
@ -255,8 +258,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="?roundBackground"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/item_background_round_nopadding"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
|
|
@ -282,8 +285,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="?roundBackground"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/item_background_round_nopadding"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
|
|
@ -309,8 +312,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="?roundBackground"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/item_background_round_nopadding"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary_md2">@color/material_blue_700</color>
|
||||
<color name="colorBackground_md2">#000</color>
|
||||
<color name="colorPrimaryDark_md2">#000</color>
|
||||
<color name="colorAccent_md2">@color/material_blue_700</color>
|
||||
<color name="colorActionBar_md2">#000</color>
|
||||
<color name="colorStickyHeader_md2">#ea000000</color>
|
||||
<color name="selectorTransparency_md2">#eaffffff</color>
|
||||
</resources>
|
||||
|
|
@ -54,9 +54,11 @@
|
|||
<item name="tabLayoutTheme">@style/Widget.MaterialComponents.TabLayout.Colored</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.ActivityMain">
|
||||
<style name="AppTheme.ActivityMain" parent="AppTheme">
|
||||
<item name="android:windowLightStatusBar">@bool/lightSystemUI</item>
|
||||
<item name="colorPrimaryDark">?android:colorBackground</item>
|
||||
<item name="android:ambientShadowAlpha">0.01</item>
|
||||
<item name="android:spotShadowAlpha">0.01</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.Black">
|
||||
|
|
|
|||
Loading…
Reference in New Issue