add a setting for the heads up: app part
Bug: 13208692
Depends-On: I6847f7a5f275aee2f608de0237dab0e45c39b33f
Change-Id: Ia410a473492aa7637449ba5a5dc068f98618ad03
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7a36ccc..b8a4a19 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1753,6 +1753,10 @@
<string name="notification_sound_title">Default notification sound</string>
<!-- Sound settings screen, notification light repeat pulsing title -->
<string name="notification_pulse_title">Pulse notification light</string>
+ <!-- Display settings screen, notification popups are enabled [CHAR LIMIT=30] -->
+ <string name="heads_up_enabled_title">Heads Up Notifications</string>
+ <!-- Display settings screen, notification popups are explained [CHAR LIMIT=45]-->
+ <string name="heads_up_enabled_summary">Important notifications will pop up</string>
<!-- Sound settings screen, the title of the volume bar to adjust the incoming call volume -->
<string name="incoming_call_volume_title">Ringtone</string>
<!-- Sound settings screen, the title of the volume bar to adjust the notification volume -->
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index a9506e8..53d9915 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -53,6 +53,12 @@
android:title="@string/notification_pulse_title"
android:persistent="false" />
+ <CheckBoxPreference
+ android:key="heads_up"
+ android:title="@string/heads_up_enabled_title"
+ android:summary="@string/heads_up_enabled_summary"
+ android:persistent="false" />
+
<PreferenceScreen
android:key="wifi_display"
android:title="@string/wifi_display_settings_title"
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index ab00a0d..06bd3b0 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -25,7 +25,9 @@
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.database.ContentObserver;
import android.os.Bundle;
+import android.os.Handler;
import android.os.RemoteException;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
@@ -51,6 +53,7 @@
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
private static final String KEY_FONT_SIZE = "font_size";
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
+ private static final String KEY_HEADS_UP = "heads_up";
private static final String KEY_SCREEN_SAVER = "screensaver";
private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
@@ -59,14 +62,16 @@
private CheckBoxPreference mNotificationPulse;
private final Configuration mCurConfig = new Configuration();
+ private final Handler mHandler = new Handler();
private ListPreference mScreenTimeoutPreference;
private Preference mScreenSaverPreference;
+ private CheckBoxPreference mHeadsUp;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- ContentResolver resolver = getActivity().getContentResolver();
+ final ContentResolver resolver = getActivity().getContentResolver();
addPreferencesFromResource(R.xml.display_settings);
@@ -102,6 +107,19 @@
Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found");
}
}
+ mHeadsUp = (CheckBoxPreference) findPreference(KEY_HEADS_UP);
+ if (mHeadsUp != null) {
+ updateHeadsUpMode(resolver);
+ mHeadsUp.setOnPreferenceChangeListener(this);
+ resolver.registerContentObserver(
+ Settings.Global.getUriFor(Settings.Global.HEADS_UP),
+ false, new ContentObserver(mHandler) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updateHeadsUpMode(resolver);
+ }
+ });
+ }
}
private void updateTimeoutPreferenceDescription(long currentTimeout) {
@@ -235,6 +253,16 @@
}
}
+ private void updateHeadsUpMode(ContentResolver resolver) {
+ mHeadsUp.setChecked(Settings.Global.HEADS_UP_ON == Settings.Global.getInt(resolver,
+ Settings.Global.HEADS_UP, Settings.Global.HEADS_UP_OFF));
+ }
+
+ private void setHeadsUpMode(ContentResolver resolver, boolean value) {
+ Settings.Global.putInt(resolver, Settings.Global.HEADS_UP,
+ value ? Settings.Global.HEADS_UP_ON : Settings.Global.HEADS_UP_OFF);
+ }
+
public void writeFontSizePreference(Object objValue) {
try {
mCurConfig.fontScale = Float.parseFloat(objValue.toString());
@@ -252,6 +280,12 @@
value ? 1 : 0);
return true;
}
+ if (preference == mHeadsUp) {
+ final boolean value = mHeadsUp.isChecked();
+ Log.d(TAG, "onPreferenceTreeClick mHeadsUp: " + value);
+ setHeadsUpMode(getContentResolver(), value);
+ return true;
+ }
return super.onPreferenceTreeClick(preferenceScreen, preference);
}