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

Commit bbc09110 authored by calderwoodra's avatar calderwoodra Committed by android-build-merger
Browse files

Merge changes I5bfa70fe,I9d662860

am: 462d9d99

Change-Id: I97913dc24202ff14fcce59d297a11fedba91896a
parents ec2558a4 462d9d99
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.dialer.duo.DuoComponent;
import com.android.dialer.logging.InteractionEvent;
import com.android.dialer.logging.Logger;
import com.android.dialer.shortcuts.ShortcutRefresher;
import com.android.dialer.strictmode.StrictModeUtils;
import com.google.common.collect.ComparisonChain;
import java.util.ArrayList;
import java.util.Comparator;
@@ -519,10 +520,19 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop
      }

      if (changed && dropEntryIndex < PIN_LIMIT) {
        final ArrayList<ContentProviderOperation> operations =
        ArrayList<ContentProviderOperation> operations =
            getReflowedPinningOperations(contactEntries, draggedEntryIndex, dropEntryIndex);
        if (!operations.isEmpty()) {
          // update the database here with the new pinned positions
        StrictModeUtils.bypass(() -> updateDatabaseWithPinnedPositions(operations));
      }
      draggedEntry = null;
    }
  }

  private void updateDatabaseWithPinnedPositions(ArrayList<ContentProviderOperation> operations) {
    if (operations.isEmpty()) {
      // Nothing to update
      return;
    }
    try {
      context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations);
      Logger.get(context).logInteraction(InteractionEvent.Type.SPEED_DIAL_PIN_CONTACT);
@@ -530,10 +540,6 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop
      LogUtil.e(TAG, "Exception thrown when pinning contacts", e);
    }
  }
      }
      draggedEntry = null;
    }
  }

  /**
   * Used when a contact is removed from speeddial. This will both unstar and set pinned position of
@@ -543,7 +549,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop
    final ContentValues values = new ContentValues(2);
    values.put(Contacts.STARRED, false);
    values.put(Contacts.PINNED, PinnedPositions.DEMOTED);
    context.getContentResolver().update(contactUri, values, null, null);
    StrictModeUtils.bypass(
        () -> context.getContentResolver().update(contactUri, values, null, null));
  }

  /**
+43 −22
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
import com.android.dialer.animation.AnimUtils;
import com.android.dialer.app.calllog.CallLogAdapter;
import com.android.dialer.app.calllog.CallLogFragment;
import com.android.dialer.app.calllog.CallLogFragment.CallLogFragmentListener;
@@ -44,6 +45,7 @@ import com.android.dialer.app.list.OldSpeedDialFragment;
import com.android.dialer.app.list.OnDragDropListener;
import com.android.dialer.app.list.OnListFragmentScrolledListener;
import com.android.dialer.app.list.PhoneFavoriteSquareTileView;
import com.android.dialer.app.list.RemoveView;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.callintent.CallSpecificAppData;
import com.android.dialer.common.FragmentUtils.FragmentUtilListener;
@@ -112,8 +114,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen

  // Speed Dial
  private MainOnPhoneNumberPickerActionListener onPhoneNumberPickerActionListener;
  private MainOldSpeedDialFragmentHostInterface oldSpeedDialFragmentHostInterface;
  private MainOnDragDropListener onDragDropListener;
  private MainOldSpeedDialFragmentHost oldSpeedDialFragmentHost;

  /** Language the device was in last time {@link #onSaveInstanceState(Bundle)} was called. */
  private String savedLanguageCode;
@@ -177,10 +178,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen

    onListFragmentScrolledListener = new MainOnListFragmentScrolledListener(snackbarContainer);
    onPhoneNumberPickerActionListener = new MainOnPhoneNumberPickerActionListener(mainActivity);
    oldSpeedDialFragmentHostInterface =
        new MainOldSpeedDialFragmentHostInterface(
            bottomNav, mainActivity.findViewById(R.id.contact_tile_drag_shadow_overlay));
    onDragDropListener = new MainOnDragDropListener();
    oldSpeedDialFragmentHost =
        new MainOldSpeedDialFragmentHost(
            bottomNav,
            mainActivity.findViewById(R.id.contact_tile_drag_shadow_overlay),
            mainActivity.findViewById(R.id.remove_view),
            mainActivity.findViewById(R.id.search_view_container));

    lastTabController = new LastTabController(mainActivity, bottomNav);

@@ -283,10 +286,8 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
      return (T) onListFragmentScrolledListener;
    } else if (callbackInterface.isInstance(onPhoneNumberPickerActionListener)) {
      return (T) onPhoneNumberPickerActionListener;
    } else if (callbackInterface.isInstance(oldSpeedDialFragmentHostInterface)) {
      return (T) oldSpeedDialFragmentHostInterface;
    } else if (callbackInterface.isInstance(onDragDropListener)) {
      return (T) onDragDropListener;
    } else if (callbackInterface.isInstance(oldSpeedDialFragmentHost)) {
      return (T) oldSpeedDialFragmentHost;
    } else {
      return null;
    }
@@ -644,25 +645,38 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    }
  }

  /** @see OldSpeedDialFragment.HostInterface */
  private static final class MainOldSpeedDialFragmentHostInterface
      implements OldSpeedDialFragment.HostInterface {
  /**
   * Handles the callbacks for {@link OldSpeedDialFragment} and drag/drop logic for drag to remove.
   *
   * @see OldSpeedDialFragment.HostInterface
   * @see OnDragDropListener
   */
  private static final class MainOldSpeedDialFragmentHost
      implements OldSpeedDialFragment.HostInterface, OnDragDropListener {

    private final BottomNavBar bottomNavBar;
    private final ImageView dragShadowOverlay;
    private final RemoveView removeView;
    private final View searchViewContainer;

    // TODO(calderwoodra): Use this for drag and drop
    @SuppressWarnings("unused")
    private DragDropController dragDropController;

    MainOldSpeedDialFragmentHostInterface(BottomNavBar bottomNavBar, ImageView dragShadowOverlay) {
    MainOldSpeedDialFragmentHost(
        BottomNavBar bottomNavBar,
        ImageView dragShadowOverlay,
        RemoveView removeView,
        View searchViewContainer) {
      this.bottomNavBar = bottomNavBar;
      this.dragShadowOverlay = dragShadowOverlay;
      this.removeView = removeView;
      this.searchViewContainer = searchViewContainer;
    }

    @Override
    public void setDragDropController(DragDropController dragDropController) {
      this.dragDropController = dragDropController;
      removeView.setDragDropController(dragDropController);
    }

    @Override
@@ -674,23 +688,30 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    public ImageView getDragShadowOverlay() {
      return dragShadowOverlay;
    }
  }

  /** @see com.android.dialer.app.list.OnDragDropListener */
  // TODO(calderwoodra): implement drag and drop
  private static final class MainOnDragDropListener implements OnDragDropListener {

    @Override
    public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) {}
    public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) {
      showRemoveView(true);
    }

    @Override
    public void onDragHovered(int x, int y, PhoneFavoriteSquareTileView view) {}

    @Override
    public void onDragFinished(int x, int y) {}
    public void onDragFinished(int x, int y) {
      showRemoveView(false);
    }

    @Override
    public void onDroppedOnRemove() {}

    private void showRemoveView(boolean show) {
      if (show) {
        AnimUtils.crossFadeViews(removeView, searchViewContainer, 300);
      } else {
        AnimUtils.crossFadeViews(searchViewContainer, removeView, 300);
      }
    }
  }

  /**
+42 −2
Original line number Diff line number Diff line
@@ -18,8 +18,7 @@
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/dialer_theme_color"
    app:contentInsetStart="0dp"
    app:contentInsetEnd="0dp">
@@ -89,4 +88,45 @@

    <include layout="@layout/expanded_search_bar"/>
  </com.android.dialer.main.impl.toolbar.SearchBarView>

  <!-- Sets android:importantForAccessibility="no" to avoid being announced when navigating with
       talkback enabled. It will still be announced when user drag or drop contact onto it.
       This is required since drag and drop event is only sent to views are visible when drag
       starts. -->
  <com.android.dialer.app.list.RemoveView
      android:id="@+id/remove_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_gravity="center_vertical"
      android:layout_margin="@dimen/search_bar_margin"
      android:contentDescription="@string/main_remove_contact"
      android:visibility="gone"
      android:importantForAccessibility="no">

    <LinearLayout
        android:id="@+id/remove_view_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/dialer_theme_color"
        android:gravity="center"
        android:orientation="horizontal">

      <ImageView
          android:id="@+id/remove_view_icon"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="8dp"
          android:layout_marginBottom="8dp"
          android:src="@drawable/quantum_ic_close_vd_theme_24"
          android:tint="@color/dialer_primary_text_color_white"/>

      <TextView
          android:id="@+id/remove_view_text"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/main_remove_contact"
          android:textColor="@color/dialer_primary_text_color_white"
          android:textSize="16sp"/>
    </LinearLayout>
  </com.android.dialer.app.list.RemoveView>
</com.android.dialer.main.impl.toolbar.MainToolbar>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -39,4 +39,7 @@
  <string name="settings">Settings</string>
  <!-- Send feedback about the app [CHAR LIMIT=20] -->
  <string name="main_send_feedback">Send feedback</string>

  <!-- Remove button that shows up when contact is long-pressed. [CHAR LIMIT=NONE] -->
  <string name="main_remove_contact">Remove</string>
</resources>
 No newline at end of file
+16 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.DialerExecutor.SuccessListener;
import com.android.dialer.common.concurrent.DialerExecutor.Worker;
import com.android.dialer.common.concurrent.DialerExecutorComponent;
import com.android.dialer.compat.android.provider.VoicemailCompat;
import com.android.dialer.contactphoto.ContactPhotoManager;
import com.android.dialer.contactphoto.NumberAttributeConverter;
import com.android.dialer.lettertile.LetterTileDrawable;
@@ -58,6 +59,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
  private final TextView primaryTextView;
  private final TextView secondaryTextView;
  private final TextView transcriptionTextView;
  private final TextView transcriptionBrandingTextView;
  private final QuickContactBadge quickContactBadge;
  private final NewVoicemailMediaPlayerView mediaPlayerView;
  private final ImageView menuButton;
@@ -76,6 +78,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
    primaryTextView = view.findViewById(R.id.primary_text);
    secondaryTextView = view.findViewById(R.id.secondary_text);
    transcriptionTextView = view.findViewById(R.id.transcription_text);
    transcriptionBrandingTextView = view.findViewById(R.id.transcription_branding);
    quickContactBadge = view.findViewById(R.id.quick_contact_photo);
    mediaPlayerView = view.findViewById(R.id.new_voicemail_media_player);
    menuButton = view.findViewById(R.id.menu_button);
@@ -226,6 +229,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
        String.valueOf(mediaPlayerView.getVoicemailUri()),
        String.valueOf(viewHolderVoicemailUri));
    transcriptionTextView.setMaxLines(1);
    transcriptionBrandingTextView.setVisibility(GONE);
    isViewHolderExpanded = false;

    mediaPlayerView.reset();
@@ -251,6 +255,8 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
    secondaryTextView.setTypeface(null, Typeface.NORMAL);
    transcriptionTextView.setTypeface(null, Typeface.NORMAL);

    transcriptionBrandingTextView.setVisibility(GONE);

    mediaPlayerView.reset();

    LogUtil.i(
@@ -319,6 +325,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On

    transcriptionTextView.setMaxLines(999);
    isViewHolderExpanded = true;
    updateBrandingText(voicemailEntry);
    // Once the media player is visible update its state
    mediaPlayerView.setVisibility(View.VISIBLE);
    mediaPlayerView.bindValuesFromAdapterOfExpandedViewHolderMediaPlayerView(
@@ -333,6 +340,15 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
        String.valueOf(mediaPlayerView.getVoicemailUri()));
  }

  private void updateBrandingText(VoicemailEntry voicemailEntry) {
    if (voicemailEntry.transcriptionState() == VoicemailCompat.TRANSCRIPTION_AVAILABLE
        && !TextUtils.isEmpty(voicemailEntry.transcription())) {
      transcriptionBrandingTextView.setVisibility(VISIBLE);
    } else {
      transcriptionBrandingTextView.setVisibility(GONE);
    }
  }

  @WorkerThread
  private Integer markVoicemailAsRead(Pair<Context, Uri> contextUriPair) {
    Assert.isWorkerThread();
Loading