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

Commit eb8bbe23 authored by Jay Aliomer's avatar Jay Aliomer Committed by Automerger Merge Worker
Browse files

Merge "Twilight mode tile when location is off" into rvc-dev am: b866719a

Change-Id: I08cf079947e15e1894468809b671de51e466b947
parents cfc2081b b866719a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ 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.LocationController;

import java.text.DateFormat;
import java.time.LocalTime;
@@ -60,12 +61,14 @@ public class NightDisplayTile extends QSTileImpl<BooleanState> implements
    private static final String PATTERN_HOUR_NINUTE_24 = "HH:mm";

    private final ColorDisplayManager mManager;
    private final LocationController mLocationController;
    private NightDisplayListener mListener;
    private boolean mIsListening;

    @Inject
    public NightDisplayTile(QSHost host) {
    public NightDisplayTile(QSHost host, LocationController locationController) {
        super(host);
        mLocationController = locationController;
        mManager = mContext.getSystemService(ColorDisplayManager.class);
        mListener = new NightDisplayListener(mContext, new Handler(Looper.myLooper()));
    }
@@ -132,6 +135,7 @@ public class NightDisplayTile extends QSTileImpl<BooleanState> implements
    private String getSecondaryLabel(boolean isNightLightActivated) {
        switch (mManager.getNightDisplayAutoMode()) {
            case ColorDisplayManager.AUTO_MODE_TWILIGHT:
                if (!mLocationController.isLocationEnabled()) return null;
                // Auto mode related to sunrise & sunset. If the light is on, it's guaranteed to be
                // turned off at sunrise. If it's off, it's guaranteed to be turned on at sunset.
                return isNightLightActivated
+6 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.LocationController;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
@@ -51,13 +52,15 @@ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements
            com.android.internal.R.drawable.ic_qs_ui_mode_night);
    private final UiModeManager mUiModeManager;
    private final BatteryController mBatteryController;
    private final LocationController mLocationController;

    @Inject
    public UiModeNightTile(QSHost host, ConfigurationController configurationController,
            BatteryController batteryController) {
            BatteryController batteryController, LocationController locationController) {
        super(host);
        mBatteryController = batteryController;
        mUiModeManager = mContext.getSystemService(UiModeManager.class);
        mLocationController = locationController;
        configurationController.observe(getLifecycle(), this);
        batteryController.observe(getLifecycle(), this);
    }
@@ -97,7 +100,8 @@ public class UiModeNightTile extends QSTileImpl<QSTile.BooleanState> implements
        if (powerSave) {
            state.secondaryLabel = mContext.getResources().getString(
                    R.string.quick_settings_dark_mode_secondary_label_battery_saver);
        } else if (uiMode == UiModeManager.MODE_NIGHT_AUTO) {
        } else if (uiMode == UiModeManager.MODE_NIGHT_AUTO
                && mLocationController.isLocationEnabled()) {
            state.secondaryLabel = mContext.getResources().getString(nightMode
                    ? R.string.quick_settings_dark_mode_secondary_label_until_sunrise
                    : R.string.quick_settings_dark_mode_secondary_label_on_at_sunset);