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

Commit e716024f authored by yueg's avatar yueg Committed by android-build-merger
Browse files

Merge "NUI logging" am: d554f435

am: 36d25802

Change-Id: I886648530f18dd7e4ddd38cbd8cff3b0bde87c2e
parents b758f21a 36d25802
Loading
Loading
Loading
Loading
+11 −2
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: 1346
  // Next Tag: 1352
  enum Type {
    UNKNOWN_AOSP_EVENT_TYPE = 1000;

@@ -658,7 +658,7 @@ message DialerImpression {
    DUO_CALL_LOG_SET_UP_ACTIVATE_SHOWN = 1325;
    DUO_CALL_LOG_INVITE_SHOWN = 1326;

    // NUI bottom navigation bar
    // NUI bottom navigation bar user actions
    MAIN_SWITCH_TAB_TO_FAVORITE = 1327;
    MAIN_SWITCH_TAB_TO_CALL_LOG = 1328;
    MAIN_SWITCH_TAB_TO_CONTACTS = 1329;
@@ -686,5 +686,14 @@ message DialerImpression {
    ANNOTATED_CALL_LOG_CHANGES_NEEDED = 1344;
    // The call log was force refreshed and changes were needed.
    ANNOTATED_CALL_LOG_FORCE_REFRESH_CHANGES_NEEDED = 1345;

    MAIN_VVM_TAB_VISIBLE = 1346;

    // Main bottom navigation bar non user actions
    MAIN_OPEN_WITH_TAB_FAVORITE = 1347;
    MAIN_OPEN_WITH_TAB_CALL_LOG = 1348;
    MAIN_OPEN_WITH_TAB_CONTACTS = 1349;
    MAIN_OPEN_WITH_TAB_VOICEMAIL = 1350;
    MAIN_OPEN_WITH_DIALPAD = 1351;
  }
}
+7 −0
Original line number Diff line number Diff line
@@ -69,5 +69,12 @@ message ScreenEvent {
    BLOCKED_NUMBER_ADD_NUMBER = 19;

    CALL_DETAILS = 20;

    MAIN_SPEED_DIAL = 21;
    MAIN_CALL_LOG = 22;
    MAIN_CONTACTS = 23;
    MAIN_VOICEMAIL = 24;
    MAIN_DIALPAD = 25;
    MAIN_SEARCH = 26;
  }
}
+5 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ public class MainSearchController implements SearchBarListener {
  private void showDialpad(boolean animate, boolean fromNewIntent) {
    Assert.checkArgument(!isDialpadVisible());

    Logger.get(mainActivity).logScreenView(ScreenEvent.Type.MAIN_DIALPAD, mainActivity);

    fab.hide();
    toolbar.slideUp(animate);
    toolbar.expand(animate, Optional.absent());
@@ -357,6 +359,9 @@ public class MainSearchController implements SearchBarListener {

  private void openSearch(Optional<String> query) {
    LogUtil.enterBlock("MainSearchController.openSearch");

    Logger.get(mainActivity).logScreenView(ScreenEvent.Type.MAIN_SEARCH, mainActivity);

    fab.hide();
    toolbar.expand(/* animate=*/ true, query);
    toolbar.showKeyboard();
+42 −17
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ import com.android.dialer.duo.DuoComponent;
import com.android.dialer.interactions.PhoneNumberInteraction;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import com.android.dialer.logging.ScreenEvent;
import com.android.dialer.main.MainActivityPeer;
import com.android.dialer.main.impl.bottomnav.BottomNavBar;
import com.android.dialer.main.impl.bottomnav.BottomNavBar.OnBottomNavTabSelectedListener;
@@ -242,6 +243,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    onPhoneNumberPickerActionListener = new MainOnPhoneNumberPickerActionListener(mainActivity);
    oldSpeedDialFragmentHost =
        new MainOldSpeedDialFragmentHost(
            mainActivity,
            bottomNav,
            mainActivity.findViewById(R.id.contact_tile_drag_shadow_overlay),
            mainActivity.findViewById(R.id.remove_view),
@@ -337,31 +339,35 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    //     select a tab here.
    //  2) Don't return early here in case the intent does contain extra data.
    //  3) External intents should take priority over other intents (like Calls.CONTENT_TYPE).
    @TabIndex int tabToSelect;
    if (Calls.CONTENT_TYPE.equals(intent.getType())) {
      Bundle extras = intent.getExtras();
      if (extras != null && extras.getInt(Calls.EXTRA_CALL_TYPE_FILTER) == Calls.VOICEMAIL_TYPE) {
        LogUtil.i("OldMainActivityPeer.onHandleIntent", "Voicemail content type intent");
        bottomNav.selectTab(TabIndex.VOICEMAIL);
        tabToSelect = TabIndex.VOICEMAIL;
        Logger.get(mainActivity).logImpression(DialerImpression.Type.VVM_NOTIFICATION_CLICKED);
      } else {
        LogUtil.i("OldMainActivityPeer.onHandleIntent", "Call log content type intent");
        bottomNav.selectTab(TabIndex.CALL_LOG);
        tabToSelect = TabIndex.CALL_LOG;
      }

    } else if (isShowTabIntent(intent)) {
      LogUtil.i("OldMainActivityPeer.onHandleIntent", "Show tab intent");
      bottomNav.selectTab(getTabFromIntent(intent));
      tabToSelect = getTabFromIntent(intent);
    } else if (lastTabController.isEnabled) {
      LogUtil.i("OldMainActivityPeer.onHandleIntent", "Show last tab");
      lastTabController.selectLastTab();
      tabToSelect = lastTabController.getLastTab();
    } else {
      bottomNav.selectTab(TabIndex.SPEED_DIAL);
      tabToSelect = TabIndex.SPEED_DIAL;
    }
    logImpressionForSelectedTab(tabToSelect);
    bottomNav.selectTab(tabToSelect);

    if (isDialOrAddCallIntent(intent)) {
      LogUtil.i("OldMainActivityPeer.onHandleIntent", "Dial or add call intent");
      // Dialpad will grab the intent and populate the number
      searchController.showDialpadFromNewIntent();
      Logger.get(mainActivity).logImpression(DialerImpression.Type.MAIN_OPEN_WITH_DIALPAD);
    }

    if (intent.getBooleanExtra(DialtactsActivity.EXTRA_CLEAR_NEW_VOICEMAILS, false)) {
@@ -370,6 +376,21 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    }
  }

  /** Log impression for non user tab selection. */
  private void logImpressionForSelectedTab(@TabIndex int tab) {
    if (tab == TabIndex.SPEED_DIAL) {
      Logger.get(mainActivity).logImpression(DialerImpression.Type.MAIN_OPEN_WITH_TAB_FAVORITE);
    } else if (tab == TabIndex.CALL_LOG) {
      Logger.get(mainActivity).logImpression(DialerImpression.Type.MAIN_OPEN_WITH_TAB_CALL_LOG);
    } else if (tab == TabIndex.CONTACTS) {
      Logger.get(mainActivity).logImpression(DialerImpression.Type.MAIN_OPEN_WITH_TAB_CONTACTS);
    } else if (tab == TabIndex.VOICEMAIL) {
      Logger.get(mainActivity).logImpression(DialerImpression.Type.MAIN_OPEN_WITH_TAB_VOICEMAIL);
    } else {
      throw new IllegalStateException("Invalid tab: " + tab);
    }
  }

  /** Returns true if the given intent is a Dial intent with data or an Add Call intent. */
  private boolean isDialOrAddCallIntent(Intent intent) {
    if (intent == null) {
@@ -819,8 +840,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
              numberOfActiveVoicemailSources));

      if (hasActiveVoicemailProvider) {
        // TODO(yueg): Use new logging for VVM_TAB_VISIBLE
        // Logger.get(context).logImpression(DialerImpression.Type.VVM_TAB_VISIBLE);
        Logger.get(context).logImpression(DialerImpression.Type.MAIN_VVM_TAB_VISIBLE);
        bottomNavBar.showVoicemail(true);
        callLogQueryHandler.fetchVoicemailUnreadCount();
      } else {
@@ -994,6 +1014,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
  private static final class MainOldSpeedDialFragmentHost
      implements OldSpeedDialFragment.HostInterface, OnDragDropListener {

    private final Context context;
    private final BottomNavBar bottomNavBar;
    private final ImageView dragShadowOverlay;
    private final RemoveView removeView;
@@ -1005,11 +1026,13 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    private DragDropController dragDropController;

    MainOldSpeedDialFragmentHost(
        Context context,
        BottomNavBar bottomNavBar,
        ImageView dragShadowOverlay,
        RemoveView removeView,
        View searchViewContainer,
        MainToolbar toolbar) {
      this.context = context;
      this.bottomNavBar = bottomNavBar;
      this.dragShadowOverlay = dragShadowOverlay;
      this.removeView = removeView;
@@ -1025,6 +1048,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    @Override
    public void showAllContactsTab() {
      bottomNavBar.selectTab(TabIndex.CONTACTS);
      Logger.get(context).logImpression(DialerImpression.Type.MAIN_OPEN_WITH_TAB_CONTACTS);
    }

    @Override
@@ -1077,22 +1101,22 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    private static final String CONTACTS_TAG = "contacts";
    private static final String VOICEMAIL_TAG = "voicemail";

    private final Context context;
    private final MainActivity mainActivity;
    private final FragmentManager fragmentManager;
    private final FloatingActionButton fab;

    @TabIndex private int selectedTab = -1;

    private MainBottomNavBarBottomNavTabListener(
        Context context, FragmentManager fragmentManager, FloatingActionButton fab) {
      this.context = context;
        MainActivity mainActivity, FragmentManager fragmentManager, FloatingActionButton fab) {
      this.mainActivity = mainActivity;
      this.fragmentManager = fragmentManager;
      this.fab = fab;
      preloadCallLogFragment();
    }

    private void preloadCallLogFragment() {
      if (ConfigProviderBindings.get(context).getBoolean("nui_preload_call_log", true)) {
      if (ConfigProviderBindings.get(mainActivity).getBoolean("nui_preload_call_log", true)) {
        CallLogFragment fragment = new CallLogFragment();
        fragmentManager
            .beginTransaction()
@@ -1106,7 +1130,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    public void onSpeedDialSelected() {
      LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onSpeedDialSelected");
      if (selectedTab != TabIndex.SPEED_DIAL) {
        Logger.get(context).logImpression(DialerImpression.Type.MAIN_SWITCH_TAB_TO_FAVORITE);
        Logger.get(mainActivity).logScreenView(ScreenEvent.Type.MAIN_SPEED_DIAL, mainActivity);
        selectedTab = TabIndex.SPEED_DIAL;
      }
      hideAllFragments();
@@ -1126,7 +1150,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    public void onCallLogSelected() {
      LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onCallLogSelected");
      if (selectedTab != TabIndex.CALL_LOG) {
        Logger.get(context).logImpression(DialerImpression.Type.MAIN_SWITCH_TAB_TO_CALL_LOG);
        Logger.get(mainActivity).logScreenView(ScreenEvent.Type.MAIN_CALL_LOG, mainActivity);
        selectedTab = TabIndex.CALL_LOG;
      }
      hideAllFragments();
@@ -1146,7 +1170,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    public void onContactsSelected() {
      LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onContactsSelected");
      if (selectedTab != TabIndex.CONTACTS) {
        Logger.get(context).logImpression(DialerImpression.Type.MAIN_SWITCH_TAB_TO_CONTACTS);
        Logger.get(mainActivity).logScreenView(ScreenEvent.Type.MAIN_CONTACTS, mainActivity);
        selectedTab = TabIndex.CONTACTS;
      }
      hideAllFragments();
@@ -1170,7 +1194,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    public void onVoicemailSelected() {
      LogUtil.enterBlock("MainBottomNavBarBottomNavTabListener.onVoicemailSelected");
      if (selectedTab != TabIndex.VOICEMAIL) {
        Logger.get(context).logImpression(DialerImpression.Type.MAIN_SWITCH_TAB_TO_VOICEMAIL);
        Logger.get(mainActivity).logScreenView(ScreenEvent.Type.MAIN_VOICEMAIL, mainActivity);
        selectedTab = TabIndex.VOICEMAIL;
      }
      hideAllFragments();
@@ -1228,7 +1252,8 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
    }

    /** Sets the last tab if the feature is enabled, otherwise defaults to speed dial. */
    void selectLastTab() {
    @TabIndex
    int getLastTab() {
      @TabIndex int tabIndex = TabIndex.SPEED_DIAL;
      if (isEnabled) {
        tabIndex =
@@ -1242,7 +1267,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen
        tabIndex = TabIndex.SPEED_DIAL;
      }

      bottomNavBar.selectTab(tabIndex);
      return tabIndex;
    }

    void onActivityStop() {
+33 −17
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.view.View;
import android.widget.LinearLayout;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -74,27 +76,35 @@ public final class BottomNavBar extends LinearLayout {

    speedDial.setOnClickListener(
        v -> {
          selectedTab = TabIndex.SPEED_DIAL;
          setSelected(speedDial);
          updateListeners(selectedTab);
          if (selectedTab != TabIndex.SPEED_DIAL) {
            Logger.get(getContext())
                .logImpression(DialerImpression.Type.MAIN_SWITCH_TAB_TO_FAVORITE);
          }
          selectTab(TabIndex.SPEED_DIAL);
        });
    callLog.setOnClickListener(
        v -> {
          selectedTab = TabIndex.CALL_LOG;
          setSelected(callLog);
          updateListeners(selectedTab);
          if (selectedTab != TabIndex.CALL_LOG) {
            Logger.get(getContext())
                .logImpression(DialerImpression.Type.MAIN_SWITCH_TAB_TO_CALL_LOG);
          }
          selectTab(TabIndex.CALL_LOG);
        });
    contacts.setOnClickListener(
        v -> {
          selectedTab = TabIndex.CONTACTS;
          setSelected(contacts);
          updateListeners(selectedTab);
          if (selectedTab != TabIndex.CONTACTS) {
            Logger.get(getContext())
                .logImpression(DialerImpression.Type.MAIN_SWITCH_TAB_TO_CONTACTS);
          }
          selectTab(TabIndex.CONTACTS);
        });
    voicemail.setOnClickListener(
        v -> {
          selectedTab = TabIndex.VOICEMAIL;
          setSelected(voicemail);
          updateListeners(selectedTab);
          if (selectedTab != TabIndex.VOICEMAIL) {
            Logger.get(getContext())
                .logImpression(DialerImpression.Type.MAIN_SWITCH_TAB_TO_VOICEMAIL);
          }
          selectTab(TabIndex.VOICEMAIL);
        });
  }

@@ -106,22 +116,28 @@ public final class BottomNavBar extends LinearLayout {
  }

  /**
   * Calls {@link View#performClick()} on the desired tab.
   * Select tab for uesr and non-user click.
   *
   * @param tab {@link TabIndex}
   */
  public void selectTab(@TabIndex int tab) {
    if (tab == TabIndex.SPEED_DIAL) {
      speedDial.performClick();
      selectedTab = TabIndex.SPEED_DIAL;
      setSelected(speedDial);
    } else if (tab == TabIndex.CALL_LOG) {
      callLog.performClick();
      selectedTab = TabIndex.CALL_LOG;
      setSelected(callLog);
    } else if (tab == TabIndex.CONTACTS) {
      contacts.performClick();
      selectedTab = TabIndex.CONTACTS;
      setSelected(contacts);
    } else if (tab == TabIndex.VOICEMAIL) {
      voicemail.performClick();
      selectedTab = TabIndex.VOICEMAIL;
      setSelected(voicemail);
    } else {
      throw new IllegalStateException("Invalid tab: " + tab);
    }

    updateListeners(selectedTab);
  }

  /**