summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-01-09 16:40:28 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-01-09 16:40:28 +0000
commit8c19b0ac8f79eb7f653ee3e07018ca7342f4e190 (patch)
tree92e2a480370fd53fdb210d1035a6c3d666628819 /java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java
parent455a7c27d5c5d4c25236d940f088a25a5bf57c2a (diff)
parent517fbff5c15c9270323b4099a39514d2487eec99 (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/listui/NewVoicemailAdapter.java')
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java64
1 files changed, 54 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;
}