Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 510d7c10 authored by linyuh's avatar linyuh Committed by android-build-merger
Browse files

Merge "Make the top row of the bottom sheet not clickable." am: 4633a7d3

am: 8c07d0db

Change-Id: I0760ce38621a5c0e1ac0204226ea9899156aea8e
parents be59ac16 8c07d0db
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -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();
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -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);

+12 −19
Original line number Diff line number Diff line
@@ -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;
  }

+0 −73
Original line number Diff line number Diff line
/*
 * 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();
  }
}
+41 −0
Original line number Diff line number Diff line
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.
}
Loading