[app] Update styles

This commit is contained in:
tehcneko 2021-10-03 22:48:24 +08:00 committed by Wang Han
parent c523263bd6
commit 4ac9612f17
11 changed files with 83 additions and 30 deletions

View File

@ -39,7 +39,7 @@ public class BlurBehindDialogBuilder extends MaterialAlertDialogBuilder {
private static final boolean supportBlur = getSystemProperty("ro.surface_flinger.supports_background_blur", false) && !getSystemProperty("persist.sys.sf.disable_blurs", false);
public BlurBehindDialogBuilder(@NonNull Context context) {
super(context);
super(context, com.google.android.material.R.style.ThemeOverlay_Material3_MaterialAlertDialog_Centered);
}
@NonNull

View File

@ -174,10 +174,11 @@ public class HomeFragment extends BaseFragment {
binding.statusIcon.setImageResource(R.drawable.ic_round_error_outline_24);
Snackbar.make(binding.snackbar, R.string.lsposed_not_active, Snackbar.LENGTH_INDEFINITE).show();
}
binding.status.setCardBackgroundColor(MaterialColors.harmonizeWithPrimary(activity, cardBackgroundColor));
cardBackgroundColor = MaterialColors.harmonizeWithPrimary(activity, cardBackgroundColor);
binding.status.setCardBackgroundColor(cardBackgroundColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
binding.status.setOutlineSpotShadowColor(MaterialColors.harmonizeWithPrimary(activity, cardBackgroundColor));
binding.status.setOutlineAmbientShadowColor(MaterialColors.harmonizeWithPrimary(activity, cardBackgroundColor));
binding.status.setOutlineSpotShadowColor(cardBackgroundColor);
binding.status.setOutlineAmbientShadowColor(cardBackgroundColor);
}
}

View File

@ -59,6 +59,7 @@ public class ThemeColorPreferenceDialogFragmentCompat extends PreferenceDialogFr
private int[] colors;
@AttrRes
private static final int DEF_STYLE_ATTR = com.google.android.material.R.attr.alertDialogStyle;
@SuppressLint("PrivateResource")
@StyleRes
private static final int DEF_STYLE_RES = com.google.android.material.R.style.MaterialAlertDialog_MaterialComponents;
@AttrRes
@ -94,6 +95,7 @@ public class ThemeColorPreferenceDialogFragmentCompat extends PreferenceDialogFr
for (int i = 0; i < themeColors.length; i++) {
colors[i] = activity.getColor(themeColors[i].getResourceId());
}
Context context = createMaterialAlertDialogThemedContext(activity);
ColorPickerDialog.Params params = new ColorPickerDialog.Params.Builder(context)
@ -115,25 +117,22 @@ public class ThemeColorPreferenceDialogFragmentCompat extends PreferenceDialogFr
materialShapeDrawable.initializeElevationOverlay(context);
materialShapeDrawable.setFillColor(ColorStateList.valueOf(surfaceColor));
// dialogCornerRadius first appeared in Android Pie
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
TypedValue dialogCornerRadiusValue = new TypedValue();
theme.resolveAttribute(android.R.attr.dialogCornerRadius, dialogCornerRadiusValue, true);
float dialogCornerRadius =
dialogCornerRadiusValue.getDimension(getContext().getResources().getDisplayMetrics());
dialogCornerRadiusValue.getDimension(activity.getResources().getDisplayMetrics());
if (dialogCornerRadiusValue.type == TypedValue.TYPE_DIMENSION && dialogCornerRadius >= 0) {
materialShapeDrawable.setCornerSize(dialogCornerRadius);
}
}
ColorPickerDialog dialog = new ColorPickerDialog(context, this, params);
dialog.setTitle(pref.getDialogTitle());
Window window = dialog.getWindow();
/* {@link Window#getDecorView()} should be called before any changes are made to the Window
* as it locks in attributes and affects layout. */
View decorView = window.getDecorView();
if (materialShapeDrawable instanceof MaterialShapeDrawable) {
((MaterialShapeDrawable) materialShapeDrawable).setElevation(ViewCompat.getElevation(decorView));
}
materialShapeDrawable.setElevation(ViewCompat.getElevation(decorView));
Drawable insetDrawable = MaterialDialogs.insetDrawable(materialShapeDrawable, backgroundInsets);
window.setBackgroundDrawable(insetDrawable);

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of LSPosed.
~
~ LSPosed is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ LSPosed is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
~
~ Copyright (C) 2021 LSPosed Contributors
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/primary_text_material_inverse" android:state_checked="true" />
<item android:color="@color/primary_text_material" />
</selector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of LSPosed.
~
~ LSPosed is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ LSPosed is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
~
~ Copyright (C) 2021 LSPosed Contributors
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/primary_text_material_inverse" />
</selector>

View File

@ -25,6 +25,7 @@
android:clipChildren="false">
<com.google.android.material.card.MaterialCardView
style="?materialCardViewElevatedStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
@ -32,7 +33,6 @@
android:minHeight="148dp"
android:outlineAmbientShadowColor="@color/home_secondary_outline_ambient_shadow_color"
android:outlineSpotShadowColor="@color/home_secondary_outline_spot_shadow_color"
app:cardCornerRadius="8dp"
app:cardElevation="@dimen/home_secondary_elevation">
<LinearLayout

View File

@ -88,7 +88,7 @@
android:layout_height="24dp"
android:layout_centerVertical="true"
app:srcCompat="@drawable/ic_round_check_circle_24"
app:tint="@color/primary_card_primary_text" />
app:tint="@color/primary_text_material_inverse" />
<TextView
android:id="@+id/status_title"
@ -99,7 +99,7 @@
android:fontFamily="sans-serif-medium"
android:textSize="16sp"
android:textAppearance="?android:attr/textAppearanceListItem"
android:textColor="@color/primary_card_primary_text" />
android:textColor="@color/primary_text_material_inverse" />
<TextView
android:id="@+id/status_summary"
@ -108,7 +108,7 @@
android:layout_below="@id/status_title"
android:layout_alignStart="@id/status_title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/primary_card_secondary_text" />
android:textColor="@color/secondary_text_material_inverse" />
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>

View File

@ -26,6 +26,9 @@
<color name="home_secondary_outline_ambient_shadow_color">@color/material_grey_700</color>
<color name="home_secondary_outline_spot_shadow_color">@color/material_grey_600</color>
<color name="primary_card_primary_text">@color/abc_primary_text_material_light</color>
<color name="primary_card_secondary_text">@color/abc_secondary_text_material_light</color>
<color name="primary_text_material_inverse">@color/abc_primary_text_material_light</color>
<color name="secondary_text_material_inverse">@color/abc_secondary_text_material_light</color>
<color name="primary_text_material">@color/abc_primary_text_material_dark</color>
<color name="secondary_text_material">@color/abc_secondary_text_material_dark</color>
</resources>

View File

@ -29,6 +29,9 @@
<color name="home_secondary_outline_ambient_shadow_color">@color/material_grey_500</color>
<color name="home_secondary_outline_spot_shadow_color">@color/material_grey_300</color>
<color name="primary_card_primary_text">@color/abc_primary_text_material_dark</color>
<color name="primary_card_secondary_text">@color/abc_secondary_text_material_dark</color>
<color name="primary_text_material_inverse">@color/abc_primary_text_material_dark</color>
<color name="secondary_text_material_inverse">@color/abc_secondary_text_material_dark</color>
<color name="primary_text_material">@color/abc_primary_text_material_light</color>
<color name="secondary_text_material">@color/abc_secondary_text_material_light</color>
</resources>

View File

@ -27,7 +27,8 @@
<item name="colorSecondary">?colorPrimary</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
<item name="colorOnSecondary">@android:color/white</item>
<item name="colorSurface">@android:color/white</item>
<item name="colorTertiary">?colorPrimary</item>
<item name="colorOnTertiary">@android:color/white</item>
<item name="colorError">@color/material_red_500</item>
<item name="colorNormal">@color/material_green_500</item>
<item name="colorInstall">@color/material_blue_500</item>
@ -49,7 +50,8 @@
<item name="colorSecondary">?colorPrimary</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
<item name="colorOnSecondary">@android:color/black</item>
<item name="colorSurface">@color/google_grey_900</item>
<item name="colorTertiary">?colorPrimary</item>
<item name="colorOnTertiary">@android:color/black</item>
<item name="colorError">@color/material_red_200</item>
<item name="colorNormal">@color/material_green_200</item>
<item name="colorInstall">@color/material_blue_200</item>
@ -92,12 +94,8 @@
<style name="HomeCard.Secondary">
<item name="cardElevation">@dimen/home_secondary_elevation</item>
<item name="android:outlineAmbientShadowColor" tools:targetApi="p">
@color/home_secondary_outline_ambient_shadow_color
</item>
<item name="android:outlineSpotShadowColor" tools:targetApi="p">
@color/home_secondary_outline_spot_shadow_color
</item>
<item name="android:outlineAmbientShadowColor" tools:targetApi="p">?attr/colorSurface</item>
<item name="android:outlineSpotShadowColor" tools:targetApi="p">?attr/colorSurface</item>
</style>
<style name="HomeCard.Tertiary">

View File

@ -43,7 +43,7 @@
<item name="useMaterialThemeColors">true</item>
</style>
<style name="ThemeOverlay.Material.Dialog.ColorPicker" parent="@style/ThemeOverlay.Material3.Dialog" />
<style name="ThemeOverlay.Material.Dialog.ColorPicker" parent="@style/ThemeOverlay.Material3.MaterialAlertDialog.Centered" tools:override="true" />
<style name="PreferenceSummaryTextStyle" tools:override="true">
<item name="android:fontFamily">sans-serif</item>
@ -62,7 +62,7 @@
</style>
<!-- Base themes -->
<style name="Base.Light" parent="Theme.Material3.Light">
<style name="Base.Light" parent="Theme.Material3.Light" tools:override="true">
<item name="android:statusBarColor">?android:colorBackground</item>
<item name="android:ambientShadowAlpha">@dimen/ambient_shadow_alpha</item>
<item name="android:spotShadowAlpha">@dimen/spot_shadow_alpha</item>
@ -85,7 +85,7 @@
<item name="switchBarBackgroundDisabled">@color/switchbar_background_light</item>
</style>
<style name="Base" parent="Theme.Material3.Dark">
<style name="Base" parent="Theme.Material3.Dark" tools:override="true">
<item name="android:statusBarColor">?android:colorBackground</item>
<item name="android:ambientShadowAlpha">@dimen/ambient_shadow_alpha</item>
<item name="android:spotShadowAlpha">@dimen/spot_shadow_alpha</item>
@ -107,4 +107,8 @@
<item name="switchBarBackgroundNormal">@color/switchbar_background_dark</item>
<item name="switchBarBackgroundDisabled">@color/switchbar_background_dark</item>
</style>
<style name="ThemeOverlay.SwitchBar" parent="android:Widget" tools:override="true">
<item name="android:colorControlActivated">@color/primary_text_material_inverse</item>
</style>
</resources>