Turn on location dialog when using twilight scheduling
Night light and Dark theme scheduling does not work when in twiligth mode. For the reason, we added a dialog to inform the user that they need to turn on location services first. Fixes: 153115618 Fixes: 153115261 Test: manual Change-Id: Iea51018a7caba5c0ec93e058ee047d067bc03867
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import android.location.LocationManager;
|
||||
|
||||
import androidx.preference.DropDownPreference;
|
||||
import androidx.preference.Preference;
|
||||
@@ -29,12 +30,14 @@ import com.android.settings.core.BasePreferenceController;
|
||||
public class NightDisplayAutoModePreferenceController extends BasePreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private final LocationManager mLocationManager;
|
||||
private DropDownPreference mPreference;
|
||||
private ColorDisplayManager mColorDisplayManager;
|
||||
|
||||
public NightDisplayAutoModePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
mLocationManager = context.getSystemService(LocationManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,6 +71,11 @@ public class NightDisplayAutoModePreferenceController extends BasePreferenceCont
|
||||
|
||||
@Override
|
||||
public final boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (String.valueOf(ColorDisplayManager.AUTO_MODE_TWILIGHT).equals(newValue)
|
||||
&& !mLocationManager.isLocationEnabled()) {
|
||||
TwilightLocationDialog.show(mContext);
|
||||
return false;
|
||||
}
|
||||
return mColorDisplayManager.setNightDisplayAutoMode(Integer.parseInt((String) newValue));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user