From 67a08ed881afd9b3f7bee630eb58d39ffd8efae2 Mon Sep 17 00:00:00 2001 From: linyuh Date: Mon, 19 Mar 2018 19:05:03 -0700 Subject: Convert @AutoValue VoicemailEntry to a proto Test: Existing tests PiperOrigin-RevId: 189678764 Change-Id: I6b9edd99e727788c65d325c1be43f0190c25c30e --- .../voicemail/listui/NewVoicemailAdapter.java | 6 +- .../listui/NewVoicemailMediaPlayerView.java | 8 +- .../voicemail/listui/NewVoicemailViewHolder.java | 45 ++++----- .../voicemail/listui/VoicemailCursorLoader.java | 59 ++++++++--- .../voicemail/listui/VoicemailEntryText.java | 22 ++-- .../dialer/voicemail/listui/menu/Modules.java | 28 +++--- .../voicemail/listui/menu/PrimaryAction.java | 24 ++--- .../dialer/voicemail/model/VoicemailEntry.java | 112 --------------------- .../dialer/voicemail/model/voicemail_entry.proto | 56 +++++++++++ 9 files changed, 163 insertions(+), 197 deletions(-) delete mode 100644 java/com/android/dialer/voicemail/model/VoicemailEntry.java create mode 100644 java/com/android/dialer/voicemail/model/voicemail_entry.proto (limited to 'java') diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java index 5eeb0fb59..64f63d9bc 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java @@ -92,7 +92,7 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter private final FragmentManager fragmentManager; /** A valid id for {@link VoicemailEntry} is greater than 0 */ - private int currentlyExpandedViewHolderId = -1; + private long currentlyExpandedViewHolderId = -1; private VoicemailErrorMessage voicemailErrorMessage; @@ -114,7 +114,7 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter * will always ensure there is only (up-to-date) view holder corresponding to a view holder id, * unlike the newVoicemailViewHolderSet. */ - private final ArrayMap newVoicemailViewHolderArrayMap = + private final ArrayMap newVoicemailViewHolderArrayMap = new ArrayMap<>(); // A single instance of a media player re-used across the expanded view holders. @@ -440,7 +440,7 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter if (!newVoicemailViewHolderArrayMap.isEmpty()) { String ids = ""; - for (int id : newVoicemailViewHolderArrayMap.keySet()) { + for (long id : newVoicemailViewHolderArrayMap.keySet()) { ids = ids + id + " "; } LogUtil.i("NewVoicemailAdapter.printArrayMap", "ids are " + ids); diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java index 52f3d0a48..f821f4f8a 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java @@ -154,11 +154,11 @@ public final class NewVoicemailMediaPlayerView extends LinearLayout { NewVoicemailViewHolderListener listener) { Assert.isNotNull(voicemailEntryFromAdapter); - Uri uri = Uri.parse(voicemailEntryFromAdapter.voicemailUri()); + Uri uri = Uri.parse(voicemailEntryFromAdapter.getVoicemailUri()); - numberVoicemailFrom = voicemailEntryFromAdapter.number().getNormalizedNumber(); - phoneAccountId = voicemailEntryFromAdapter.phoneAccountId(); - phoneAccountComponentName = voicemailEntryFromAdapter.phoneAccountComponentName(); + numberVoicemailFrom = voicemailEntryFromAdapter.getNumber().getNormalizedNumber(); + phoneAccountId = voicemailEntryFromAdapter.getPhoneAccountId(); + phoneAccountComponentName = voicemailEntryFromAdapter.getPhoneAccountComponentName(); Assert.isNotNull(viewHolder); Assert.isNotNull(uri); diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java index 1f857840e..d42c255eb 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java @@ -45,7 +45,6 @@ import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.compat.android.provider.VoicemailCompat; import com.android.dialer.glidephotomanager.GlidePhotoManager; -import com.android.dialer.glidephotomanager.PhotoInfo; import com.android.dialer.time.Clock; import com.android.dialer.voicemail.listui.menu.NewVoicemailMenu; import com.android.dialer.voicemail.model.VoicemailEntry; @@ -64,7 +63,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On private final ImageView menuButton; private final Clock clock; private boolean isViewHolderExpanded; - private int viewHolderId; + private long viewHolderId; private VoicemailEntry voicemailEntryOfViewHolder; @NonNull private Uri viewHolderVoicemailUri; private final NewVoicemailViewHolderListener voicemailViewHolderListener; @@ -117,7 +116,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On FragmentManager fragmentManager, NewVoicemailMediaPlayer mediaPlayer, int position, - int currentlyExpandedViewHolderId) { + long currentlyExpandedViewHolderId) { LogUtil.i( "NewVoicemailViewHolder.bindViewHolderValuesFromAdapter", @@ -128,16 +127,16 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On cursor.getCount()); voicemailEntryOfViewHolder = VoicemailCursorLoader.toVoicemailEntry(cursor); - viewHolderId = voicemailEntryOfViewHolder.id(); + viewHolderId = voicemailEntryOfViewHolder.getId(); LogUtil.i( "NewVoicemailViewHolder.bindViewHolderValuesFromAdapter", "viewholderId:%d", viewHolderId); - viewHolderVoicemailUri = Uri.parse(voicemailEntryOfViewHolder.voicemailUri()); + viewHolderVoicemailUri = Uri.parse(voicemailEntryOfViewHolder.getVoicemailUri()); primaryTextView.setText( VoicemailEntryText.buildPrimaryVoicemailText(context, voicemailEntryOfViewHolder)); secondaryTextView.setText( VoicemailEntryText.buildSecondaryVoicemailText(context, clock, voicemailEntryOfViewHolder)); - String voicemailTranscription = voicemailEntryOfViewHolder.transcription(); + String voicemailTranscription = voicemailEntryOfViewHolder.getTranscription(); if (TextUtils.isEmpty(voicemailTranscription)) { transcriptionTextView.setVisibility(GONE); @@ -204,10 +203,10 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On LogUtil.v( "NewVoicemailViewHolder.boldViewHolderIfUnread", "id:%d, isRead:%d", - voicemailEntryOfViewHolder.id(), - voicemailEntryOfViewHolder.isRead()); + voicemailEntryOfViewHolder.getId(), + voicemailEntryOfViewHolder.getIsRead()); - if (voicemailEntryOfViewHolder.isRead() == 0) { + if (voicemailEntryOfViewHolder.getIsRead() == 0) { primaryTextView.setTypeface(Typeface.DEFAULT, Typeface.BOLD); secondaryTextView.setTypeface(Typeface.DEFAULT, Typeface.BOLD); transcriptionTextView.setTypeface(Typeface.DEFAULT, Typeface.BOLD); @@ -215,13 +214,11 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On } private void setPhoto(VoicemailEntry voicemailEntry) { - PhotoInfo.Builder photoInfoBuilder = - NumberAttributesConverter.toPhotoInfoBuilder(voicemailEntry.numberAttributes()); - if (!TextUtils.isEmpty(voicemailEntry.formattedNumber())) { - photoInfoBuilder.setFormattedNumber(voicemailEntry.formattedNumber()); - } - - glidePhotoManager.loadQuickContactBadge(quickContactBadge, photoInfoBuilder.build()); + glidePhotoManager.loadQuickContactBadge( + quickContactBadge, + NumberAttributesConverter.toPhotoInfoBuilder(voicemailEntry.getNumberAttributes()) + .setFormattedNumber(voicemailEntry.getFormattedNumber()) + .build()); } void collapseViewHolder() { @@ -293,9 +290,9 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On Assert.isNotNull(voicemailViewHolderListener); Assert.checkArgument( - voicemailEntry.id() == viewHolderId, "ensure that the adapter binding has taken place"); + voicemailEntry.getId() == viewHolderId, "ensure that the adapter binding has taken place"); Assert.checkArgument( - Uri.parse(voicemailEntry.voicemailUri()).equals(viewHolderVoicemailUri), + Uri.parse(voicemailEntry.getVoicemailUri()).equals(viewHolderVoicemailUri), "ensure that the adapter binding has taken place"); LogUtil.i( "NewVoicemailViewHolder.expandAndBindViewHolderAndMediaPlayerViewWithAdapterValues", @@ -305,15 +302,15 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On isViewHolderExpanded, String.valueOf(viewHolderVoicemailUri), String.valueOf(mediaPlayerView.getVoicemailUri()), - voicemailEntry.isRead()); + voicemailEntry.getIsRead()); - if (voicemailEntry.isRead() == 0) { + if (voicemailEntry.getIsRead() == 0) { // update as read. primaryTextView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); secondaryTextView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); transcriptionTextView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); - Uri uri = Uri.parse(voicemailEntry.voicemailUri()); + Uri uri = Uri.parse(voicemailEntry.getVoicemailUri()); Worker, Integer> markVoicemailRead = this::markVoicemailAsRead; SuccessListener markedAsReadVoicemailCallBack = this::onVoicemailMarkedAsRead; @@ -344,8 +341,8 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On } private void updateBrandingText(VoicemailEntry voicemailEntry) { - if (voicemailEntry.transcriptionState() == VoicemailCompat.TRANSCRIPTION_AVAILABLE - && !TextUtils.isEmpty(voicemailEntry.transcription())) { + if (voicemailEntry.getTranscriptionState() == VoicemailCompat.TRANSCRIPTION_AVAILABLE + && !TextUtils.isEmpty(voicemailEntry.getTranscription())) { transcriptionBrandingTextView.setVisibility(VISIBLE); } else { transcriptionBrandingTextView.setVisibility(GONE); @@ -435,7 +432,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On return isViewHolderExpanded; } - public int getViewHolderId() { + public long getViewHolderId() { return viewHolderId; } diff --git a/java/com/android/dialer/voicemail/listui/VoicemailCursorLoader.java b/java/com/android/dialer/voicemail/listui/VoicemailCursorLoader.java index 5f717cf0c..f242484f3 100644 --- a/java/com/android/dialer/voicemail/listui/VoicemailCursorLoader.java +++ b/java/com/android/dialer/voicemail/listui/VoicemailCursorLoader.java @@ -20,6 +20,7 @@ import android.content.Context; import android.database.Cursor; import android.provider.CallLog.Calls; import android.support.v4.content.CursorLoader; +import android.text.TextUtils; import com.android.dialer.DialerPhoneNumber; import com.android.dialer.NumberAttributes; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog; @@ -99,22 +100,48 @@ final class VoicemailCursorLoader extends CursorLoader { "CP2 info incomplete for number: %s", LogUtil.sanitizePii(number.getNormalizedNumber())); - return VoicemailEntry.builder() - .setId(cursor.getInt(ID)) - .setTimestamp(cursor.getLong(TIMESTAMP)) - .setNumber(number) - .setFormattedNumber(cursor.getString(FORMATTED_NUMBER)) - .setDuration(cursor.getLong(DURATION)) - .setTranscription(cursor.getString(TRANSCRIPTION)) - .setVoicemailUri(cursor.getString(VOICEMAIL_URI)) - .setGeocodedLocation(cursor.getString(GEOCODED_LOCATION)) - .setCallType(cursor.getInt(CALL_TYPE)) - .setIsRead(cursor.getInt(IS_READ)) - .setNumberAttributes(numberAttributes) - .setTranscriptionState(cursor.getInt(TRANSCRIPTION_STATE)) - .setPhoneAccountComponentName(cursor.getString(PHONE_ACCOUNT_COMPONENT_NAME)) - .setPhoneAccountId(cursor.getString(PHONE_ACCOUNT_ID)) - .build(); + VoicemailEntry.Builder voicemailEntryBuilder = + VoicemailEntry.newBuilder() + .setId(cursor.getInt(ID)) + .setTimestamp(cursor.getLong(TIMESTAMP)) + .setNumber(number) + .setDuration(cursor.getLong(DURATION)) + .setCallType(cursor.getInt(CALL_TYPE)) + .setIsRead(cursor.getInt(IS_READ)) + .setNumberAttributes(numberAttributes) + .setTranscriptionState(cursor.getInt(TRANSCRIPTION_STATE)); + + String formattedNumber = cursor.getString(FORMATTED_NUMBER); + if (!TextUtils.isEmpty(formattedNumber)) { + voicemailEntryBuilder.setFormattedNumber(formattedNumber); + } + + String geocodedLocation = cursor.getString(GEOCODED_LOCATION); + if (!TextUtils.isEmpty(geocodedLocation)) { + voicemailEntryBuilder.setGeocodedLocation(geocodedLocation); + } + + String transcription = cursor.getString(TRANSCRIPTION); + if (!TextUtils.isEmpty(transcription)) { + voicemailEntryBuilder.setTranscription(transcription); + } + + String voicemailUri = cursor.getString(VOICEMAIL_URI); + if (!TextUtils.isEmpty(voicemailUri)) { + voicemailEntryBuilder.setVoicemailUri(voicemailUri); + } + + String phoneAccountComponentName = cursor.getString(PHONE_ACCOUNT_COMPONENT_NAME); + if (!TextUtils.isEmpty(phoneAccountComponentName)) { + voicemailEntryBuilder.setPhoneAccountComponentName(phoneAccountComponentName); + } + + String phoneAccountId = cursor.getString(PHONE_ACCOUNT_ID); + if (!TextUtils.isEmpty(phoneAccountId)) { + voicemailEntryBuilder.setPhoneAccountId(phoneAccountId); + } + + return voicemailEntryBuilder.build(); } static long getTimestamp(Cursor cursor) { diff --git a/java/com/android/dialer/voicemail/listui/VoicemailEntryText.java b/java/com/android/dialer/voicemail/listui/VoicemailEntryText.java index 4aaf2d1e7..973f9b1a8 100644 --- a/java/com/android/dialer/voicemail/listui/VoicemailEntryText.java +++ b/java/com/android/dialer/voicemail/listui/VoicemailEntryText.java @@ -33,10 +33,10 @@ public class VoicemailEntryText { public static String buildPrimaryVoicemailText(Context context, VoicemailEntry data) { StringBuilder primaryText = new StringBuilder(); - if (!TextUtils.isEmpty(data.numberAttributes().getName())) { - primaryText.append(data.numberAttributes().getName()); - } else if (!TextUtils.isEmpty(data.formattedNumber())) { - primaryText.append(data.formattedNumber()); + if (!TextUtils.isEmpty(data.getNumberAttributes().getName())) { + primaryText.append(data.getNumberAttributes().getName()); + } else if (!TextUtils.isEmpty(data.getFormattedNumber())) { + primaryText.append(data.getFormattedNumber()); } else { // TODO(uabdullah): Handle CallLog.Calls.PRESENTATION_*, including Verizon restricted numbers. primaryText.append(context.getText(R.string.voicemail_entry_unknown)); @@ -71,7 +71,7 @@ public class VoicemailEntryText { private static String secondaryTextPrefix( Context context, Clock clock, VoicemailEntry voicemailEntry) { StringBuilder secondaryText = new StringBuilder(); - String location = voicemailEntry.geocodedLocation(); + String location = voicemailEntry.getGeocodedLocation(); if (!TextUtils.isEmpty(location)) { secondaryText.append(location); } @@ -80,9 +80,9 @@ public class VoicemailEntryText { } secondaryText.append( CallLogDates.newCallLogTimestampLabel( - context, clock.currentTimeMillis(), voicemailEntry.timestamp())); + context, clock.currentTimeMillis(), voicemailEntry.getTimestamp())); - long duration = voicemailEntry.duration(); + long duration = voicemailEntry.getDuration(); if (duration >= 0) { secondaryText.append(" • "); String formattedDuration = getVoicemailDuration(context, voicemailEntry); @@ -92,15 +92,17 @@ public class VoicemailEntryText { } static String getVoicemailDuration(Context context, VoicemailEntry voicemailEntry) { - long minutes = TimeUnit.SECONDS.toMinutes(voicemailEntry.duration()); - long seconds = voicemailEntry.duration() - TimeUnit.MINUTES.toSeconds(minutes); + long minutes = TimeUnit.SECONDS.toMinutes(voicemailEntry.getDuration()); + long seconds = voicemailEntry.getDuration() - TimeUnit.MINUTES.toSeconds(minutes); // The format for duration is "MM:SS" and we never expect the duration to be > 5 minutes // However an incorrect duration could be set by the framework/someone to be >99, and in that // case cap it at 99, for the UI to still be able to display it in "MM:SS" format. if (minutes > 99) { LogUtil.w( - "VoicemailEntryText.getVoicemailDuration", "Duration was %d", voicemailEntry.duration()); + "VoicemailEntryText.getVoicemailDuration", + "Duration was %d", + voicemailEntry.getDuration()); minutes = 99; } return context.getString(R.string.voicemailDurationFormat, minutes, seconds); diff --git a/java/com/android/dialer/voicemail/listui/menu/Modules.java b/java/com/android/dialer/voicemail/listui/menu/Modules.java index c3c883ceb..226063c1b 100644 --- a/java/com/android/dialer/voicemail/listui/menu/Modules.java +++ b/java/com/android/dialer/voicemail/listui/menu/Modules.java @@ -43,11 +43,11 @@ final class Modules { Optional moduleForAddingContacts = SharedModules.createModuleForAddingToContacts( context, - voicemailEntry.number(), - voicemailEntry.numberAttributes().getName(), - voicemailEntry.numberAttributes().getLookupUri(), - voicemailEntry.numberAttributes().getIsBlocked(), - voicemailEntry.numberAttributes().getIsSpam()); + voicemailEntry.getNumber(), + voicemailEntry.getNumberAttributes().getName(), + voicemailEntry.getNumberAttributes().getLookupUri(), + voicemailEntry.getNumberAttributes().getIsBlocked(), + voicemailEntry.getNumberAttributes().getIsSpam()); if (moduleForAddingContacts.isPresent()) { modules.add(moduleForAddingContacts.get()); } @@ -55,8 +55,8 @@ final class Modules { Optional moduleForSendingTextMessage = SharedModules.createModuleForSendingTextMessage( context, - voicemailEntry.number().getNormalizedNumber(), - voicemailEntry.numberAttributes().getIsBlocked()); + voicemailEntry.getNumber().getNormalizedNumber(), + voicemailEntry.getNumberAttributes().getIsBlocked()); if (moduleForSendingTextMessage.isPresent()) { modules.add(moduleForSendingTextMessage.get()); } @@ -67,23 +67,23 @@ final class Modules { BlockReportSpamDialogInfo blockReportSpamDialogInfo = BlockReportSpamDialogInfo.newBuilder() - .setNormalizedNumber(voicemailEntry.number().getNormalizedNumber()) - .setCountryIso(voicemailEntry.number().getCountryIso()) - .setCallType(voicemailEntry.callType()) + .setNormalizedNumber(voicemailEntry.getNumber().getNormalizedNumber()) + .setCountryIso(voicemailEntry.getNumber().getCountryIso()) + .setCallType(voicemailEntry.getCallType()) .setReportingLocation(ReportingLocation.Type.VOICEMAIL_HISTORY) - .setContactSource(voicemailEntry.numberAttributes().getContactSource()) + .setContactSource(voicemailEntry.getNumberAttributes().getContactSource()) .build(); modules.addAll( SharedModules.createModulesHandlingBlockedOrSpamNumber( context, blockReportSpamDialogInfo, - voicemailEntry.numberAttributes().getIsBlocked(), - voicemailEntry.numberAttributes().getIsSpam())); + voicemailEntry.getNumberAttributes().getIsBlocked(), + voicemailEntry.getNumberAttributes().getIsSpam())); // TODO(zachh): Module for CallComposer. Optional moduleForCopyingNumber = SharedModules.createModuleForCopyingNumber( - context, voicemailEntry.number().getNormalizedNumber()); + context, voicemailEntry.getNumber().getNormalizedNumber()); if (moduleForCopyingNumber.isPresent()) { modules.add(moduleForCopyingNumber.get()); } diff --git a/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java b/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java index dbc417c6c..14c83563a 100644 --- a/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java +++ b/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java @@ -19,7 +19,6 @@ package com.android.dialer.voicemail.listui.menu; import android.content.Context; import android.text.TextUtils; import com.android.dialer.calllogutils.NumberAttributesConverter; -import com.android.dialer.glidephotomanager.PhotoInfo; import com.android.dialer.historyitemactions.HistoryItemPrimaryActionInfo; import com.android.dialer.voicemail.model.VoicemailEntry; @@ -34,30 +33,27 @@ final class PrimaryAction { // setSecondaryText - check in with UX static HistoryItemPrimaryActionInfo fromVoicemailEntry( Context context, VoicemailEntry voicemailEntry) { - PhotoInfo.Builder photoInfoBuilder = - NumberAttributesConverter.toPhotoInfoBuilder(voicemailEntry.numberAttributes()); - if (!TextUtils.isEmpty(voicemailEntry.formattedNumber())) { - photoInfoBuilder.setFormattedNumber(voicemailEntry.formattedNumber()); - } - return HistoryItemPrimaryActionInfo.builder() - .setNumber(voicemailEntry.number()) - .setPhotoInfo(photoInfoBuilder.build()) + .setNumber(voicemailEntry.getNumber()) + .setPhotoInfo( + NumberAttributesConverter.toPhotoInfoBuilder(voicemailEntry.getNumberAttributes()) + .setFormattedNumber(voicemailEntry.getFormattedNumber()) + .build()) .setPrimaryText(buildPrimaryVoicemailText(context, voicemailEntry)) .setSecondaryText(buildSecondaryVoicemailText(voicemailEntry)) .build(); } private static CharSequence buildSecondaryVoicemailText(VoicemailEntry voicemailEntry) { - return voicemailEntry.geocodedLocation(); + return voicemailEntry.getGeocodedLocation(); } public static String buildPrimaryVoicemailText(Context context, VoicemailEntry data) { StringBuilder primaryText = new StringBuilder(); - if (!TextUtils.isEmpty(data.numberAttributes().getName())) { - primaryText.append(data.numberAttributes().getName()); - } else if (!TextUtils.isEmpty(data.formattedNumber())) { - primaryText.append(data.formattedNumber()); + if (!TextUtils.isEmpty(data.getNumberAttributes().getName())) { + primaryText.append(data.getNumberAttributes().getName()); + } else if (!TextUtils.isEmpty(data.getFormattedNumber())) { + primaryText.append(data.getFormattedNumber()); } else { // TODO(uabdullah): Handle CallLog.Calls.PRESENTATION_*, including Verizon restricted numbers. // primaryText.append(context.getText(R.string.voicemail_unknown)); diff --git a/java/com/android/dialer/voicemail/model/VoicemailEntry.java b/java/com/android/dialer/voicemail/model/VoicemailEntry.java deleted file mode 100644 index 2f554b11f..000000000 --- a/java/com/android/dialer/voicemail/model/VoicemailEntry.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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.model; - -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import com.android.dialer.DialerPhoneNumber; -import com.android.dialer.NumberAttributes; -import com.android.dialer.compat.android.provider.VoicemailCompat; -import com.google.auto.value.AutoValue; - -/** Data class containing the contents of a voicemail entry from the AnnotatedCallLog. */ -@AutoValue -public abstract class VoicemailEntry { - - public static Builder builder() { - return new AutoValue_VoicemailEntry.Builder() - .setId(0) - .setTimestamp(0) - .setNumber(DialerPhoneNumber.getDefaultInstance()) - .setNumberAttributes(NumberAttributes.getDefaultInstance()) - .setDuration(0) - .setCallType(0) - .setIsRead(0) - .setTranscriptionState(VoicemailCompat.TRANSCRIPTION_NOT_STARTED); - } - - public abstract int id(); - - public abstract long timestamp(); - - @NonNull - public abstract DialerPhoneNumber number(); - - @Nullable - public abstract String formattedNumber(); - - @Nullable - public abstract String geocodedLocation(); - - public abstract long duration(); - - @Nullable - public abstract String transcription(); - - @Nullable - public abstract String voicemailUri(); - - public abstract int callType(); - - public abstract int isRead(); - - public abstract NumberAttributes numberAttributes(); - - public abstract int transcriptionState(); - - @Nullable - public abstract String phoneAccountComponentName(); - - @Nullable - public abstract String phoneAccountId(); - - /** Builder for {@link VoicemailEntry}. */ - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder setId(int id); - - public abstract Builder setTimestamp(long timestamp); - - public abstract Builder setNumber(@NonNull DialerPhoneNumber number); - - public abstract Builder setFormattedNumber(@Nullable String formattedNumber); - - public abstract Builder setDuration(long duration); - - public abstract Builder setTranscription(@Nullable String transcription); - - public abstract Builder setVoicemailUri(@Nullable String voicemailUri); - - public abstract Builder setGeocodedLocation(@Nullable String geocodedLocation); - - public abstract Builder setCallType(int callType); - - public abstract Builder setIsRead(int isRead); - - public abstract Builder setNumberAttributes(NumberAttributes numberAttributes); - - public abstract Builder setTranscriptionState(int transcriptionState); - - public abstract Builder setPhoneAccountComponentName( - @Nullable String phoneAccountComponentName); - - public abstract Builder setPhoneAccountId(@Nullable String phoneAccountId); - - public abstract VoicemailEntry build(); - } -} diff --git a/java/com/android/dialer/voicemail/model/voicemail_entry.proto b/java/com/android/dialer/voicemail/model/voicemail_entry.proto new file mode 100644 index 000000000..c9ca35212 --- /dev/null +++ b/java/com/android/dialer/voicemail/model/voicemail_entry.proto @@ -0,0 +1,56 @@ +syntax = "proto2"; + +option java_package = "com.android.dialer.voicemail.model"; +option java_multiple_files = true; +option optimize_for = LITE_RUNTIME; + + +package com.android.dialer.voicemail.model; + +import "java/com/android/dialer/calllog/database/contract/number_attributes.proto"; +import "java/com/android/dialer/phonenumberproto/dialer_phone_number.proto"; + +// Contains contents of a voicemail entry from the AnnotatedCallLog. +message VoicemailEntry { + // Value in column AnnotatedCallLog._ID + optional int64 id = 1; + + // Value in column AnnotatedCallLog.TIMESTAMP + optional int64 timestamp = 2; + + // Value in column AnnotatedCallLog.NUMBER + optional com.android.dialer.DialerPhoneNumber number = 3; + + // Value in column AnnotatedCallLog.FORMATTED_NUMBER + optional string formatted_number = 4; + + // Value in column AnnotatedCallLog.GEOCODED_LOCATION + optional string geocoded_location = 5; + + // Value in column AnnotatedCallLog.DURATION + optional int64 duration = 6; + + // Value in column AnnotatedCallLog.TRANSCRIPTION + optional string transcription = 7; + + // Value in column AnnotatedCallLog.VOICEMAIL_URI + optional string voicemail_uri = 8; + + // Value in column AnnotatedCallLog.CALL_TYPE + optional int32 call_type = 9; + + // Value in column AnnotatedCallLog.IS_READ + optional int32 is_read = 10; + + // Value in column AnnotatedCallLog.NUMBER_ATTRIBUTES + optional com.android.dialer.NumberAttributes number_attributes = 11; + + // Value in column AnnotatedCallLog.TRANSCRIPTION_STATE + optional int32 transcription_state = 12; + + // Value in column AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME + optional string phone_account_component_name = 13; + + // Value in column AnnotatedCallLog.PHONE_ACCOUNT_ID + optional string phone_account_id = 14; +} -- cgit v1.2.3