Merge "Settings: Wire up Display > Lift to wake." into lmp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d39d731473
@@ -2051,6 +2051,8 @@
|
|||||||
<string name="screensaver_settings_button">Settings</string>
|
<string name="screensaver_settings_button">Settings</string>
|
||||||
<!-- Sound & display settings screen, setting option name to change whether the screen adjusts automatically based on lighting conditions -->
|
<!-- Sound & display settings screen, setting option name to change whether the screen adjusts automatically based on lighting conditions -->
|
||||||
<string name="automatic_brightness">Automatic brightness</string>
|
<string name="automatic_brightness">Automatic brightness</string>
|
||||||
|
<!-- [CHAR LIMIT=40] Display settings screen, setting option name to change whether the device wakes up when a lift gesture is detected. -->
|
||||||
|
<string name="lift_to_wake_title">Lift to wake</string>
|
||||||
<!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
|
<!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
|
||||||
<string name="title_font_size">Font size</string>
|
<string name="title_font_size">Font size</string>
|
||||||
<!-- Sound & display settings screen, setting option summary displaying the currently selected font size -->
|
<!-- Sound & display settings screen, setting option summary displaying the currently selected font size -->
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
settings:keywords="@string/keywords_display_brightness_level"
|
settings:keywords="@string/keywords_display_brightness_level"
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<SwitchPreference
|
||||||
android:key="auto_brightness"
|
android:key="auto_brightness"
|
||||||
android:title="@string/auto_brightness_title"
|
android:title="@string/auto_brightness_title"
|
||||||
settings:keywords="@string/keywords_display_auto_brightness"
|
settings:keywords="@string/keywords_display_auto_brightness"
|
||||||
@@ -51,6 +51,11 @@
|
|||||||
android:title="@string/screensaver_settings_title"
|
android:title="@string/screensaver_settings_title"
|
||||||
android:fragment="com.android.settings.DreamSettings" />
|
android:fragment="com.android.settings.DreamSettings" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="lift_to_wake"
|
||||||
|
android:title="@string/lift_to_wake_title"
|
||||||
|
android:persistent="false" />
|
||||||
|
|
||||||
<com.android.settings.WarnedListPreference
|
<com.android.settings.WarnedListPreference
|
||||||
android:key="font_size"
|
android:key="font_size"
|
||||||
android:title="@string/title_font_size"
|
android:title="@string/title_font_size"
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings;
|
|||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
|
|
||||||
|
import static android.provider.Settings.Secure.WAKE_GESTURE_ENABLED;
|
||||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
|
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
|
||||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
|
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
|
||||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
|
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||||
@@ -31,14 +32,15 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.hardware.Sensor;
|
||||||
|
import android.hardware.SensorManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.preference.CheckBoxPreference;
|
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.preference.SwitchPreference;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -56,6 +58,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
|
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
|
||||||
private static final String KEY_FONT_SIZE = "font_size";
|
private static final String KEY_FONT_SIZE = "font_size";
|
||||||
private static final String KEY_SCREEN_SAVER = "screensaver";
|
private static final String KEY_SCREEN_SAVER = "screensaver";
|
||||||
|
private static final String KEY_LIFT_TO_WAKE = "lift_to_wake";
|
||||||
private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
|
private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
|
||||||
|
|
||||||
private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
|
private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
|
||||||
@@ -63,11 +66,11 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
private WarnedListPreference mFontSizePref;
|
private WarnedListPreference mFontSizePref;
|
||||||
|
|
||||||
private final Configuration mCurConfig = new Configuration();
|
private final Configuration mCurConfig = new Configuration();
|
||||||
private final Handler mHandler = new Handler();
|
|
||||||
|
|
||||||
private ListPreference mScreenTimeoutPreference;
|
private ListPreference mScreenTimeoutPreference;
|
||||||
private Preference mScreenSaverPreference;
|
private Preference mScreenSaverPreference;
|
||||||
private CheckBoxPreference mAutoBrightnessPreference;
|
private SwitchPreference mLiftToWakePreference;
|
||||||
|
private SwitchPreference mAutoBrightnessPreference;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -96,11 +99,23 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
mFontSizePref.setOnPreferenceClickListener(this);
|
mFontSizePref.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
if (isAutomaticBrightnessAvailable(getResources())) {
|
if (isAutomaticBrightnessAvailable(getResources())) {
|
||||||
mAutoBrightnessPreference = (CheckBoxPreference) findPreference(KEY_AUTO_BRIGHTNESS);
|
mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
|
||||||
mAutoBrightnessPreference.setOnPreferenceChangeListener(this);
|
mAutoBrightnessPreference.setOnPreferenceChangeListener(this);
|
||||||
} else {
|
} else {
|
||||||
removePreference(KEY_AUTO_BRIGHTNESS);
|
removePreference(KEY_AUTO_BRIGHTNESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isLiftToWakeAvailable(getActivity())) {
|
||||||
|
mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
|
||||||
|
mLiftToWakePreference.setOnPreferenceChangeListener(this);
|
||||||
|
} else {
|
||||||
|
removePreference(KEY_LIFT_TO_WAKE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isLiftToWakeAvailable(Context context) {
|
||||||
|
SensorManager sensors = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
|
return sensors != null && sensors.getDefaultSensor(Sensor.TYPE_WAKE_GESTURE) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAutomaticBrightnessAvailable(Resources res) {
|
private static boolean isAutomaticBrightnessAvailable(Resources res) {
|
||||||
@@ -235,6 +250,12 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL);
|
SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||||
mAutoBrightnessPreference.setChecked(brightnessMode != SCREEN_BRIGHTNESS_MODE_MANUAL);
|
mAutoBrightnessPreference.setChecked(brightnessMode != SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update lift-to-wake if it is available.
|
||||||
|
if (mLiftToWakePreference != null) {
|
||||||
|
int value = Settings.Secure.getInt(getContentResolver(), WAKE_GESTURE_ENABLED, 0);
|
||||||
|
mLiftToWakePreference.setChecked(value != 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateScreenSaverSummary() {
|
private void updateScreenSaverSummary() {
|
||||||
@@ -278,6 +299,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,
|
Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,
|
||||||
auto ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : SCREEN_BRIGHTNESS_MODE_MANUAL);
|
auto ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||||
}
|
}
|
||||||
|
if (preference == mLiftToWakePreference) {
|
||||||
|
boolean value = (Boolean) objValue;
|
||||||
|
Settings.Secure.putInt(getContentResolver(), WAKE_GESTURE_ENABLED, value ? 1 : 0);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,6 +344,9 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
if (!isAutomaticBrightnessAvailable(context.getResources())) {
|
if (!isAutomaticBrightnessAvailable(context.getResources())) {
|
||||||
result.add(KEY_AUTO_BRIGHTNESS);
|
result.add(KEY_AUTO_BRIGHTNESS);
|
||||||
}
|
}
|
||||||
|
if (!isLiftToWakeAvailable(context)) {
|
||||||
|
result.add(KEY_LIFT_TO_WAKE);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user