summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2013-07-15 13:32:26 +0200
committerfuzz <fuzzzzzzzzzzzzzzzzzz@gmail.com>2013-07-27 21:44:37 +0900
commitb55f7fa4641aff0fb837f4cd81dc1e66b1e885be (patch)
treeb292a36d08ab70f3e5e67b4f18e3885648c5fa4a /src/com
parent5a29d4365a177b80fc1b912a9100d34d14cbc672 (diff)
downloadpackages_apps_settings-b55f7fa4641aff0fb837f4cd81dc1e66b1e885be.zip
packages_apps_settings-b55f7fa4641aff0fb837f4cd81dc1e66b1e885be.tar.gz
packages_apps_settings-b55f7fa4641aff0fb837f4cd81dc1e66b1e885be.tar.bz2
Make notification-shade-collapse-after-dismiss behaviour configurable.
Change-Id: Icbf706a582279b86d901fb727b58663713606521
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/cyanogenmod/NotificationDrawer.java (renamed from src/com/android/settings/cyanogenmod/PowerWidget.java)98
-rw-r--r--src/com/android/settings/cyanogenmod/StatusBar.java74
2 files changed, 91 insertions, 81 deletions
diff --git a/src/com/android/settings/cyanogenmod/PowerWidget.java b/src/com/android/settings/cyanogenmod/NotificationDrawer.java
index 33091b7..fd45989 100644
--- a/src/com/android/settings/cyanogenmod/PowerWidget.java
+++ b/src/com/android/settings/cyanogenmod/NotificationDrawer.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import android.app.ListFragment;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -55,15 +56,17 @@ import com.android.settings.SettingsPreferenceFragment;
import static com.android.internal.util.cm.QSUtils.deviceSupportsMobileData;
-public class PowerWidget extends SettingsPreferenceFragment implements
+public class NotificationDrawer extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
private static final String TAG = "PowerWidget";
private static final String SEPARATOR = "OV=I=XseparatorX=I=VO";
+ private static final String UI_COLLAPSE_BEHAVIOUR = "notification_drawer_collapse_on_dismiss";
private static final String UI_EXP_WIDGET = "expanded_widget";
private static final String UI_EXP_WIDGET_HIDE_ONCHANGE = "expanded_hide_onchange";
private static final String UI_EXP_WIDGET_HIDE_SCROLLBAR = "expanded_hide_scrollbar";
private static final String UI_EXP_WIDGET_HAPTIC_FEEDBACK = "expanded_haptic_feedback";
+ private ListPreference mCollapseOnDismiss;
private CheckBoxPreference mPowerWidget;
private CheckBoxPreference mPowerWidgetHideOnChange;
private CheckBoxPreference mPowerWidgetHideScrollBar;
@@ -74,72 +77,85 @@ public class PowerWidget extends SettingsPreferenceFragment implements
super.onCreate(savedInstanceState);
if (getPreferenceManager() != null) {
- addPreferencesFromResource(R.xml.power_widget_settings);
+ addPreferencesFromResource(R.xml.notification_drawer);
+ ContentResolver resolver = getActivity().getContentResolver();
PreferenceScreen prefSet = getPreferenceScreen();
+ int collapseBehaviour = Settings.System.getInt(resolver,
+ Settings.System.STATUS_BAR_COLLAPSE_ON_DISMISS,
+ Settings.System.STATUS_BAR_COLLAPSE_IF_NO_CLEARABLE);
+ mCollapseOnDismiss = (ListPreference) prefSet.findPreference(UI_COLLAPSE_BEHAVIOUR);
+ mCollapseOnDismiss.setValue(String.valueOf(collapseBehaviour));
+ mCollapseOnDismiss.setOnPreferenceChangeListener(this);
+ updateCollapseBehaviourSummary(collapseBehaviour);
+
mPowerWidget = (CheckBoxPreference) prefSet.findPreference(UI_EXP_WIDGET);
+ mPowerWidget.setOnPreferenceChangeListener(this);
mPowerWidgetHideOnChange = (CheckBoxPreference) prefSet
.findPreference(UI_EXP_WIDGET_HIDE_ONCHANGE);
+ mPowerWidgetHideOnChange.setOnPreferenceChangeListener(this);
mPowerWidgetHideScrollBar = (CheckBoxPreference) prefSet
.findPreference(UI_EXP_WIDGET_HIDE_SCROLLBAR);
+ mPowerWidgetHideScrollBar.setOnPreferenceChangeListener(this);
mPowerWidgetHapticFeedback = (ListPreference) prefSet
.findPreference(UI_EXP_WIDGET_HAPTIC_FEEDBACK);
mPowerWidgetHapticFeedback.setOnPreferenceChangeListener(this);
mPowerWidgetHapticFeedback.setSummary(mPowerWidgetHapticFeedback.getEntry());
- mPowerWidget.setChecked((Settings.System.getInt(getActivity().getApplicationContext()
- .getContentResolver(),
- Settings.System.EXPANDED_VIEW_WIDGET, 0) == 1));
- mPowerWidgetHideOnChange.setChecked((Settings.System.getInt(getActivity()
- .getApplicationContext().getContentResolver(),
- Settings.System.EXPANDED_HIDE_ONCHANGE, 0) == 1));
- mPowerWidgetHideScrollBar.setChecked((Settings.System.getInt(getActivity()
- .getApplicationContext().getContentResolver(),
- Settings.System.EXPANDED_HIDE_SCROLLBAR, 0) == 1));
+ mPowerWidget.setChecked(Settings.System.getInt(resolver,
+ Settings.System.EXPANDED_VIEW_WIDGET, 0) == 1);
+ mPowerWidgetHideOnChange.setChecked(Settings.System.getInt(resolver,
+ Settings.System.EXPANDED_HIDE_ONCHANGE, 0) == 1);
+ mPowerWidgetHideScrollBar.setChecked(Settings.System.getInt(resolver,
+ Settings.System.EXPANDED_HIDE_SCROLLBAR, 0) == 1);
mPowerWidgetHapticFeedback.setValue(Integer.toString(Settings.System.getInt(
- getActivity().getApplicationContext().getContentResolver(),
- Settings.System.EXPANDED_HAPTIC_FEEDBACK, 2)));
+ resolver, Settings.System.EXPANDED_HAPTIC_FEEDBACK, 2)));
}
}
+ private void updateCollapseBehaviourSummary(int setting) {
+ String[] summaries = getResources().getStringArray(
+ R.array.notification_drawer_collapse_on_dismiss_summaries);
+ mCollapseOnDismiss.setSummary(summaries[setting]);
+ }
+
+ @Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (preference == mPowerWidgetHapticFeedback) {
+ ContentResolver resolver = getActivity().getContentResolver();
+
+ if (preference == mCollapseOnDismiss) {
+ int value = Integer.valueOf((String) newValue);
+ Settings.System.putInt(resolver,
+ Settings.System.STATUS_BAR_COLLAPSE_ON_DISMISS, value);
+ updateCollapseBehaviourSummary(value);
+ return true;
+ } else if (preference == mPowerWidget) {
+ boolean value = (Boolean) newValue;
+ Settings.System.putInt(resolver,
+ Settings.System.EXPANDED_VIEW_WIDGET, value ? 1 : 0);
+ return true;
+ } else if (preference == mPowerWidgetHideOnChange) {
+ boolean value = (Boolean) newValue;
+ Settings.System.putInt(resolver,
+ Settings.System.EXPANDED_HIDE_ONCHANGE, value ? 1 : 0);
+ return true;
+ } else if (preference == mPowerWidgetHideScrollBar) {
+ boolean value = (Boolean) newValue;
+ Settings.System.putInt(resolver,
+ Settings.System.EXPANDED_HIDE_SCROLLBAR, value ? 1 : 0);
+ return true;
+ } else if (preference == mPowerWidgetHapticFeedback) {
int intValue = Integer.parseInt((String) newValue);
int index = mPowerWidgetHapticFeedback.findIndexOfValue((String) newValue);
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
+ Settings.System.putInt(resolver,
Settings.System.EXPANDED_HAPTIC_FEEDBACK, intValue);
mPowerWidgetHapticFeedback.setSummary(mPowerWidgetHapticFeedback.getEntries()[index]);
return true;
}
- return false;
- }
-
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- boolean value;
-
- if (preference == mPowerWidget) {
- value = mPowerWidget.isChecked();
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.EXPANDED_VIEW_WIDGET,
- value ? 1 : 0);
- } else if (preference == mPowerWidgetHideOnChange) {
- value = mPowerWidgetHideOnChange.isChecked();
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.EXPANDED_HIDE_ONCHANGE,
- value ? 1 : 0);
- } else if (preference == mPowerWidgetHideScrollBar) {
- value = mPowerWidgetHideScrollBar.isChecked();
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.EXPANDED_HIDE_SCROLLBAR,
- value ? 1 : 0);
- } else {
- // If we didn't handle it, let preferences handle it.
- return super.onPreferenceTreeClick(preferenceScreen, preference);
- }
- return true;
+ return false;
}
public static class PowerWidgetChooser extends SettingsPreferenceFragment
diff --git a/src/com/android/settings/cyanogenmod/StatusBar.java b/src/com/android/settings/cyanogenmod/StatusBar.java
index f9e911a..7b739ad 100644
--- a/src/com/android/settings/cyanogenmod/StatusBar.java
+++ b/src/com/android/settings/cyanogenmod/StatusBar.java
@@ -16,6 +16,7 @@
package com.android.settings.cyanogenmod;
+import android.content.ContentResolver;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
@@ -49,7 +50,6 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc
private CheckBoxPreference mStatusBarClock;
private CheckBoxPreference mStatusBarBrightnessControl;
private CheckBoxPreference mStatusBarNotifCount;
- private PreferenceCategory mPrefCategoryGeneral;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -58,6 +58,7 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc
addPreferencesFromResource(R.xml.status_bar);
PreferenceScreen prefSet = getPreferenceScreen();
+ ContentResolver resolver = getActivity().getContentResolver();
mStatusBarClock = (CheckBoxPreference) prefSet.findPreference(STATUS_BAR_CLOCK);
mStatusBarBrightnessControl = (CheckBoxPreference) prefSet.findPreference(STATUS_BAR_BRIGHTNESS_CONTROL);
@@ -65,15 +66,15 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc
mStatusBarBattery = (ListPreference) prefSet.findPreference(STATUS_BAR_BATTERY);
mStatusBarCmSignal = (ListPreference) prefSet.findPreference(STATUS_BAR_SIGNAL);
- mStatusBarClock.setChecked((Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_CLOCK, 1) == 1));
+ mStatusBarClock.setChecked(Settings.System.getInt(resolver, Settings.System.STATUS_BAR_CLOCK, 1) == 1);
+ mStatusBarClock.setOnPreferenceChangeListener(this);
if (DateFormat.is24HourFormat(getActivity())) {
((PreferenceCategory) prefSet.findPreference(STATUS_BAR_CLOCK_CATEGORY))
.removePreference(prefSet.findPreference(STATUS_BAR_AM_PM));
} else {
mStatusBarAmPm = (ListPreference) prefSet.findPreference(STATUS_BAR_AM_PM);
- int statusBarAmPm = Settings.System.getInt(getActivity().getContentResolver(),
+ int statusBarAmPm = Settings.System.getInt(resolver,
Settings.System.STATUS_BAR_AM_PM, 2);
mStatusBarAmPm.setValue(String.valueOf(statusBarAmPm));
@@ -81,91 +82,84 @@ public class StatusBar extends SettingsPreferenceFragment implements OnPreferenc
mStatusBarAmPm.setOnPreferenceChangeListener(this);
}
- mStatusBarBrightnessControl.setChecked((Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_BRIGHTNESS_CONTROL, 0) == 1));
+ mStatusBarBrightnessControl.setChecked(Settings.System.getInt(resolver,
+ Settings.System.STATUS_BAR_BRIGHTNESS_CONTROL, 0) == 1);
+ mStatusBarBrightnessControl.setChecked(Settings.System.getInt(resolver,
+ Settings.System.STATUS_BAR_BRIGHTNESS_CONTROL, 0) == 1);
+ mStatusBarBrightnessControl.setOnPreferenceChangeListener(this);
try {
- if (Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS_MODE) == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
+ if (Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE)
+ == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
mStatusBarBrightnessControl.setEnabled(false);
mStatusBarBrightnessControl.setSummary(R.string.status_bar_toggle_info);
}
} catch (SettingNotFoundException e) {
}
- int statusBarBattery = Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_BATTERY, 0);
+ int statusBarBattery = Settings.System.getInt(resolver, Settings.System.STATUS_BAR_BATTERY, 0);
mStatusBarBattery.setValue(String.valueOf(statusBarBattery));
mStatusBarBattery.setSummary(mStatusBarBattery.getEntry());
mStatusBarBattery.setOnPreferenceChangeListener(this);
- int signalStyle = Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_SIGNAL_TEXT, 0);
+ int signalStyle = Settings.System.getInt(resolver, Settings.System.STATUS_BAR_SIGNAL_TEXT, 0);
mStatusBarCmSignal.setValue(String.valueOf(signalStyle));
mStatusBarCmSignal.setSummary(mStatusBarCmSignal.getEntry());
mStatusBarCmSignal.setOnPreferenceChangeListener(this);
mStatusBarNotifCount = (CheckBoxPreference) prefSet.findPreference(STATUS_BAR_NOTIF_COUNT);
- mStatusBarNotifCount.setChecked((Settings.System.getInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_NOTIF_COUNT, 0) == 1));
+ mStatusBarNotifCount.setChecked(Settings.System.getInt(resolver,
+ Settings.System.STATUS_BAR_NOTIF_COUNT, 0) == 1);
+ mStatusBarNotifCount.setOnPreferenceChangeListener(this);
- mPrefCategoryGeneral = (PreferenceCategory) findPreference(STATUS_BAR_CATEGORY_GENERAL);
+ PreferenceCategory generalCategory =
+ (PreferenceCategory) findPreference(STATUS_BAR_CATEGORY_GENERAL);
if (Utils.isWifiOnly(getActivity())) {
- mPrefCategoryGeneral.removePreference(mStatusBarCmSignal);
+ generalCategory.removePreference(mStatusBarCmSignal);
}
if (Utils.isTablet(getActivity())) {
- mPrefCategoryGeneral.removePreference(mStatusBarBrightnessControl);
+ generalCategory.removePreference(mStatusBarBrightnessControl);
}
-
}
+ @Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
+ ContentResolver resolver = getActivity().getContentResolver();
if (mStatusBarAmPm != null && preference == mStatusBarAmPm) {
int statusBarAmPm = Integer.valueOf((String) newValue);
int index = mStatusBarAmPm.findIndexOfValue((String) newValue);
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_AM_PM, statusBarAmPm);
+ Settings.System.putInt(resolver, Settings.System.STATUS_BAR_AM_PM, statusBarAmPm);
mStatusBarAmPm.setSummary(mStatusBarAmPm.getEntries()[index]);
return true;
} else if (preference == mStatusBarBattery) {
int statusBarBattery = Integer.valueOf((String) newValue);
int index = mStatusBarBattery.findIndexOfValue((String) newValue);
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_BATTERY, statusBarBattery);
+ Settings.System.putInt(resolver, Settings.System.STATUS_BAR_BATTERY, statusBarBattery);
mStatusBarBattery.setSummary(mStatusBarBattery.getEntries()[index]);
return true;
} else if (preference == mStatusBarCmSignal) {
int signalStyle = Integer.valueOf((String) newValue);
int index = mStatusBarCmSignal.findIndexOfValue((String) newValue);
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_SIGNAL_TEXT, signalStyle);
+ Settings.System.putInt(resolver, Settings.System.STATUS_BAR_SIGNAL_TEXT, signalStyle);
mStatusBarCmSignal.setSummary(mStatusBarCmSignal.getEntries()[index]);
return true;
- }
- return false;
- }
-
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- boolean value;
-
- if (preference == mStatusBarClock) {
- value = mStatusBarClock.isChecked();
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_CLOCK, value ? 1 : 0);
+ } else if (preference == mStatusBarClock) {
+ boolean value = (Boolean) newValue;
+ Settings.System.putInt(resolver, Settings.System.STATUS_BAR_CLOCK, value ? 1 : 0);
return true;
} else if (preference == mStatusBarBrightnessControl) {
- value = mStatusBarBrightnessControl.isChecked();
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
+ boolean value = (Boolean) newValue;
+ Settings.System.putInt(resolver,
Settings.System.STATUS_BAR_BRIGHTNESS_CONTROL, value ? 1 : 0);
return true;
} else if (preference == mStatusBarNotifCount) {
- value = mStatusBarNotifCount.isChecked();
- Settings.System.putInt(getActivity().getApplicationContext().getContentResolver(),
- Settings.System.STATUS_BAR_NOTIF_COUNT, value ? 1 : 0);
+ boolean value = (Boolean) newValue;
+ Settings.System.putInt(resolver, Settings.System.STATUS_BAR_NOTIF_COUNT, value ? 1 : 0);
return true;
}
+
return false;
}
}