diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-09 01:46:28 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-09 01:46:28 +0000 |
commit | 20ebcdca46e6be68050cd44087f0f768f5dae5c6 (patch) | |
tree | 5bc845fb459a8958ec9c5a055d12a84c92b23443 /java | |
parent | d806c2321eba63fa6d8f28471ab48847b8b6e92c (diff) | |
parent | 77c2b4c1711cee43b69d54bf180e14ccda70e92f (diff) |
Merge changes I220cb741,I471b2d19
* changes:
Add "Set up" and "Invite" for video to call log entry actions
Fix voicemail populator bug and change emergency call to emergency call back.
Diffstat (limited to 'java')
8 files changed, 123 insertions, 31 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index 4f78bc97f..f4565550a 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -828,65 +828,65 @@ public class CallLogAdapter extends GroupingListAdapter } private void loadAndRender( - final CallLogListItemViewHolder views, + final CallLogListItemViewHolder viewHolder, final long rowId, final PhoneCallDetails details, final CallDetailsEntries callDetailsEntries) { - LogUtil.d("CallLogAdapter.loadAndRender", "position: %d", views.getAdapterPosition()); + LogUtil.d("CallLogAdapter.loadAndRender", "position: %d", viewHolder.getAdapterPosition()); // Reset block and spam information since this view could be reused which may contain // outdated data. - views.isSpam = false; - views.blockId = null; - views.isSpamFeatureEnabled = false; + viewHolder.isSpam = false; + viewHolder.blockId = null; + viewHolder.isSpamFeatureEnabled = false; // Attempt to set the isCallComposerCapable field. If capabilities are unknown for this number, // the value will be false while capabilities are requested. mExpandCollapseListener will // attempt to set the field properly in that case - views.isCallComposerCapable = isCallComposerCapable(views.number); - views.setDetailedPhoneDetails(callDetailsEntries); - views.duoReady = getDuo().isReachable(mActivity, views.number); + viewHolder.isCallComposerCapable = isCallComposerCapable(viewHolder.number); + viewHolder.setDetailedPhoneDetails(callDetailsEntries); + viewHolder.duo = getDuo(); final AsyncTask<Void, Void, Boolean> loadDataTask = new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... params) { - views.blockId = + viewHolder.blockId = mFilteredNumberAsyncQueryHandler.getBlockedIdSynchronous( - views.number, views.countryIso); - details.isBlocked = views.blockId != null; + viewHolder.number, viewHolder.countryIso); + details.isBlocked = viewHolder.blockId != null; if (isCancelled()) { return false; } if (mIsSpamEnabled) { - views.isSpamFeatureEnabled = true; + viewHolder.isSpamFeatureEnabled = true; // Only display the call as a spam call if there are incoming calls in the list. // Call log cards with only outgoing calls should never be displayed as spam. - views.isSpam = + viewHolder.isSpam = details.hasIncomingCalls() && Spam.get(mActivity) - .checkSpamStatusSynchronous(views.number, views.countryIso); - details.isSpam = views.isSpam; + .checkSpamStatusSynchronous(viewHolder.number, viewHolder.countryIso); + details.isSpam = viewHolder.isSpam; } - return !isCancelled() && loadData(views, rowId, details); + return !isCancelled() && loadData(viewHolder, rowId, details); } @Override protected void onPostExecute(Boolean success) { - views.isLoaded = true; + viewHolder.isLoaded = true; if (success) { - views.callbackAction = getCallbackAction(views.rowId); - int currentDayGroup = getDayGroup(views.rowId); + viewHolder.callbackAction = getCallbackAction(viewHolder.rowId); + int currentDayGroup = getDayGroup(viewHolder.rowId); if (currentDayGroup != details.previousGroup) { - views.dayGroupHeaderVisibility = View.VISIBLE; - views.dayGroupHeaderText = getGroupDescription(currentDayGroup); + viewHolder.dayGroupHeaderVisibility = View.VISIBLE; + viewHolder.dayGroupHeaderText = getGroupDescription(currentDayGroup); } else { - views.dayGroupHeaderVisibility = View.GONE; + viewHolder.dayGroupHeaderVisibility = View.GONE; } - render(views, details, rowId); + render(viewHolder, details, rowId); } } }; - views.asyncTask = loadDataTask; + viewHolder.asyncTask = loadDataTask; mAsyncTaskExecutor.submit(LOAD_DATA_TASK_IDENTIFIER, loadDataTask); } diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index 26ca5bd26..a5a0cff21 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -78,6 +78,7 @@ import com.android.dialer.constants.ActivityRequestCodes; import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.dialercontact.SimDetails; +import com.android.dialer.duo.Duo; import com.android.dialer.duo.DuoConstants; import com.android.dialer.lettertile.LetterTileDrawable; import com.android.dialer.lettertile.LetterTileDrawable.ContactType; @@ -147,6 +148,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public View callButtonView; public View videoCallButtonView; + public View setUpVideoButtonView; + public View inviteVideoButtonView; public View createNewContactButtonView; public View addToExistingContactButtonView; public View sendMessageView; @@ -228,7 +231,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public boolean isSpam; public boolean isCallComposerCapable; - public boolean duoReady; + public Duo duo; private View.OnClickListener mExpandCollapseListener; private final OnActionModeStateChangedListener onActionModeStateChangedListener; @@ -466,6 +469,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder videoCallButtonView = actionsView.findViewById(R.id.video_call_action); videoCallButtonView.setOnClickListener(this); + setUpVideoButtonView = actionsView.findViewById(R.id.set_up_video_action); + setUpVideoButtonView.setOnClickListener(this); + + inviteVideoButtonView = actionsView.findViewById(R.id.invite_video_action); + inviteVideoButtonView.setOnClickListener(this); + createNewContactButtonView = actionsView.findViewById(R.id.create_new_contact_action); createNewContactButtonView.setOnClickListener(this); @@ -593,6 +602,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder // This saves us having to remember to set it to GONE in multiple places. callButtonView.setVisibility(View.GONE); videoCallButtonView.setVisibility(View.GONE); + setUpVideoButtonView.setVisibility(View.GONE); + inviteVideoButtonView.setVisibility(View.GONE); if (isFullyUndialableVoicemail()) { // Sometimes the voicemail server will report the message is from some non phone number @@ -665,9 +676,15 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder && (hasPlacedCarrierVideoCall() || canSupportCarrierVideoCall())) { videoCallButtonView.setTag(IntentProvider.getReturnVideoCallIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); - } else if (duoReady) { + } else if (duo.isReachable(mContext, number)) { videoCallButtonView.setTag(IntentProvider.getDuoVideoIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); + } else if (duo.isActivated(mContext)) { + inviteVideoButtonView.setTag(IntentProvider.getDuoInviteIntentProvider(number)); + inviteVideoButtonView.setVisibility(View.VISIBLE); + } else if (duo.isEnabled(mContext)) { + setUpVideoButtonView.setTag(IntentProvider.getSetUpDuoIntentProvider()); + setUpVideoButtonView.setVisibility(View.VISIBLE); } break; default: @@ -755,7 +772,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private boolean showDuoPrimaryButton() { return accountHandle != null && accountHandle.getComponentName().equals(DuoConstants.PHONE_ACCOUNT_COMPONENT_NAME) - && duoReady; + && duo.isReachable(mContext, number); } private static boolean hasDialableChar(CharSequence number) { diff --git a/java/com/android/dialer/app/calllog/IntentProvider.java b/java/com/android/dialer/app/calllog/IntentProvider.java index 0835d894c..996bca0f6 100644 --- a/java/com/android/dialer/app/calllog/IntentProvider.java +++ b/java/com/android/dialer/app/calllog/IntentProvider.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.net.Uri; import android.provider.ContactsContract; import android.support.annotation.Nullable; +import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.TelephonyManager; import com.android.contacts.common.model.Contact; @@ -32,6 +33,7 @@ import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.duo.DuoComponent; +import com.android.dialer.duo.DuoConstants; import com.android.dialer.precall.PreCall; import com.android.dialer.util.IntentUtil; import java.util.ArrayList; @@ -102,6 +104,29 @@ public abstract class IntentProvider { }; } + public static IntentProvider getSetUpDuoIntentProvider() { + return new IntentProvider() { + @Override + public Intent getIntent(Context context) { + return new Intent("com.google.android.apps.tachyon.action.REGISTER") + .setPackage(DuoConstants.PACKAGE_NAME); + } + }; + } + + public static IntentProvider getDuoInviteIntentProvider(String number) { + return new IntentProvider() { + @Override + public Intent getIntent(Context context) { + Intent intent = + new Intent("com.google.android.apps.tachyon.action.INVITE") + .setPackage(DuoConstants.PACKAGE_NAME) + .setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null /* fragment */)); + return intent; + } + }; + } + public static IntentProvider getReturnVoicemailCallIntentProvider( @Nullable PhoneAccountHandle phoneAccountHandle) { return new IntentProvider() { diff --git a/java/com/android/dialer/app/res/layout/call_log_list_item_actions.xml b/java/com/android/dialer/app/res/layout/call_log_list_item_actions.xml index ec9e5a00e..7df0d1551 100644 --- a/java/com/android/dialer/app/res/layout/call_log_list_item_actions.xml +++ b/java/com/android/dialer/app/res/layout/call_log_list_item_actions.xml @@ -73,6 +73,34 @@ </LinearLayout> <LinearLayout + android:id="@+id/set_up_video_action" + style="@style/CallLogActionStyle"> + + <ImageView + style="@style/CallLogActionIconStyle" + android:src="@drawable/quantum_ic_videocam_white_24"/> + + <TextView + style="@style/CallLogActionTextStyle" + android:text="@string/call_log_action_set_up_video"/> + + </LinearLayout> + + <LinearLayout + android:id="@+id/invite_video_action" + style="@style/CallLogActionStyle"> + + <ImageView + style="@style/CallLogActionIconStyle" + android:src="@drawable/quantum_ic_videocam_white_24"/> + + <TextView + style="@style/CallLogActionTextStyle" + android:text="@string/call_log_action_invite_video"/> + + </LinearLayout> + + <LinearLayout android:id="@+id/create_new_contact_action" style="@style/CallLogActionStyle"> diff --git a/java/com/android/dialer/app/res/values/strings.xml b/java/com/android/dialer/app/res/values/strings.xml index 01c477680..99720c2a6 100644 --- a/java/com/android/dialer/app/res/values/strings.xml +++ b/java/com/android/dialer/app/res/values/strings.xml @@ -348,6 +348,16 @@ [CHAR LIMIT=30] --> <string name="call_log_action_video_call">Video call</string> + <!-- Button text for the "Set up" video calling option displayed underneath an entry in the call log. + Tapping causes a the user to be taken to set up video calling. + [CHAR LIMIT=30] --> + <string name="call_log_action_set_up_video">Set up</string> + + <!-- Button text for the "Invite" option displayed underneath an entry in the call log. + Tapping causes a the user to be taken to the messaging app with a message ready to invite them to set up video calling. + [CHAR LIMIT=30] --> + <string name="call_log_action_invite_video">Invite</string> + <!-- Button text for a button displayed underneath an entry in the call log, which opens up a messaging app to send a SMS to the number represented by the call log entry. [CHAR LIMIT=30] --> diff --git a/java/com/android/dialer/databasepopulator/VoicemailPopulator.java b/java/com/android/dialer/databasepopulator/VoicemailPopulator.java index b1f8d1fe4..97f6b0a32 100644 --- a/java/com/android/dialer/databasepopulator/VoicemailPopulator.java +++ b/java/com/android/dialer/databasepopulator/VoicemailPopulator.java @@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit; /** Populates the device database with voicemail entries. */ public final class VoicemailPopulator { private static final String ACCOUNT_ID = "ACCOUNT_ID"; - + private static String componentName = ""; private static final Voicemail.Builder[] SIMPLE_VOICEMAILS = { // Long transcription with an embedded phone number. Voicemail.builder() @@ -48,6 +48,7 @@ public final class VoicemailPopulator { + "I hope you listen to all of it. This is very important. " + "Hi, this is a very long voicemail. " + "I hope you listen to all of it. It's very important.") + .setPhoneAccountComponentName(componentName) .setDurationSeconds(10) .setIsRead(false), // RTL transcription. @@ -55,24 +56,28 @@ public final class VoicemailPopulator { .setPhoneNumber("+1-302-6365454") .setTranscription("هزاران دوست کم اند و یک دشمن زیاد") .setDurationSeconds(60) + .setPhoneAccountComponentName(componentName) .setIsRead(true), // Empty number. Voicemail.builder() .setPhoneNumber("") .setTranscription("") .setDurationSeconds(60) + .setPhoneAccountComponentName(componentName) .setIsRead(true), // No duration. Voicemail.builder() .setPhoneNumber("+1-302-6365454") .setTranscription("") .setDurationSeconds(0) + .setPhoneAccountComponentName(componentName) .setIsRead(true), // Short number. Voicemail.builder() .setPhoneNumber("711") .setTranscription("This is a short voicemail.") .setDurationSeconds(12) + .setPhoneAccountComponentName(componentName) .setIsRead(true), }; @@ -118,7 +123,7 @@ public final class VoicemailPopulator { public static void enableVoicemail(@NonNull Context context) { PhoneAccountHandle handle = new PhoneAccountHandle(new ComponentName(context, VoicemailPopulator.class), ACCOUNT_ID); - + componentName = handle.getComponentName().toString(); ContentValues values = new ContentValues(); values.put(Status.SOURCE_PACKAGE, handle.getComponentName().getPackageName()); if (VERSION.SDK_INT >= VERSION_CODES.N_MR1) { @@ -147,6 +152,8 @@ public final class VoicemailPopulator { public abstract boolean getIsRead(); + public abstract String getPhoneAccountComponentName(); + public static Builder builder() { return new AutoValue_VoicemailPopulator_Voicemail.Builder(); } @@ -159,6 +166,7 @@ public final class VoicemailPopulator { values.put(Voicemails.SOURCE_PACKAGE, context.getPackageName()); values.put(Voicemails.IS_READ, getIsRead() ? 1 : 0); values.put(Voicemails.TRANSCRIPTION, getTranscription()); + values.put(Voicemails.PHONE_ACCOUNT_COMPONENT_NAME, getPhoneAccountComponentName()); return values; } @@ -175,6 +183,8 @@ public final class VoicemailPopulator { public abstract Builder setIsRead(boolean isRead); + public abstract Builder setPhoneAccountComponentName(String phoneAccountComponentName); + public abstract Voicemail build(); } } diff --git a/java/com/android/dialer/simulator/impl/SimulatorNotifications.java b/java/com/android/dialer/simulator/impl/SimulatorNotifications.java index 4ed7c9b8f..a243c34c3 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorNotifications.java +++ b/java/com/android/dialer/simulator/impl/SimulatorNotifications.java @@ -56,6 +56,7 @@ final class SimulatorNotifications { .setTranscription(String.format("Short transcript %d", i)) .setDurationSeconds(60) .setIsRead(false) + .setPhoneAccountComponentName("") .setTimeMillis(System.currentTimeMillis() - TimeUnit.HOURS.toMillis(i)) .build(); voicemails.add(voicemail.getAsContentValues(context)); diff --git a/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java b/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java index 451896b73..9ffcfc8a8 100644 --- a/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java +++ b/java/com/android/dialer/simulator/impl/SimulatorVoiceCall.java @@ -39,7 +39,8 @@ final class SimulatorVoiceCall .addItem("Incoming call", () -> new SimulatorVoiceCall(context).addNewIncomingCall(false)) .addItem("Outgoing call", () -> new SimulatorVoiceCall(context).addNewOutgoingCall()) .addItem("Spam call", () -> new SimulatorVoiceCall(context).addNewIncomingCall(true)) - .addItem("Emergency call", () -> new SimulatorVoiceCall(context).addNewEmergencyCall()) + .addItem( + "Emergency call back", () -> new SimulatorVoiceCall(context).addNewEmergencyCallBack()) .addItem( "GSM conference", () -> new SimulatorConferenceCreator(context, Simulator.CONFERENCE_TYPE_GSM).start(5)) @@ -71,7 +72,7 @@ final class SimulatorVoiceCall SimulatorSimCallManager.addNewOutgoingCall(context, callerId, false /* isVideo */); } - private void addNewEmergencyCall() { + private void addNewEmergencyCallBack() { String callerId = "911"; connectionTag = SimulatorSimCallManager.addNewIncomingCall(context, callerId, false); } |