Loading res/values/strings.xml +4 −29 Original line number Diff line number Diff line Loading @@ -476,7 +476,7 @@ <string name="preferences_general_title">Calendar view setting</string> <!-- This is the title of a section in the Settings screen for settings related to reminders for calendar events --> <string name="preferences_reminder_title">Reminder settings</string> <string name="preferences_reminder_title">Notifications \u0026 reminders</string> <!-- Settings check box label to hide events that the user has declined to attend --> <string name="preferences_hide_declined_title">Hide declined events</string> <!-- Settings week start label to start week on specific day--> Loading @@ -495,8 +495,10 @@ <string name="preferences_alerts_title">Notifications</string> <!-- Settings dialog label that specifies when the phone should vibrate --> <string name="preferences_alerts_vibrateWhen_title">Vibrate</string> <!-- The old value for enabling vibration. used only for migrating --> <string translatable="false" name="prefDefault_alerts_vibrate_true">always</string> <!-- Title of ringtone selector dialog --> <string name="preferences_alerts_ringtone_title">Choose ringtone</string> <string name="preferences_alerts_ringtone_title">Sound</string> <!-- Title of check box label to enable or disable pop-up notifications --> <string name="preferences_alerts_popup_title">Pop-up notification</string> <!-- List item label for setting the default number of reminder minutes --> Loading @@ -523,33 +525,6 @@ <!-- Build version of the application --> <string name="preferences_build_version">Build version</string> <!-- The vibrate notification modes --> <string-array name="prefEntries_alerts_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_alerts_vibrateWhen">never</string> <!-- The value to use then migrating from old versions for a true vibrate setting --> <string translatable="false" name="prefDefault_alerts_vibrate_true">always</string> <!-- The value to use then migrating from old versions for a false vibrate setting --> <string translatable="false" name="prefDefault_alerts_vibrate_false">never</string> <!-- The vibrateWhen values --> <string-array translatable="false" name="prefValues_alerts_vibrateWhen"> <item>always</item> <item>silent</item> <item>never</item> </string-array> <!-- Dialog title for the Vibrate dialog --> <string name="prefDialogTitle_vibrateWhen">Vibrate</string> <!-- Widget --> <skip/> <!-- Title for calendar gadget when displayed in list of all other gadgets --> Loading res/xml/general_preferences.xml +3 −6 Original line number Diff line number Diff line Loading @@ -64,14 +64,11 @@ android:ringtoneType="notification" android:defaultValue="content://settings/system/notification_sound" /> <ListPreference <CheckBoxPreference android:layout="?android:attr/preferenceLayoutChild" android:key="preferences_alerts_vibrateWhen" android:key="preferences_alerts_vibrate" android:title="@string/preferences_alerts_vibrateWhen_title" android:entries="@array/prefEntries_alerts_vibrateWhen" android:entryValues="@array/prefValues_alerts_vibrateWhen" android:defaultValue="@string/prefDefault_alerts_vibrateWhen" android:dialogTitle="@string/prefDialogTitle_vibrateWhen" /> android:defaultValue="false" /> <CheckBoxPreference android:layout="?android:attr/preferenceLayoutChild" Loading src/com/android/calendar/GeneralPreferences.java +41 −27 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.os.Vibrator; import android.preference.CheckBoxPreference; Loading Loading @@ -59,7 +62,6 @@ public class GeneralPreferences extends PreferenceFragment implements public static final String KEY_ALERTS_CATEGORY = "preferences_alerts_category"; public static final String KEY_ALERTS = "preferences_alerts"; public static final String KEY_ALERTS_VIBRATE = "preferences_alerts_vibrate"; public static final String KEY_ALERTS_VIBRATE_WHEN = "preferences_alerts_vibrateWhen"; public static final String KEY_ALERTS_RINGTONE = "preferences_alerts_ringtone"; public static final String KEY_ALERTS_POPUP = "preferences_alerts_popup"; Loading Loading @@ -102,7 +104,7 @@ public class GeneralPreferences extends PreferenceFragment implements public static final boolean DEFAULT_SHOW_WEEK_NUM = false; CheckBoxPreference mAlert; ListPreference mVibrateWhen; CheckBoxPreference mVibrate; RingtonePreference mRingtone; CheckBoxPreference mPopup; CheckBoxPreference mUseHomeTZ; Loading Loading @@ -141,17 +143,21 @@ public class GeneralPreferences extends PreferenceFragment implements final PreferenceScreen preferenceScreen = getPreferenceScreen(); mAlert = (CheckBoxPreference) preferenceScreen.findPreference(KEY_ALERTS); mVibrateWhen = (ListPreference) preferenceScreen.findPreference(KEY_ALERTS_VIBRATE_WHEN); mVibrate = (CheckBoxPreference) preferenceScreen.findPreference(KEY_ALERTS_VIBRATE); Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); if (vibrator == null || !vibrator.hasVibrator()) { PreferenceCategory mAlertGroup = (PreferenceCategory) preferenceScreen .findPreference(KEY_ALERTS_CATEGORY); mAlertGroup.removePreference(mVibrateWhen); } else { mVibrateWhen.setSummary(mVibrateWhen.getEntry()); mAlertGroup.removePreference(mVibrate); } mRingtone = (RingtonePreference) preferenceScreen.findPreference(KEY_ALERTS_RINGTONE); String ringToneUri = Utils.getSharedPreference(activity, KEY_ALERTS_RINGTONE, ""); if (!TextUtils.isEmpty(ringToneUri)) { String ringtone = getRingtoneTitleFromUri(getActivity(), ringToneUri); mRingtone.setSummary(ringtone == null ? "" : ringtone); } mPopup = (CheckBoxPreference) preferenceScreen.findPreference(KEY_ALERTS_POPUP); mUseHomeTZ = (CheckBoxPreference) preferenceScreen.findPreference(KEY_HOME_TZ_ENABLED); mHideDeclined = (CheckBoxPreference) preferenceScreen.findPreference(KEY_HIDE_DECLINED); Loading Loading @@ -181,8 +187,8 @@ public class GeneralPreferences extends PreferenceFragment implements } @Override public void onResume() { super.onResume(); public void onStart() { super.onStart(); getPreferenceScreen().getSharedPreferences() .registerOnSharedPreferenceChangeListener(this); setPreferenceListeners(this); Loading @@ -199,16 +205,15 @@ public class GeneralPreferences extends PreferenceFragment implements mDefaultReminder.setOnPreferenceChangeListener(listener); mRingtone.setOnPreferenceChangeListener(listener); mHideDeclined.setOnPreferenceChangeListener(listener); mVibrateWhen.setOnPreferenceChangeListener(listener); mVibrate.setOnPreferenceChangeListener(listener); } @Override public void onPause() { super.onPause(); public void onStop() { getPreferenceScreen().getSharedPreferences() .unregisterOnSharedPreferenceChangeListener(this); setPreferenceListeners(null); super.onStop(); } @Override Loading Loading @@ -266,17 +271,32 @@ public class GeneralPreferences extends PreferenceFragment implements mDefaultReminder.setValue((String) newValue); mDefaultReminder.setSummary(mDefaultReminder.getEntry()); } else if (preference == mRingtone) { // TODO update this after b/3417832 is fixed if (newValue instanceof String) { String ringtone = getRingtoneTitleFromUri(getActivity(), (String) newValue); mRingtone.setSummary(ringtone == null ? "" : ringtone); } return true; } else if (preference == mVibrate) { mVibrate.setChecked((Boolean) newValue); return true; } else if (preference == mVibrateWhen) { mVibrateWhen.setValue((String)newValue); mVibrateWhen.setSummary(mVibrateWhen.getEntry()); } else { return true; } return false; } public String getRingtoneTitleFromUri(Context context, String uri) { if (TextUtils.isEmpty(uri)) { return null; } Ringtone ring = RingtoneManager.getRingtone(getActivity(), Uri.parse(uri)); if (ring != null) { return ring.getTitle(context); } return null; } /** * If necessary, upgrades previous versions of preferences to the current * set of keys and values. Loading @@ -284,13 +304,9 @@ public class GeneralPreferences extends PreferenceFragment implements */ private void migrateOldPreferences(SharedPreferences prefs) { // If needed, migrate vibration setting from a previous version if (!prefs.contains(KEY_ALERTS_VIBRATE_WHEN) && prefs.contains(KEY_ALERTS_VIBRATE)) { int stringId = prefs.getBoolean(KEY_ALERTS_VIBRATE, false) ? R.string.prefDefault_alerts_vibrate_true : R.string.prefDefault_alerts_vibrate_false; mVibrateWhen.setValue(getActivity().getString(stringId)); } mVibrate.setChecked(Utils.getDefaultVibrate(getActivity(), prefs)); // If needed, migrate the old alerts type settin if (!prefs.contains(KEY_ALERTS) && prefs.contains(KEY_ALERTS_TYPE)) { String type = prefs.getString(KEY_ALERTS_TYPE, ALERT_TYPE_STATUS_BAR); Loading Loading @@ -319,13 +335,11 @@ public class GeneralPreferences extends PreferenceFragment implements */ private void updateChildPreferences() { if (mAlert.isChecked()) { mVibrateWhen.setEnabled(true); mVibrate.setEnabled(true); mRingtone.setEnabled(true); mPopup.setEnabled(true); } else { mVibrateWhen.setValue( getActivity().getString(R.string.prefDefault_alerts_vibrate_false)); mVibrateWhen.setEnabled(false); mVibrate.setEnabled(false); mRingtone.setEnabled(false); mPopup.setEnabled(false); } Loading src/com/android/calendar/Utils.java +22 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,8 @@ public class Utils { public static final String KEY_QUICK_RESPONSES = "preferences_quick_responses"; public static final String KEY_ALERTS_VIBRATE_WHEN = "preferences_alerts_vibrateWhen"; public static final String APPWIDGET_DATA_TYPE = "vnd.android.data/update"; static final String MACHINE_GENERATED_ADDRESS = "calendar.google.com"; Loading Loading @@ -242,6 +244,26 @@ public class Utils { return mTZUtils.formatDateRange(context, startMillis, endMillis, flags); } public static boolean getDefaultVibrate(Context context, SharedPreferences prefs) { boolean vibrate; if (prefs.contains(KEY_ALERTS_VIBRATE_WHEN)) { // Migrate setting to new 4.2 behavior // // silent and never -> off // always -> on String vibrateWhen = prefs.getString(KEY_ALERTS_VIBRATE_WHEN, null); vibrate = vibrateWhen != null && vibrateWhen.equals(context .getString(R.string.prefDefault_alerts_vibrate_true)); prefs.edit().remove(KEY_ALERTS_VIBRATE_WHEN).commit(); Log.d(TAG, "Migrating KEY_ALERTS_VIBRATE_WHEN(" + vibrateWhen + ") to KEY_ALERTS_VIBRATE = " + vibrate); } else { vibrate = prefs.getBoolean(GeneralPreferences.KEY_ALERTS_VIBRATE, false); } return vibrate; } public static String[] getSharedPreference(Context context, String key, String[] defaultValue) { SharedPreferences prefs = GeneralPreferences.getSharedPreferences(context); Set<String> ss = prefs.getStringSet(key, null); Loading src/com/android/calendar/alerts/AlertService.java +1 −49 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.media.AudioManager; import android.net.Uri; import android.os.Bundle; import android.os.Handler; Loading @@ -44,7 +43,6 @@ import android.text.format.Time; import android.util.Log; import com.android.calendar.GeneralPreferences; import com.android.calendar.R; import com.android.calendar.Utils; import java.util.ArrayList; Loading Loading @@ -585,7 +583,6 @@ public class AlertService extends Service { // Use app local storage to keep track of fired alerts to fix problem of multiple // installed calendar apps potentially causing missed alarms. boolean newAlertOverride = false; String alertIdStr = Long.toString(alertId); if (AlertUtils.BYPASS_DB && ((currentTime - alarmTime) / MINUTE_MS < 1)) { // To avoid re-firing alerts, only fire if alarmTime is very recent. Otherwise // we can get refires for non-dismissed alerts after app installation, or if the Loading Loading @@ -667,18 +664,6 @@ public class AlertService extends Service { } // TODO: Prefer accepted events in case of ties. int newStatus; switch (status) { case Attendees.ATTENDEE_STATUS_ACCEPTED: newStatus = 2; break; case Attendees.ATTENDEE_STATUS_TENTATIVE: newStatus = 1; break; default: newStatus = 0; } NotificationInfo newInfo = new NotificationInfo(eventName, location, description, beginTime, endTime, eventId, allDay, newAlert); Loading Loading @@ -911,40 +896,7 @@ public class AlertService extends Service { private boolean getDefaultVibrate() { if (defaultVibrate < 0) { // Find out the circumstances under which to vibrate. // Migrate from pre-Froyo boolean setting if necessary. String vibrateWhen; // "always" or "silent" or "never" if(prefs.contains(GeneralPreferences.KEY_ALERTS_VIBRATE_WHEN)) { // Look up Froyo setting vibrateWhen = prefs.getString(GeneralPreferences.KEY_ALERTS_VIBRATE_WHEN, null); } else if(prefs.contains(GeneralPreferences.KEY_ALERTS_VIBRATE)) { // No Froyo setting. Migrate pre-Froyo setting to new Froyo-defined value. boolean vibrate = prefs.getBoolean(GeneralPreferences.KEY_ALERTS_VIBRATE, false); vibrateWhen = vibrate ? context.getString(R.string.prefDefault_alerts_vibrate_true) : context.getString(R.string.prefDefault_alerts_vibrate_false); } else { // No setting. Use Froyo-defined default. vibrateWhen = context.getString(R.string.prefDefault_alerts_vibrateWhen); } if (vibrateWhen.equals("always")) { defaultVibrate = 1; } else if (!vibrateWhen.equals("silent")) { defaultVibrate = 0; } else { // Settings are to vibrate when silent. Return true if it is now silent. AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) { defaultVibrate = 1; } else { defaultVibrate = 0; } } defaultVibrate = Utils.getDefaultVibrate(context, prefs) ? 1 : 0; } return defaultVibrate == 1; } Loading Loading
res/values/strings.xml +4 −29 Original line number Diff line number Diff line Loading @@ -476,7 +476,7 @@ <string name="preferences_general_title">Calendar view setting</string> <!-- This is the title of a section in the Settings screen for settings related to reminders for calendar events --> <string name="preferences_reminder_title">Reminder settings</string> <string name="preferences_reminder_title">Notifications \u0026 reminders</string> <!-- Settings check box label to hide events that the user has declined to attend --> <string name="preferences_hide_declined_title">Hide declined events</string> <!-- Settings week start label to start week on specific day--> Loading @@ -495,8 +495,10 @@ <string name="preferences_alerts_title">Notifications</string> <!-- Settings dialog label that specifies when the phone should vibrate --> <string name="preferences_alerts_vibrateWhen_title">Vibrate</string> <!-- The old value for enabling vibration. used only for migrating --> <string translatable="false" name="prefDefault_alerts_vibrate_true">always</string> <!-- Title of ringtone selector dialog --> <string name="preferences_alerts_ringtone_title">Choose ringtone</string> <string name="preferences_alerts_ringtone_title">Sound</string> <!-- Title of check box label to enable or disable pop-up notifications --> <string name="preferences_alerts_popup_title">Pop-up notification</string> <!-- List item label for setting the default number of reminder minutes --> Loading @@ -523,33 +525,6 @@ <!-- Build version of the application --> <string name="preferences_build_version">Build version</string> <!-- The vibrate notification modes --> <string-array name="prefEntries_alerts_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_alerts_vibrateWhen">never</string> <!-- The value to use then migrating from old versions for a true vibrate setting --> <string translatable="false" name="prefDefault_alerts_vibrate_true">always</string> <!-- The value to use then migrating from old versions for a false vibrate setting --> <string translatable="false" name="prefDefault_alerts_vibrate_false">never</string> <!-- The vibrateWhen values --> <string-array translatable="false" name="prefValues_alerts_vibrateWhen"> <item>always</item> <item>silent</item> <item>never</item> </string-array> <!-- Dialog title for the Vibrate dialog --> <string name="prefDialogTitle_vibrateWhen">Vibrate</string> <!-- Widget --> <skip/> <!-- Title for calendar gadget when displayed in list of all other gadgets --> Loading
res/xml/general_preferences.xml +3 −6 Original line number Diff line number Diff line Loading @@ -64,14 +64,11 @@ android:ringtoneType="notification" android:defaultValue="content://settings/system/notification_sound" /> <ListPreference <CheckBoxPreference android:layout="?android:attr/preferenceLayoutChild" android:key="preferences_alerts_vibrateWhen" android:key="preferences_alerts_vibrate" android:title="@string/preferences_alerts_vibrateWhen_title" android:entries="@array/prefEntries_alerts_vibrateWhen" android:entryValues="@array/prefValues_alerts_vibrateWhen" android:defaultValue="@string/prefDefault_alerts_vibrateWhen" android:dialogTitle="@string/prefDialogTitle_vibrateWhen" /> android:defaultValue="false" /> <CheckBoxPreference android:layout="?android:attr/preferenceLayoutChild" Loading
src/com/android/calendar/GeneralPreferences.java +41 −27 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.os.Vibrator; import android.preference.CheckBoxPreference; Loading Loading @@ -59,7 +62,6 @@ public class GeneralPreferences extends PreferenceFragment implements public static final String KEY_ALERTS_CATEGORY = "preferences_alerts_category"; public static final String KEY_ALERTS = "preferences_alerts"; public static final String KEY_ALERTS_VIBRATE = "preferences_alerts_vibrate"; public static final String KEY_ALERTS_VIBRATE_WHEN = "preferences_alerts_vibrateWhen"; public static final String KEY_ALERTS_RINGTONE = "preferences_alerts_ringtone"; public static final String KEY_ALERTS_POPUP = "preferences_alerts_popup"; Loading Loading @@ -102,7 +104,7 @@ public class GeneralPreferences extends PreferenceFragment implements public static final boolean DEFAULT_SHOW_WEEK_NUM = false; CheckBoxPreference mAlert; ListPreference mVibrateWhen; CheckBoxPreference mVibrate; RingtonePreference mRingtone; CheckBoxPreference mPopup; CheckBoxPreference mUseHomeTZ; Loading Loading @@ -141,17 +143,21 @@ public class GeneralPreferences extends PreferenceFragment implements final PreferenceScreen preferenceScreen = getPreferenceScreen(); mAlert = (CheckBoxPreference) preferenceScreen.findPreference(KEY_ALERTS); mVibrateWhen = (ListPreference) preferenceScreen.findPreference(KEY_ALERTS_VIBRATE_WHEN); mVibrate = (CheckBoxPreference) preferenceScreen.findPreference(KEY_ALERTS_VIBRATE); Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); if (vibrator == null || !vibrator.hasVibrator()) { PreferenceCategory mAlertGroup = (PreferenceCategory) preferenceScreen .findPreference(KEY_ALERTS_CATEGORY); mAlertGroup.removePreference(mVibrateWhen); } else { mVibrateWhen.setSummary(mVibrateWhen.getEntry()); mAlertGroup.removePreference(mVibrate); } mRingtone = (RingtonePreference) preferenceScreen.findPreference(KEY_ALERTS_RINGTONE); String ringToneUri = Utils.getSharedPreference(activity, KEY_ALERTS_RINGTONE, ""); if (!TextUtils.isEmpty(ringToneUri)) { String ringtone = getRingtoneTitleFromUri(getActivity(), ringToneUri); mRingtone.setSummary(ringtone == null ? "" : ringtone); } mPopup = (CheckBoxPreference) preferenceScreen.findPreference(KEY_ALERTS_POPUP); mUseHomeTZ = (CheckBoxPreference) preferenceScreen.findPreference(KEY_HOME_TZ_ENABLED); mHideDeclined = (CheckBoxPreference) preferenceScreen.findPreference(KEY_HIDE_DECLINED); Loading Loading @@ -181,8 +187,8 @@ public class GeneralPreferences extends PreferenceFragment implements } @Override public void onResume() { super.onResume(); public void onStart() { super.onStart(); getPreferenceScreen().getSharedPreferences() .registerOnSharedPreferenceChangeListener(this); setPreferenceListeners(this); Loading @@ -199,16 +205,15 @@ public class GeneralPreferences extends PreferenceFragment implements mDefaultReminder.setOnPreferenceChangeListener(listener); mRingtone.setOnPreferenceChangeListener(listener); mHideDeclined.setOnPreferenceChangeListener(listener); mVibrateWhen.setOnPreferenceChangeListener(listener); mVibrate.setOnPreferenceChangeListener(listener); } @Override public void onPause() { super.onPause(); public void onStop() { getPreferenceScreen().getSharedPreferences() .unregisterOnSharedPreferenceChangeListener(this); setPreferenceListeners(null); super.onStop(); } @Override Loading Loading @@ -266,17 +271,32 @@ public class GeneralPreferences extends PreferenceFragment implements mDefaultReminder.setValue((String) newValue); mDefaultReminder.setSummary(mDefaultReminder.getEntry()); } else if (preference == mRingtone) { // TODO update this after b/3417832 is fixed if (newValue instanceof String) { String ringtone = getRingtoneTitleFromUri(getActivity(), (String) newValue); mRingtone.setSummary(ringtone == null ? "" : ringtone); } return true; } else if (preference == mVibrate) { mVibrate.setChecked((Boolean) newValue); return true; } else if (preference == mVibrateWhen) { mVibrateWhen.setValue((String)newValue); mVibrateWhen.setSummary(mVibrateWhen.getEntry()); } else { return true; } return false; } public String getRingtoneTitleFromUri(Context context, String uri) { if (TextUtils.isEmpty(uri)) { return null; } Ringtone ring = RingtoneManager.getRingtone(getActivity(), Uri.parse(uri)); if (ring != null) { return ring.getTitle(context); } return null; } /** * If necessary, upgrades previous versions of preferences to the current * set of keys and values. Loading @@ -284,13 +304,9 @@ public class GeneralPreferences extends PreferenceFragment implements */ private void migrateOldPreferences(SharedPreferences prefs) { // If needed, migrate vibration setting from a previous version if (!prefs.contains(KEY_ALERTS_VIBRATE_WHEN) && prefs.contains(KEY_ALERTS_VIBRATE)) { int stringId = prefs.getBoolean(KEY_ALERTS_VIBRATE, false) ? R.string.prefDefault_alerts_vibrate_true : R.string.prefDefault_alerts_vibrate_false; mVibrateWhen.setValue(getActivity().getString(stringId)); } mVibrate.setChecked(Utils.getDefaultVibrate(getActivity(), prefs)); // If needed, migrate the old alerts type settin if (!prefs.contains(KEY_ALERTS) && prefs.contains(KEY_ALERTS_TYPE)) { String type = prefs.getString(KEY_ALERTS_TYPE, ALERT_TYPE_STATUS_BAR); Loading Loading @@ -319,13 +335,11 @@ public class GeneralPreferences extends PreferenceFragment implements */ private void updateChildPreferences() { if (mAlert.isChecked()) { mVibrateWhen.setEnabled(true); mVibrate.setEnabled(true); mRingtone.setEnabled(true); mPopup.setEnabled(true); } else { mVibrateWhen.setValue( getActivity().getString(R.string.prefDefault_alerts_vibrate_false)); mVibrateWhen.setEnabled(false); mVibrate.setEnabled(false); mRingtone.setEnabled(false); mPopup.setEnabled(false); } Loading
src/com/android/calendar/Utils.java +22 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,8 @@ public class Utils { public static final String KEY_QUICK_RESPONSES = "preferences_quick_responses"; public static final String KEY_ALERTS_VIBRATE_WHEN = "preferences_alerts_vibrateWhen"; public static final String APPWIDGET_DATA_TYPE = "vnd.android.data/update"; static final String MACHINE_GENERATED_ADDRESS = "calendar.google.com"; Loading Loading @@ -242,6 +244,26 @@ public class Utils { return mTZUtils.formatDateRange(context, startMillis, endMillis, flags); } public static boolean getDefaultVibrate(Context context, SharedPreferences prefs) { boolean vibrate; if (prefs.contains(KEY_ALERTS_VIBRATE_WHEN)) { // Migrate setting to new 4.2 behavior // // silent and never -> off // always -> on String vibrateWhen = prefs.getString(KEY_ALERTS_VIBRATE_WHEN, null); vibrate = vibrateWhen != null && vibrateWhen.equals(context .getString(R.string.prefDefault_alerts_vibrate_true)); prefs.edit().remove(KEY_ALERTS_VIBRATE_WHEN).commit(); Log.d(TAG, "Migrating KEY_ALERTS_VIBRATE_WHEN(" + vibrateWhen + ") to KEY_ALERTS_VIBRATE = " + vibrate); } else { vibrate = prefs.getBoolean(GeneralPreferences.KEY_ALERTS_VIBRATE, false); } return vibrate; } public static String[] getSharedPreference(Context context, String key, String[] defaultValue) { SharedPreferences prefs = GeneralPreferences.getSharedPreferences(context); Set<String> ss = prefs.getStringSet(key, null); Loading
src/com/android/calendar/alerts/AlertService.java +1 −49 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.media.AudioManager; import android.net.Uri; import android.os.Bundle; import android.os.Handler; Loading @@ -44,7 +43,6 @@ import android.text.format.Time; import android.util.Log; import com.android.calendar.GeneralPreferences; import com.android.calendar.R; import com.android.calendar.Utils; import java.util.ArrayList; Loading Loading @@ -585,7 +583,6 @@ public class AlertService extends Service { // Use app local storage to keep track of fired alerts to fix problem of multiple // installed calendar apps potentially causing missed alarms. boolean newAlertOverride = false; String alertIdStr = Long.toString(alertId); if (AlertUtils.BYPASS_DB && ((currentTime - alarmTime) / MINUTE_MS < 1)) { // To avoid re-firing alerts, only fire if alarmTime is very recent. Otherwise // we can get refires for non-dismissed alerts after app installation, or if the Loading Loading @@ -667,18 +664,6 @@ public class AlertService extends Service { } // TODO: Prefer accepted events in case of ties. int newStatus; switch (status) { case Attendees.ATTENDEE_STATUS_ACCEPTED: newStatus = 2; break; case Attendees.ATTENDEE_STATUS_TENTATIVE: newStatus = 1; break; default: newStatus = 0; } NotificationInfo newInfo = new NotificationInfo(eventName, location, description, beginTime, endTime, eventId, allDay, newAlert); Loading Loading @@ -911,40 +896,7 @@ public class AlertService extends Service { private boolean getDefaultVibrate() { if (defaultVibrate < 0) { // Find out the circumstances under which to vibrate. // Migrate from pre-Froyo boolean setting if necessary. String vibrateWhen; // "always" or "silent" or "never" if(prefs.contains(GeneralPreferences.KEY_ALERTS_VIBRATE_WHEN)) { // Look up Froyo setting vibrateWhen = prefs.getString(GeneralPreferences.KEY_ALERTS_VIBRATE_WHEN, null); } else if(prefs.contains(GeneralPreferences.KEY_ALERTS_VIBRATE)) { // No Froyo setting. Migrate pre-Froyo setting to new Froyo-defined value. boolean vibrate = prefs.getBoolean(GeneralPreferences.KEY_ALERTS_VIBRATE, false); vibrateWhen = vibrate ? context.getString(R.string.prefDefault_alerts_vibrate_true) : context.getString(R.string.prefDefault_alerts_vibrate_false); } else { // No setting. Use Froyo-defined default. vibrateWhen = context.getString(R.string.prefDefault_alerts_vibrateWhen); } if (vibrateWhen.equals("always")) { defaultVibrate = 1; } else if (!vibrateWhen.equals("silent")) { defaultVibrate = 0; } else { // Settings are to vibrate when silent. Return true if it is now silent. AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) { defaultVibrate = 1; } else { defaultVibrate = 0; } } defaultVibrate = Utils.getDefaultVibrate(context, prefs) ? 1 : 0; } return defaultVibrate == 1; } Loading