add a setting for the heads up: app part

Bug: 13208692
Depends-On: I6847f7a5f275aee2f608de0237dab0e45c39b33f
Change-Id: Ia410a473492aa7637449ba5a5dc068f98618ad03
This commit is contained in:
Chris Wren
2014-02-28 16:16:59 -05:00
parent 0f9ab45376
commit ad1b7eb398
3 changed files with 45 additions and 1 deletions

View File

@@ -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 -->

View File

@@ -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"

View File

@@ -25,7 +25,9 @@ import android.content.ContentResolver;
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 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
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 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
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 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
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 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
}
}
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 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
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);
}