From d6180d452cc6085f64c25d487bfaee3a614dd67a Mon Sep 17 00:00:00 2001 From: linyuh Date: Mon, 19 Mar 2018 20:09:53 -0700 Subject: Make the top row of the bottom sheet not clickable. Test: Existing tests PiperOrigin-RevId: 189683790 Change-Id: I0209e7fa839175041da29e9a6d8a590133121376 --- .../dialer/calllog/ui/menu/BottomSheetHeader.java | 42 +++++++++++++ .../dialer/calllog/ui/menu/NewCallLogMenu.java | 2 +- .../dialer/calllog/ui/menu/PrimaryAction.java | 45 ------------- .../HistoryItemActionBottomSheet.java | 31 ++++----- .../HistoryItemPrimaryActionInfo.java | 73 ---------------------- .../history_item_bottom_sheet_header_info.proto | 41 ++++++++++++ .../voicemail/listui/menu/BottomSheetHeader.java | 57 +++++++++++++++++ .../voicemail/listui/menu/NewVoicemailMenu.java | 2 +- .../voicemail/listui/menu/PrimaryAction.java | 65 ------------------- 9 files changed, 154 insertions(+), 204 deletions(-) create mode 100644 java/com/android/dialer/calllog/ui/menu/BottomSheetHeader.java delete mode 100644 java/com/android/dialer/calllog/ui/menu/PrimaryAction.java delete mode 100644 java/com/android/dialer/historyitemactions/HistoryItemPrimaryActionInfo.java create mode 100644 java/com/android/dialer/historyitemactions/history_item_bottom_sheet_header_info.proto create mode 100644 java/com/android/dialer/voicemail/listui/menu/BottomSheetHeader.java delete mode 100644 java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java diff --git a/java/com/android/dialer/calllog/ui/menu/BottomSheetHeader.java b/java/com/android/dialer/calllog/ui/menu/BottomSheetHeader.java new file mode 100644 index 000000000..d348541d7 --- /dev/null +++ b/java/com/android/dialer/calllog/ui/menu/BottomSheetHeader.java @@ -0,0 +1,42 @@ +/* + * 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.calllog.ui.menu; + +import android.content.Context; +import android.provider.CallLog.Calls; +import com.android.dialer.calllog.model.CoalescedRow; +import com.android.dialer.calllogutils.CallLogEntryText; +import com.android.dialer.calllogutils.NumberAttributesConverter; +import com.android.dialer.historyitemactions.HistoryItemBottomSheetHeaderInfo; + +/** Configures the top row in the bottom sheet. */ +final class BottomSheetHeader { + + static HistoryItemBottomSheetHeaderInfo fromRow(Context context, CoalescedRow row) { + return HistoryItemBottomSheetHeaderInfo.newBuilder() + .setNumber(row.getNumber()) + .setPhotoInfo( + NumberAttributesConverter.toPhotoInfoBuilder(row.getNumberAttributes()) + .setFormattedNumber(row.getFormattedNumber()) + .setIsVideo((row.getFeatures() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) + .build()) + .setPrimaryText(CallLogEntryText.buildPrimaryText(context, row).toString()) + .setSecondaryText( + CallLogEntryText.buildSecondaryTextForBottomSheet(context, row).toString()) + .build(); + } +} diff --git a/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java b/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java index 5be19ce0c..78354caac 100644 --- a/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java +++ b/java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java @@ -36,7 +36,7 @@ public final class NewCallLogMenu { return view -> { HistoryItemActionBottomSheet.show( context, - PrimaryAction.fromRow(context, row), + BottomSheetHeader.fromRow(context, row), Modules.fromRow(context, row), glidePhotoManager); diff --git a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java deleted file mode 100644 index 279869d70..000000000 --- a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java +++ /dev/null @@ -1,45 +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.calllog.ui.menu; - -import android.content.Context; -import android.provider.CallLog.Calls; -import com.android.dialer.calllog.model.CoalescedRow; -import com.android.dialer.calllogutils.CallLogEntryText; -import com.android.dialer.calllogutils.CallLogIntents; -import com.android.dialer.calllogutils.NumberAttributesConverter; -import com.android.dialer.historyitemactions.HistoryItemPrimaryActionInfo; - -/** Configures the primary action row (top row) for the bottom sheet. */ -final class PrimaryAction { - - static HistoryItemPrimaryActionInfo fromRow(Context context, CoalescedRow row) { - CharSequence primaryText = CallLogEntryText.buildPrimaryText(context, row); - - return HistoryItemPrimaryActionInfo.builder() - .setNumber(row.getNumber()) - .setPhotoInfo( - NumberAttributesConverter.toPhotoInfoBuilder(row.getNumberAttributes()) - .setFormattedNumber(row.getFormattedNumber()) - .setIsVideo((row.getFeatures() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) - .build()) - .setPrimaryText(primaryText) - .setSecondaryText(CallLogEntryText.buildSecondaryTextForBottomSheet(context, row)) - .setIntent(CallLogIntents.getCallBackIntent(context, row)) - .build(); - } -} diff --git a/java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java b/java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java index 47aa1003f..ce303272c 100644 --- a/java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java +++ b/java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java @@ -34,36 +34,36 @@ import java.util.List; /** * {@link BottomSheetDialog} used to show a list of actions in a bottom sheet menu. * - *

{@link #show(Context, HistoryItemPrimaryActionInfo, List, GlidePhotoManager)} should be used - * to create and display the menu. Modules are built using {@link HistoryItemActionModule} and some - * defaults are provided by {@link IntentModule} and {@link DividerModule}. + *

{@link #show(Context, HistoryItemBottomSheetHeaderInfo, List, GlidePhotoManager)} should be + * used to create and display the menu. Modules are built using {@link HistoryItemActionModule} and + * some defaults are provided by {@link IntentModule} and {@link DividerModule}. */ public class HistoryItemActionBottomSheet extends BottomSheetDialog implements OnClickListener { private final List modules; - private final HistoryItemPrimaryActionInfo historyItemPrimaryActionInfo; + private final HistoryItemBottomSheetHeaderInfo historyItemBottomSheetHeaderInfo; private final GlidePhotoManager glidePhotoManager; private HistoryItemActionBottomSheet( Context context, - HistoryItemPrimaryActionInfo historyItemPrimaryActionInfo, + HistoryItemBottomSheetHeaderInfo historyItemBottomSheetHeaderInfo, List modules, GlidePhotoManager glidePhotoManager) { super(context); this.modules = modules; - this.historyItemPrimaryActionInfo = historyItemPrimaryActionInfo; + this.historyItemBottomSheetHeaderInfo = historyItemBottomSheetHeaderInfo; this.glidePhotoManager = glidePhotoManager; setContentView(LayoutInflater.from(context).inflate(R.layout.sheet_layout, null)); } public static HistoryItemActionBottomSheet show( Context context, - HistoryItemPrimaryActionInfo historyItemPrimaryActionInfo, + HistoryItemBottomSheetHeaderInfo historyItemBottomSheetHeaderInfo, List modules, GlidePhotoManager glidePhotoManager) { HistoryItemActionBottomSheet sheet = new HistoryItemActionBottomSheet( - context, historyItemPrimaryActionInfo, modules, glidePhotoManager); + context, historyItemBottomSheetHeaderInfo, modules, glidePhotoManager); sheet.show(); return sheet; } @@ -90,25 +90,18 @@ public class HistoryItemActionBottomSheet extends BottomSheetDialog implements O // TODO(zachh): The contact image should be badged with a video icon if it is for a video call. glidePhotoManager.loadQuickContactBadge( contactView.findViewById(R.id.quick_contact_photo), - historyItemPrimaryActionInfo.photoInfo()); + historyItemBottomSheetHeaderInfo.getPhotoInfo()); TextView primaryTextView = contactView.findViewById(R.id.primary_text); TextView secondaryTextView = contactView.findViewById(R.id.secondary_text); - primaryTextView.setText(historyItemPrimaryActionInfo.primaryText()); - if (!TextUtils.isEmpty(historyItemPrimaryActionInfo.secondaryText())) { - secondaryTextView.setText(historyItemPrimaryActionInfo.secondaryText()); + primaryTextView.setText(historyItemBottomSheetHeaderInfo.getPrimaryText()); + if (!TextUtils.isEmpty(historyItemBottomSheetHeaderInfo.getSecondaryText())) { + secondaryTextView.setText(historyItemBottomSheetHeaderInfo.getSecondaryText()); } else { secondaryTextView.setVisibility(View.GONE); secondaryTextView.setText(null); } - if (historyItemPrimaryActionInfo.intent() != null) { - contactView.setOnClickListener( - (view) -> { - getContext().startActivity(historyItemPrimaryActionInfo.intent()); - dismiss(); - }); - } return contactView; } diff --git a/java/com/android/dialer/historyitemactions/HistoryItemPrimaryActionInfo.java b/java/com/android/dialer/historyitemactions/HistoryItemPrimaryActionInfo.java deleted file mode 100644 index ccc9420c6..000000000 --- a/java/com/android/dialer/historyitemactions/HistoryItemPrimaryActionInfo.java +++ /dev/null @@ -1,73 +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.historyitemactions; - -import android.content.Intent; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import com.android.dialer.DialerPhoneNumber; -import com.android.dialer.glidephotomanager.PhotoInfo; -import com.google.auto.value.AutoValue; - -/** - * Contains information necessary to construct the primary action for a history item's bottom sheet. - * - *

A history item is one that is displayed in the call log or the voicemail fragment. - */ -@AutoValue -public abstract class HistoryItemPrimaryActionInfo { - - @Nullable - public abstract DialerPhoneNumber number(); - - @NonNull - public abstract PhotoInfo photoInfo(); - - @Nullable - public abstract CharSequence primaryText(); - - @Nullable - public abstract CharSequence secondaryText(); - - /** - * The intent to fire when the user clicks the top row of the bottom sheet. Null if no action - * should occur (e.g. if the number is unknown). - */ - @Nullable - public abstract Intent intent(); - - // TODO(a bug): Add SIM info. - - /** Builder for {@link HistoryItemPrimaryActionInfo}. */ - @AutoValue.Builder - public abstract static class Builder { - public abstract Builder setNumber(@Nullable DialerPhoneNumber dialerPhoneNumber); - - public abstract Builder setPhotoInfo(@NonNull PhotoInfo photoInfo); - - public abstract Builder setPrimaryText(@Nullable CharSequence primaryText); - - public abstract Builder setSecondaryText(@Nullable CharSequence secondaryText); - - public abstract Builder setIntent(@Nullable Intent intent); - - public abstract HistoryItemPrimaryActionInfo build(); - } - - public static Builder builder() { - return new AutoValue_HistoryItemPrimaryActionInfo.Builder(); - } -} diff --git a/java/com/android/dialer/historyitemactions/history_item_bottom_sheet_header_info.proto b/java/com/android/dialer/historyitemactions/history_item_bottom_sheet_header_info.proto new file mode 100644 index 000000000..ef71ecd7e --- /dev/null +++ b/java/com/android/dialer/historyitemactions/history_item_bottom_sheet_header_info.proto @@ -0,0 +1,41 @@ +syntax = "proto2"; + +option java_package = "com.android.dialer.historyitemactions"; +option java_multiple_files = true; +option optimize_for = LITE_RUNTIME; + + +package com.android.dialer.historyitemactions; + +import "java/com/android/dialer/glidephotomanager/photo_info.proto"; +import "java/com/android/dialer/phonenumberproto/dialer_phone_number.proto"; + +// Contains information necessary to construct the header for a history item's +// bottom sheet. +// +// A history item is one that is displayed in the call log or the voicemail +// fragment. +// +// Next ID: 5 +message HistoryItemBottomSheetHeaderInfo { + // The phone number associated with the item. + optional com.android.dialer.DialerPhoneNumber number = 1; + + // Information used to load the contact photo. + optional com.android.dialer.glidephotomanager.PhotoInfo photo_info = 2; + + // Primary text of the header, which can be + // (1) a presentation name (e.g., "Restricted", "Unknown", etc.), + // (2) the contact name, or + // (3) the formatted number. + optional string primary_text = 3; + + // Secondary test of the header, which describes the number. + // Some examples are: + // "Mobile • 555-1234", + // "Blocked • Mobile • 555-1234", and + // "Spam • Mobile • 555-1234". + optional string secondary_text = 4; + + // TODO(a bug): Add SIM info. +} diff --git a/java/com/android/dialer/voicemail/listui/menu/BottomSheetHeader.java b/java/com/android/dialer/voicemail/listui/menu/BottomSheetHeader.java new file mode 100644 index 000000000..bf86278b2 --- /dev/null +++ b/java/com/android/dialer/voicemail/listui/menu/BottomSheetHeader.java @@ -0,0 +1,57 @@ +/* + * 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.listui.menu; + +import android.text.TextUtils; +import com.android.dialer.calllogutils.NumberAttributesConverter; +import com.android.dialer.historyitemactions.HistoryItemBottomSheetHeaderInfo; +import com.android.dialer.voicemail.model.VoicemailEntry; + +/** Configures the top row in the bottom sheet for the Voicemail Tab */ +final class BottomSheetHeader { + + static HistoryItemBottomSheetHeaderInfo fromVoicemailEntry(VoicemailEntry voicemailEntry) { + return HistoryItemBottomSheetHeaderInfo.newBuilder() + .setNumber(voicemailEntry.getNumber()) + .setPhotoInfo( + NumberAttributesConverter.toPhotoInfoBuilder(voicemailEntry.getNumberAttributes()) + .setFormattedNumber(voicemailEntry.getFormattedNumber()) + .build()) + .setPrimaryText(buildPrimaryVoicemailText(voicemailEntry)) + .setSecondaryText(buildSecondaryVoicemailText(voicemailEntry)) + .build(); + } + + private static String buildSecondaryVoicemailText(VoicemailEntry voicemailEntry) { + return voicemailEntry.getGeocodedLocation(); + } + + private static String buildPrimaryVoicemailText(VoicemailEntry data) { + StringBuilder primaryText = new StringBuilder(); + 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)); + // TODO(uabdullah): Figure out why http://gpaste/5980163120562176 error when using string + primaryText.append("Unknown"); + } + return primaryText.toString(); + } +} diff --git a/java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java b/java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java index 7c669e194..7ec86c5b9 100644 --- a/java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java +++ b/java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java @@ -31,7 +31,7 @@ public final class NewVoicemailMenu { return (view) -> HistoryItemActionBottomSheet.show( context, - PrimaryAction.fromVoicemailEntry(context, voicemailEntry), + BottomSheetHeader.fromVoicemailEntry(voicemailEntry), Modules.fromVoicemailEntry(context, voicemailEntry), glidePhotoManager); } diff --git a/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java b/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java deleted file mode 100644 index 14c83563a..000000000 --- a/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java +++ /dev/null @@ -1,65 +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.listui.menu; - -import android.content.Context; -import android.text.TextUtils; -import com.android.dialer.calllogutils.NumberAttributesConverter; -import com.android.dialer.historyitemactions.HistoryItemPrimaryActionInfo; -import com.android.dialer.voicemail.model.VoicemailEntry; - -/** Configures the primary action row (top row) for theottom sheet for the Voicemail Tab */ -final class PrimaryAction { - - // TODO(uabdullah): Need to do the following: - // setIsVideo - check if is passing in voicemailEntry.features() is required - // setLookupUri - check if passing in voicemailEntry.lookupUri() is required - // setIntent - allow video calling - // setPrimaryText - check in with UX - // setSecondaryText - check in with UX - static HistoryItemPrimaryActionInfo fromVoicemailEntry( - Context context, VoicemailEntry voicemailEntry) { - return HistoryItemPrimaryActionInfo.builder() - .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.getGeocodedLocation(); - } - - public static String buildPrimaryVoicemailText(Context context, VoicemailEntry data) { - StringBuilder primaryText = new StringBuilder(); - 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)); - // TODO(uabdullah): Figure out why http://gpaste/5980163120562176 error when using string - primaryText.append("Unknown"); - } - return primaryText.toString(); - } -} -- cgit v1.2.3