From 5ee0b1e574ed93c7000e355e4a6b03fb9ed8aaba Mon Sep 17 00:00:00 2001 From: zachh Date: Tue, 3 Oct 2017 17:27:01 -0700 Subject: Only show the most recent call type icon in the new call log, instead of the last 3. This is according to the latest PRD: https://docs.google.com/document/d/1FLoQ6kNYL-QKplbniJAIUCHku87S9eYuYPs6IXe-U78 Also cleaned up warnings in CallLogQueryHandler. Screenshot: https://screenshot.googleplex.com/Z7p4BRVpLpE Bug: 34672501 Test: unit PiperOrigin-RevId: 170941445 Change-Id: Ibf79b70eda3837ea46d365729aaed0a87961e42b --- .../database/AnnotatedCallLogDatabaseHelper.java | 2 +- .../calllog/database/annotated_call_log.proto | 15 -------- .../contract/AnnotatedCallLogContract.java | 27 ++++++-------- .../systemcalllog/SystemCallLogDataSource.java | 42 ++++++++-------------- .../ui/CoalescedAnnotatedCallLogCursorLoader.java | 17 +++------ .../dialer/calllog/ui/NewCallLogViewHolder.java | 16 +++++---- 6 files changed, 40 insertions(+), 79 deletions(-) delete mode 100644 java/com/android/dialer/calllog/database/annotated_call_log.proto (limited to 'java/com/android/dialer/calllog') diff --git a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java index e1ec0f6b1..40d922f41 100644 --- a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java +++ b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java @@ -54,7 +54,7 @@ class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper { .append(AnnotatedCallLog.IS_VOICEMAIL + " integer, ") // Columns only in AnnotatedCallLog .append(AnnotatedCallLog.NUMBER + " blob, ") - .append(AnnotatedCallLog.TYPE + " integer") + .append(AnnotatedCallLog.CALL_TYPE + " integer") .append(");") .toString(); diff --git a/java/com/android/dialer/calllog/database/annotated_call_log.proto b/java/com/android/dialer/calllog/database/annotated_call_log.proto deleted file mode 100644 index de2bc5f14..000000000 --- a/java/com/android/dialer/calllog/database/annotated_call_log.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto2"; - -option java_package = "com.android.dialer"; -option java_multiple_files = true; -option optimize_for = LITE_RUNTIME; - -// DIALER_SCRUB.UNCOMMENT_IN_OPEN_SOURCE option optimize_for = LITE_RUNTIME; - -package com.android.dialer; - -// A list of android.provider.CallLog.Calls.TYPE values ordered from newest to -// oldest. -message CallTypes { - repeated int32 type = 1; -} diff --git a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java index 25950f6b9..d466da9ae 100644 --- a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java +++ b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java @@ -148,6 +148,13 @@ public class AnnotatedCallLogContract { */ String IS_VOICEMAIL = "is_voicemail"; + /** + * Copied from {@link android.provider.CallLog.Calls#TYPE}. + * + *

Type: INTEGER (int) + */ + String CALL_TYPE = "call_type"; + String[] ALL_COMMON_COLUMNS = new String[] { _ID, @@ -165,7 +172,8 @@ public class AnnotatedCallLogContract { PHONE_ACCOUNT_COLOR, FEATURES, IS_BUSINESS, - IS_VOICEMAIL + IS_VOICEMAIL, + CALL_TYPE }; } @@ -196,13 +204,6 @@ public class AnnotatedCallLogContract { *

Type: BLOB */ public static final String NUMBER = "number"; - - /** - * Copied from {@link android.provider.CallLog.Calls#TYPE}. - * - *

Type: INTEGER (int) - */ - public static final String TYPE = "type"; } /** @@ -232,19 +233,11 @@ public class AnnotatedCallLogContract { */ public static final String NUMBER_CALLS = "number_calls"; - /** - * The call types of the most recent 3 calls, encoded as a CallTypes proto. - * - *

TYPE: BLOB - */ - public static final String CALL_TYPES = "call_types"; - /** * Columns that are only in the {@link CoalescedAnnotatedCallLog} but not the {@link * AnnotatedCallLog}. */ - private static final String[] COLUMNS_ONLY_IN_COALESCED_CALL_LOG = - new String[] {NUMBER_CALLS, CALL_TYPES}; + private static final String[] COLUMNS_ONLY_IN_COALESCED_CALL_LOG = new String[] {NUMBER_CALLS}; /** All columns in the {@link CoalescedAnnotatedCallLog}. */ public static final String[] ALL_COLUMNS = diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java index 1bdbb8a1b..d6ad618b3 100644 --- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java +++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java @@ -38,9 +38,7 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.text.TextUtils; import android.util.ArraySet; -import com.android.dialer.CallTypes; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog; -import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog; import com.android.dialer.calllog.datasources.CallLogDataSource; import com.android.dialer.calllog.datasources.CallLogMutations; import com.android.dialer.calllog.datasources.util.RowCombiner; @@ -153,30 +151,20 @@ public class SystemCallLogDataSource implements CallLogDataSource { @Override public ContentValues coalesce(List individualRowsSortedByTimestampDesc) { // TODO(zachh): Complete implementation. - ContentValues coalescedValues = - new RowCombiner(individualRowsSortedByTimestampDesc) - .useMostRecentLong(AnnotatedCallLog.TIMESTAMP) - .useMostRecentLong(AnnotatedCallLog.NEW) - .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL) - .useMostRecentString(AnnotatedCallLog.NAME) - .useMostRecentString(AnnotatedCallLog.FORMATTED_NUMBER) - .useMostRecentString(AnnotatedCallLog.PHOTO_URI) - .useMostRecentLong(AnnotatedCallLog.PHOTO_ID) - .useMostRecentString(AnnotatedCallLog.LOOKUP_URI) - .useMostRecentString(AnnotatedCallLog.GEOCODED_LOCATION) - .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_LABEL) - .useSingleValueLong(AnnotatedCallLog.PHONE_ACCOUNT_COLOR) - .combine(); - - CallTypes.Builder callTypes = CallTypes.newBuilder(); - // Store a maximum of 3 call types since that's all we show to users via icons. - for (int i = 0; i < 3 && i < individualRowsSortedByTimestampDesc.size(); i++) { - callTypes.addType( - individualRowsSortedByTimestampDesc.get(i).getAsInteger(AnnotatedCallLog.TYPE)); - } - coalescedValues.put(CoalescedAnnotatedCallLog.CALL_TYPES, callTypes.build().toByteArray()); - - return coalescedValues; + return new RowCombiner(individualRowsSortedByTimestampDesc) + .useMostRecentLong(AnnotatedCallLog.TIMESTAMP) + .useMostRecentLong(AnnotatedCallLog.NEW) + .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL) + .useMostRecentString(AnnotatedCallLog.NAME) + .useMostRecentString(AnnotatedCallLog.FORMATTED_NUMBER) + .useMostRecentString(AnnotatedCallLog.PHOTO_URI) + .useMostRecentLong(AnnotatedCallLog.PHOTO_ID) + .useMostRecentString(AnnotatedCallLog.LOOKUP_URI) + .useMostRecentString(AnnotatedCallLog.GEOCODED_LOCATION) + .useSingleValueString(AnnotatedCallLog.PHONE_ACCOUNT_LABEL) + .useSingleValueLong(AnnotatedCallLog.PHONE_ACCOUNT_COLOR) + .useMostRecentLong(AnnotatedCallLog.CALL_TYPE) + .combine(); } @TargetApi(Build.VERSION_CODES.M) // Uses try-with-resources @@ -286,7 +274,7 @@ public class SystemCallLogDataSource implements CallLogDataSource { contentValues.put(AnnotatedCallLog.NUMBER, numberAsProtoBytes); } - contentValues.put(AnnotatedCallLog.TYPE, type); + contentValues.put(AnnotatedCallLog.CALL_TYPE, type); contentValues.put(AnnotatedCallLog.NAME, cachedName); contentValues.put(AnnotatedCallLog.FORMATTED_NUMBER, formattedNumber); contentValues.put(AnnotatedCallLog.PHOTO_URI, cachedPhotoUri); diff --git a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java index d89338350..13a801ac8 100644 --- a/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java +++ b/java/com/android/dialer/calllog/ui/CoalescedAnnotatedCallLogCursorLoader.java @@ -19,12 +19,8 @@ package com.android.dialer.calllog.ui; import android.content.Context; import android.database.Cursor; import android.support.annotation.ColorInt; -import android.support.annotation.NonNull; import android.support.v4.content.CursorLoader; -import com.android.dialer.CallTypes; import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog; -import com.android.dialer.common.Assert; -import com.google.protobuf.InvalidProtocolBufferException; /** CursorLoader for the coalesced annotated call log. */ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { @@ -47,8 +43,8 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { private static final int FEATURES = 13; private static final int IS_BUSINESS = 14; private static final int IS_VOICEMAIL = 15; - private static final int NUMBER_CALLS = 16; - private static final int CALL_TYPES = 17; + private static final int TYPE = 16; + private static final int NUMBER_CALLS = 17; /** Convenience class for accessing values using an abbreviated syntax. */ static final class Row { @@ -127,13 +123,8 @@ final class CoalescedAnnotatedCallLogCursorLoader extends CursorLoader { return cursor.getInt(NUMBER_CALLS); } - @NonNull - CallTypes callTypes() { - try { - return CallTypes.parseFrom(cursor.getBlob(CALL_TYPES)); - } catch (InvalidProtocolBufferException e) { - throw Assert.createAssertionFailException("Couldn't parse call types", e); - } + int callType() { + return cursor.getInt(TYPE); } } diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index e198a38e8..8ac419e56 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -66,8 +66,7 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { primaryTextView.setText(buildPrimaryText(row)); secondaryTextView.setText(buildSecondaryText(row)); - if (row.isNew()) { - // TODO(zachh): Figure out correct styling for new/missed/unread calls. + if (isNewMissedCall(row)) { primaryTextView.setTextAppearance(R.style.primary_textview_new_call); // TODO(zachh): Styling for call type icons when the call is new. secondaryTextView.setTextAppearance(R.style.secondary_textview_new_call); @@ -95,6 +94,12 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { return primaryText.toString(); } + private boolean isNewMissedCall(CoalescedAnnotatedCallLogCursorLoader.Row row) { + // Show missed call styling if the most recent call in the group was missed and it is still + // marked as NEW. It is not clear what IS_READ should be used for and it is currently not used. + return row.callType() == Calls.MISSED_TYPE && row.isNew(); + } + private String buildSecondaryText(CoalescedAnnotatedCallLogCursorLoader.Row row) { /* * Rules: (Duo video, )?$Label|$Location • Date @@ -158,10 +163,9 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } private void setSecondaryCallTypes(Row row) { - // Only call type icons are shown before the secondary text. - for (int callType : row.callTypes().getTypeList()) { - secondaryCallTypeIconsView.add(callType); - } + // Only call type icon is shown before the secondary text. + secondaryCallTypeIconsView.add(row.callType()); + // TODO(zachh): Per new mocks, may need to add method to CallTypeIconsView to disable coloring. } -- cgit v1.2.3