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

Commit f9fe8c36 authored by shagbag913's avatar shagbag913 Committed by Paul Keith
Browse files

AODTile: disable tile when power save mode is on



AOD is not allowed when power save mode is active, reflect that upon the
tile.

Signed-off-by: default avatarNurKeinNeid <mralexman3000@gmail.com>
Change-Id: I3fc7f2a33d25a1616e8df5698ca2bc2a23d45cbb
parent 4b04f74e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@

    <!-- AOD QS tile -->
    <string name="quick_settings_aod_label">AOD</string>
    <string name="quick_settings_aod_off_powersave_label">AOD off\nBattery saver</string>

    <!-- Content description of the location tile in quick settings when on, battery saving mode (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_quick_settings_location_battery_saving">Location reporting: battery saving mode.</string>
+19 −3
Original line number Diff line number Diff line
@@ -24,20 +24,31 @@ import com.android.systemui.R;
import com.android.systemui.plugins.qs.QSTile.BooleanState;
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.policy.BatteryController;

import org.lineageos.internal.logging.LineageMetricsLogger;

import javax.inject.Inject;

public class AODTile extends QSTileImpl<BooleanState> {
public class AODTile extends QSTileImpl<BooleanState> implements
        BatteryController.BatteryStateChangeCallback {
    private boolean mAodDisabled;
    private final Icon mIcon = ResourceIcon.get(R.drawable.ic_qs_aod);
    private final BatteryController mBatteryController;

    @Inject
    public AODTile(QSHost host) {
    public AODTile(QSHost host, BatteryController batteryController) {
        super(host);
        mAodDisabled = Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.DOZE_ALWAYS_ON, 1) == 0;

        mBatteryController = batteryController;
        batteryController.observe(getLifecycle(), this);
    }

    @Override
    public void onPowerSaveChanged(boolean isPowerSave) {
        refreshState();
    }

    @Override
@@ -67,6 +78,9 @@ public class AODTile extends QSTileImpl<BooleanState> {

    @Override
    public CharSequence getTileLabel() {
        if (mBatteryController.isAodPowerSave()) {
            return mContext.getString(R.string.quick_settings_aod_off_powersave_label);
        }
        return mContext.getString(R.string.quick_settings_aod_label);
    }

@@ -79,7 +93,9 @@ public class AODTile extends QSTileImpl<BooleanState> {
        state.value = mAodDisabled;
        state.slash.isSlashed = state.value;
        state.label = mContext.getString(R.string.quick_settings_aod_label);
        if (mAodDisabled) {
        if (mBatteryController.isAodPowerSave()) {
            state.state = Tile.STATE_UNAVAILABLE;
        } else if (mAodDisabled) {
            state.state = Tile.STATE_INACTIVE;
        } else {
            state.state = Tile.STATE_ACTIVE;