diff options
author | Eric Erfanian <erfanian@google.com> | 2017-06-19 12:40:59 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-06-19 20:00:08 +0000 |
commit | ea7890cd5e829ed3f0b5f726561c569690af2030 (patch) | |
tree | 235ab5ab9f9215782c29ef350d275fe12e7b2f74 /java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java | |
parent | 91ce7d2a476bd04fe525049a37a2f8b2824e9724 (diff) |
Update AOSP Dialer source from internal google3 repository at
cl/159428781.
Test: make, treehugger
This CL updates the AOSP Dialer source with all the changes that have
gone into the private google3 repository. This includes all the
changes from cl/158012278 (6/05/2017) to cl/159428781 (6/19/2017).
This goal of these drops is to keep the AOSP source in sync with the
internal google3 repository. Currently these sync are done by hand
with very minor modifications to the internal source code.
See the Android.mk file for list of modifications.
Our current goal is to do frequent drops (daily if possible) and
eventually switched to an automated process.
Merged-In: Ie60a84b3936efd0ea3d95d7c86bf96d2b1663030
Change-Id: If1fa394df2609f0d38b4f794c83f4db3f1006484
Diffstat (limited to 'java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java')
-rw-r--r-- | java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java | 150 |
1 files changed, 2 insertions, 148 deletions
diff --git a/java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java b/java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java index 132e8a328..e639eff23 100644 --- a/java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java +++ b/java/com/android/dialer/app/voicemail/error/Vvm3VoicemailMessageCreator.java @@ -16,32 +16,19 @@ package com.android.dialer.app.voicemail.error; -import android.app.AlertDialog; -import android.content.ComponentName; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; import android.net.Uri; import android.os.Build.VERSION_CODES; -import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; -import android.support.annotation.VisibleForTesting; -import android.telecom.PhoneAccountHandle; -import android.telephony.TelephonyManager; import android.view.View; import android.view.View.OnClickListener; -import com.android.contacts.common.compat.TelephonyManagerCompat; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.app.voicemail.error.VoicemailErrorMessage.Action; -import com.android.dialer.common.LogUtil; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; -import com.android.voicemail.VoicemailClient; -import com.android.voicemail.VoicemailComponent; -import java.util.Locale; /** * Create error message from {@link VoicemailStatus} for VVM3 visual voicemail. VVM3 is used only by @@ -84,15 +71,13 @@ public class Vvm3VoicemailMessageCreator { public static final int PIN_NOT_SET = -100; public static final int SUBSCRIBER_UNKNOWN = -99; - private static final String ISO639_SPANISH = "es"; - @VisibleForTesting static final String VVM3_TOS_ACCEPTANCE_FLAG_KEY = "vvm3_tos_acceptance_flag"; - @Nullable public static VoicemailErrorMessage create( final Context context, final VoicemailStatus status, final VoicemailStatusReader statusReader) { - VoicemailErrorMessage tosMessage = maybeShowTosMessage(context, status, statusReader); + VoicemailErrorMessage tosMessage = + new VoicemailTosMessageCreator(context, status, statusReader).maybeCreateTosMessage(); if (tosMessage != null) { return tosMessage; } @@ -299,135 +284,4 @@ public class Vvm3VoicemailMessageCreator { } }); } - - @Nullable - private static VoicemailErrorMessage maybeShowTosMessage( - final Context context, - final VoicemailStatus status, - final VoicemailStatusReader statusReader) { - final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - if (preferences.getBoolean(VVM3_TOS_ACCEPTANCE_FLAG_KEY, false)) { - return null; - } - Logger.get(context).logImpression(DialerImpression.Type.VOICEMAIL_VVM3_TOS_SHOWN); - - CharSequence termsAndConditions; - CharSequence acceptText; - CharSequence declineText; - // TODO(b/29082671): use LocaleList - if (Locale.getDefault().getLanguage().equals(new Locale(ISO639_SPANISH).getLanguage())) { - // Spanish - termsAndConditions = context.getString(R.string.verizon_terms_and_conditions_1_1_spanish); - acceptText = context.getString(R.string.verizon_terms_and_conditions_accept_spanish); - declineText = context.getString(R.string.verizon_terms_and_conditions_decline_spanish); - } else { - termsAndConditions = context.getString(R.string.verizon_terms_and_conditions_1_1_english); - acceptText = context.getString(R.string.verizon_terms_and_conditions_accept_english); - declineText = context.getString(R.string.verizon_terms_and_conditions_decline_english); - } - - return new VoicemailTosMessage( - context.getString(R.string.verizon_terms_and_conditions_title), - context.getString(R.string.verizon_terms_and_conditions_message, termsAndConditions), - new Action( - declineText, - new OnClickListener() { - @Override - public void onClick(View v) { - LogUtil.i("Vvm3VoicemailMessageCreator.maybeShowTosMessage", "decline clicked"); - PhoneAccountHandle handle = - new PhoneAccountHandle( - ComponentName.unflattenFromString(status.phoneAccountComponentName), - status.phoneAccountId); - Logger.get(context) - .logImpression(DialerImpression.Type.VOICEMAIL_VVM3_TOS_DECLINE_CLICKED); - showDeclineTosDialog(context, handle, status); - } - }), - new Action( - acceptText, - new OnClickListener() { - @Override - public void onClick(View v) { - LogUtil.i("Vvm3VoicemailMessageCreator.maybeShowTosMessage", "accept clicked"); - preferences.edit().putBoolean(VVM3_TOS_ACCEPTANCE_FLAG_KEY, true).apply(); - Logger.get(context) - .logImpression(DialerImpression.Type.VOICEMAIL_VVM3_TOS_ACCEPTED); - statusReader.refresh(); - } - }, - true /* raised */)) - .setModal(true); - } - - private static void showDeclineTosDialog( - final Context context, final PhoneAccountHandle handle, VoicemailStatus status) { - if (PIN_NOT_SET == status.configurationState) { - LogUtil.i( - "Vvm3VoicemailMessageCreator.showDeclineTosDialog", - "PIN_NOT_SET, showing set PIN dialog"); - showSetPinBeforeDeclineDialog(context); - return; - } - LogUtil.i( - "Vvm3VoicemailMessageCreator.showDeclineTosDialog", - "showing decline ToS dialog, status=" + status); - final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class); - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setMessage(R.string.verizon_terms_and_conditions_decline_dialog_message); - builder.setPositiveButton( - R.string.verizon_terms_and_conditions_decline_dialog_downgrade, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Logger.get(context).logImpression(DialerImpression.Type.VOICEMAIL_VVM3_TOS_DECLINED); - VoicemailClient voicemailClient = VoicemailComponent.get(context).getVoicemailClient(); - if (voicemailClient.isVoicemailModuleEnabled()) { - voicemailClient.setVoicemailEnabled(context, status.getPhoneAccountHandle(), false); - } else { - TelephonyManagerCompat.setVisualVoicemailEnabled(telephonyManager, handle, false); - } - } - }); - - builder.setNegativeButton( - android.R.string.cancel, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - - builder.setCancelable(true); - builder.show(); - } - - private static void showSetPinBeforeDeclineDialog(final Context context) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setMessage(R.string.verizon_terms_and_conditions_decline_set_pin_dialog_message); - builder.setPositiveButton( - R.string.verizon_terms_and_conditions_decline_set_pin_dialog_set_pin, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Logger.get(context) - .logImpression(DialerImpression.Type.VOICEMAIL_VVM3_TOS_DECLINE_CHANGE_PIN_SHOWN); - Intent intent = new Intent(TelephonyManager.ACTION_CONFIGURE_VOICEMAIL); - context.startActivity(intent); - } - }); - - builder.setNegativeButton( - android.R.string.cancel, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - - builder.setCancelable(true); - builder.show(); - } } |