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

Commit 3d97f592 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "NUI favorite logging"

parents 9893a89d c451dd56
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ message CallInitiationType {
    DIALPAD = 2;

    SPEED_DIAL = 3;
    SPEED_DIAL_DISAMBIG_DIALOG = 20;

    REMOTE_DIRECTORY = 4;

+15 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ message DialerImpression {
  // Event enums to be used for Impression Logging in Dialer.
  // It's perfectly acceptable for this enum to be large
  // Values should be from 1000 to 100000.
  // Next Tag: 1399
  // Next Tag: 1409
  enum Type {
    UNKNOWN_AOSP_EVENT_TYPE = 1000;

@@ -783,5 +783,19 @@ message DialerImpression {
    // Impressions for PhoneLookup
    PEOPLE_API_PHONE_LOOKUP_TIMEOUT = 1397;
    CP2_EXTENDED_DIRECTORY_PHONE_LOOKUP_TIMEOUT = 1398;

    // Favorite general
    FAVORITE_ADD_FAVORITE = 1399;
    FAVORITE_OPEN_DISAMBIG_DIALOG = 1400;
    FAVORITE_REMOVE_FAVORITE_BY_DRAG_AND_DROP = 1401;
    FAVORITE_MOVE_FAVORITE_BY_DRAG_AND_DROP = 1402;
    // Favorite menu
    FAVORITE_OPEN_FAVORITE_MENU = 1403;
    FAVORITE_SEND_MESSAGE = 1404;
    FAVORITE_OPEN_CONTACT_CARD = 1405;
    FAVORITE_REMOVE_FAVORITE = 1406;  // Include drag and drop
    // Favorite disambig
    FAVORITE_SET_VIDEO_DEFAULT = 1407;
    FAVORITE_SET_VOICE_DEFAULT = 1408;
  }
}
+5 −3
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public class DisambigDialog extends DialogFragment {
  private SpeedDialUiItem speedDialUiItem;
  @VisibleForTesting public List<Channel> channels;
  @VisibleForTesting public LinearLayout container;
  private CheckBox rememberThisChoice;
  @VisibleForTesting public CheckBox rememberThisChoice;

  /** Show a disambiguation dialog for a starred contact without a favorite communication avenue. */
  public static DisambigDialog show(SpeedDialUiItem speedDialUiItem, FragmentManager manager) {
@@ -174,6 +174,7 @@ public class DisambigDialog extends DialogFragment {

  private void onVideoOptionClicked(Channel channel) {
    if (rememberThisChoice.isChecked()) {
      Logger.get(getContext()).logImpression(DialerImpression.Type.FAVORITE_SET_VIDEO_DEFAULT);
      setDefaultChannel(getContext().getApplicationContext(), speedDialUiItem, channel);
    }

@@ -185,7 +186,7 @@ public class DisambigDialog extends DialogFragment {

    PreCall.start(
        getContext(),
        new CallIntentBuilder(channel.number(), CallInitiationType.Type.SPEED_DIAL)
        new CallIntentBuilder(channel.number(), CallInitiationType.Type.SPEED_DIAL_DISAMBIG_DIALOG)
            .setAllowAssistedDial(true)
            .setIsVideoCall(true)
            .setIsDuoCall(channel.technology() == Channel.DUO));
@@ -194,12 +195,13 @@ public class DisambigDialog extends DialogFragment {

  private void onVoiceOptionClicked(Channel channel) {
    if (rememberThisChoice.isChecked()) {
      Logger.get(getContext()).logImpression(DialerImpression.Type.FAVORITE_SET_VOICE_DEFAULT);
      setDefaultChannel(getContext().getApplicationContext(), speedDialUiItem, channel);
    }

    PreCall.start(
        getContext(),
        new CallIntentBuilder(channel.number(), CallInitiationType.Type.SPEED_DIAL)
        new CallIntentBuilder(channel.number(), CallInitiationType.Type.SPEED_DIAL_DISAMBIG_DIALOG)
            .setAllowAssistedDial(true));
    dismiss();
  }
+12 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
@@ -162,7 +163,7 @@ public class SpeedDialFragment extends Fragment {
    recyclerView.setAdapter(adapter);

    // Setup drag and drop touch helper
    ItemTouchHelper.Callback callback = new SpeedDialItemTouchHelperCallback(adapter);
    ItemTouchHelper.Callback callback = new SpeedDialItemTouchHelperCallback(getContext(), adapter);
    ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
    touchHelper.attachToRecyclerView(recyclerView);
    adapter.setItemTouchHelper(touchHelper);
@@ -249,6 +250,7 @@ public class SpeedDialFragment extends Fragment {
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ActivityRequestCodes.SPEED_DIAL_ADD_FAVORITE) {
      if (resultCode == AppCompatActivity.RESULT_OK && data.getData() != null) {
        Logger.get(getContext()).logImpression(DialerImpression.Type.FAVORITE_ADD_FAVORITE);
        updateSpeedDialItemsOnResume = false;
        speedDialLoaderListener.listen(
            getContext(),
@@ -335,7 +337,8 @@ public class SpeedDialFragment extends Fragment {
    }
  }

  private static final class SpeedDialFavoritesListener implements FavoriteContactsListener {
  @VisibleForTesting
  static final class SpeedDialFavoritesListener implements FavoriteContactsListener {

    private final FragmentActivity activity;
    private final FragmentManager childFragmentManager;
@@ -369,6 +372,7 @@ public class SpeedDialFragment extends Fragment {
        return;
      }

      Logger.get(activity).logImpression(DialerImpression.Type.FAVORITE_OPEN_DISAMBIG_DIALOG);
      DisambigDialog.show(speedDialUiItem, childFragmentManager);
    }

@@ -389,6 +393,7 @@ public class SpeedDialFragment extends Fragment {

    @Override
    public void showContextMenu(View view, SpeedDialUiItem speedDialUiItem) {
      Logger.get(activity).logImpression(DialerImpression.Type.FAVORITE_OPEN_FAVORITE_MENU);
      layoutManager.setScrollEnabled(false);
      contextMenu =
          ContextMenu.show(activity, view, speedDialContextMenuItemListener, speedDialUiItem);
@@ -406,6 +411,8 @@ public class SpeedDialFragment extends Fragment {

    @Override
    public void onRequestRemove(SpeedDialUiItem speedDialUiItem) {
      Logger.get(activity)
          .logImpression(DialerImpression.Type.FAVORITE_REMOVE_FAVORITE_BY_DRAG_AND_DROP);
      speedDialContextMenuItemListener.removeFavoriteContact(speedDialUiItem);
    }

@@ -439,11 +446,13 @@ public class SpeedDialFragment extends Fragment {

      @Override
      public void openSmsConversation(String number) {
        Logger.get(activity).logImpression(DialerImpression.Type.FAVORITE_SEND_MESSAGE);
        activity.startActivity(IntentUtil.getSendSmsIntent(number));
      }

      @Override
      public void removeFavoriteContact(SpeedDialUiItem speedDialUiItem) {
        Logger.get(activity).logImpression(DialerImpression.Type.FAVORITE_REMOVE_FAVORITE);
        speedDialLoaderListener.listen(
            activity,
            UiItemLoaderComponent.get(activity)
@@ -457,6 +466,7 @@ public class SpeedDialFragment extends Fragment {

      @Override
      public void openContactInfo(SpeedDialUiItem speedDialUiItem) {
        Logger.get(activity).logImpression(DialerImpression.Type.FAVORITE_OPEN_CONTACT_CARD);
        activity.startActivity(
            new Intent(
                Intent.ACTION_VIEW,
+20 −1
Original line number Diff line number Diff line
@@ -16,17 +16,21 @@

package com.android.dialer.speeddial.draghelper;

import android.content.Context;
import android.graphics.Canvas;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.support.v7.widget.helper.ItemTouchHelper;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;

/** {@link ItemTouchHelper} for Speed Dial favorite contacts. */
public class SpeedDialItemTouchHelperCallback extends ItemTouchHelper.Callback {

  private final ItemTouchHelperAdapter adapter;
  private final Context context;

  // When dragged item is in removeView, onMove() and onChildDraw() are called in turn. This
  // behavior changes when dragged item entering/leaving removeView. The boolean field
@@ -34,7 +38,8 @@ public class SpeedDialItemTouchHelperCallback extends ItemTouchHelper.Callback {
  private boolean movedOverRemoveView;
  private boolean inRemoveView;

  public SpeedDialItemTouchHelperCallback(ItemTouchHelperAdapter adapter) {
  public SpeedDialItemTouchHelperCallback(Context context, ItemTouchHelperAdapter adapter) {
    this.context = context;
    this.adapter = adapter;
  }

@@ -90,6 +95,20 @@ public class SpeedDialItemTouchHelperCallback extends ItemTouchHelper.Callback {
    return true;
  }

  @Override
  public void onMoved(
      @NonNull RecyclerView recyclerView,
      @NonNull ViewHolder viewHolder,
      int fromPos,
      @NonNull ViewHolder viewHolder1,
      int toPos,
      int x,
      int y) {
    Logger.get(context)
        .logImpression(DialerImpression.Type.FAVORITE_MOVE_FAVORITE_BY_DRAG_AND_DROP);
    super.onMoved(recyclerView, viewHolder, fromPos, viewHolder1, toPos, x, y);
  }

  @Override
  public void onChildDraw(
      @NonNull Canvas canvas,