summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2017-11-06 09:05:10 -0800
committerzachh <zachh@google.com>2017-11-11 16:24:38 +0000
commit7dd13e1353d34c796bf27412d83d83f516efcb7e (patch)
treec6e20d807e1c33623d596d91556b39351d3bbd85
parent7eb42e93396e085ade51020cb9c44f4651a56c71 (diff)
Add expand and collapse media player logic for NUI Voicemail Fragment
This adds a file called new_voicemail_media_player_layout.xml that can be expanded and collapsed on tapping the voicemail entry. This file will later be updated in accordance with the specs, but the logic for expansion and collapsing would not be affected by the future cosmetic change. Video=https://drive.google.com/open?id=1aIpmVfUYrFrg_FZ4tRX_TX6pU9YgPQaN Bug: 64882313,68382421 Test: Unit Tests PiperOrigin-RevId: 174713873 Change-Id: I15a6c5f01715429a6eb51fee447a5b42f25fdb56
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java87
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java4
-rw-r--r--java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml8
-rw-r--r--java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_media_player_layout.xml38
4 files changed, 137 insertions, 0 deletions
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java
new file mode 100644
index 000000000..11aa9ac2e
--- /dev/null
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java
@@ -0,0 +1,87 @@
+/*
+ * 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;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import com.android.dialer.common.LogUtil;
+
+/**
+ * The view of the media player that is visible when a {@link NewVoicemailViewHolder} is expanded.
+ */
+public class NewVoicemailMediaPlayer extends LinearLayout {
+
+ private Button playButton;
+ private Button speakerButton;
+ private Button deleteButton;
+
+ public NewVoicemailMediaPlayer(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ LogUtil.enterBlock("NewVoicemailMediaPlayer");
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ inflater.inflate(R.layout.new_voicemail_media_player_layout, this);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ LogUtil.enterBlock("NewVoicemailMediaPlayer.onFinishInflate");
+ initializeMediaPlayerButtons();
+ setupListenersForMediaPlayerButtons();
+ }
+
+ private void initializeMediaPlayerButtons() {
+ playButton = findViewById(R.id.playButton);
+ speakerButton = findViewById(R.id.speakerButton);
+ deleteButton = findViewById(R.id.deleteButton);
+ }
+
+ private void setupListenersForMediaPlayerButtons() {
+ playButton.setOnClickListener(playButtonListener);
+ speakerButton.setOnClickListener(speakerButtonListener);
+ deleteButton.setOnClickListener(deleteButtonListener);
+ }
+
+ private final View.OnClickListener playButtonListener =
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ LogUtil.i("NewVoicemailMediaPlayer.playButtonListener", "onClick");
+ }
+ };
+
+ private final View.OnClickListener speakerButtonListener =
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ LogUtil.i("NewVoicemailMediaPlayer.speakerButtonListener", "onClick");
+ }
+ };
+
+ private final View.OnClickListener deleteButtonListener =
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ LogUtil.i("NewVoicemailMediaPlayer.deleteButtonListener", "onClick");
+ }
+ };
+}
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
index 5580cb46d..d4bfefd22 100644
--- a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
@@ -38,6 +38,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
private final TextView secondaryTextView;
private final TextView transcriptionTextView;
private final QuickContactBadge quickContactBadge;
+ private final View mediaPlayerView;
private final Clock clock;
private boolean isViewHolderExpanded;
private int viewHolderId;
@@ -51,6 +52,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
secondaryTextView = view.findViewById(R.id.secondary_text);
transcriptionTextView = view.findViewById(R.id.transcription_text);
quickContactBadge = view.findViewById(R.id.quick_contact_photo);
+ mediaPlayerView = view.findViewById(R.id.new_voicemail_media_player);
this.clock = clock;
voicemailViewHolderListener = newVoicemailViewHolderListener;
}
@@ -91,11 +93,13 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On
void collapseViewHolder() {
transcriptionTextView.setMaxLines(1);
isViewHolderExpanded = false;
+ mediaPlayerView.setVisibility(View.GONE);
}
void expandViewHolder() {
transcriptionTextView.setMaxLines(999);
isViewHolderExpanded = true;
+ mediaPlayerView.setVisibility(View.VISIBLE);
}
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
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 d9c557f1a..80bb1b593 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
@@ -81,6 +81,14 @@
android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"
android:layout_gravity="center_vertical"
android:visibility="gone"/>
+
+ <com.android.dialer.voicemail.listui.NewVoicemailMediaPlayer
+ android:id="@+id/new_voicemail_media_player"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ />
+
</LinearLayout>
<!-- TODO(a bug): Add ripple effect -->
diff --git a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_media_player_layout.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_media_player_layout.xml
new file mode 100644
index 000000000..762782fb5
--- /dev/null
+++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_media_player_layout.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <!-- TODO(a bug): Remove these buttons as this is a place holder for the Media Player -->
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Play"
+ android:id="@+id/playButton" />
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Speaker"
+ android:id="@+id/speakerButton" />
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Delete"
+ android:id="@+id/deleteButton" />
+</LinearLayout>