diff options
Diffstat (limited to 'java/com/android/dialer/voicemail/settings')
-rw-r--r-- | java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java | 61 | ||||
-rw-r--r-- | java/com/android/dialer/voicemail/settings/res/values/strings.xml | 7 |
2 files changed, 59 insertions, 9 deletions
diff --git a/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java b/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java index aaa1e150d..5ae26f5f7 100644 --- a/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java +++ b/java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java @@ -14,6 +14,8 @@ package com.android.dialer.voicemail.settings; import android.annotation.TargetApi; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.Intent; import android.os.Build.VERSION_CODES; import android.os.Bundle; @@ -226,16 +228,13 @@ public class VoicemailSettingsFragment extends PreferenceFragment LogUtil.d(TAG, "onPreferenceChange: \"" + preference + "\" changed to \"" + objValue + "\""); if (preference.getKey().equals(voicemailVisualVoicemail.getKey())) { boolean isEnabled = (boolean) objValue; - voicemailClient.setVoicemailEnabled(getContext(), phoneAccountHandle, isEnabled); - - if (isEnabled) { - Logger.get(getContext()).logImpression(DialerImpression.Type.VVM_USER_ENABLED_IN_SETTINGS); + if (!isEnabled) { + showDisableConfirmationDialog(); + // Don't let the preference setting proceed. + return false; } else { - Logger.get(getContext()).logImpression(DialerImpression.Type.VVM_USER_DISABLED_IN_SETTINGS); + updateVoicemailEnabled(true); } - - updateChangePin(); - updateDonateVoicemail(); } else if (preference.getKey().equals(autoArchiveSwitchPreference.getKey())) { logArchiveToggle((boolean) objValue); voicemailClient.setVoicemailArchiveEnabled( @@ -246,10 +245,24 @@ public class VoicemailSettingsFragment extends PreferenceFragment getContext(), phoneAccountHandle, (boolean) objValue); } - // Always let the preference setting proceed. + // Let the preference setting proceed. return true; } + private void updateVoicemailEnabled(boolean isEnabled) { + voicemailClient.setVoicemailEnabled(getContext(), phoneAccountHandle, isEnabled); + voicemailVisualVoicemail.setChecked(isEnabled); + + if (isEnabled) { + Logger.get(getContext()).logImpression(DialerImpression.Type.VVM_USER_ENABLED_IN_SETTINGS); + } else { + Logger.get(getContext()).logImpression(DialerImpression.Type.VVM_USER_DISABLED_IN_SETTINGS); + } + + updateChangePin(); + updateDonateVoicemail(); + } + private void updateChangePin() { if (!voicemailClient.isVoicemailEnabled(getContext(), phoneAccountHandle)) { voicemailChangePinPreference.setSummary( @@ -305,4 +318,34 @@ public class VoicemailSettingsFragment extends PreferenceFragment .putExtra(Settings.EXTRA_CHANNEL_ID, channelId) .putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName()); } + + private void showDisableConfirmationDialog() { + LogUtil.i(TAG, "showDisableConfirmationDialog"); + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(R.string.confirm_disable_voicemail_dialog_title); + builder.setMessage(R.string.confirm_disable_voicemail_dialog_message); + builder.setPositiveButton( + R.string.confirm_disable_voicemail_accept_dialog_label, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + LogUtil.i(TAG, "showDisableConfirmationDialog, confirmed"); + updateVoicemailEnabled(false); + dialog.dismiss(); + } + }); + + builder.setNegativeButton( + android.R.string.cancel, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + LogUtil.i(TAG, "showDisableConfirmationDialog, cancelled"); + dialog.dismiss(); + } + }); + + builder.setCancelable(true); + builder.show(); + } } diff --git a/java/com/android/dialer/voicemail/settings/res/values/strings.xml b/java/com/android/dialer/voicemail/settings/res/values/strings.xml index 4e502b488..10fa459ff 100644 --- a/java/com/android/dialer/voicemail/settings/res/values/strings.xml +++ b/java/com/android/dialer/voicemail/settings/res/values/strings.xml @@ -118,4 +118,11 @@ <!-- Summary information for visual voicemail donation setting [CHAR LIMIT=NONE] --> <string name="voicemail_donate_preference_summary_info">Let Google review your voicemail messages to improve transcription quality</string> + <!-- Title for disable visual voicemail confirmation dialog [CHAR LIMIT=40] --> + <string name="confirm_disable_voicemail_dialog_title">Turn off visual voicemail</string> + <!-- Message explaining the implictions of disabling visual voicemail [CHAR LIMIT=NONE] --> + <string name="confirm_disable_voicemail_dialog_message">This will delete any voicemail and Google transcripts stored within this app. Your carrier may keep its own copies.</string> + <!-- The label for the confirm-disable-voicemail button [CHAR LIMIT=16] --> + <string name="confirm_disable_voicemail_accept_dialog_label">TURN OFF</string> + </resources> |