Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding the silent mode setting

  • Loading branch information...
commit 3428b77b210cc92811f0fc603c0df853b244d364 1 parent 6e5248a
javroch authored
6 res/values/arrays.xml
View
@@ -54,6 +54,12 @@
<item>@string/airplane_mode_option_summary_checked</item>
</string-array>
+ <!-- Arrays for the silent mode option capability -->
+ <string-array name="silent_mode_option_summaries">
+ <item>@string/silent_mode_option_summary_unchecked</item>
+ <item>@string/silent_mode_option_summary_checked</item>
+ </string-array>
+
<!-- Arrays for the status bar battery capability -->
<string-array name="status_bar_battery_summaries">
<item>@string/status_bar_battery_summary_unchecked</item>
5 res/values/strings.xml
View
@@ -41,6 +41,11 @@ dangerous and could compromise the security of your system!</string>
<string name="airplane_mode_option_summary_unchecked">Removed from the Power menu</string>
<string name="airplane_mode_option_summary_checked">Option in the Power menu</string>
+ <!-- Setting checkbox title for silent mode option -->
+ <string name="silent_mode_option">Silent mode option</string>
+ <string name="silent_mode_option_summary_unchecked">Removed from the Power menu</string>
+ <string name="silent_mode_option_summary_checked">Option in the Power menu</string>
+
<!-- Setting checkbox title for status bar battery -->
<string name="status_bar_battery">Battery percentage</string>
<string name="status_bar_battery_summary_unchecked">Removed from the Status bar</string>
5 res/xml/clean_extras.xml
View
@@ -52,6 +52,11 @@
android:key="airplane_mode_option"
android:title="@string/airplane_mode_option"
android:persistent="false" />
+
+ <CheckBoxPreference
+ android:key="silent_mode_option"
+ android:title="@string/silent_mode_option"
+ android:persistent="false" />
</PreferenceCategory>
36 src/com/javroch/cleanextras/CleanSettingsActivity.java
View
@@ -32,7 +32,7 @@
private Object mSelectedRootValue;
/*
- * Airplane mode options
+ * Airplane mode option
*/
private CheckBoxPreference mAirplaneModeOption;
private static final String AIRPLANE_MODE_OPTION_KEY = Settings.System.AIRPLANE_MODE_OPTION;
@@ -40,6 +40,14 @@
private static final String AIRPLANE_MODE_SETTINGS_PROPERTY = "ro.clean.airplane_mode";
/*
+ * Silent mode option
+ */
+ private CheckBoxPreference mSilentModeOption;
+ private static final String SILENT_MODE_OPTION_KEY = Settings.System.SILENT_MODE_OPTION;
+ private static final int SILENT_MODE_OPTION_DEFAULT = 1;
+ private static final String SILENT_MODE_SETTINGS_PROPERTY = "ro.clean.silent_mode";
+
+ /*
* Reboot option
*/
private ListPreference mRebootOption;
@@ -103,6 +111,8 @@ protected void onCreate(Bundle savedInstanceState) {
mAirplaneModeOption = (CheckBoxPreference) findPreference(AIRPLANE_MODE_OPTION_KEY);
+ mSilentModeOption = (CheckBoxPreference) findPreference(SILENT_MODE_OPTION_KEY);
+
mStatusBarBattery = (CheckBoxPreference) findPreference(STATUS_BAR_BATTERY_KEY);
mLauncherScreenCount = (ListPreference) findPreference(LAUNCHER_SCREEN_COUNT_KEY);
@@ -112,6 +122,7 @@ protected void onCreate(Bundle savedInstanceState) {
removeRebootOptions();
removeScreenshotOptions();
removeAirplaneModeOptions();
+ removeSilentModeOptions();
removeBatteryOptions();
removeLauncherScreenOptions();
@@ -166,6 +177,15 @@ private void removeAirplaneModeOptions() {
}
}
}
+
+ private void removeSilentModeOptions() {
+ String silentModeSettings = SystemProperties.get(SILENT_MODE_SETTINGS_PROPERTY, "");
+ if (!"1".equals(silentModeSettings)) {
+ if (mSilentModeOption != null) {
+ mPowerMenuCategory.removePreference(mSilentModeOption);
+ }
+ }
+ }
private void removeRebootOptions() {
String rebootSettings = SystemProperties.get(REBOOT_SETTINGS_PROPERTY, "");
@@ -193,6 +213,7 @@ public void onResume() {
updateRebootOptions();
updateScreenshotOptions();
updateAirplaneModeOptions();
+ updateSilentModeOptions();
updateBatteryOptions();
updateLauncherScreenOptions();
}
@@ -221,6 +242,12 @@ private void updateAirplaneModeOptions() {
mAirplaneModeOption.setChecked(value);
mAirplaneModeOption.setSummary(getResources().getStringArray(R.array.airplane_mode_option_summaries)[value ? 1 : 0]);
}
+
+ private void updateSilentModeOptions() {
+ Boolean value = Settings.System.getInt(getContentResolver(), SILENT_MODE_OPTION_KEY, SILENT_MODE_OPTION_DEFAULT) == 1;
+ mSilentModeOption.setChecked(value);
+ mSilentModeOption.setSummary(getResources().getStringArray(R.array.silent_mode_option_summaries)[value ? 1 : 0]);
+ }
private void updateRebootOptions() {
int value = Settings.System.getInt(getContentResolver(), REBOOT_OPTION_KEY, REBOOT_OPTION_DEFAULT);
@@ -273,6 +300,8 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
writeScreenshotOptions();
} else if (preference == mAirplaneModeOption) {
writeAirplaneModeOptions();
+ } else if (preference == mSilentModeOption) {
+ writeSilentModeOptions();
} else if (preference == mStatusBarBattery) {
writeBatteryOptions();
}
@@ -299,6 +328,11 @@ private void writeAirplaneModeOptions() {
Settings.System.putInt(getContentResolver(), AIRPLANE_MODE_OPTION_KEY, mAirplaneModeOption.isChecked() ? 1 : 0);
updateAirplaneModeOptions();
}
+
+ private void writeSilentModeOptions() {
+ Settings.System.putInt(getContentResolver(), SILENT_MODE_OPTION_KEY, mSilentModeOption.isChecked() ? 1 : 0);
+ updateSilentModeOptions();
+ }
private void writeRebootOptions(Object newValue) {
Settings.System.putInt(getContentResolver(), REBOOT_OPTION_KEY, Integer.valueOf(newValue.toString()));
Please sign in to comment.
Something went wrong with that request. Please try again.