summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml2
-rw-r--r--res/values/strings.xml9
-rw-r--r--res/xml/power_menu_settings.xml53
-rw-r--r--res/xml/system_settings.xml6
-rw-r--r--src/com/android/settings/cyanogenmod/PowerMenu.java112
5 files changed, 182 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 047148b..595aa81 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1504,6 +1504,8 @@
<activity android:name=".profiles.NFCProfileSelect" />
+ <activity android:name=".cyanogenmod.PowerMenu" />
+
<activity android:name=".profiles.NFCProfile"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aaf839f..35669d1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4739,5 +4739,14 @@
<string name="pref_flash_mode_title">Flash mode</string>
<string name="expanded_haptic_feedback_title">Haptic feedback</string>
+ <!-- Power menu enable disable -->
+ <string name="power_menu_title">Power menu</string>
+ <string name="power_menu_reboot_title">Reboot menu</string>
+ <string name="power_menu_screenshot_title">Screenshot</string>
+ <string name="power_menu_profiles_title">Profile switcher</string>
+ <string name="power_menu_airplane_title">Airplane mode</string>
+ <string name="power_menu_silent_title">Sound panel</string>
+
+
<!-- **** CYANOGENMOD ADDITIONS END **** -->
</resources>
diff --git a/res/xml/power_menu_settings.xml b/res/xml/power_menu_settings.xml
new file mode 100644
index 0000000..5425b24
--- /dev/null
+++ b/res/xml/power_menu_settings.xml
@@ -0,0 +1,53 @@
+<?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_title"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+
+ <CheckBoxPreference
+ android:key="power_menu_reboot"
+ android:title="@string/power_menu_reboot_title"
+ android:defaultValue="true" />
+
+ <CheckBoxPreference
+ android:key="power_menu_screenshot"
+ android:title="@string/power_menu_screenshot_title"
+ android:defaultValue="false" />
+
+<!-- Remove for now until merged
+ <CheckBoxPreference
+ android:key="power_menu_expanded_desktop"
+ android:title="@string/power_menu_expanded_desktop"
+ android:defaultValue="false" />
+-->
+ <CheckBoxPreference
+ android:key="power_menu_profiles"
+ android:title="@string/power_menu_profiles_title"
+ android:defaultValue="true" />
+
+ <CheckBoxPreference
+ android:key="power_menu_airplane"
+ android:title="@string/power_menu_airplane_title"
+ android:defaultValue="true" />
+
+ <CheckBoxPreference
+ android:key="power_menu_silent"
+ android:title="@string/power_menu_silent_title"
+ android:defaultValue="true" />
+
+</PreferenceScreen>
diff --git a/res/xml/system_settings.xml b/res/xml/system_settings.xml
index 6f5480a..7b375c5 100644
--- a/res/xml/system_settings.xml
+++ b/res/xml/system_settings.xml
@@ -32,4 +32,10 @@
android:entryValues="@array/entryvalues_font_size"
android:dialogTitle="@string/dialog_title_font_size" />
+ <PreferenceScreen
+ android:key="power_menu"
+ android:title="@string/power_menu_title"
+ android:fragment="com.android.settings.cyanogenmod.PowerMenu" />
+
+
</PreferenceScreen>
diff --git a/src/com/android/settings/cyanogenmod/PowerMenu.java b/src/com/android/settings/cyanogenmod/PowerMenu.java
new file mode 100644
index 0000000..5ba60a5
--- /dev/null
+++ b/src/com/android/settings/cyanogenmod/PowerMenu.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2012 CyanogenMod
+ *
+ * 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.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.PreferenceScreen;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
+public class PowerMenu extends SettingsPreferenceFragment {
+ private static final String TAG = "PowerMenu";
+
+ private static final String KEY_REBOOT = "power_menu_reboot";
+ private static final String KEY_SCREENSHOT = "power_menu_screenshot";
+ private static final String KEY_PROFILES = "power_menu_profiles";
+ private static final String KEY_AIRPLANE = "power_menu_airplane";
+ private static final String KEY_SILENT = "power_menu_silent";
+
+ private CheckBoxPreference mRebootPref;
+ private CheckBoxPreference mScreenshotPref;
+ private CheckBoxPreference mProfilesPref;
+ private CheckBoxPreference mAirplanePref;
+ private CheckBoxPreference mSilentPref;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.power_menu_settings);
+
+ mRebootPref = (CheckBoxPreference) findPreference(KEY_REBOOT);
+ mRebootPref.setChecked((Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_MENU_REBOOT_ENABLED, 1) == 1));
+
+ mScreenshotPref = (CheckBoxPreference) findPreference(KEY_SCREENSHOT);
+ mScreenshotPref.setChecked((Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_MENU_SCREENSHOT_ENABLED, 0) == 1));
+
+ mProfilesPref = (CheckBoxPreference) findPreference(KEY_PROFILES);
+ mProfilesPref.setChecked((Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_MENU_PROFILES_ENABLED, 1) == 1));
+
+ // Only enable if System Profiles are also enabled
+ boolean enabled = Settings.System.getInt(getContentResolver(),
+ Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1;
+ mProfilesPref.setEnabled(enabled);
+
+ mAirplanePref = (CheckBoxPreference) findPreference(KEY_AIRPLANE);
+ mAirplanePref.setChecked((Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_MENU_AIRPLANE_ENABLED, 1) == 1));
+
+ mSilentPref = (CheckBoxPreference) findPreference(KEY_SILENT);
+ mSilentPref.setChecked((Settings.System.getInt(getContentResolver(),
+ Settings.System.POWER_MENU_SILENT_ENABLED, 1) == 1));
+
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+ boolean value;
+
+ if (preference == mScreenshotPref) {
+ value = mScreenshotPref.isChecked();
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.POWER_MENU_SCREENSHOT_ENABLED,
+ value ? 1 : 0);
+ } else if (preference == mRebootPref) {
+ value = mRebootPref.isChecked();
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.POWER_MENU_REBOOT_ENABLED,
+ value ? 1 : 0);
+ } else if (preference == mProfilesPref) {
+ value = mProfilesPref.isChecked();
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.POWER_MENU_PROFILES_ENABLED,
+ value ? 1 : 0);
+ } else if (preference == mAirplanePref) {
+ value = mAirplanePref.isChecked();
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.POWER_MENU_AIRPLANE_ENABLED,
+ value ? 1 : 0);
+ } else if (preference == mSilentPref) {
+ value = mSilentPref.isChecked();
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.POWER_MENU_SILENT_ENABLED,
+ value ? 1 : 0);
+ } else {
+ return super.onPreferenceTreeClick(preferenceScreen, preference);
+ }
+
+ return true;
+ }
+
+}