summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/voicemail
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2017-12-15 10:45:50 -0800
committerCopybara-Service <copybara-piper@google.com>2017-12-15 12:13:12 -0800
commit4dc34a89ea820d1ca0115ada6fdf776150c1f07f (patch)
tree05eb175de624c8d998bfb57134ec30d77a9c1b02 /java/com/android/dialer/voicemail
parent0f47b8b7b33a39b1bc49ac86b82e3949296ef9f0 (diff)
Implement basic bottom sheet in NUI Voicemail tab.
Implement the basic bottom sheet that displays name, location add to contacts, send a message and copy number option. Bug: 64882313,70682949 Test: Unit test, additional unit tests in the next CL that will implement calling from bottom sheet. PiperOrigin-RevId: 179212401 Change-Id: I23281587a0d42cea595e4dc1608f997036e2dbd0
Diffstat (limited to 'java/com/android/dialer/voicemail')
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java7
-rw-r--r--java/com/android/dialer/voicemail/listui/menu/AndroidManifest.xml16
-rw-r--r--java/com/android/dialer/voicemail/listui/menu/Modules.java59
-rw-r--r--java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java36
-rw-r--r--java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java71
5 files changed, 189 insertions, 0 deletions
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
index bc23288bb..24bed0f04 100644
--- a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
@@ -27,6 +27,7 @@ import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.ImageView;
import android.widget.QuickContactBadge;
import android.widget.TextView;
import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog;
@@ -35,6 +36,7 @@ import com.android.dialer.common.LogUtil;
import com.android.dialer.contactphoto.ContactPhotoManager;
import com.android.dialer.lettertile.LetterTileDrawable;
import com.android.dialer.time.Clock;
+import com.android.dialer.voicemail.listui.menu.NewVoicemailMenu;
import com.android.dialer.voicemail.model.VoicemailEntry;
/** {@link RecyclerView.ViewHolder} for the new voicemail tab. */
@@ -46,6 +48,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
private final TextView transcriptionTextView;
private final QuickContactBadge quickContactBadge;
private final NewVoicemailMediaPlayerView mediaPlayerView;
+ private final ImageView menuButton;
private final Clock clock;
private boolean isViewHolderExpanded;
private int viewHolderId;
@@ -63,6 +66,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
transcriptionTextView = view.findViewById(R.id.transcription_text);
quickContactBadge = view.findViewById(R.id.quick_contact_photo);
mediaPlayerView = view.findViewById(R.id.new_voicemail_media_player);
+ menuButton = view.findViewById(R.id.menu_button);
this.clock = clock;
voicemailViewHolderListener = newVoicemailViewHolderListener;
@@ -121,6 +125,9 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
}
itemView.setOnClickListener(this);
+ menuButton.setOnClickListener(
+ NewVoicemailMenu.createOnClickListener(context, voicemailEntryOfViewHolder));
+
setPhoto(voicemailEntryOfViewHolder);
// Update the expanded/collapsed state of this view holder
diff --git a/java/com/android/dialer/voicemail/listui/menu/AndroidManifest.xml b/java/com/android/dialer/voicemail/listui/menu/AndroidManifest.xml
new file mode 100644
index 000000000..07d4d22eb
--- /dev/null
+++ b/java/com/android/dialer/voicemail/listui/menu/AndroidManifest.xml
@@ -0,0 +1,16 @@
+<!--
+ ~ Copyright (C) 2017 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<manifest package="com.android.dialer.voicemail.listui.menu"/> \ No newline at end of file
diff --git a/java/com/android/dialer/voicemail/listui/menu/Modules.java b/java/com/android/dialer/voicemail/listui/menu/Modules.java
new file mode 100644
index 000000000..bb98d76eb
--- /dev/null
+++ b/java/com/android/dialer/voicemail/listui/menu/Modules.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.voicemail.listui.menu;
+
+import android.content.Context;
+import com.android.dialer.contactactions.ContactActionModule;
+import com.android.dialer.contactactions.DividerModule;
+import com.android.dialer.contactactions.SharedModules;
+import com.android.dialer.voicemail.model.VoicemailEntry;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Configures the modules for the voicemail bottom sheet; these are the rows below the top row
+ * (primary action) in the bottom sheet.
+ */
+final class Modules {
+
+ static List<ContactActionModule> fromVoicemailEntry(
+ Context context, VoicemailEntry voicemailEntry) {
+ // Conditionally add each module, which are items in the bottom sheet's menu.
+ List<ContactActionModule> modules = new ArrayList<>();
+
+ // TODO(uabdullah): Handle maybeAddModuleForVideoOrAudioCall(context, modules, row);
+ SharedModules.maybeAddModuleForAddingToContacts(
+ context,
+ modules,
+ voicemailEntry.number(),
+ voicemailEntry.name(),
+ voicemailEntry.lookupUri());
+
+ String originalNumber = voicemailEntry.number().getRawInput().getNumber();
+ SharedModules.maybeAddModuleForSendingTextMessage(context, modules, originalNumber);
+
+ if (!modules.isEmpty()) {
+ modules.add(new DividerModule());
+ }
+
+ // TODO(zachh): Module for blocking/unblocking spam.
+ // TODO(zachh): Module for CallComposer.
+ SharedModules.maybeAddModuleForCopyingNumber(context, modules, originalNumber);
+
+ return modules;
+ }
+}
diff --git a/java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java b/java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java
new file mode 100644
index 000000000..9af8de6f5
--- /dev/null
+++ b/java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.voicemail.listui.menu;
+
+import android.content.Context;
+import android.view.View;
+import com.android.dialer.contactactions.ContactActionBottomSheet;
+import com.android.dialer.voicemail.model.VoicemailEntry;
+
+/** Handles configuration of the bottom sheet menus for voicemail entries. */
+public final class NewVoicemailMenu {
+
+ /** Creates and returns the OnClickListener which opens the menu for the provided row. */
+ public static View.OnClickListener createOnClickListener(
+ Context context, VoicemailEntry voicemailEntry) {
+ return (view) ->
+ ContactActionBottomSheet.show(
+ context,
+ PrimaryAction.fromVoicemailEntry(context, voicemailEntry),
+ Modules.fromVoicemailEntry(context, voicemailEntry));
+ }
+}
diff --git a/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java b/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java
new file mode 100644
index 000000000..7f4ac8052
--- /dev/null
+++ b/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.voicemail.listui.menu;
+
+import android.content.Context;
+import android.text.TextUtils;
+import com.android.dialer.contactactions.ContactPrimaryActionInfo;
+import com.android.dialer.contactactions.ContactPrimaryActionInfo.PhotoInfo;
+import com.android.dialer.lettertile.LetterTileDrawable;
+import com.android.dialer.voicemail.model.VoicemailEntry;
+
+/** Configures the primary action row (top row) for theottom sheet for the Voicemail Tab */
+final class PrimaryAction {
+
+ // TODO(uabdullah): Need to do the following:
+ // setIsVideo - check if is passing in voicemailEntry.features() is required
+ // setLookupUri - check if passing in voicemailEntry.lookupUri() is required
+ // setIntent - allow video calling
+ // setPrimaryText - check in with UX
+ // setSecondaryText - check in with UX
+ static ContactPrimaryActionInfo fromVoicemailEntry(
+ Context context, VoicemailEntry voicemailEntry) {
+ return ContactPrimaryActionInfo.builder()
+ .setNumber(voicemailEntry.number())
+ .setPhotoInfo(
+ PhotoInfo.builder()
+ .setPhotoId(voicemailEntry.photoId())
+ .setPhotoUri(voicemailEntry.photoUri())
+ .setIsVideo(false)
+ .setContactType(
+ LetterTileDrawable.TYPE_DEFAULT) // TODO(uabdullah): Use proper type.
+ .setDisplayName(voicemailEntry.name())
+ .build())
+ .setPrimaryText(buildPrimaryVoicemailText(context, voicemailEntry))
+ .setSecondaryText(buildSecondaryVoicemailText(voicemailEntry))
+ .build();
+ }
+
+ private static CharSequence buildSecondaryVoicemailText(VoicemailEntry voicemailEntry) {
+ return voicemailEntry.geocodedLocation();
+ }
+
+ public static String buildPrimaryVoicemailText(Context context, VoicemailEntry data) {
+ StringBuilder primaryText = new StringBuilder();
+ if (!TextUtils.isEmpty(data.name())) {
+ primaryText.append(data.name());
+ } else if (!TextUtils.isEmpty(data.formattedNumber())) {
+ primaryText.append(data.formattedNumber());
+ } else {
+ // TODO(uabdullah): Handle CallLog.Calls.PRESENTATION_*, including Verizon restricted numbers.
+ // primaryText.append(context.getText(R.string.voicemail_unknown));
+ // TODO(uabdullah): Figure out why http://gpaste/5980163120562176 error when using string
+ primaryText.append("Unknown");
+ }
+ return primaryText.toString();
+ }
+}