Skip to content

Commit 029bda7

Browse files
committed
add option to toggle menu button unlock
Change-Id: I8a994832f4024f1bfce6baba8540bf97f09ffc9f
1 parent 05523fb commit 029bda7

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

apps/SpareParts/res/values/strings.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333

3434
<string name="general_title">General</string>
3535

36+
<!-- extra -->
37+
<string name="extra_title">Extras</string>
38+
<string name="title_menu_unlock_screen">Menu button unlock</string>
39+
<string name="summary_on_menu_unlock_screen">Disable Menu button unlock</string>
40+
<string name="summary_off_menu_unlock_screen">Enable Menu button unlock</string>
41+
<!-- end extra -->
42+
3643
<string name="title_window_animations">Window animations</string>
3744
<string name="summary_window_animations">Speed of animations in individual windows</string>
3845
<string name="dialog_title_window_animations">Select window speed</string>

apps/SpareParts/res/xml/spare_parts.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@
4747

4848
</PreferenceCategory>
4949

50+
51+
<!-- extra -->
52+
<PreferenceCategory
53+
android:title="@string/extra_title">
54+
55+
<CheckBoxPreference
56+
android:key="menu_unlock_screen"
57+
android:title="@string/title_menu_unlock_screen"
58+
android:summaryOn="@string/summary_on_menu_unlock_screen"
59+
android:summaryOff="@string/summary_off_menu_unlock_screen" />
60+
</PreferenceCategory>
61+
<!-- end -->
62+
5063
<PreferenceCategory
5164
android:title="@string/general_title">
5265

apps/SpareParts/src/com/android/spare_parts/SpareParts.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public class SpareParts extends PreferenceActivity
5151
private static final String BATTERY_INFORMATION_PREF = "battery_information_settings";
5252
private static final String USAGE_STATISTICS_PREF = "usage_statistics_settings";
5353

54+
//extra
55+
private static final String MENU_UNLOCK_SCREEN_PREF = "menu_unlock_screen";
56+
//end extra
57+
5458
private static final String WINDOW_ANIMATIONS_PREF = "window_animations";
5559
private static final String TRANSITION_ANIMATIONS_PREF = "transition_animations";
5660
private static final String FANCY_IME_ANIMATIONS_PREF = "fancy_ime_animations";
@@ -61,6 +65,10 @@ public class SpareParts extends PreferenceActivity
6165

6266
private final Configuration mCurConfig = new Configuration();
6367

68+
//extra
69+
private CheckBoxPreference mMenuUnlockScreenPref;
70+
//end extra
71+
6472
private ListPreference mWindowAnimationsPref;
6573
private ListPreference mTransitionAnimationsPref;
6674
private CheckBoxPreference mFancyImeAnimationsPref;
@@ -113,6 +121,10 @@ public void onCreate(Bundle icicle) {
113121

114122
PreferenceScreen prefSet = getPreferenceScreen();
115123

124+
//extra
125+
mMenuUnlockScreenPref = (CheckBoxPreference) prefSet.findPreference(MENU_UNLOCK_SCREEN_PREF);
126+
//end extra
127+
116128
mWindowAnimationsPref = (ListPreference) prefSet.findPreference(WINDOW_ANIMATIONS_PREF);
117129
mWindowAnimationsPref.setOnPreferenceChangeListener(this);
118130
mTransitionAnimationsPref = (ListPreference) prefSet.findPreference(TRANSITION_ANIMATIONS_PREF);
@@ -142,6 +154,11 @@ public void onCreate(Bundle icicle) {
142154
}
143155

144156
private void updateToggles() {
157+
//extra
158+
mMenuUnlockScreenPref.setChecked(Settings.System.getInt(
159+
getContentResolver(),
160+
Settings.System.MENU_UNLOCK_SCREEN, 0) != 0);
161+
//end extra
145162
mFancyImeAnimationsPref.setChecked(Settings.System.getInt(
146163
getContentResolver(),
147164
Settings.System.FANCY_IME_ANIMATIONS, 0) != 0);
@@ -242,7 +259,13 @@ public void readEndButtonPreference(ListPreference pref) {
242259
}
243260

244261
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
245-
if (FANCY_IME_ANIMATIONS_PREF.equals(key)) {
262+
//extra
263+
if (MENU_UNLOCK_SCREEN_PREF.equals(key)) {
264+
Settings.System.putInt(getContentResolver(),
265+
Settings.System.MENU_UNLOCK_SCREEN,
266+
mMenuUnlockScreenPref.isChecked() ? 1 : 0);
267+
//end extra
268+
} else if (FANCY_IME_ANIMATIONS_PREF.equals(key)) {
246269
Settings.System.putInt(getContentResolver(),
247270
Settings.System.FANCY_IME_ANIMATIONS,
248271
mFancyImeAnimationsPref.isChecked() ? 1 : 0);

0 commit comments

Comments
 (0)