add a setting for the heads up: app part
Bug: 13208692 Depends-On: I6847f7a5f275aee2f608de0237dab0e45c39b33f Change-Id: Ia410a473492aa7637449ba5a5dc068f98618ad03
This commit is contained in:
@@ -1753,6 +1753,10 @@
|
|||||||
<string name="notification_sound_title">Default notification sound</string>
|
<string name="notification_sound_title">Default notification sound</string>
|
||||||
<!-- Sound settings screen, notification light repeat pulsing title -->
|
<!-- Sound settings screen, notification light repeat pulsing title -->
|
||||||
<string name="notification_pulse_title">Pulse notification light</string>
|
<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 -->
|
<!-- Sound settings screen, the title of the volume bar to adjust the incoming call volume -->
|
||||||
<string name="incoming_call_volume_title">Ringtone</string>
|
<string name="incoming_call_volume_title">Ringtone</string>
|
||||||
<!-- Sound settings screen, the title of the volume bar to adjust the notification volume -->
|
<!-- Sound settings screen, the title of the volume bar to adjust the notification volume -->
|
||||||
|
@@ -53,6 +53,12 @@
|
|||||||
android:title="@string/notification_pulse_title"
|
android:title="@string/notification_pulse_title"
|
||||||
android:persistent="false" />
|
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
|
<PreferenceScreen
|
||||||
android:key="wifi_display"
|
android:key="wifi_display"
|
||||||
android:title="@string/wifi_display_settings_title"
|
android:title="@string/wifi_display_settings_title"
|
||||||
|
@@ -25,7 +25,9 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.database.ContentObserver;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.ListPreference;
|
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_SCREEN_TIMEOUT = "screen_timeout";
|
||||||
private static final String KEY_FONT_SIZE = "font_size";
|
private static final String KEY_FONT_SIZE = "font_size";
|
||||||
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
|
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 String KEY_SCREEN_SAVER = "screensaver";
|
||||||
|
|
||||||
private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
|
private static final int DLG_GLOBAL_CHANGE_WARNING = 1;
|
||||||
@@ -59,14 +62,16 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
private CheckBoxPreference mNotificationPulse;
|
private CheckBoxPreference mNotificationPulse;
|
||||||
|
|
||||||
private final Configuration mCurConfig = new Configuration();
|
private final Configuration mCurConfig = new Configuration();
|
||||||
|
private final Handler mHandler = new Handler();
|
||||||
|
|
||||||
private ListPreference mScreenTimeoutPreference;
|
private ListPreference mScreenTimeoutPreference;
|
||||||
private Preference mScreenSaverPreference;
|
private Preference mScreenSaverPreference;
|
||||||
|
private CheckBoxPreference mHeadsUp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
ContentResolver resolver = getActivity().getContentResolver();
|
final ContentResolver resolver = getActivity().getContentResolver();
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.display_settings);
|
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");
|
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) {
|
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) {
|
public void writeFontSizePreference(Object objValue) {
|
||||||
try {
|
try {
|
||||||
mCurConfig.fontScale = Float.parseFloat(objValue.toString());
|
mCurConfig.fontScale = Float.parseFloat(objValue.toString());
|
||||||
@@ -252,6 +280,12 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
value ? 1 : 0);
|
value ? 1 : 0);
|
||||||
return true;
|
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);
|
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user