From bc9d0073e0dd5125ed215fe4d36e38354b855bd5 Mon Sep 17 00:00:00 2001 From: uabdullah Date: Tue, 14 Nov 2017 11:51:49 -0800 Subject: Set total duration for NUI voicemail media player seekbar The duration of the voicemail shown in the seekbar/media player (upon expanding) should be the same as the duration shown when the voicemail view holder is collapsed. Both values are retrieved from the same source (VoicemailEntry). Bug: 64882313,68382421,69268144 Test: Unit Tests PiperOrigin-RevId: 175712662 Change-Id: I70496c004d52deb1793e6d6354b0ec79bf4c4398 --- .../contract/AnnotatedCallLogContract.java | 2 +- .../listui/NewVoicemailMediaPlayerView.java | 24 +++++++++++++++------- .../voicemail/listui/NewVoicemailViewHolder.java | 1 + .../voicemail/listui/VoicemailEntryText.java | 2 +- .../layout/new_voicemail_media_player_layout.xml | 2 -- 5 files changed, 20 insertions(+), 11 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java index d3318d125..c9b463e74 100644 --- a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java +++ b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java @@ -227,7 +227,7 @@ public class AnnotatedCallLogContract { /** * See {@link android.provider.CallLog.Calls#DURATION}. * - *

TYPE: INTEGER (int) + *

TYPE: INTEGER (long) */ public static final String DURATION = "duration"; diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java index 1e56a8189..b2d93b17c 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java @@ -25,18 +25,19 @@ import android.media.MediaPlayer.OnErrorListener; import android.media.MediaPlayer.OnPreparedListener; import android.net.Uri; import android.provider.VoicemailContract; -import android.support.annotation.VisibleForTesting; import android.support.v4.util.Pair; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; +import android.widget.TextView; import com.android.dialer.common.Assert; 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.voicemail.model.VoicemailEntry; /** * The view of the media player that is visible when a {@link NewVoicemailViewHolder} is expanded. @@ -46,6 +47,7 @@ public class NewVoicemailMediaPlayerView extends LinearLayout { private Button playButton; private Button speakerButton; private Button deleteButton; + private TextView totalDurationView; private Uri voicemailUri; private FragmentManager fragmentManager; private MediaPlayer mediaPlayer; @@ -62,14 +64,15 @@ public class NewVoicemailMediaPlayerView extends LinearLayout { protected void onFinishInflate() { super.onFinishInflate(); LogUtil.enterBlock("NewVoicemailMediaPlayer.onFinishInflate"); - initializeMediaPlayerButtons(); + initializeMediaPlayerButtonsAndViews(); setupListenersForMediaPlayerButtons(); } - private void initializeMediaPlayerButtons() { + private void initializeMediaPlayerButtonsAndViews() { playButton = findViewById(R.id.playButton); speakerButton = findViewById(R.id.speakerButton); deleteButton = findViewById(R.id.deleteButton); + totalDurationView = findViewById(R.id.playback_seek_total_duration); } private void setupListenersForMediaPlayerButtons() { @@ -171,7 +174,6 @@ public class NewVoicemailMediaPlayerView extends LinearLayout { } }; - @VisibleForTesting(otherwise = VisibleForTesting.NONE) OnCompletionListener onCompletionListener = new OnCompletionListener() { @@ -197,7 +199,6 @@ public class NewVoicemailMediaPlayerView extends LinearLayout { } }; - @VisibleForTesting(otherwise = VisibleForTesting.NONE) OnErrorListener onErrorListener = new OnErrorListener() { @Override @@ -210,12 +211,21 @@ public class NewVoicemailMediaPlayerView extends LinearLayout { } }; - public void setVoicemailUri(Uri voicemailUri) { + void setVoicemailUri(Uri voicemailUri) { Assert.isNotNull(voicemailUri); this.voicemailUri = voicemailUri; } - public void setFragmentManager(FragmentManager fragmentManager) { + void setFragmentManager(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } + + // TODO(uabdullah): Merge with voicemailUri (http://cl/175585919) + void setVoicemailDuration(VoicemailEntry voicemailEntry) { + Assert.isNotNull(voicemailEntry); + Assert.isNotNull(totalDurationView); + + totalDurationView.setText( + VoicemailEntryText.getVoicemailDuration(getContext(), voicemailEntry)); + } } diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java index 078a029c9..d5546c33f 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java @@ -81,6 +81,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On setPhoto(voicemailEntry); mediaPlayerView.setVoicemailUri(Uri.parse(voicemailEntry.voicemailUri())); mediaPlayerView.setFragmentManager(fragmentManager); + mediaPlayerView.setVoicemailDuration(voicemailEntry); } // TODO(uabdullah): Consider/Implement TYPE (e.g Spam, TYPE_VOICEMAIL) diff --git a/java/com/android/dialer/voicemail/listui/VoicemailEntryText.java b/java/com/android/dialer/voicemail/listui/VoicemailEntryText.java index f59220105..d73d1f0de 100644 --- a/java/com/android/dialer/voicemail/listui/VoicemailEntryText.java +++ b/java/com/android/dialer/voicemail/listui/VoicemailEntryText.java @@ -91,7 +91,7 @@ public class VoicemailEntryText { return secondaryText.toString(); } - private static String getVoicemailDuration(Context context, VoicemailEntry voicemailEntry) { + static String getVoicemailDuration(Context context, VoicemailEntry voicemailEntry) { long minutes = TimeUnit.SECONDS.toMinutes(voicemailEntry.duration()); long seconds = voicemailEntry.duration() - TimeUnit.MINUTES.toSeconds(minutes); 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 index a21b6aa6c..e8e560059 100644 --- 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 @@ -55,13 +55,11 @@ android:max="0" android:progress="0"/> - -- cgit v1.2.3