Search in sources :

Example 1 with VoicemailClient

use of com.android.voicemail.VoicemailClient in project android_packages_apps_Dialer by LineageOS.

the class VoicemailTosMessageCreator method showDeclineTosDialog.

private void showDeclineTosDialog(final PhoneAccountHandle handle) {
    if (isVvm3() && Vvm3VoicemailMessageCreator.PIN_NOT_SET == status.configurationState) {
        LogUtil.i("VoicemailTosMessageCreator.showDeclineTosDialog", "PIN_NOT_SET, showing set PIN dialog");
        showSetPinBeforeDeclineDialog();
        return;
    }
    LogUtil.i("VoicemailTosMessageCreator.showDeclineVerizonTosDialog", "showing decline ToS dialog, status=" + status);
    final TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(getTosDeclinedDialogMessageId());
    builder.setPositiveButton(getTosDeclinedDialogDowngradeId(), 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();
}
Also used : AlertDialog(android.app.AlertDialog) TelephonyManager(android.telephony.TelephonyManager) DialogInterface(android.content.DialogInterface) VoicemailClient(com.android.voicemail.VoicemailClient)

Example 2 with VoicemailClient

use of com.android.voicemail.VoicemailClient in project android_packages_apps_Dialer by LineageOS.

the class OmtpVoicemailMessageCreator method createInboxErrorMessage.

@Nullable
private static VoicemailErrorMessage createInboxErrorMessage(Context context, VoicemailStatus status, VoicemailStatusReader statusReader) {
    float voicemailOccupiedFraction = (float) status.quotaOccupied / (float) status.quotaTotal;
    if (voicemailOccupiedFraction < QUOTA_NEAR_FULL_THRESHOLD) {
        return null;
    }
    boolean isFull = voicemailOccupiedFraction >= QUOTA_FULL_THRESHOLD;
    PhoneAccountHandle phoneAccountHandle = status.getPhoneAccountHandle();
    PerAccountSharedPreferences sharedPreferenceForAccount = new PerAccountSharedPreferences(context, phoneAccountHandle, PreferenceManager.getDefaultSharedPreferences(context));
    VoicemailClient voicemailClient = VoicemailComponent.get(context).getVoicemailClient();
    boolean shouldShowPromoForArchive = !isPromoForArchiveDismissed(sharedPreferenceForAccount, isFull) && !voicemailClient.isVoicemailArchiveEnabled(context, phoneAccountHandle) && voicemailClient.isVoicemailArchiveAvailable(context);
    if (!shouldShowPromoForArchive) {
        if (isFull) {
            Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SHOWN_VM_FULL_ERROR_MESSAGE);
            return new VoicemailErrorMessage(context.getString(R.string.voicemail_error_inbox_full_title), context.getString(R.string.voicemail_error_inbox_full_message));
        } else {
            Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SHOWN_VM_ALMOST_FULL_ERROR_MESSAGE);
            return new VoicemailErrorMessage(context.getString(R.string.voicemail_error_inbox_near_full_title), context.getString(R.string.voicemail_error_inbox_near_full_message));
        }
    }
    String title;
    CharSequence message;
    DialerImpression.Type enabledImpression;
    DialerImpression.Type dismissedImpression;
    String dismissedKey;
    if (isFull) {
        Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SHOWN_VM_FULL_PROMO);
        title = context.getString(R.string.voicemail_error_inbox_full_turn_archive_on_title);
        message = context.getText(R.string.voicemail_error_inbox_full_turn_archive_on_message);
        enabledImpression = DialerImpression.Type.VVM_USER_ENABLED_ARCHIVE_FROM_VM_FULL_PROMO;
        dismissedImpression = DialerImpression.Type.VVM_USER_DISMISSED_VM_FULL_PROMO;
        dismissedKey = VOICEMAIL_PROMO_DISMISSED_KEY;
    } else {
        Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SHOWN_VM_ALMOST_FULL_PROMO);
        title = context.getString(R.string.voicemail_error_inbox_almost_full_turn_archive_on_title);
        message = context.getText(R.string.voicemail_error_inbox_almost_full_turn_archive_on_message);
        enabledImpression = DialerImpression.Type.VVM_USER_ENABLED_ARCHIVE_FROM_VM_ALMOST_FULL_PROMO;
        dismissedImpression = DialerImpression.Type.VVM_USER_DISMISSED_VM_ALMOST_FULL_PROMO;
        dismissedKey = VOICEMAIL_PROMO_ALMOST_FULL_DISMISSED_KEY;
    }
    return createVMQuotaPromo(context, phoneAccountHandle, status, statusReader, voicemailClient, sharedPreferenceForAccount, title, message, enabledImpression, dismissedImpression, dismissedKey);
}
Also used : PerAccountSharedPreferences(com.android.dialer.common.PerAccountSharedPreferences) PhoneAccountHandle(android.telecom.PhoneAccountHandle) VoicemailClient(com.android.voicemail.VoicemailClient) DialerImpression(com.android.dialer.logging.DialerImpression) Nullable(android.support.annotation.Nullable)

Aggregations

VoicemailClient (com.android.voicemail.VoicemailClient)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 Nullable (android.support.annotation.Nullable)1 PhoneAccountHandle (android.telecom.PhoneAccountHandle)1 TelephonyManager (android.telephony.TelephonyManager)1 PerAccountSharedPreferences (com.android.dialer.common.PerAccountSharedPreferences)1 DialerImpression (com.android.dialer.logging.DialerImpression)1