[2/2] OmniGears: more improve Active Display
1. fix http://jira.omnirom.org/browse/OMNI-651
2. fix http://jira.omnirom.org/browse/OMNI-641
3. add http://jira.omnirom.org/browse/OMNI-652
4. Add option Double tap to sleep every where
5. Add option to show and choose wallpaper behind active display
6. Allow to show numbers of notification on Handle
7. minor improvements
8. add battery circle around handle
PS8
string rework
PS9
recalc brightness to % value
Change-Id: Iceaae6eecbdd3dbce4347b2e3994272b10f3c490
diff --git a/res/values/custom_strings.xml b/res/values/custom_strings.xml
index a9b3345..a50fd30 100644
--- a/res/values/custom_strings.xml
+++ b/res/values/custom_strings.xml
@@ -22,7 +22,7 @@
<string name="reset">Reset</string>
<string name="bars_and_menus_settings">Bars and menus</string>
- <string name="active_display_settings">ActiveDisplay</string>
+ <string name="active_display_settings">Active display</string>
<string name="bars_and_menus_category_status_bar_title">Status bar</string>
<string name="bars_and_menus_category_navigation_bar_title">Navigation bar</string>
<string name="status_bar_battery_title">Battery style</string>
@@ -238,14 +238,20 @@
<string name="ad_enable_title">Enable</string>
<string name="ad_enable_summary_on">Active display enabled</string>
<string name="ad_enable_summary_off">Active display disabled</string>
- <string name="ad_bypass_title">Bypass active display</string>
- <string name="ad_bypass_summary">When no notifications exist, pocket mode will launch the lockscreen</string>
+ <string name="ad_bypass_title">Bypass mode</string>
+ <string name="ad_bypass_summary">Pocket mode will launch the lockscreen when no notifications exist</string>
<string name="ad_text_title">Notification text</string>
<string name="ad_text_summary">Show the notification text around the ring</string>
- <string name="ad_content_title">Use custom notification view</string>
- <string name="ad_content_summary">Use Active display style for showing notification details, rather than system style</string>
- <string name="ad_all_notifications_title">Ongoing notifications</string>
- <string name="ad_all_notifications_summary">Show ongoing, non-clearable notifications</string>
+ <string name="ad_content_title">Custom notification view</string>
+ <string name="ad_content_summary">Use active display style for notification details</string>
+ <string name="ad_annoying_title">Less frequent notification</string>
+ <string name="ad_annoying_summary">Limit the notification to once per time period</string>
+ <string name="ad_double_tap_title">Double tap to sleep</string>
+ <string name="ad_double_tap_summary">Turn screen off with double tap</string>
+ <string name="ad_wallpaper_title">Wallpaper see through</string>
+ <string name="ad_wallpaper_summary">Show blurred wallpaper behind active display</string>
+ <string name="ad_all_notifications_title">Show ongoing</string>
+ <string name="ad_all_notifications_summary">Show non-clearable notifications</string>
<string name="ad_hide_low_priority_title">Hide low priority</string>
<string name="ad_hide_low_priority_summary">Hide notifications marked as low priority</string>
<string name="ad_pocket_mode_title">Pocket mode</string>
@@ -253,22 +259,22 @@
<string name="ad_redisplay_title">Re-display notifications</string>
<string name="ad_timeout_title">Display timeout</string>
<string name="ad_threshold_title">Proximity time threshold</string>
- <string name="ad_threshold_summary">Duration the proximity sensor must be covered before Active display is shown</string>
- <string name="ad_brightness_title">Notification brightness</string>
+ <string name="ad_threshold_summary">Time the proximity sensor must be covered before active display is shown</string>
+ <string name="ad_brightness_title">Display brightness</string>
<string name="ad_customizations_title">Advanced settings</string>
<string name="ad_excluded_apps_title">Excluded apps</string>
<string name="ad_excluded_apps_summary">No notifications will be shown for these apps</string>
<string name="ad_privacy_apps_title">Privacy mode</string>
- <string name="ad_privacy_apps_summary">No details will be shown for notifications belonging to these apps</string>
+ <string name="ad_privacy_apps_summary">No details will be shown for notifications from these apps</string>
<string name="ad_show_date_title">Show date</string>
<string name="ad_show_ampm_title">Show AM/PM</string>
<string name="ad_sunlight_mode_title">Sunlight mode</string>
- <string name="ad_brightness_summary">Active display brightness (Only applies when automatic brightness is disabled)</string>
+ <string name="ad_brightness_summary">Used on manual brightness control</string>
<string name="ad_show_date_summary">Show the date above the clock</string>
<string name="ad_show_ampm_summary">Show AM/PM indicator when using the 12-hour time format</string>
- <string name="ad_sunlight_mode_summary">Invert colors when in bright areas such as under direct sunlight</string>
- <string name="ad_turnoff_mode_title">Auto-sleep display</string>
- <string name="ad_turnoff_mode_summary">Put device to sleep again if it was woken by Pocket mode, and is returned to the pocket</string>
+ <string name="ad_sunlight_mode_summary">Invert colors in bright environment</string>
+ <string name="ad_turnoff_mode_title">Auto-sleep</string>
+ <string name="ad_turnoff_mode_summary">Put to sleep after woken by pocket mode and returned to the pocket</string>
<string name="ad_redisplay_never">Never</string>
<string name="ad_redisplay_1m">1 minute</string>
<string name="ad_redisplay_5m">5 minutes</string>
diff --git a/res/xml/active_display_settings.xml b/res/xml/active_display_settings.xml
index b7f396d..ddbb5c5 100644
--- a/res/xml/active_display_settings.xml
+++ b/res/xml/active_display_settings.xml
@@ -24,37 +24,27 @@
android:summaryOff="@string/ad_enable_summary_off"
android:summaryOn="@string/ad_enable_summary_on" />
- <CheckBoxPreference
- android:key="ad_content"
- android:persistent="false"
+ <org.omnirom.omnigears.preference.SystemCheckBoxPreference
+ android:key="active_display_content"
+ android:defaultValue="true"
android:title="@string/ad_content_title"
android:summary="@string/ad_content_summary"
android:dependency="ad_enable"/>
- <CheckBoxPreference
- android:key="ad_bypass"
- android:persistent="false"
- android:title="@string/ad_bypass_title"
- android:summary="@string/ad_bypass_summary"
- android:dependency="ad_enable"/>
-
- <CheckBoxPreference
- android:key="ad_text"
- android:persistent="false"
+ <org.omnirom.omnigears.preference.SystemCheckBoxPreference
+ android:key="active_display_text"
android:title="@string/ad_text_title"
android:summary="@string/ad_text_summary"
android:dependency="ad_enable"/>
- <CheckBoxPreference
- android:key="ad_all_notifications"
- android:persistent="false"
+ <org.omnirom.omnigears.preference.SystemCheckBoxPreference
+ android:key="active_display_all_notifications"
android:title="@string/ad_all_notifications_title"
android:summary="@string/ad_all_notifications_summary"
android:dependency="ad_enable"/>
- <CheckBoxPreference
- android:key="ad_hide_low_priority"
- android:persistent="false"
+ <org.omnirom.omnigears.preference.SystemCheckBoxPreference
+ android:key="active_display_hide_low_priority_notifications"
android:title="@string/ad_hide_low_priority_title"
android:summary="@string/ad_hide_low_priority_summary"
android:dependency="ad_enable"/>
@@ -69,6 +59,13 @@
android:dependency="ad_enable"/>
<CheckBoxPreference
+ android:key="ad_bypass"
+ android:persistent="false"
+ android:title="@string/ad_bypass_title"
+ android:summary="@string/ad_bypass_summary"
+ android:dependency="ad_enable"/>
+
+ <CheckBoxPreference
android:key="ad_sunlight_mode"
android:persistent="false"
android:title="@string/ad_sunlight_mode_title"
@@ -84,10 +81,48 @@
android:entryValues="@array/ad_redisplay_values"
android:dependency="ad_enable"/>
+ <org.omnirom.omnigears.chameleonos.SeekBarPreference
+ android:key="ad_annoying"
+ android:persistent="false"
+ android:title="@string/ad_annoying_title"
+ android:summary="@string/ad_annoying_summary"
+ android:max="60"
+ settings:min="0"
+ settings:interval="1"
+ settings:unitsLeft=""
+ settings:unitsRight="s"
+ android:dependency="ad_enable" />
+
<PreferenceCategory
android:key="ad_customizations"
android:title="@string/ad_customizations_title" />
+ <org.omnirom.omnigears.preference.SystemCheckBoxPreference
+ android:key="active_display_wallpaper"
+ android:title="@string/ad_wallpaper_title"
+ android:summary="@string/ad_wallpaper_summary"
+ android:dependency="ad_enable"/>
+
+ <org.omnirom.omnigears.preference.SystemCheckBoxPreference
+ android:key="active_display_double_tap"
+ android:title="@string/ad_double_tap_title"
+ android:summary="@string/ad_double_tap_summary"
+ android:dependency="ad_enable"/>
+
+ <org.omnirom.omnigears.preference.SystemCheckBoxPreference
+ android:key="active_display_show_date"
+ android:defaultValue="true"
+ android:title="@string/ad_show_date_title"
+ android:summary="@string/ad_show_date_summary"
+ android:dependency="ad_enable"/>
+
+ <CheckBoxPreference
+ android:key="ad_show_ampm"
+ android:persistent="false"
+ android:title="@string/ad_show_ampm_title"
+ android:summary="@string/ad_show_ampm_summary"
+ android:dependency="ad_enable"/>
+
<org.omnirom.omnigears.chameleonos.AppMultiSelectListPreference
android:key="ad_excluded_apps"
android:persistent="false"
@@ -103,20 +138,6 @@
android:dependency="ad_enable" />
<CheckBoxPreference
- android:key="ad_show_date"
- android:persistent="false"
- android:title="@string/ad_show_date_title"
- android:summary="@string/ad_show_date_summary"
- android:dependency="ad_enable"/>
-
- <CheckBoxPreference
- android:key="ad_show_ampm"
- android:persistent="false"
- android:title="@string/ad_show_ampm_title"
- android:summary="@string/ad_show_ampm_summary"
- android:dependency="ad_enable"/>
-
- <CheckBoxPreference
android:key="ad_turnoff_mode"
android:persistent="true"
android:title="@string/ad_turnoff_mode_title"
diff --git a/src/org/omnirom/omnigears/chameleonos/ActiveDisplaySettings.java b/src/org/omnirom/omnigears/chameleonos/ActiveDisplaySettings.java
index b13c80b..356258c 100644
--- a/src/org/omnirom/omnigears/chameleonos/ActiveDisplaySettings.java
+++ b/src/org/omnirom/omnigears/chameleonos/ActiveDisplaySettings.java
@@ -40,22 +40,20 @@
import java.util.HashSet;
import java.util.Set;
+import android.util.Log;
+
public class ActiveDisplaySettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener {
private static final String TAG = "ActiveDisplaySettings";
private static final String KEY_ENABLED = "ad_enable";
- private static final String KEY_SHOW_TEXT = "ad_text";
- private static final String KEY_SHOW_CONTENT = "ad_content";
+ private static final String KEY_ANNOYING = "ad_annoying";
private static final String KEY_BYPASS_CONTENT = "ad_bypass";
- private static final String KEY_ALL_NOTIFICATIONS = "ad_all_notifications";
- private static final String KEY_HIDE_LOW_PRIORITY = "ad_hide_low_priority";
private static final String KEY_POCKET_MODE = "ad_pocket_mode";
private static final String KEY_SUNLIGHT_MODE = "ad_sunlight_mode";
private static final String KEY_REDISPLAY = "ad_redisplay";
private static final String KEY_EXCLUDED_APPS = "ad_excluded_apps";
private static final String KEY_PRIVACY_APPS = "ad_privacy_apps";
- private static final String KEY_SHOW_DATE = "ad_show_date";
private static final String KEY_SHOW_AMPM = "ad_show_ampm";
private static final String KEY_BRIGHTNESS = "ad_brightness";
private static final String KEY_TIMEOUT = "ad_timeout";
@@ -66,22 +64,21 @@
private Context mContext;
private SwitchPreference mEnabledPref;
- private CheckBoxPreference mShowTextPref;
- private CheckBoxPreference mShowContentPref;
- private CheckBoxPreference mBypassPref;
- private CheckBoxPreference mAllNotificationsPref;
- private CheckBoxPreference mHideLowPriorityPref;
- private ListPreference mPocketModePref;
- private CheckBoxPreference mSunlightModePref;
- private ListPreference mRedisplayPref;
private AppMultiSelectListPreference mExcludedAppsPref;
private AppMultiSelectListPreference mPrivacyAppsPref;
- private CheckBoxPreference mShowDatePref;
+ private CheckBoxPreference mBypassPref;
private CheckBoxPreference mShowAmPmPref;
- private SeekBarPreference mBrightnessLevel;
- private ListPreference mDisplayTimeout;
- private ListPreference mProximityThreshold;
+ private CheckBoxPreference mSunlightModePref;
private CheckBoxPreference mTurnOffModePref;
+ private SeekBarPreference mBrightnessLevel;
+ private SeekBarPreference mAnnoyingNotification;
+ private ListPreference mDisplayTimeout;
+ private ListPreference mPocketModePref;
+ private ListPreference mProximityThreshold;
+ private ListPreference mRedisplayPref;
+ private int mMinimumBacklight;
+ private int mMaximumBacklight;
+
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -98,14 +95,6 @@
Settings.System.ENABLE_ACTIVE_DISPLAY, 0) == 1));
mEnabledPref.setOnPreferenceChangeListener(this);
- mShowTextPref = (CheckBoxPreference) prefSet.findPreference(KEY_SHOW_TEXT);
- mShowTextPref.setChecked((Settings.System.getInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_TEXT, 0) == 1));
-
- mShowContentPref = (CheckBoxPreference) prefSet.findPreference(KEY_SHOW_CONTENT);
- mShowContentPref.setChecked((Settings.System.getInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_CONTENT, 1) != 0));
-
mBypassPref = (CheckBoxPreference) prefSet.findPreference(KEY_BYPASS_CONTENT);
mPocketModePref = (ListPreference) prefSet.findPreference(KEY_POCKET_MODE);
mProximityThreshold = (ListPreference) prefSet.findPreference(KEY_THRESHOLD);
@@ -123,27 +112,19 @@
int mode = Settings.System.getInt(mResolver,
Settings.System.ACTIVE_DISPLAY_POCKET_MODE, 0);
mPocketModePref.setValue(String.valueOf(mode));
- updatePocketModeSummary(mode);
+ mPocketModePref.setSummary(mPocketModePref.getEntry());
mPocketModePref.setOnPreferenceChangeListener(this);
long threshold = Settings.System.getLong(mResolver,
Settings.System.ACTIVE_DISPLAY_THRESHOLD, 5000L);
mProximityThreshold.setValue(String.valueOf(threshold));
- updateThresholdSummary(threshold);
+ mProximityThreshold.setSummary(mProximityThreshold.getEntry());
mProximityThreshold.setOnPreferenceChangeListener(this);
mTurnOffModePref.setChecked((Settings.System.getInt(mResolver,
Settings.System.ACTIVE_DISPLAY_TURNOFF_MODE, 0) == 1));
}
- mAllNotificationsPref = (CheckBoxPreference) prefSet.findPreference(KEY_ALL_NOTIFICATIONS);
- mAllNotificationsPref.setChecked((Settings.System.getInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_ALL_NOTIFICATIONS, 0) == 1));
-
- mHideLowPriorityPref = (CheckBoxPreference) prefSet.findPreference(KEY_HIDE_LOW_PRIORITY);
- mHideLowPriorityPref.setChecked((Settings.System.getInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_HIDE_LOW_PRIORITY_NOTIFICATIONS, 0) == 1));
-
mSunlightModePref = (CheckBoxPreference) prefSet.findPreference(KEY_SUNLIGHT_MODE);
if (!DeviceUtils.deviceSupportsLightSensor(mContext)) {
@@ -157,61 +138,59 @@
long timeout = Settings.System.getLong(mResolver,
Settings.System.ACTIVE_DISPLAY_REDISPLAY, 0);
mRedisplayPref.setValue(String.valueOf(timeout));
- updateRedisplaySummary(timeout);
+ mRedisplayPref.setSummary(mRedisplayPref.getEntry());
mRedisplayPref.setOnPreferenceChangeListener(this);
+ mAnnoyingNotification = (SeekBarPreference) prefSet.findPreference(KEY_ANNOYING);
+ mAnnoyingNotification.setValue(Settings.System.getInt(mResolver,
+ Settings.System.ACTIVE_DISPLAY_ANNOYING, 0));
+ mAnnoyingNotification.setOnPreferenceChangeListener(this);
+
mExcludedAppsPref = (AppMultiSelectListPreference) prefSet.findPreference(KEY_EXCLUDED_APPS);
Set<String> excludedApps = getExcludedApps();
- if (excludedApps != null) mExcludedAppsPref.setValues(excludedApps);
+ if (excludedApps != null) {
+ mExcludedAppsPref.setValues(excludedApps);
+ }
mExcludedAppsPref.setOnPreferenceChangeListener(this);
mPrivacyAppsPref = (AppMultiSelectListPreference) prefSet.findPreference(KEY_PRIVACY_APPS);
Set<String> privacyApps = getPrivacyApps();
- if (privacyApps != null) mPrivacyAppsPref.setValues(privacyApps);
+ if (privacyApps != null) {
+ mPrivacyAppsPref.setValues(privacyApps);
+ }
mPrivacyAppsPref.setOnPreferenceChangeListener(this);
- mShowDatePref = (CheckBoxPreference) prefSet.findPreference(KEY_SHOW_DATE);
- mShowDatePref.setChecked((Settings.System.getInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_SHOW_DATE, 0) == 1));
-
mShowAmPmPref = (CheckBoxPreference) prefSet.findPreference(KEY_SHOW_AMPM);
mShowAmPmPref.setChecked((Settings.System.getInt(mResolver,
Settings.System.ACTIVE_DISPLAY_SHOW_AMPM, 0) == 1));
- mShowAmPmPref.setEnabled(!is24Hour());
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
- int minimumBacklight = pm.getMinimumScreenBrightnessSetting();
- int maximumBacklight = pm.getMaximumScreenBrightnessSetting();
+ mMinimumBacklight = pm.getMinimumScreenBrightnessSetting();
+ mMaximumBacklight = pm.getMaximumScreenBrightnessSetting();
mBrightnessLevel = (SeekBarPreference) prefSet.findPreference(KEY_BRIGHTNESS);
- mBrightnessLevel.setMaxValue(maximumBacklight - minimumBacklight);
- mBrightnessLevel.setMinValue(minimumBacklight);
- mBrightnessLevel.setValue(Settings.System.getInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_BRIGHTNESS, maximumBacklight) - minimumBacklight);
- mBrightnessLevel.setOnPreferenceChangeListener(this);
-
- try {
- if (Settings.System.getInt(mResolver,
- Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
- mBrightnessLevel.setEnabled(false);
- mBrightnessLevel.setSummary(R.string.status_bar_toggle_info);
- }
- } catch (SettingNotFoundException e) {
- }
+ int brightness = Settings.System.getInt(mResolver,
+ Settings.System.ACTIVE_DISPLAY_BRIGHTNESS, mMaximumBacklight);
+ int realBrightness = (int)(((float)brightness / (float)mMaximumBacklight) * 100);
+ mBrightnessLevel.setValue(realBrightness);
+ mBrightnessLevel.setOnPreferenceChangeListener(this);
mDisplayTimeout = (ListPreference) prefSet.findPreference(KEY_TIMEOUT);
- mDisplayTimeout.setOnPreferenceChangeListener(this);
timeout = Settings.System.getLong(mResolver,
Settings.System.ACTIVE_DISPLAY_TIMEOUT, 8000L);
mDisplayTimeout.setValue(String.valueOf(timeout));
- updateTimeoutSummary(timeout);
+ mDisplayTimeout.setSummary(mDisplayTimeout.getEntry());
+ mDisplayTimeout.setOnPreferenceChangeListener(this);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference == mRedisplayPref) {
- int timeout = Integer.valueOf((String) newValue);
- updateRedisplaySummary(timeout);
+ int val = Integer.parseInt((String) newValue);
+ int index = mRedisplayPref.findIndexOfValue((String) newValue);
+ Settings.System.putInt(mResolver,
+ Settings.System.ACTIVE_DISPLAY_REDISPLAY, val);
+ mRedisplayPref.setSummary(mRedisplayPref.getEntries()[index]);
return true;
} else if (preference == mEnabledPref) {
Settings.System.putInt(mResolver,
@@ -219,8 +198,11 @@
((Boolean) newValue).booleanValue() ? 1 : 0);
return true;
} else if (preference == mPocketModePref) {
- int mode = Integer.valueOf((String) newValue);
- updatePocketModeSummary(mode);
+ int val = Integer.parseInt((String) newValue);
+ int index = mPocketModePref.findIndexOfValue((String) newValue);
+ Settings.System.putInt(mResolver,
+ Settings.System.ACTIVE_DISPLAY_POCKET_MODE, val);
+ mPocketModePref.setSummary(mPocketModePref.getEntries()[index]);
return true;
} else if (preference == mExcludedAppsPref) {
storeExcludedApps((Set<String>) newValue);
@@ -228,18 +210,29 @@
} else if (preference == mPrivacyAppsPref) {
storePrivacyApps((Set<String>) newValue);
return true;
+ } else if (preference == mAnnoyingNotification) {
+ int annoying = ((Integer)newValue).intValue();
+ Settings.System.putInt(mResolver,
+ Settings.System.ACTIVE_DISPLAY_ANNOYING, annoying);
+ return true;
} else if (preference == mBrightnessLevel) {
int brightness = ((Integer)newValue).intValue();
- Settings.System.putInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_BRIGHTNESS, brightness);
+ int realBrightness = Math.max(mMinimumBacklight, (int)(((float)brightness / (float)100) * mMaximumBacklight));
+ Settings.System.putInt(mResolver, Settings.System.ACTIVE_DISPLAY_BRIGHTNESS, realBrightness);
return true;
} else if (preference == mDisplayTimeout) {
- long timeout = Integer.valueOf((String) newValue);
- updateTimeoutSummary(timeout);
+ int val = Integer.parseInt((String) newValue);
+ int index = mDisplayTimeout.findIndexOfValue((String) newValue);
+ Settings.System.putInt(mResolver,
+ Settings.System.ACTIVE_DISPLAY_TIMEOUT, val);
+ mDisplayTimeout.setSummary(mDisplayTimeout.getEntries()[index]);
return true;
} else if (preference == mProximityThreshold) {
- long threshold = Integer.valueOf((String) newValue);
- updateThresholdSummary(threshold);
+ int val = Integer.parseInt((String) newValue);
+ int index = mProximityThreshold.findIndexOfValue((String) newValue);
+ Settings.System.putInt(mResolver,
+ Settings.System.ACTIVE_DISPLAY_THRESHOLD, val);
+ mProximityThreshold.setSummary(mProximityThreshold.getEntries()[index]);
return true;
}
return false;
@@ -248,41 +241,16 @@
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
boolean value;
- if (preference == mShowTextPref) {
- value = mShowTextPref.isChecked();
- Settings.System.putInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_TEXT,
- value ? 1 : 0);
- } else if (preference == mShowContentPref) {
- value = mShowContentPref.isChecked();
- Settings.System.putInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_CONTENT,
- value ? 1 : 0);
- } else if (preference == mBypassPref) {
+ if (preference == mBypassPref) {
value = mBypassPref.isChecked();
Settings.System.putInt(mResolver,
Settings.System.ACTIVE_DISPLAY_BYPASS,
value ? 1 : 0);
- } else if (preference == mAllNotificationsPref) {
- value = mAllNotificationsPref.isChecked();
- Settings.System.putInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_ALL_NOTIFICATIONS,
- value ? 1 : 0);
- } else if (preference == mHideLowPriorityPref) {
- value = mHideLowPriorityPref.isChecked();
- Settings.System.putInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_HIDE_LOW_PRIORITY_NOTIFICATIONS,
- value ? 1 : 0);
} else if (preference == mSunlightModePref) {
value = mSunlightModePref.isChecked();
Settings.System.putInt(mResolver,
Settings.System.ACTIVE_DISPLAY_SUNLIGHT_MODE,
value ? 1 : 0);
- } else if (preference == mShowDatePref) {
- value = mShowDatePref.isChecked();
- Settings.System.putInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_SHOW_DATE,
- value ? 1 : 0);
} else if (preference == mShowAmPmPref) {
value = mShowAmPmPref.isChecked();
Settings.System.putInt(mResolver,
@@ -300,43 +268,12 @@
return true;
}
- private void updatePocketModeSummary(int value) {
- mPocketModePref.setSummary(
- mPocketModePref.getEntries()[mPocketModePref.findIndexOfValue("" + value)]);
- Settings.System.putInt(mResolver,
- Settings.System.ACTIVE_DISPLAY_POCKET_MODE, value);
- }
-
- private void updateRedisplaySummary(long value) {
- mRedisplayPref.setSummary(mRedisplayPref.getEntries()[mRedisplayPref.findIndexOfValue("" + value)]);
- Settings.System.putLong(mResolver,
- Settings.System.ACTIVE_DISPLAY_REDISPLAY, value);
- }
-
- private void updateTimeoutSummary(long value) {
- try {
- mDisplayTimeout.setSummary(mDisplayTimeout.getEntries()[mDisplayTimeout.findIndexOfValue("" + value)]);
- Settings.System.putLong(mResolver,
- Settings.System.ACTIVE_DISPLAY_TIMEOUT, value);
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- }
-
- private void updateThresholdSummary(long value) {
- try {
- mProximityThreshold.setSummary(mProximityThreshold.getEntries()[mProximityThreshold.findIndexOfValue("" + value)]);
- Settings.System.putLong(mResolver,
- Settings.System.ACTIVE_DISPLAY_THRESHOLD, value);
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- }
-
private Set<String> getExcludedApps() {
String excluded = Settings.System.getString(mResolver,
Settings.System.ACTIVE_DISPLAY_EXCLUDED_APPS);
- if (TextUtils.isEmpty(excluded))
+ if (TextUtils.isEmpty(excluded)) {
return null;
-
+ }
return new HashSet<String>(Arrays.asList(excluded.split("\\|")));
}
@@ -355,9 +292,9 @@
private Set<String> getPrivacyApps() {
String privacies = Settings.System.getString(mResolver,
Settings.System.ACTIVE_DISPLAY_PRIVACY_APPS);
- if (TextUtils.isEmpty(privacies))
+ if (TextUtils.isEmpty(privacies)) {
return null;
-
+ }
return new HashSet<String>(Arrays.asList(privacies.split("\\|")));
}
diff --git a/src/org/omnirom/omnigears/chameleonos/AppMultiSelectListPreference.java b/src/org/omnirom/omnigears/chameleonos/AppMultiSelectListPreference.java
index 6600a47..2e8e19d 100644
--- a/src/org/omnirom/omnigears/chameleonos/AppMultiSelectListPreference.java
+++ b/src/org/omnirom/omnigears/chameleonos/AppMultiSelectListPreference.java
@@ -175,14 +175,17 @@
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
final CharSequence[] defaultValues = a.getTextArray(index);
- final int valueCount = defaultValues.length;
- final Set<String> result = new HashSet<String>();
+ if (defaultValues != null) {
+ final int valueCount = defaultValues.length;
+ final Set<String> result = new HashSet<String>();
- for (int i = 0; i < valueCount; i++) {
- result.add(defaultValues[i].toString());
+ for (int i = 0; i < valueCount; i++) {
+ result.add(defaultValues[i].toString());
+ }
+
+ return result;
}
-
- return result;
+ return null;
}
@Override
@@ -256,11 +259,11 @@
private final static Comparator<MyApplicationInfo> sDisplayNameComparator
= new Comparator<MyApplicationInfo>() {
- public final int
- compare(MyApplicationInfo a, MyApplicationInfo b) {
- return collator.compare(a.label, b.label);
- }
private final Collator collator = Collator.getInstance();
+
+ public final int compare(MyApplicationInfo a, MyApplicationInfo b) {
+ return collator.compare(a.label, b.label);
+ }
};
}