forked from daproy/android_packages_apps_Settings
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0007-option-to-hide-items-from-power-menu-2-2.patch
222 lines (217 loc) · 10.3 KB
/
0007-option-to-hide-items-from-power-menu-2-2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
From fb8ae38bd77a699f08d3310f71f7a7db79230c98 Mon Sep 17 00:00:00 2001
From: Konsta <[email protected]>
Date: Tue, 19 Jun 2012 12:12:20 +0300
Subject: [PATCH 11/16] option to hide items from power menu (2/2)
Change-Id: Ib40cb1c5c5ddba96bf6573f3fba38305ee8e0009
---
res/values/strings.xml | 13 +++
res/xml/power_menu.xml | 52 ++++++++++
res/xml/system_settings.xml | 6 ++
.../settings/cyanogenmod/PowerMenuSettings.java | 99 ++++++++++++++++++++
4 files changed, 170 insertions(+)
create mode 100644 res/xml/power_menu.xml
create mode 100644 src/com/android/settings/cyanogenmod/PowerMenuSettings.java
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 417eeb5..6c3ccba 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4545,6 +4545,19 @@ found in the list of installed apps.</string>
<string name="partition_info_sdext">/sd-ext (EXT)</string>
<string name="partition_info_used_of">/</string>
+ <!-- Power menu settings -->
+ <string name="power_menu_settings_title">Power menu</string>
+ <string name="power_dialog_show_reboot_toggle_title">Reboot</string>
+ <string name="power_dialog_show_reboot_toggle_summary">Show reboot in power menu</string>
+ <string name="power_dialog_show_profile_toggle_title">Profile</string>
+ <string name="power_dialog_show_profile_toggle_summary">Show profile in power menu</string>
+ <string name="power_dialog_show_screenshot_toggle_title">Screenshot</string>
+ <string name="power_dialog_show_screenshot_toggle_summary">Show screenshot in power menu</string>
+ <string name="power_dialog_show_airplane_toggle_title">Airplane mode</string>
+ <string name="power_dialog_show_airplane_toggle_summary">Show airplane mode in power menu</string>
+ <string name="power_dialog_show_sound_toggle_title">Sound options</string>
+ <string name="power_dialog_show_sound_toggle_summary">Show sound options in power menu</string>
+
<string name="increasing_ring_title">Ascending ringtone</string>
<!-- Sound settings screen, the caption of the checkbox for making incoming calls increase in volume -->
<string name="checkbox_increasing_ring">Enable</string>
diff --git a/res/xml/power_menu.xml b/res/xml/power_menu.xml
new file mode 100644
index 0000000..251f671
--- /dev/null
+++ b/res/xml/power_menu.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The CyanogenMod Project
+
+ 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.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/power_menu_settings_title"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+
+ <CheckBoxPreference
+ android:key="power_dialog_show_reboot_toggle"
+ android:title="@string/power_dialog_show_reboot_toggle_title"
+ android:summary="@string/power_dialog_show_reboot_toggle_summary"
+ android:defaultValue="true" />
+
+ <CheckBoxPreference
+ android:key="power_dialog_show_profile_toggle"
+ android:title="@string/power_dialog_show_profile_toggle_title"
+ android:summary="@string/power_dialog_show_profile_toggle_summary"
+ android:defaultValue="true" />
+
+ <CheckBoxPreference
+ android:key="power_dialog_show_screenshot_toggle"
+ android:title="@string/power_dialog_show_screenshot_toggle_title"
+ android:summary="@string/power_dialog_show_screenshot_toggle_summary"
+ android:defaultValue="true" />
+
+ <CheckBoxPreference
+ android:key="power_dialog_show_airplane_toggle"
+ android:title="@string/power_dialog_show_airplane_toggle_title"
+ android:summary="@string/power_dialog_show_airplane_toggle_summary"
+ android:defaultValue="true" />
+
+ <CheckBoxPreference
+ android:key="power_dialog_show_sound_toggle"
+ android:title="@string/power_dialog_show_sound_toggle_title"
+ android:summary="@string/power_dialog_show_sound_toggle_summary"
+ android:defaultValue="true" />
+
+</PreferenceScreen>
diff --git a/res/xml/system_settings.xml b/res/xml/system_settings.xml
index a511bae..a268218 100644
--- a/res/xml/system_settings.xml
+++ b/res/xml/system_settings.xml
@@ -35,6 +35,12 @@
android:title="@string/notification_drawer_title" />
<PreferenceScreen
+ android:key="power_menu"
+ android:fragment="com.android.settings.cyanogenmod.PowerMenuSettings"
+ android:title="@string/power_menu_settings_title" >
+ </PreferenceScreen>
+
+ <PreferenceScreen
android:key="wallpaper"
android:title="@string/wallpaper_settings_title"
android:fragment="com.android.settings.WallpaperTypeSettings" />
diff --git a/src/com/android/settings/cyanogenmod/PowerMenuSettings.java b/src/com/android/settings/cyanogenmod/PowerMenuSettings.java
new file mode 100644
index 0000000..7eca40b
--- /dev/null
+++ b/src/com/android/settings/cyanogenmod/PowerMenuSettings.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * 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.cyanogenmod;
+
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceScreen;
+import android.preference.CheckBoxPreference;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
+public class PowerMenuSettings extends SettingsPreferenceFragment {
+
+ private static final String TAG = "PowerMenuSettings";
+ private static final String POWER_DIALOG_SHOW_REBOOT_TOGGLE = "power_dialog_show_reboot_toggle";
+ private static final String POWER_DIALOG_SHOW_PROFILE_TOGGLE = "power_dialog_show_profile_toggle";
+ private static final String POWER_DIALOG_SHOW_SCREENSHOT_TOGGLE = "power_dialog_show_screenshot_toggle";
+ private static final String POWER_DIALOG_SHOW_AIRPLANE_TOGGLE = "power_dialog_show_airplane_toggle";
+ private static final String POWER_DIALOG_SHOW_SOUND_TOGGLE = "power_dialog_show_sound_toggle";
+
+ private CheckBoxPreference mEnableRebootToggle;
+ private CheckBoxPreference mEnableProfileToggle;
+ private CheckBoxPreference mEnableScreenshotToggle;
+ private CheckBoxPreference mEnableAirplaneToggle;
+ private CheckBoxPreference mEnableSoundToggle;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.power_menu);
+
+ mEnableRebootToggle = (CheckBoxPreference) findPreference(POWER_DIALOG_SHOW_REBOOT_TOGGLE);
+ mEnableRebootToggle.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_DIALOG_SHOW_REBOOT_TOGGLE, 1) == 1);
+
+ mEnableProfileToggle = (CheckBoxPreference) findPreference(POWER_DIALOG_SHOW_PROFILE_TOGGLE);
+ mEnableProfileToggle.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_DIALOG_SHOW_PROFILE_TOGGLE, 1) == 1);
+
+ mEnableScreenshotToggle = (CheckBoxPreference) findPreference(POWER_DIALOG_SHOW_SCREENSHOT_TOGGLE);
+ mEnableScreenshotToggle.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_DIALOG_SHOW_SCREENSHOT_TOGGLE, 1) == 1);
+
+ mEnableAirplaneToggle = (CheckBoxPreference) findPreference(POWER_DIALOG_SHOW_AIRPLANE_TOGGLE);
+ mEnableAirplaneToggle.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_DIALOG_SHOW_AIRPLANE_TOGGLE, 1) == 1);
+
+ mEnableSoundToggle = (CheckBoxPreference) findPreference(POWER_DIALOG_SHOW_SOUND_TOGGLE);
+ mEnableSoundToggle.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_DIALOG_SHOW_SOUND_TOGGLE, 1) == 1);
+
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+
+ if (preference == mEnableRebootToggle) {
+ Settings.System.putInt(getContentResolver(), Settings.System.POWER_DIALOG_SHOW_REBOOT_TOGGLE,
+ mEnableRebootToggle.isChecked() ? 1 : 0);
+ return true;
+ } else if (preference == mEnableProfileToggle) {
+ Settings.System.putInt(getContentResolver(), Settings.System.POWER_DIALOG_SHOW_PROFILE_TOGGLE,
+ mEnableProfileToggle.isChecked() ? 1 : 0);
+ return true;
+ } else if (preference == mEnableScreenshotToggle) {
+ Settings.System.putInt(getContentResolver(), Settings.System.POWER_DIALOG_SHOW_SCREENSHOT_TOGGLE,
+ mEnableScreenshotToggle.isChecked() ? 1 : 0);
+ return true;
+ } else if (preference == mEnableAirplaneToggle) {
+ Settings.System.putInt(getContentResolver(), Settings.System.POWER_DIALOG_SHOW_AIRPLANE_TOGGLE,
+ mEnableAirplaneToggle.isChecked() ? 1 : 0);
+ return true;
+ } else if (preference == mEnableSoundToggle) {
+ Settings.System.putInt(getContentResolver(), Settings.System.POWER_DIALOG_SHOW_SOUND_TOGGLE,
+ mEnableSoundToggle.isChecked() ? 1 : 0);
+ return true;
+ }
+ return false;
+ }
+
+}
--
1.7.9.5