Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ffda2b17 authored by mxyyiyi's avatar mxyyiyi
Browse files

[Expressive Battery] Update battery manager illustration.

- Battery > Battery Manager: select illustration res based on current theme.

Bug: 407993397
Test: visual
Flag: com.android.settingslib.widget.theme.flags.is_expressive_design_enabled
Change-Id: Ic51dd23d2c8df3607f945f5cfab5d029fe770d47
parent 8cb24b2d
Loading
Loading
Loading
Loading
+1 −0

File added.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Diff line number Diff line
@@ -24,14 +24,14 @@

    <com.android.settingslib.widget.IllustrationPreference
        android:key="auto_awesome_battery"
        settings:lottie_rawRes="@raw/auto_awesome_battery_lottie" />
        settings:lottie_rawRes="@raw/auto_awesome_battery_lottie"
        settings:controller="com.android.settings.fuelgauge.AdaptiveBatteryIllustrationPreferenceController"/>

    <SwitchPreferenceCompat
        android:key="smart_battery"
        android:title="@string/smart_battery_title"
        android:summary="@string/smart_battery_summary"
        settings:controller="com.android.settings.fuelgauge.SmartBatteryPreferenceController"
        settings:allowDividerAbove="true"/>
        settings:controller="com.android.settings.fuelgauge.SmartBatteryPreferenceController"/>

    <SwitchPreferenceCompat
        android:key="auto_restriction"
+51 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.fuelgauge;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.preference.Preference;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.widget.IllustrationPreference;
import com.android.settingslib.widget.SettingsThemeHelper;

public class AdaptiveBatteryIllustrationPreferenceController extends BasePreferenceController {
    private static final String TAG = "AdaptiveBatteryIllustrationPreferenceController";
    private static final String ILLUSTRATION_PREFERENCE_KEY = "auto_awesome_battery";

    public AdaptiveBatteryIllustrationPreferenceController(@NonNull Context context) {
        super(context, ILLUSTRATION_PREFERENCE_KEY);
    }

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
    }

    @Override
    public void updateState(Preference preference) {
        super.updateState(preference);
        if (SettingsThemeHelper.isExpressiveTheme(mContext)) {
            final IllustrationPreference illustration = (IllustrationPreference) preference;
            illustration.setLottieAnimationResId(R.raw.auto_awesome_battery_expressive_lottie);
            illustration.applyDynamicColor();
        }
    }
}