summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-02-03 02:08:28 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-02-03 02:08:28 +0000
commit462d9d99aa1081817d56b1d919cfe49338b81f7e (patch)
tree2c0e8f1b3dac28c1aa77341281b46a2f8be4fb91
parent024ea0c4e6893d095a63e3733ba6c063df9945a3 (diff)
parent1579e1c993ecef391a1a828cb2ac13d2985d893d (diff)
Merge changes I5bfa70fe,I9d662860
* changes: Implemented drag to remove in NUI with old favorites. NUI VM Transcribed by Google UI Support
-rw-r--r--java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java29
-rw-r--r--java/com/android/dialer/main/impl/OldMainActivityPeer.java65
-rw-r--r--java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml44
-rw-r--r--java/com/android/dialer/main/impl/toolbar/res/values/strings.xml3
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java16
-rw-r--r--java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml10
-rw-r--r--java/com/android/dialer/voicemail/listui/res/values/strings.xml3
7 files changed, 135 insertions, 35 deletions
diff --git a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java
index ed64f7a52..a20185989 100644
--- a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java
+++ b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java
@@ -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,22 +520,27 @@ 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
- try {
- context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations);
- Logger.get(context).logInteraction(InteractionEvent.Type.SPEED_DIAL_PIN_CONTACT);
- } catch (RemoteException | OperationApplicationException e) {
- LogUtil.e(TAG, "Exception thrown when pinning contacts", e);
- }
- }
+ 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);
+ } catch (RemoteException | OperationApplicationException e) {
+ LogUtil.e(TAG, "Exception thrown when pinning contacts", e);
+ }
+ }
+
/**
* Used when a contact is removed from speeddial. This will both unstar and set pinned position of
* the contact to PinnedPosition.DEMOTED so that it doesn't show up anymore in the favorites list.
@@ -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));
}
/**
diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
index c7410d541..16b74d5ff 100644
--- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java
+++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java
@@ -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);
+ }
+ }
}
/**
diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
index 9b0086b38..7c4cee2b3 100644
--- a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
+++ b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml
@@ -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
diff --git a/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml b/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml
index c1d153f1f..6af235b81 100644
--- a/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml
+++ b/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml
@@ -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
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
index 71c98031a..b0c07df66 100644
--- a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
@@ -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();
diff --git a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml
index 95769fe32..6900627dd 100644
--- a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml
+++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml
@@ -82,6 +82,16 @@
android:layout_gravity="center_vertical"
android:visibility="gone"/>
+ <TextView
+ android:id="@+id/transcription_branding"
+ style="@style/SecondaryText"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"
+ android:layout_gravity="center_vertical"
+ android:text="@string/voicemail_transcription_branding_text"
+ android:visibility="gone"/>
+
<com.android.dialer.voicemail.listui.NewVoicemailMediaPlayerView
android:id="@+id/new_voicemail_media_player"
android:layout_width="match_parent"
diff --git a/java/com/android/dialer/voicemail/listui/res/values/strings.xml b/java/com/android/dialer/voicemail/listui/res/values/strings.xml
index e7373d69f..db33c1909 100644
--- a/java/com/android/dialer/voicemail/listui/res/values/strings.xml
+++ b/java/com/android/dialer/voicemail/listui/res/values/strings.xml
@@ -54,4 +54,7 @@ If you do not accept all of these terms and conditions, do not use Visual Voice
<string translatable="false" name="verizon_terms_and_conditions_accept_english">Turn On</string>
+ <!-- Label indicating who provided the voicemail transcription [CHAR LIMIT=64] -->
+ <string name="voicemail_transcription_branding_text">Transcribed by Google</string>
+
</resources>