Merge "Add expand and collapse media player logic for NUI Voicemail Fragment"
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 0000000..11aa9ac
--- /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 5580cb4..d4bfefd 100644
--- a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java
@@ -38,6 +38,7 @@
   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 @@
     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 @@
   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 d9c557f..80bb1b5 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 0000000..762782f
--- /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>