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

Commit eac73f30 authored by Eric Erfanian's avatar Eric Erfanian Committed by Gerrit Code Review
Browse files

Merge changes I7be0efad,I4d6fb104,Idc15d873,I6b3241bc,If8c6e798, ...

* changes:
  Updated logic on showing voice/video/sms options in favorites menus.
  Implemented remove starred contact from speed dial fragment.
  Remove audio change behavior for background calling.
  Move DialerCall.State to an independent package.
  Logging for background calling and HFP device support.
  HFP device support change.
  Handle missing permission.READ_CALL_LOG when initializing the badge for missed calls.
parents c28ed744 16b77d4d
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ message DialerImpression {
  // Event enums to be used for Impression Logging in Dialer.
  // It's perfectly acceptable for this enum to be large
  // Values should be from 1000 to 100000.
  // Next Tag: 1392
  // Next Tag: 1397
  enum Type {
    UNKNOWN_AOSP_EVENT_TYPE = 1000;

@@ -770,5 +770,14 @@ message DialerImpression {
    // Send button clicked in RTT call, this includes send button on keyboard.
    RTT_SEND_BUTTON_CLICKED = 1387;
    RTT_KEYBOARD_SEND_BUTTON_CLICKED = 1388;

    // For background calling
    START_CALL_IN_BUBBLE_MODE = 1392;

    // Switch audio route
    IN_CALL_SWITCH_AUDIO_ROUTE_SPEAKER = 1393;
    IN_CALL_SWITCH_AUDIO_ROUTE_WIRED_HEADSET = 1394;
    IN_CALL_SWITCH_AUDIO_ROUTE_EARPIECE = 1395;
    IN_CALL_SWITCH_AUDIO_ROUTE_BLUETOOTH = 1396;
  }
}
+10 −4
Original line number Diff line number Diff line
@@ -457,6 +457,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    return DialpadFragment.isAddCallMode(intent);
  }

  @SuppressLint("MissingPermission")
  @Override
  public void onActivityResume() {
    callLogFragmentListener.onActivityResume();
@@ -492,11 +493,16 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    bottomNavTabListener.ensureCorrectCallLogShown();
    bottomNavTabListener.ensureCorrectVoicemailShown();

    // Config the badge of missed calls for the new call log.
    if (bottomNavTabListener.newCallLogFragmentActive()) {
      if (PermissionsUtil.hasCallLogReadPermissions(activity)) {
        missedCallCountObserver.onChange(false); // Set the initial value for the badge
        activity
            .getContentResolver()
            .registerContentObserver(Calls.CONTENT_URI, true, missedCallCountObserver);
      } else {
        bottomNav.setNotificationCount(TabIndex.CALL_LOG, 0);
      }
    }

    // add 1 sec delay to get memory snapshot so that dialer wont react slowly on resume.
+3 −6
Original line number Diff line number Diff line
@@ -16,15 +16,15 @@

package com.android.dialer.main.impl.bottomnav;

import android.annotation.SuppressLint;
import android.Manifest;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.provider.CallLog.Calls;
import android.support.annotation.RequiresPermission;
import com.android.dialer.common.concurrent.DialerExecutorComponent;
import com.android.dialer.common.concurrent.UiListener;
import com.android.dialer.main.impl.bottomnav.BottomNavBar.TabIndex;
import com.android.dialer.util.PermissionsUtil;
import com.google.common.util.concurrent.ListenableFuture;

/**
@@ -45,7 +45,7 @@ public final class MissedCallCountObserver extends ContentObserver {
    this.uiListener = uiListener;
  }

  @SuppressLint("MissingPermission")
  @RequiresPermission(Manifest.permission.READ_CALL_LOG)
  @Override
  public void onChange(boolean selfChange) {
    ListenableFuture<Integer> countFuture =
@@ -53,9 +53,6 @@ public final class MissedCallCountObserver extends ContentObserver {
            .backgroundExecutor()
            .submit(
                () -> {
                  if (!PermissionsUtil.hasCallLogReadPermissions(appContext)) {
                    return 0;
                  }
                  try (Cursor cursor =
                      appContext
                          .getContentResolver()
+15 −29
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ package com.android.dialer.speeddial;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.dialer.common.Assert;
import com.android.dialer.speeddial.database.SpeedDialEntry.Channel;
import com.android.dialer.speeddial.loader.SpeedDialUiItem;

@@ -30,13 +32,13 @@ public class ContextMenu extends LinearLayout {

  private ContextMenuItemListener listener;

  private TextView voiceView;
  private TextView videoView;
  private TextView smsView;

  private SpeedDialUiItem speedDialUiItem;
  private Channel voiceChannel;
  private Channel videoChannel;
  private Channel smsChannel;

  public ContextMenu(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
@@ -50,9 +52,11 @@ public class ContextMenu extends LinearLayout {
    videoView.setOnClickListener(v -> placeVideoCall());

    smsView = findViewById(R.id.send_message_container);
    smsView.setOnClickListener(v -> listener.openSmsConversation(smsChannel.number()));
    smsView.setOnClickListener(v -> listener.openSmsConversation(voiceChannel.number()));

    voiceView = findViewById(R.id.voice_call_container);
    voiceView.setOnClickListener(v -> placeVoiceCall());

    findViewById(R.id.voice_call_container).setOnClickListener(v -> placeVoiceCall());
    findViewById(R.id.remove_container)
        .setOnClickListener(v -> listener.removeFavoriteContact(speedDialUiItem));
    findViewById(R.id.contact_info_container)
@@ -76,14 +80,11 @@ public class ContextMenu extends LinearLayout {
    setX((float) (childLocation[0] + .5 * childLayout.getWidth() - .5 * getWidth()));
    setY(childLocation[1] - parentLocation[1] + childLayout.getHeight());

    voiceChannel = speedDialUiItem.getDeterministicVoiceChannel();
    videoChannel = speedDialUiItem.getDeterministicVideoChannel();
    videoView.setVisibility(
        videoChannel == null && !speedDialUiItem.hasVideoChannels() ? View.GONE : View.VISIBLE);

    // TODO(calderwoodra): disambig dialog for texts?
    smsChannel = voiceChannel;
    smsView.setVisibility(smsChannel == null ? View.GONE : View.VISIBLE);
    voiceChannel = speedDialUiItem.getDefaultVoiceChannel();
    videoChannel = speedDialUiItem.getDefaultVideoChannel();
    voiceView.setVisibility(videoChannel == null ? View.GONE : View.VISIBLE);
    videoView.setVisibility(videoChannel == null ? View.GONE : View.VISIBLE);
    smsView.setVisibility(voiceChannel == null ? View.GONE : View.VISIBLE);

    // TODO(calderwoodra): a11y
    // TODO(calderwoodra): animate this similar to the bubble menu
@@ -102,19 +103,11 @@ public class ContextMenu extends LinearLayout {
  }

  private void placeVoiceCall() {
    if (voiceChannel == null) {
      listener.disambiguateCall(speedDialUiItem);
    } else {
      listener.placeCall(voiceChannel);
    }
    listener.placeCall(Assert.isNotNull(voiceChannel));
  }

  private void placeVideoCall() {
    if (videoChannel == null) {
      listener.disambiguateCall(speedDialUiItem);
    } else {
      listener.placeCall(videoChannel);
    }
    listener.placeCall(Assert.isNotNull(videoChannel));
  }

  public boolean isVisible() {
@@ -122,19 +115,12 @@ public class ContextMenu extends LinearLayout {
  }

  /** Listener to report user clicks on menu items. */
  @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
  public interface ContextMenuItemListener {

    /** Called when the user selects "voice call" or "video call" option from the context menu. */
    void placeCall(Channel channel);

    /**
     * Called when the user selects "voice call" or "video call" option from the context menu, but
     * it's not clear which channel they want to call.
     *
     * <p>TODO(calderwoodra): discuss with product how we want to handle these cases
     */
    void disambiguateCall(SpeedDialUiItem speedDialUiItem);

    /** Called when the user selects "send message" from the context menu. */
    void openSmsConversation(String number);

+34 −56
Original line number Diff line number Diff line
@@ -105,6 +105,10 @@ public class SpeedDialFragment extends Fragment {
    LogUtil.enterBlock("SpeedDialFragment.onCreateView");
    View rootLayout = inflater.inflate(R.layout.fragment_speed_dial, container, false);

    speedDialLoaderListener =
        DialerExecutorComponent.get(getContext())
            .createUiListener(getChildFragmentManager(), "speed_dial_loader_listener");

    // Setup favorite contact context menu
    contextMenu = rootLayout.findViewById(R.id.favorite_contact_context_menu);
    contextMenuBackground = rootLayout.findViewById(R.id.context_menu_background);
@@ -124,7 +128,10 @@ public class SpeedDialFragment extends Fragment {
            rootLayout,
            contextMenu,
            contextMenuBackground,
            new SpeedDialContextMenuItemListener(getActivity(), getChildFragmentManager()),
            new SpeedDialContextMenuItemListener(
                getActivity(),
                new UpdateSpeedDialAdapterListener(),
                speedDialLoaderListener),
            layoutManager);
    adapter =
        new SpeedDialAdapter(getContext(), favoritesListener, suggestedListener, headerListener);
@@ -138,10 +145,6 @@ public class SpeedDialFragment extends Fragment {
    ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
    touchHelper.attachToRecyclerView(recyclerView);
    adapter.setItemTouchHelper(touchHelper);

    speedDialLoaderListener =
        DialerExecutorComponent.get(getContext())
            .createUiListener(getChildFragmentManager(), "speed_dial_loader_listener");
    return rootLayout;
  }

@@ -317,19 +320,17 @@ public class SpeedDialFragment extends Fragment {
      Channel defaultChannel = speedDialUiItem.defaultChannel();

      // Add voice call module
      Channel voiceChannel = speedDialUiItem.getDeterministicVoiceChannel();
      Channel voiceChannel = speedDialUiItem.getDefaultVoiceChannel();
      if (voiceChannel != null) {
        modules.add(
            IntentModule.newCallModule(
                getContext(),
                new CallIntentBuilder(voiceChannel.number(), CallInitiationType.Type.SPEED_DIAL)
                    .setAllowAssistedDial(true)));
      } else {
        modules.add(new DisambigDialogModule(speedDialUiItem, /* isVideo = */ false));
      }

      // Add video if we can determine the correct channel
      Channel videoChannel = speedDialUiItem.getDeterministicVideoChannel();
      Channel videoChannel = speedDialUiItem.getDefaultVideoChannel();
      if (videoChannel != null) {
        modules.add(
            IntentModule.newCallModule(
@@ -337,8 +338,6 @@ public class SpeedDialFragment extends Fragment {
                new CallIntentBuilder(videoChannel.number(), CallInitiationType.Type.SPEED_DIAL)
                    .setIsVideoCall(true)
                    .setAllowAssistedDial(true)));
      } else if (speedDialUiItem.hasVideoChannels()) {
        modules.add(new DisambigDialogModule(speedDialUiItem, /* isVideo = */ true));
      }

      // Add sms module
@@ -396,58 +395,21 @@ public class SpeedDialFragment extends Fragment {
        return false;
      }
    }

    private final class DisambigDialogModule implements HistoryItemActionModule {

      private final SpeedDialUiItem speedDialUiItem;
      private final boolean isVideo;

      DisambigDialogModule(SpeedDialUiItem speedDialUiItem, boolean isVideo) {
        this.speedDialUiItem = speedDialUiItem;
        this.isVideo = isVideo;
      }

      @Override
      public int getStringId() {
        if (isVideo) {
          return R.string.contact_menu_video_call;
        } else {
          return R.string.contact_menu_voice_call;
        }
      }

      @Override
      public int getDrawableId() {
        if (isVideo) {
          return R.drawable.quantum_ic_videocam_vd_theme_24;
        } else {
          return R.drawable.quantum_ic_phone_vd_theme_24;
        }
      }

      @Override
      public boolean onClick() {
        DisambigDialog.show(speedDialUiItem, getChildFragmentManager());
        return true;
      }
    }
  }

  private static final class SpeedDialContextMenuItemListener implements ContextMenuItemListener {

    private final FragmentActivity activity;
    private final FragmentManager childFragmentManager;
    private final SupportUiListener<ImmutableList<SpeedDialUiItem>> speedDialLoaderListener;
    private final UpdateSpeedDialAdapterListener updateAdapterListener;

    SpeedDialContextMenuItemListener(
        FragmentActivity activity, FragmentManager childFragmentManager) {
        FragmentActivity activity,
        UpdateSpeedDialAdapterListener updateAdapterListener,
        SupportUiListener<ImmutableList<SpeedDialUiItem>> speedDialLoaderListener) {
      this.activity = activity;
      this.childFragmentManager = childFragmentManager;
    }

    @Override
    public void disambiguateCall(SpeedDialUiItem speedDialUiItem) {
      // TODO(calderwoodra): show only video or voice channels in the disambig dialog
      DisambigDialog.show(speedDialUiItem, childFragmentManager);
      this.updateAdapterListener = updateAdapterListener;
      this.speedDialLoaderListener = speedDialLoaderListener;
    }

    @Override
@@ -472,7 +434,15 @@ public class SpeedDialFragment extends Fragment {

    @Override
    public void removeFavoriteContact(SpeedDialUiItem speedDialUiItem) {
      // TODO(calderwoodra): implement remove
      speedDialLoaderListener.listen(
          activity,
          UiItemLoaderComponent.get(activity)
              .speedDialUiItemMutator()
              .removeSpeedDialUiItem(speedDialUiItem),
          updateAdapterListener::updateAdapter,
          throwable -> {
            throw new RuntimeException(throwable);
          });
    }

    @Override
@@ -485,6 +455,14 @@ public class SpeedDialFragment extends Fragment {
    }
  }

  /** Listener for when a SpeedDialUiItem is updated. */
  private class UpdateSpeedDialAdapterListener {

    void updateAdapter(ImmutableList<SpeedDialUiItem> speedDialUiItems) {
      onSpeedDialUiItemListLoaded(speedDialUiItems);
    }
  }

  /** Interface for {@link SpeedDialFragment} to communicate with its host/parent. */
  public interface HostInterface {

Loading