diff options
author | mdooley <mdooley@google.com> | 2017-11-29 08:53:31 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-11-29 11:50:44 -0800 |
commit | b9ca335dbbc3325643549f6fbf2dac06a5502d26 (patch) | |
tree | 0145604277fbcf00e8bf48b835a5a9d7fb922e40 /java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java | |
parent | 00d18e0efe89d7bbd4c69de6988ef6f9a62df782 (diff) | |
download | android_packages_apps_Dialer-b9ca335dbbc3325643549f6fbf2dac06a5502d26.tar.gz android_packages_apps_Dialer-b9ca335dbbc3325643549f6fbf2dac06a5502d26.tar.bz2 android_packages_apps_Dialer-b9ca335dbbc3325643549f6fbf2dac06a5502d26.zip |
Delete voicemails when disabling visual voicemail
For privacy reasons we now delete all voicemails and transcriptions when
the user disables visual voicemail, (after confirming that they want to do this
via a dialog).
Note: we only delete voicemails whose source package is the google dialer.
Note: the voicemails will be re-downloaded and re-transcribed if the user re-enables visual voicemail
Bug: 69323147
Test: manual and unit test
PiperOrigin-RevId: 177315139
Change-Id: Ie04496dc5960b485794733fbf74f7f704e806023
Diffstat (limited to 'java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java')
-rw-r--r-- | java/com/android/dialer/voicemail/settings/VoicemailSettingsFragment.java | 61 |
1 files changed, 52 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(); + } } |