diff options
author | linyuh <linyuh@google.com> | 2018-03-19 20:09:53 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-19 20:11:52 -0700 |
commit | d6180d452cc6085f64c25d487bfaee3a614dd67a (patch) | |
tree | 82dbfdd08c98e6412e36428085639053848373cc | |
parent | 67a08ed881afd9b3f7bee630eb58d39ffd8efae2 (diff) |
Make the top row of the bottom sheet not clickable.
Test: Existing tests
PiperOrigin-RevId: 189683790
Change-Id: I0209e7fa839175041da29e9a6d8a590133121376
-rw-r--r-- | java/com/android/dialer/calllog/ui/menu/BottomSheetHeader.java (renamed from java/com/android/dialer/calllog/ui/menu/PrimaryAction.java) | 19 | ||||
-rw-r--r-- | java/com/android/dialer/calllog/ui/menu/NewCallLogMenu.java | 2 | ||||
-rw-r--r-- | java/com/android/dialer/historyitemactions/HistoryItemActionBottomSheet.java | 31 | ||||
-rw-r--r-- | java/com/android/dialer/historyitemactions/HistoryItemPrimaryActionInfo.java | 73 | ||||
-rw-r--r-- | java/com/android/dialer/historyitemactions/history_item_bottom_sheet_header_info.proto | 41 | ||||
-rw-r--r-- | java/com/android/dialer/voicemail/listui/menu/BottomSheetHeader.java (renamed from java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java) | 24 | ||||
-rw-r--r-- | java/com/android/dialer/voicemail/listui/menu/NewVoicemailMenu.java | 2 |
7 files changed, 71 insertions, 121 deletions
diff --git a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java b/java/com/android/dialer/calllog/ui/menu/BottomSheetHeader.java index 279869d70..d348541d7 100644 --- a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java +++ b/java/com/android/dialer/calllog/ui/menu/BottomSheetHeader.java @@ -20,26 +20,23 @@ 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; +import com.android.dialer.historyitemactions.HistoryItemBottomSheetHeaderInfo; -/** Configures the primary action row (top row) for the bottom sheet. */ -final class PrimaryAction { +/** Configures the top row in the bottom sheet. */ +final class BottomSheetHeader { - static HistoryItemPrimaryActionInfo fromRow(Context context, CoalescedRow row) { - CharSequence primaryText = CallLogEntryText.buildPrimaryText(context, row); - - return HistoryItemPrimaryActionInfo.builder() + 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(primaryText) - .setSecondaryText(CallLogEntryText.buildSecondaryTextForBottomSheet(context, row)) - .setIntent(CallLogIntents.getCallBackIntent(context, row)) + .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/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. * - * <p>{@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}. + * <p>{@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<HistoryItemActionModule> modules; - private final HistoryItemPrimaryActionInfo historyItemPrimaryActionInfo; + private final HistoryItemBottomSheetHeaderInfo historyItemBottomSheetHeaderInfo; private final GlidePhotoManager glidePhotoManager; private HistoryItemActionBottomSheet( Context context, - HistoryItemPrimaryActionInfo historyItemPrimaryActionInfo, + HistoryItemBottomSheetHeaderInfo historyItemBottomSheetHeaderInfo, List<HistoryItemActionModule> 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<HistoryItemActionModule> 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. - * - * <p>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/PrimaryAction.java b/java/com/android/dialer/voicemail/listui/menu/BottomSheetHeader.java index 14c83563a..bf86278b2 100644 --- a/java/com/android/dialer/voicemail/listui/menu/PrimaryAction.java +++ b/java/com/android/dialer/voicemail/listui/menu/BottomSheetHeader.java @@ -16,39 +16,31 @@ 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.historyitemactions.HistoryItemBottomSheetHeaderInfo; import com.android.dialer.voicemail.model.VoicemailEntry; -/** Configures the primary action row (top row) for theottom sheet for the Voicemail Tab */ -final class PrimaryAction { +/** Configures the top row in the bottom sheet for the Voicemail Tab */ +final class BottomSheetHeader { - // 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() + static HistoryItemBottomSheetHeaderInfo fromVoicemailEntry(VoicemailEntry voicemailEntry) { + return HistoryItemBottomSheetHeaderInfo.newBuilder() .setNumber(voicemailEntry.getNumber()) .setPhotoInfo( NumberAttributesConverter.toPhotoInfoBuilder(voicemailEntry.getNumberAttributes()) .setFormattedNumber(voicemailEntry.getFormattedNumber()) .build()) - .setPrimaryText(buildPrimaryVoicemailText(context, voicemailEntry)) + .setPrimaryText(buildPrimaryVoicemailText(voicemailEntry)) .setSecondaryText(buildSecondaryVoicemailText(voicemailEntry)) .build(); } - private static CharSequence buildSecondaryVoicemailText(VoicemailEntry voicemailEntry) { + private static String buildSecondaryVoicemailText(VoicemailEntry voicemailEntry) { return voicemailEntry.getGeocodedLocation(); } - public static String buildPrimaryVoicemailText(Context context, VoicemailEntry data) { + private static String buildPrimaryVoicemailText(VoicemailEntry data) { StringBuilder primaryText = new StringBuilder(); if (!TextUtils.isEmpty(data.getNumberAttributes().getName())) { primaryText.append(data.getNumberAttributes().getName()); 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); } |