Settings: Add pocket lock toggle
AICP Pie: Modified defaults to false. Brought up to 10 with androidx @jhenrique09 edits: Adapt strings, and also use config_pocketModeSupported on isAvailable Change-Id: I398c8f0be23c27cbcf1fb57eed44a801b31bc6c9 Settings: Remove pocket lock toggle icons * Also move it to lockscreen settings Change-Id: Iae8a6b4739c317e723c0cfad46db5ceb494f74f8 Signed-off-by: Dmitrii <bankersenator@gmail.com>
This commit is contained in:
@@ -337,4 +337,8 @@
|
||||
<string name="doze_gesture_ambient_summary">Show Ambient Display instead of fully waking the screen up</string>
|
||||
<string name="gesture_wake_ambient">Show Ambient</string>
|
||||
<string name="gesture_wake">Fully wake</string>
|
||||
|
||||
<!-- Pocket mode -->
|
||||
<string name="proximity_wake_title">Pocket mode</string>
|
||||
<string name="proximity_wake_summary">Check the proximity sensor prior to waking up screen</string>
|
||||
</resources>
|
||||
|
||||
@@ -74,6 +74,11 @@
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.display.ScreenTimeoutSettings"
|
||||
settings:controller="com.android.settings.display.ScreenTimeoutPreferenceController"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="pocket_judge"
|
||||
android:title="@string/proximity_wake_title"
|
||||
android:summary="@string/proximity_wake_summary" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.android.settings.display.BrightnessLevelPreferenceController;
|
||||
import com.android.settings.display.CameraGesturePreferenceController;
|
||||
import com.android.settings.display.DisplayScreen;
|
||||
import com.android.settings.display.LiftToWakePreferenceController;
|
||||
import com.android.settings.display.PocketJudgePreferenceController;
|
||||
import com.android.settings.display.ShowOperatorNamePreferenceController;
|
||||
import com.android.settings.display.TapToWakePreferenceController;
|
||||
import com.android.settings.display.EnableBlursPreferenceController;
|
||||
@@ -87,6 +88,7 @@ public class DisplaySettings extends DashboardFragment {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new CameraGesturePreferenceController(context));
|
||||
controllers.add(new LiftToWakePreferenceController(context));
|
||||
controllers.add(new PocketJudgePreferenceController(context));
|
||||
controllers.add(new TapToWakePreferenceController(context));
|
||||
controllers.add(new EnableBlursPreferenceController(context));
|
||||
controllers.add(new VrDisplayPreferenceController(context));
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Paranoid Android
|
||||
*
|
||||
* 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.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.DisplaySettings;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import static android.provider.Settings.System.POCKET_JUDGE;
|
||||
|
||||
public class PocketJudgePreferenceController extends AbstractPreferenceController implements
|
||||
PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_POCKET_JUDGE = "pocket_judge";
|
||||
|
||||
public PocketJudgePreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_POCKET_JUDGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
int pocketJudgeValue = Settings.System.getInt(mContext.getContentResolver(),
|
||||
POCKET_JUDGE, 0);
|
||||
((SwitchPreferenceCompat) preference).setChecked(pocketJudgeValue != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_pocketModeSupported);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean pocketJudgeValue = (Boolean) newValue;
|
||||
Settings.System.putInt(mContext.getContentResolver(), POCKET_JUDGE, pocketJudgeValue ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user