summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Taylor <tomtaylor@google.com>2012-11-27 17:03:05 -0800
committerTom Taylor <tomtaylor@google.com>2012-11-27 17:03:05 -0800
commit90e32e59610d4a395716b1cfa9c8b041b45e3d4e (patch)
tree5e8b10a3a6a9aad47ddd782b3d051764b67b207a
parent24da6ee1d535d5d7aa1d43e1a386bb37048fbbc6 (diff)
downloadMms-90e32e59610d4a395716b1cfa9c8b041b45e3d4e.tar.gz
Change tri-state vibrate to single checkbox
Bug 7616158 Update strings and summaries to match the spec, as well. Removed now unused strings. Change-Id: I4858cb093db55fc38380926de27c92e38ff436e9
-rw-r--r--res/values/strings.xml30
-rw-r--r--res/xml/preferences.xml17
-rw-r--r--src/com/android/mms/transaction/MessagingNotification.java37
-rwxr-xr-xsrc/com/android/mms/ui/MessagingPreferenceActivity.java61
4 files changed, 57 insertions, 88 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cfd49209..7e1c01d5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -349,44 +349,20 @@
<string name="pref_title_mms_delete">Multimedia message limit</string>
<!-- Settings item for boolean option to display message notifications -->
<string name="pref_title_notification_enabled">Notifications</string>
- <!-- Settings item description for boolean message notification option -->
- <string name="pref_summary_notification_enabled">Display message notifications in status bar</string>
<!-- Settings item for boolean option to vibrate during message notification -->
<string name="pref_title_notification_vibrateWhen">Vibrate</string>
- <!-- Settings item description for boolean vibrate option -->
- <string name="pref_summary_notification_vibrateWhen">Also vibrate when notified</string>
<!-- Settings item for entering ringtone selection screen -->
- <string name="pref_title_notification_ringtone">Choose ringtone</string>
+ <string name="pref_title_notification_ringtone">Sound</string>
<!-- Settings item for setting the number of message to save for each conversation -->
<string name="pref_messages_to_save">Set number of messages to save</string>
+ <!-- Settings screen, what to display for Ringtone when the user chooses "silent" [CHAR LIMIT=100]-->
+ <string name="silent_ringtone">Silent</string>
- <!-- The vibrate notification modes -->
- <string-array name="prefEntries_vibrateWhen">
- <!-- Always -->
- <item>Always</item>
- <!-- Only when the phone is in Silent mode -->
- <item>Only when silent</item>
- <!-- Never -->
- <item>Never</item>
- </string-array>
-
- <!-- The default vibrateWhen value, when none is set -->
- <string translatable="false" name="prefDefault_vibrateWhen">never</string>
<!-- The value to use when migrating from old versions for a true vibrate setting -->
<string translatable="false" name="prefDefault_vibrate_true">always</string>
<!-- The value to use when migrating from old versions for a false vibrate setting -->
<string translatable="false" name="prefDefault_vibrate_false">never</string>
- <!-- The vibrateWhen values -->
- <string-array translatable="false" name="prefValues_vibrateWhen">
- <item>always</item>
- <item>silent</item>
- <item>never</item>
- </string-array>
-
- <!-- Dialog title for the Vibrate dialog -->
- <string name="prefDialogTitle_vibrateWhen">Vibrate</string>
-
<!-- Settings item for boolean option to auto-retrieve incoming MMS messages -->
<string name="pref_title_mms_auto_retrieval">Auto-retrieve</string>
<!-- Settings item description for boolean MMS auto-retrieve option -->
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index fd80c5a1..54ebb4b9 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -78,22 +78,15 @@
<PreferenceCategory android:title="@string/pref_notification_settings_title">
<CheckBoxPreference android:key="pref_key_enable_notifications"
android:title="@string/pref_title_notification_enabled"
- android:summary="@string/pref_summary_notification_enabled"
android:defaultValue="true" />
- <RingtonePreference android:layout="?android:attr/preferenceLayoutChild"
- android:dependency="pref_key_enable_notifications"
- android:key="pref_key_ringtone"
+ <RingtonePreference android:key="pref_key_ringtone"
android:title="@string/pref_title_notification_ringtone"
android:ringtoneType="notification"
- android:defaultValue="content://settings/system/notification_sound" />
- <ListPreference android:layout="?android:attr/preferenceLayoutChild"
android:dependency="pref_key_enable_notifications"
- android:key="pref_key_vibrateWhen"
- android:defaultValue="@string/prefDefault_vibrateWhen"
+ android:defaultValue="content://settings/system/notification_sound" />
+ <CheckBoxPreference android:key="pref_key_vibrate"
android:title="@string/pref_title_notification_vibrateWhen"
- android:summary="@string/pref_summary_notification_vibrateWhen"
- android:entries="@array/prefEntries_vibrateWhen"
- android:entryValues="@array/prefValues_vibrateWhen"
- android:dialogTitle="@string/prefDialogTitle_vibrateWhen" />
+ android:dependency="pref_key_enable_notifications"
+ android:defaultValue="false" />
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/mms/transaction/MessagingNotification.java b/src/com/android/mms/transaction/MessagingNotification.java
index 334707e6..e52ad3ff 100644
--- a/src/com/android/mms/transaction/MessagingNotification.java
+++ b/src/com/android/mms/transaction/MessagingNotification.java
@@ -893,27 +893,24 @@ public class MessagingNotification {
if (isNew) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
- String vibrateWhen;
- if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN)) {
- vibrateWhen =
- sp.getString(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN, null);
- } else if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE)) {
- vibrateWhen =
- sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE, false) ?
- context.getString(R.string.prefDefault_vibrate_true) :
- context.getString(R.string.prefDefault_vibrate_false);
- } else {
- vibrateWhen = context.getString(R.string.prefDefault_vibrateWhen);
- }
-
- boolean vibrateAlways = vibrateWhen.equals("always");
- boolean vibrateSilent = vibrateWhen.equals("silent");
- AudioManager audioManager =
- (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
- boolean nowSilent =
- audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE;
- if (vibrateAlways || vibrateSilent && nowSilent) {
+ boolean vibrate = false;
+ if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE)) {
+ // The most recent change to the vibrate preference is to store a boolean
+ // value in NOTIFICATION_VIBRATE. If prefs contain that preference, use that
+ // first.
+ vibrate = sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE,
+ false);
+ } else if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN)) {
+ // This is to support the pre-JellyBean MR1.1 version of vibrate preferences
+ // when vibrate was a tri-state setting. As soon as the user opens the Messaging
+ // app's settings, it will migrate this setting from NOTIFICATION_VIBRATE_WHEN
+ // to the boolean value stored in NOTIFICATION_VIBRATE.
+ String vibrateWhen =
+ sp.getString(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN, null);
+ vibrate = "always".equals(vibrateWhen);
+ }
+ if (vibrate) {
defaults |= Notification.DEFAULT_VIBRATE;
}
diff --git a/src/com/android/mms/ui/MessagingPreferenceActivity.java b/src/com/android/mms/ui/MessagingPreferenceActivity.java
index 1d498cb8..d1deb578 100755
--- a/src/com/android/mms/ui/MessagingPreferenceActivity.java
+++ b/src/com/android/mms/ui/MessagingPreferenceActivity.java
@@ -18,12 +18,16 @@
package com.android.mms.ui;
import android.app.ActionBar;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.media.Ringtone;
+import android.media.RingtoneManager;
+import android.net.Uri;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
@@ -33,6 +37,7 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
+import android.preference.RingtonePreference;
import android.provider.SearchRecentSuggestions;
import android.text.TextUtils;
import android.view.Menu;
@@ -76,14 +81,13 @@ public class MessagingPreferenceActivity extends PreferenceActivity
private Preference mMmsReadReportPref;
private Preference mManageSimPref;
private Preference mClearHistoryPref;
- private ListPreference mVibrateWhenPref;
+ private CheckBoxPreference mVibratePref;
private CheckBoxPreference mEnableNotificationsPref;
private CheckBoxPreference mMmsAutoRetrievialPref;
+ private RingtonePreference mRingtonePref;
private Recycler mSmsRecycler;
private Recycler mMmsRecycler;
private static final int CONFIRM_CLEAR_SEARCH_HISTORY_DIALOG = 3;
- private CharSequence[] mVibrateEntries;
- private CharSequence[] mVibrateValues;
@Override
protected void onCreate(Bundle icicle) {
@@ -118,10 +122,8 @@ public class MessagingPreferenceActivity extends PreferenceActivity
mClearHistoryPref = findPreference("pref_key_mms_clear_history");
mEnableNotificationsPref = (CheckBoxPreference) findPreference(NOTIFICATION_ENABLED);
mMmsAutoRetrievialPref = (CheckBoxPreference) findPreference(AUTO_RETRIEVAL);
- mVibrateWhenPref = (ListPreference) findPreference(NOTIFICATION_VIBRATE_WHEN);
-
- mVibrateEntries = getResources().getTextArray(R.array.prefEntries_vibrateWhen);
- mVibrateValues = getResources().getTextArray(R.array.prefValues_vibrateWhen);
+ mVibratePref = (CheckBoxPreference) findPreference(NOTIFICATION_VIBRATE);
+ mRingtonePref = (RingtonePreference) findPreference(NOTIFICATION_RINGTONE);
setMessagePreferences();
}
@@ -184,14 +186,18 @@ public class MessagingPreferenceActivity extends PreferenceActivity
setEnabledNotificationsPref();
- // If needed, migrate vibration setting from a previous version
+ // If needed, migrate vibration setting from the previous tri-state setting stored in
+ // NOTIFICATION_VIBRATE_WHEN to the boolean setting stored in NOTIFICATION_VIBRATE.
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
- if (!sharedPreferences.contains(NOTIFICATION_VIBRATE_WHEN) &&
- sharedPreferences.contains(NOTIFICATION_VIBRATE)) {
- int stringId = sharedPreferences.getBoolean(NOTIFICATION_VIBRATE, false) ?
- R.string.prefDefault_vibrate_true :
- R.string.prefDefault_vibrate_false;
- mVibrateWhenPref.setValue(getString(stringId));
+ if (sharedPreferences.contains(NOTIFICATION_VIBRATE_WHEN)) {
+ String vibrateWhen = sharedPreferences.
+ getString(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN, null);
+ boolean vibrate = "always".equals(vibrateWhen);
+ SharedPreferences.Editor prefsEditor = sharedPreferences.edit();
+ prefsEditor.putBoolean(NOTIFICATION_VIBRATE, vibrate);
+ prefsEditor.remove(NOTIFICATION_VIBRATE_WHEN); // remove obsolete setting
+ prefsEditor.apply();
+ mVibratePref.setChecked(vibrate);
}
mSmsRecycler = Recycler.getSmsRecycler();
@@ -201,7 +207,15 @@ public class MessagingPreferenceActivity extends PreferenceActivity
setSmsDisplayLimit();
setMmsDisplayLimit();
- adjustVibrateSummary(mVibrateWhenPref.getValue());
+ String soundValue = sharedPreferences.getString(NOTIFICATION_RINGTONE, null);
+ setRingtoneSummary(soundValue);
+ }
+
+ private void setRingtoneSummary(String soundValue) {
+ Uri soundUri = TextUtils.isEmpty(soundValue) ? null : Uri.parse(soundValue);
+ Ringtone tone = soundUri != null ? RingtoneManager.getRingtone(this, soundUri) : null;
+ mRingtonePref.setSummary(tone != null ? tone.getTitle(this)
+ : getResources().getString(R.string.silent_ringtone));
}
private void setEnabledNotificationsPref() {
@@ -345,29 +359,18 @@ public class MessagingPreferenceActivity extends PreferenceActivity
}
private void registerListeners() {
- mVibrateWhenPref.setOnPreferenceChangeListener(this);
+ mRingtonePref.setOnPreferenceChangeListener(this);
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean result = false;
- if (preference == mVibrateWhenPref) {
- adjustVibrateSummary((String)newValue);
+ if (preference == mRingtonePref) {
+ setRingtoneSummary((String)newValue);
result = true;
}
return result;
}
- private void adjustVibrateSummary(String value) {
- int len = mVibrateValues.length;
- for (int i = 0; i < len; i++) {
- if (mVibrateValues[i].equals(value)) {
- mVibrateWhenPref.setSummary(mVibrateEntries[i]);
- return;
- }
- }
- mVibrateWhenPref.setSummary(null);
- }
-
// For the group mms feature to be enabled, the following must be true:
// 1. the feature is enabled in mms_config.xml (currently on by default)
// 2. the feature is enabled in the mms settings page