Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77c2b4c1 authored by roldenburg's avatar roldenburg Committed by Copybara-Service
Browse files

Add "Set up" and "Invite" for video to call log entry actions

Bug: 70034799
Test: GoogleCallLogAdapterTest
PiperOrigin-RevId: 178434462
Change-Id: I220cb74116aaa5dc3518de0dd20f2cdefda4049b
parent a4c1acdf
Loading
Loading
Loading
Loading
+24 −24
Original line number Diff line number Diff line
@@ -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);
  }

+20 −3
Original line number Diff line number Diff line
@@ -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) {
+25 −0
Original line number Diff line number Diff line
@@ -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() {
+28 −0
Original line number Diff line number Diff line
@@ -72,6 +72,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">
+10 −0
Original line number Diff line number Diff line
@@ -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] -->