diff options
author | uabdullah <uabdullah@google.com> | 2017-09-29 15:38:38 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-10-03 10:39:52 -0700 |
commit | 259c569c371f6b24ab940a90a9a4c504f0b6fe3b (patch) | |
tree | 4baee256af9e94083dec4b69a738878f6633516a /java | |
parent | f7f9f3ba0f255ce8f9023ffb0aa61f927695da0a (diff) |
Create UI support for voicemail transcription, location, date and duration.
Screenshot:http://screen/dwihQaaeaQC
Bug: 64882313,33006245
Test: NewVoicemailCallLogViewHolderTest, NewVoicemailCallLogAdapterTest
PiperOrigin-RevId: 170542645
Change-Id: I00c145c5856c3f1f53d12b0fd7bd80c63bb8a094
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/dialer/voicemail/datasources/VoicemailData.java | 53 | ||||
-rw-r--r-- | java/com/android/dialer/voicemail/listui/NewVoicemailCallLogAdapter.java | 15 | ||||
-rw-r--r-- | java/com/android/dialer/voicemail/listui/NewVoicemailCallLogViewHolder.java | 19 | ||||
-rw-r--r-- | java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java | 20 | ||||
-rw-r--r-- | java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_call_log_entry.xml (renamed from java/com/android/dialer/voicemail/listui/res/layout/voicemail_call_log_entry.xml) | 35 | ||||
-rw-r--r-- | java/com/android/dialer/voicemail/listui/res/values/dimens.xml | 2 |
6 files changed, 125 insertions, 19 deletions
diff --git a/java/com/android/dialer/voicemail/datasources/VoicemailData.java b/java/com/android/dialer/voicemail/datasources/VoicemailData.java new file mode 100644 index 000000000..c3c1ff51b --- /dev/null +++ b/java/com/android/dialer/voicemail/datasources/VoicemailData.java @@ -0,0 +1,53 @@ +/* + * 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.datasources; + +import com.google.auto.value.AutoValue; + +/** Dummy voicemail data class to allow us to work on the UI for the new voicemail tab. */ +@AutoValue +public abstract class VoicemailData { + public abstract String name(); + + public abstract String location(); + + public abstract String date(); + + public abstract String duration(); + + public abstract String transcription(); + + public static Builder builder() { + return new AutoValue_VoicemailData.Builder(); + } + + /** Creates instances of {@link VoicemailData}. */ + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder setName(String value); + + public abstract Builder setLocation(String value); + + public abstract Builder setDate(String value); + + public abstract Builder setDuration(String value); + + public abstract Builder setTranscription(String value); + + public abstract VoicemailData build(); + } +} diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailCallLogAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailCallLogAdapter.java index 63dae20d9..b40c8630e 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailCallLogAdapter.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailCallLogAdapter.java @@ -20,23 +20,23 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.android.dialer.common.LogUtil; +import com.android.dialer.voicemail.datasources.VoicemailData; import java.util.List; /** {@link RecyclerView.Adapter} for the new voicemail call log fragment. */ final class NewVoicemailCallLogAdapter extends RecyclerView.Adapter<NewVoicemailCallLogViewHolder> { - private final List<String> values; + private final List<VoicemailData> voicemailData; - NewVoicemailCallLogAdapter(List<String> myDataset) { - values = myDataset; + NewVoicemailCallLogAdapter(List<VoicemailData> dataSet) { + voicemailData = dataSet; } @Override public NewVoicemailCallLogViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext()); - View v = inflater.inflate(R.layout.voicemail_call_log_entry, viewGroup, false); - + View v = inflater.inflate(R.layout.new_voicemail_call_log_entry, viewGroup, false); NewVoicemailCallLogViewHolder newVoicemailCallLogViewHolder = new NewVoicemailCallLogViewHolder(v); return newVoicemailCallLogViewHolder; @@ -45,12 +45,11 @@ final class NewVoicemailCallLogAdapter extends RecyclerView.Adapter<NewVoicemail @Override public void onBindViewHolder(NewVoicemailCallLogViewHolder viewHolder, int position) { LogUtil.i("onBindViewHolder", "position" + position); - String name = values.get(position); - viewHolder.setPrimaryText(name); + viewHolder.bind(voicemailData.get(position)); } @Override public int getItemCount() { - return values.size(); + return voicemailData.size(); } } diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailCallLogViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailCallLogViewHolder.java index 239c94633..9ec768464 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailCallLogViewHolder.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailCallLogViewHolder.java @@ -18,18 +18,33 @@ package com.android.dialer.voicemail.listui; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.TextView; +import com.android.dialer.voicemail.datasources.VoicemailData; /** {@link RecyclerView.ViewHolder} for the new voicemail call log. */ final class NewVoicemailCallLogViewHolder extends RecyclerView.ViewHolder { private final TextView primaryTextView; + private final TextView secondaryTextView; + private final TextView transcriptionTextView; NewVoicemailCallLogViewHolder(View view) { super(view); primaryTextView = (TextView) view.findViewById(R.id.primary_text); + secondaryTextView = (TextView) view.findViewById(R.id.secondary_text); + transcriptionTextView = (TextView) view.findViewById(R.id.transcription_text); } - public void setPrimaryText(String name) { - this.primaryTextView.setText(name); + void bind(VoicemailData voicemailData) { + primaryTextView.setText(voicemailData.name()); + secondaryTextView.setText(getVoicemailLocationDateAndDuration(voicemailData)); + transcriptionTextView.setText(voicemailData.transcription()); + } + + private String getVoicemailLocationDateAndDuration(VoicemailData voicemailData) { + return voicemailData.location() + + " · " + + voicemailData.date() + + " · " + + voicemailData.duration(); } } diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java b/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java index cb8cc317c..3629b7551 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailFragment.java @@ -25,8 +25,10 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.android.dialer.common.LogUtil; +import com.android.dialer.voicemail.datasources.VoicemailData; import java.util.ArrayList; import java.util.List; +import java.util.Random; /** Fragment for Dialer Voicemail Tab. */ public final class NewVoicemailFragment extends Fragment { @@ -40,13 +42,23 @@ public final class NewVoicemailFragment extends Fragment { recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // TODO(uabdullah): To be removed once we hook up the UI to the voicemail backend - List<String> input = new ArrayList<>(); + List<VoicemailData> voicemailData = new ArrayList<>(); + Random rand = new Random(); for (int i = 0; i < 50; i++) { - input.add("Umer Abdullah " + i); + VoicemailData mocked = + VoicemailData.builder() + .setName("Fatima Abdullah " + i) + .setLocation("San Francisco, CA") + .setDate("March " + (rand.nextInt(30) + 1)) + .setDuration("00:" + (rand.nextInt(50) + 10)) + .setTranscription( + "This is a transcription text message that literally means nothing.") + .build(); + voicemailData.add(mocked); } - LogUtil.i("onCreateView", "size of input:" + input.size()); - recyclerView.setAdapter(new NewVoicemailCallLogAdapter(input)); + LogUtil.i("onCreateView", "size of input:" + voicemailData.size()); + recyclerView.setAdapter(new NewVoicemailCallLogAdapter(voicemailData)); return view; } } diff --git a/java/com/android/dialer/voicemail/listui/res/layout/voicemail_call_log_entry.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_call_log_entry.xml index 3986a0e8c..01c0ee12e 100644 --- a/java/com/android/dialer/voicemail/listui/res/layout/voicemail_call_log_entry.xml +++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_call_log_entry.xml @@ -21,7 +21,6 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/call_log_entry_top_margin" android:paddingTop="@dimen/call_log_entry_padding_top_start" - android:paddingBottom="@dimen/call_log_entry_padding_bottom_end" android:paddingStart="@dimen/call_log_entry_padding_top_start" android:paddingEnd="@dimen/call_log_entry_padding_bottom_end" android:gravity="center_vertical"> @@ -43,22 +42,47 @@ android:layout_toStartOf="@+id/menu_button" android:orientation="vertical"> + <TextView + android:id="@+id/primary_text" + style="@style/PrimaryText" + 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"/> + <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> + <ImageView + android:layout_width="@dimen/voicemail_icon_size" + android:layout_height="@dimen/voicemail_icon_size" + android:layout_marginStart="@dimen/voicemail_icon_margin" + android:layout_gravity="center_vertical" + android:src="@drawable/quantum_ic_voicemail_vd_theme_24" + android:tint="@color/dialtacts_theme_color" + android:tintMode="multiply" + /> + <TextView - android:id="@+id/primary_text" - style="@style/PrimaryText" + android:id="@+id/secondary_text" + style="@style/SecondaryText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"/> </LinearLayout> + + <TextView + android:id="@+id/transcription_text" + 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"/> + </LinearLayout> - <!--TODO(uabdullah): Figure out why android:src="@drawable/quantum_ic_more_vert_vd_theme_24" - causes http://gpaste/5400195130982400 --> <ImageView android:id="@+id/menu_button" android:layout_width="@dimen/call_log_entry_menu_button_size" @@ -67,5 +91,6 @@ android:layout_centerVertical="true" android:background="?android:attr/selectableItemBackgroundBorderless" android:scaleType="center" + android:src="@drawable/quantum_ic_more_vert_vd_theme_24" android:tint="@color/dialer_secondary_text_color"/> </RelativeLayout> diff --git a/java/com/android/dialer/voicemail/listui/res/values/dimens.xml b/java/com/android/dialer/voicemail/listui/res/values/dimens.xml index 4ef0fc1a4..3df5827a5 100644 --- a/java/com/android/dialer/voicemail/listui/res/values/dimens.xml +++ b/java/com/android/dialer/voicemail/listui/res/values/dimens.xml @@ -25,4 +25,6 @@ <dimen name="call_log_entry_photo_text_margin">8dp</dimen> <dimen name="call_log_entry_menu_button_size">48dp</dimen> + <dimen name="voicemail_icon_margin">12dp</dimen> + <dimen name="voicemail_icon_size">16dp</dimen> </resources> |