diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-01-09 16:40:28 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-01-09 16:40:28 +0000 |
commit | 8c19b0ac8f79eb7f653ee3e07018ca7342f4e190 (patch) | |
tree | 92e2a480370fd53fdb210d1035a6c3d666628819 /java/com/android/dialer/voicemail | |
parent | 455a7c27d5c5d4c25236d940f088a25a5bf57c2a (diff) | |
parent | 517fbff5c15c9270323b4099a39514d2487eec99 (diff) |
Merge changes Iddf5ef33,I1b718e30,I0c7386f6,I81069948,I3bec477d, ...
* changes:
Update strings for Duo "Set up" and "Invite" buttons
Hide emergency calls in the call log
Simplifying implementation of the coalescing logic in the new call log.
Updating Dialer v16 licenses.
Use ContactsContract.PhoneLookup for invalid numbers in Cp2PhoneLookup.
Add RTT call chat window.
Updated T9 search bolding to include wrapping to the next word.
Initial setup of voicemail error messages
Automated rollback of changelist 178323108
Add "delete" option in the 3-dot menu of the new call log
Diffstat (limited to 'java/com/android/dialer/voicemail')
3 files changed, 120 insertions, 10 deletions
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java index 93d5cda3e..32c5b6991 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java @@ -55,12 +55,14 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> /** IntDef for the different types of rows that can be shown in the call log. */ @Retention(RetentionPolicy.SOURCE) - @IntDef({RowType.HEADER, RowType.VOICEMAIL_ENTRY}) + @IntDef({RowType.HEADER, RowType.VOICEMAIL_ENTRY, RowType.VOICEMAIL_ALERT}) @interface RowType { + /** A row representing a voicemail alert. */ + int VOICEMAIL_ALERT = 1; /** Header that displays "Today" or "Older". */ - int HEADER = 1; + int HEADER = 2; /** A row representing a voicemail entry. */ - int VOICEMAIL_ENTRY = 2; + int VOICEMAIL_ENTRY = 3; } private Cursor cursor; @@ -70,6 +72,8 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> private int todayHeaderPosition = Integer.MAX_VALUE; /** {@link Integer#MAX_VALUE} when the "Older" header should not be displayed. */ private int olderHeaderPosition = Integer.MAX_VALUE; + /** {@link Integer#MAX_VALUE} when the voicemail alert message should not be displayed. */ + private int voicemailAlertPosition = Integer.MAX_VALUE; private final FragmentManager fragmentManager; /** A valid id for {@link VoicemailEntry} is greater than 0 */ @@ -113,16 +117,26 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> private void updateHeaderPositions() { LogUtil.i( "NewVoicemailAdapter.updateHeaderPositions", - "before updating todayPos:%d, olderPos:%d", + "before updating todayPos:%d, olderPos:%d, alertPos:%d", todayHeaderPosition, - olderHeaderPosition); + olderHeaderPosition, + voicemailAlertPosition); + + int alertOffSet = 0; + if (voicemailAlertPosition != Integer.MAX_VALUE) { + Assert.checkArgument( + voicemailAlertPosition == 0, "voicemail alert can only be 0, when showing"); + alertOffSet = 1; + } + // Calculate header adapter positions by reading cursor. long currentTimeMillis = clock.currentTimeMillis(); if (cursor.moveToNext()) { long firstTimestamp = VoicemailCursorLoader.getTimestamp(cursor); if (CallLogDates.isSameDay(currentTimeMillis, firstTimestamp)) { - this.todayHeaderPosition = 0; - int adapterPosition = 2; // Accounted for "Today" header and first row. + this.todayHeaderPosition = 0 + alertOffSet; + int adapterPosition = + 2 + alertOffSet; // Accounted for the "Alert", "Today" header and first row. while (cursor.moveToNext()) { long timestamp = VoicemailCursorLoader.getTimestamp(cursor); @@ -144,9 +158,11 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> } LogUtil.i( "NewVoicemailAdapter.updateHeaderPositions", - "after updating todayPos:%d, olderPos:%d", + "after updating todayPos:%d, olderPos:%d, alertOffSet:%d, alertPos:%d", todayHeaderPosition, - olderHeaderPosition); + olderHeaderPosition, + alertOffSet, + voicemailAlertPosition); } private void initializeMediaPlayerListeners() { @@ -169,6 +185,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext()); View view; switch (viewType) { + case RowType.VOICEMAIL_ALERT: + view = inflater.inflate(R.layout.new_voicemail_entry_alert, viewGroup, false); + return new NewVoicemailAlertViewHolder(view); case RowType.HEADER: view = inflater.inflate(R.layout.new_voicemail_entry_header, viewGroup, false); return new NewVoicemailHeaderViewHolder(view); @@ -223,14 +242,33 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> return; } + if (viewHolder instanceof NewVoicemailAlertViewHolder) { + LogUtil.i( + "NewVoicemailAdapter.onBindViewHolder", "view holder at pos:%d is a alert", position); + NewVoicemailAlertViewHolder alertViewHolder = (NewVoicemailAlertViewHolder) viewHolder; + @RowType int viewType = getItemViewType(position); + Assert.checkArgument(position == 0); + if (position == voicemailAlertPosition) { + // TODO(a bug): Update this with the alert messages + alertViewHolder.setHeader("Temporary placeholder, update this with the alert messages"); + } else { + throw Assert.createIllegalStateFailException( + "Unexpected view type " + viewType + " at position: " + position); + } + return; + } + LogUtil.i( "NewVoicemailAdapter.onBindViewHolder", - "view holder at pos:%d is a not a header", + "view holder at pos:%d is a not a header or an alert", position); NewVoicemailViewHolder newVoicemailViewHolder = (NewVoicemailViewHolder) viewHolder; int previousHeaders = 0; + if (voicemailAlertPosition != Integer.MAX_VALUE && position > voicemailAlertPosition) { + previousHeaders++; + } if (todayHeaderPosition != Integer.MAX_VALUE && position > todayHeaderPosition) { previousHeaders++; } @@ -826,6 +864,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> // TODO(uabdullah): a bug Remove logging, temporarily here for debugging. LogUtil.enterBlock("NewVoicemailAdapter.getItemCount"); int numberOfHeaders = 0; + if (voicemailAlertPosition != Integer.MAX_VALUE) { + numberOfHeaders++; + } if (todayHeaderPosition != Integer.MAX_VALUE) { numberOfHeaders++; } @@ -846,6 +887,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> @Override public int getItemViewType(int position) { LogUtil.enterBlock("NewVoicemailAdapter.getItemViewType"); + if (voicemailAlertPosition != Integer.MAX_VALUE && position == voicemailAlertPosition) { + return RowType.VOICEMAIL_ALERT; + } if (todayHeaderPosition != Integer.MAX_VALUE && position == todayHeaderPosition) { return RowType.HEADER; } diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java new file mode 100644 index 000000000..ec603b5c8 --- /dev/null +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAlertViewHolder.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2018 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.support.v7.widget.RecyclerView.ViewHolder; +import android.view.View; +import android.widget.TextView; + +/** ViewHolder for {@link NewVoicemailAdapter} to display voicemail error states. */ +final class NewVoicemailAlertViewHolder extends ViewHolder { + + private final TextView errorTextView; + + NewVoicemailAlertViewHolder(View view) { + super(view); + errorTextView = view.findViewById(R.id.new_voicemail_alert_text); + } + + void setHeader(String error) { + errorTextView.setText(error); + } +} diff --git a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml new file mode 100644 index 000000000..e8dcd02d6 --- /dev/null +++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry_alert.xml @@ -0,0 +1,30 @@ +<?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 + --> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:height="48dp" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <!-- TODO(uabdullah): Confirm with UX on mocks --> + <TextView + android:id="@+id/new_voicemail_alert_text" + style="@style/SecondaryText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/voicemail_header_margin_start" + android:layout_centerVertical="true"/> +</RelativeLayout> |