From 45ac3f280df1ad822ea2975c22de1ca9081a42a7 Mon Sep 17 00:00:00 2001 From: mxyyiyi Date: Thu, 6 Feb 2025 12:17:21 +0800 Subject: [PATCH] [Expressive Battery] Update screen on time text preference style. For expressive style: - Update the enlarge font size - Remove the background Bug: 349652542 Test: visual Flag: com.android.settingslib.widget.theme.flags.is_expressive_design_enabled Change-Id: If85d2903eec6d1f7c3b58e71daef2409325ac83d --- res/layout/preference_text_view.xml | 4 ++-- .../fuelgauge/batteryusage/ScreenOnTimeController.java | 4 +++- .../settings/fuelgauge/batteryusage/TextViewPreference.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/res/layout/preference_text_view.xml b/res/layout/preference_text_view.xml index 3d0b2a1d9c7..9d8fafddf36 100644 --- a/res/layout/preference_text_view.xml +++ b/res/layout/preference_text_view.xml @@ -18,8 +18,8 @@ android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="24dp" - android:layout_marginTop="8dp" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:textAlignment="viewStart" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorPrimary" /> \ No newline at end of file diff --git a/src/com/android/settings/fuelgauge/batteryusage/ScreenOnTimeController.java b/src/com/android/settings/fuelgauge/batteryusage/ScreenOnTimeController.java index 379cef3a22a..9c56c178392 100644 --- a/src/com/android/settings/fuelgauge/batteryusage/ScreenOnTimeController.java +++ b/src/com/android/settings/fuelgauge/batteryusage/ScreenOnTimeController.java @@ -30,6 +30,7 @@ import com.android.settings.R; import com.android.settings.Utils; import com.android.settings.core.BasePreferenceController; import com.android.settings.fuelgauge.BatteryUtils; +import com.android.settingslib.widget.SettingsThemeHelper; import java.util.Locale; import java.util.regex.Matcher; @@ -119,10 +120,11 @@ public class ScreenOnTimeController extends BasePreferenceController { } final SpannableString spannableText = new SpannableString(text); + final int enlargeFontSizeDp = SettingsThemeHelper.isExpressiveTheme(context) ? 64 : 36; final Matcher matcher = NUMBER_PATTERN.matcher(text); while (matcher.find()) { spannableText.setSpan( - new AbsoluteSizeSpan(36, true /* dip */), + new AbsoluteSizeSpan(enlargeFontSizeDp, true /* dip */), matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); diff --git a/src/com/android/settings/fuelgauge/batteryusage/TextViewPreference.java b/src/com/android/settings/fuelgauge/batteryusage/TextViewPreference.java index b20ef39f160..c9047385e33 100644 --- a/src/com/android/settings/fuelgauge/batteryusage/TextViewPreference.java +++ b/src/com/android/settings/fuelgauge/batteryusage/TextViewPreference.java @@ -25,9 +25,10 @@ import androidx.preference.PreferenceViewHolder; import com.android.internal.annotations.VisibleForTesting; import com.android.settings.R; +import com.android.settingslib.widget.GroupSectionDividerMixin; /** A preference for a single text view. */ -public class TextViewPreference extends Preference { +public class TextViewPreference extends Preference implements GroupSectionDividerMixin { private static final String TAG = "TextViewPreference"; @VisibleForTesting CharSequence mText;