Skip to content
Browse files

Settings: Advanced low battery indicator options (2/2)

Based on a idea I saw on Liquid and from CR3C0 (thanks guys) which we
modified to an extended version

This commit introduces following new SlimBean modes to indicate low battery

     * 0 = show dialog + play sound (default)
     * 1 = fire notification + play sound
     * 2 = show dialog only
     * 3 = fire notification only
     * 4 = play sound only
     * 5 = none

Due that notification is a unique SlimBean feature some words on it. Notification
behaviour is the same as Pop-up. User can dismiss it manually or it is
dismissed automatically if charger is connected. Also you user get a
status bar ticker message about the notification and notification is always
on first place of list. And last if vibration is enabled
notification vibrates.

cheers

Change-Id: Ia8fa8c420e6ef334266a7734fb080026a8396340
  • Loading branch information...
1 parent 5baab1a commit 334b83850eb9b280d7589a818a8a297d1e3d3346 @kufikugel kufikugel committed with Gerrit Code Review Mar 7, 2013
View
19 res/values/arrays.xml
@@ -1999,6 +1999,25 @@
<item>6</item>
</string-array>
+ <!-- Low battery warning policy -->
+ <string-array name="pref_low_battery_warning_policy_entries">
+ <item>@string/low_battery_warning_policy_popup_sound</item>
+ <item>@string/low_battery_warning_policy_notif_sound</item>
+ <item>@string/low_battery_warning_policy_popup</item>
+ <item>@string/low_battery_warning_policy_notif</item>
+ <item>@string/low_battery_warning_policy_sound</item>
+ <item>@string/low_battery_warning_policy_disabled</item>
+ </string-array>
+
+ <string-array name="pref_low_battery_warning_policy_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>4</item>
+ <item>5</item>
+ </string-array>
+
<!-- Recents RAM bar-->
<string-array name="entries_ram_bar_mode">
<item>@string/ram_bar_none</item>
View
8 res/values/strings.xml
@@ -4893,6 +4893,14 @@
<string name="custom_carrier_label_title">Custom carrier label</string>
<string name="custom_carrier_label_explain">Please enter a new label. Enter an empty to revert to stock label.</string>
<string name="custom_carrier_label_notset">Custom label currently not set</string>
+ <string name="pref_low_battery_warning_policy_title">Low battery warning</string>
+ <string name="pref_low_battery_warning_policy_dialog_title">Indicate low battery warning with</string>
+ <string name="low_battery_warning_policy_popup_sound">Pop-up and sound</string>
+ <string name="low_battery_warning_policy_notif_sound">Notification and sound</string>
+ <string name="low_battery_warning_policy_popup">Pop-up dialog only</string>
+ <string name="low_battery_warning_policy_notif">Notification only</string>
+ <string name="low_battery_warning_policy_sound">Sound only</string>
+ <string name="low_battery_warning_policy_disabled">Disabled</string>
<!-- LCD Density -->
<string name="dpi">DPI</string>
View
8 res/xml/user_interface_settings.xml
@@ -44,6 +44,14 @@
android:summary="@string/high_end_gfx_summary"
android:defaultValue="true" />
+ <ListPreference
+ android:key="pref_low_battery_warning_policy"
+ android:title="@string/pref_low_battery_warning_policy_title"
+ android:dialogTitle="@string/pref_low_battery_warning_policy_dialog_title"
+ android:entries="@array/pref_low_battery_warning_policy_entries"
+ android:entryValues="@array/pref_low_battery_warning_policy_values"
+ android:defaultValue="0" />
+
<PreferenceScreen
android:key="recents_ram_bar"
android:fragment="com.android.settings.slim.RamBar"
View
19 src/com/android/settings/slim/UserInterface.java
@@ -28,6 +28,7 @@
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceCategory;
@@ -52,6 +53,7 @@
private static final String KEY_DUAL_PANE = "dual_pane";
private static final String KEY_HIGH_END_GFX = "high_end_gfx";
private static final String PREF_CUSTOM_CARRIER_LABEL = "custom_carrier_label";
+ private static final String KEY_LOW_BATTERY_WARNING_POLICY = "pref_low_battery_warning_policy";
private Preference mLcdDensity;
private CheckBoxPreference mUseAltResolver;
@@ -60,6 +62,7 @@
private CheckBoxPreference mDualPane;
private CheckBoxPreference mHighEndGfx;
private Preference mCustomLabel;
+ private ListPreference mLowBatteryWarning;
private String mCustomLabelText = null;
private int newDensityValue;
@@ -115,6 +118,13 @@ public void onCreate(Bundle savedInstanceState) {
Settings.System.DUAL_PANE_PREFS, (preferDualPane ? 1 : 0)) == 1;
mDualPane.setChecked(dualPaneMode);
+ mLowBatteryWarning = (ListPreference) findPreference(KEY_LOW_BATTERY_WARNING_POLICY);
+ int lowBatteryWarning = Settings.System.getInt(getActivity().getContentResolver(),
+ Settings.System.POWER_UI_LOW_BATTERY_WARNING_POLICY, 0);
+ mLowBatteryWarning.setValue(String.valueOf(lowBatteryWarning));
+ mLowBatteryWarning.setSummary(mLowBatteryWarning.getEntry());
+ mLowBatteryWarning.setOnPreferenceChangeListener(this);
+
mHighEndGfx = (CheckBoxPreference) findPreference(KEY_HIGH_END_GFX);
if (!ActivityManager.isHighEndGfx()) {
@@ -161,6 +171,15 @@ public void onPause() {
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference == mLowBatteryWarning) {
+ int lowBatteryWarning = Integer.valueOf((String) newValue);
+ int index = mLowBatteryWarning.findIndexOfValue((String) newValue);
+ Settings.System.putInt(getActivity().getContentResolver(),
+ Settings.System.POWER_UI_LOW_BATTERY_WARNING_POLICY,
+ lowBatteryWarning);
+ mLowBatteryWarning.setSummary(mLowBatteryWarning.getEntries()[index]);
+ return true;
+ }
return false;
}

0 comments on commit 334b838

Please sign in to comment.
Something went wrong with that request. Please try again.