From 4deaebc5a988eb83440693721f1ab28b180d8779 Mon Sep 17 00:00:00 2001 From: uabdullah Date: Mon, 22 Jan 2018 18:19:07 -0800 Subject: Move legacy voicemail/error to nui voicemail/listui/error All packages relating to NUI voicemail should be under third_party/java_src/android_app/dialer/java/com/android/dialer/voicemail/listui. Since there is a chance that during NUI development the legacy third_party/java_src/android_app/dialer/java/com/android/dialer/app/voicemail/error might undergo changes, it makes sense to move this package to the nui, so that no changes in the legacy code are missed for nui. This refactoring would also allow us to ensure that the strings do not need to be translated and that most of the code can be re-used for nui by hooking up the fragment and adapter to voicemail/listui/error. Bug: 71700117 Test: Unit tests PiperOrigin-RevId: 182868896 Change-Id: I23329654df5ce2bf612101708ed001ca308ae1ac --- .../app/voicemail/error/VoicemailErrorMessage.java | 256 --------------------- 1 file changed, 256 deletions(-) delete mode 100644 java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java (limited to 'java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java') diff --git a/java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java b/java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java deleted file mode 100644 index be7dccda8..000000000 --- a/java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.dialer.app.voicemail.error; - -import android.content.Context; -import android.content.Intent; -import android.provider.Settings; -import android.provider.VoicemailContract; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.telecom.PhoneAccountHandle; -import android.view.View; -import android.view.View.OnClickListener; -import com.android.dialer.callintent.CallInitiationType; -import com.android.dialer.callintent.CallIntentBuilder; -import com.android.dialer.common.Assert; -import com.android.dialer.common.PerAccountSharedPreferences; -import com.android.dialer.logging.DialerImpression; -import com.android.dialer.logging.Logger; -import com.android.dialer.precall.PreCall; -import com.android.dialer.voicemail.settings.VoicemailChangePinActivity; -import com.android.voicemail.VoicemailClient; -import com.android.voicemail.VoicemailComponent; -import java.util.Arrays; -import java.util.List; - -/** - * Represents an error determined from the current {@link - * android.provider.VoicemailContract.Status}. The message will contain a title, a description, and - * a list of actions that can be performed. - */ -public class VoicemailErrorMessage { - - private final CharSequence title; - private final CharSequence description; - private final List actions; - - private boolean modal; - private Integer imageResourceId; - - /** Something the user can click on to resolve an error, such as retrying or calling voicemail */ - public static class Action { - - private final CharSequence text; - private final View.OnClickListener listener; - private final boolean raised; - - public Action(CharSequence text, View.OnClickListener listener) { - this(text, listener, false); - } - - public Action(CharSequence text, View.OnClickListener listener, boolean raised) { - this.text = text; - this.listener = listener; - this.raised = raised; - } - - public CharSequence getText() { - return text; - } - - public View.OnClickListener getListener() { - return listener; - } - - public boolean isRaised() { - return raised; - } - } - - public CharSequence getTitle() { - return title; - } - - public CharSequence getDescription() { - return description; - } - - @Nullable - public List getActions() { - return actions; - } - - public boolean isModal() { - return modal; - } - - public VoicemailErrorMessage setModal(boolean value) { - modal = value; - return this; - } - - @Nullable - public Integer getImageResourceId() { - return imageResourceId; - } - - public VoicemailErrorMessage setImageResourceId(Integer imageResourceId) { - this.imageResourceId = imageResourceId; - return this; - } - - public VoicemailErrorMessage(CharSequence title, CharSequence description, Action... actions) { - this(title, description, Arrays.asList(actions)); - } - - public VoicemailErrorMessage( - CharSequence title, CharSequence description, @Nullable List actions) { - this.title = title; - this.description = description; - this.actions = actions; - } - - @NonNull - public static Action createChangeAirplaneModeAction(final Context context) { - return new Action( - context.getString(R.string.voicemail_action_turn_off_airplane_mode), - new OnClickListener() { - @Override - public void onClick(View v) { - Logger.get(context) - .logImpression(DialerImpression.Type.VVM_CHANGE_AIRPLANE_MODE_CLICKED); - Intent intent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS); - context.startActivity(intent); - } - }); - } - - @NonNull - public static Action createSetPinAction( - final Context context, PhoneAccountHandle phoneAccountHandle) { - return new Action( - context.getString(R.string.voicemail_action_set_pin), - new OnClickListener() { - @Override - public void onClick(View v) { - Logger.get(context) - .logImpression(DialerImpression.Type.VOICEMAIL_ALERT_SET_PIN_CLICKED); - Intent intent = new Intent(VoicemailChangePinActivity.ACTION_CHANGE_PIN); - intent.putExtra(VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE, phoneAccountHandle); - context.startActivity(intent); - } - }); - } - - @NonNull - public static Action createCallVoicemailAction( - final Context context, final PhoneAccountHandle phoneAccountHandle) { - return new Action( - context.getString(R.string.voicemail_action_call_voicemail), - new OnClickListener() { - @Override - public void onClick(View v) { - Logger.get(context).logImpression(DialerImpression.Type.VVM_CALL_VOICEMAIL_CLICKED); - PreCall.start( - context, - CallIntentBuilder.forVoicemail( - phoneAccountHandle, CallInitiationType.Type.VOICEMAIL_ERROR_MESSAGE)); - } - }); - } - - @NonNull - public static Action createSyncAction(final Context context, final VoicemailStatus status) { - return new Action( - context.getString(R.string.voicemail_action_sync), - new OnClickListener() { - @Override - public void onClick(View v) { - Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_SYNC); - Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL); - intent.setPackage(status.sourcePackage); - context.sendBroadcast(intent); - } - }); - } - - @NonNull - public static Action createRetryAction(final Context context, final VoicemailStatus status) { - return new Action( - context.getString(R.string.voicemail_action_retry), - new OnClickListener() { - @Override - public void onClick(View v) { - Logger.get(context).logImpression(DialerImpression.Type.VVM_USER_RETRY); - Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL); - intent.setPackage(status.sourcePackage); - context.sendBroadcast(intent); - } - }); - } - - @NonNull - public static Action createTurnArchiveOnAction( - final Context context, - DialerImpression.Type impressionToLog, - final VoicemailStatus status, - VoicemailStatusReader statusReader, - VoicemailClient voicemailClient, - PhoneAccountHandle phoneAccountHandle) { - return new Action( - context.getString(R.string.voicemail_action_turn_archive_on), - new OnClickListener() { - @Override - public void onClick(View v) { - Assert.checkArgument( - VoicemailComponent.get(context) - .getVoicemailClient() - .isVoicemailArchiveAvailable(context)); - Logger.get(context).logImpression(impressionToLog); - voicemailClient.setVoicemailArchiveEnabled(context, phoneAccountHandle, true); - Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL); - intent.setPackage(status.sourcePackage); - context.sendBroadcast(intent); - statusReader.refresh(); - } - }); - } - - @NonNull - public static Action createDismissTurnArchiveOnAction( - final Context context, - DialerImpression.Type impressionToLog, - VoicemailStatusReader statusReader, - PerAccountSharedPreferences sharedPreferenceForAccount, - String preferenceKeyToUpdate) { - return new Action( - context.getString(R.string.voicemail_action_dimiss), - new OnClickListener() { - @Override - public void onClick(View v) { - Assert.checkArgument( - VoicemailComponent.get(context) - .getVoicemailClient() - .isVoicemailArchiveAvailable(context)); - Logger.get(context).logImpression(impressionToLog); - sharedPreferenceForAccount.edit().putBoolean(preferenceKeyToUpdate, true).apply(); - statusReader.refresh(); - } - }); - } -} -- cgit v1.2.3