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 --- .../HistoryItemActionBottomSheet.java | 31 ++++----- .../HistoryItemPrimaryActionInfo.java | 73 ---------------------- .../history_item_bottom_sheet_header_info.proto | 41 ++++++++++++ 3 files changed, 53 insertions(+), 92 deletions(-) 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 (limited to 'java/com/android/dialer/historyitemactions') 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. +} -- cgit v1.2.3