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

Commit 8c7d7f7a authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge changes Ib8b3a874,I7935231d into main

* changes:
  Log event when tapping on do not bubble convo
  Log event when tapping on app settings
parents 9bfa7087 c1b68ef6
Loading
Loading
Loading
Loading
+40 −2
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.wm.shell.shared.handles.RegionSamplingHelper
import com.android.wm.shell.taskview.TaskView
import com.android.wm.shell.taskview.TaskViewTaskController
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import com.google.common.util.concurrent.MoreExecutors.directExecutor
import java.util.Collections
import java.util.concurrent.Executor
@@ -147,6 +148,7 @@ class BubbleBarExpandedViewTest {
    @After
    fun tearDown() {
        testableRegionSamplingHelper?.stopAndDestroy()
        getInstrumentation().waitForIdleSync()
    }

    @Test
@@ -218,8 +220,8 @@ class BubbleBarExpandedViewTest {
    @Test
    fun testEventLogging_dismissBubbleViaAppMenu() {
        getInstrumentation().runOnMainSync { bubbleExpandedView.handleView.performClick() }
        val dismissMenuItem =
            bubbleExpandedView.findViewWithTag<View>(BubbleBarMenuView.DISMISS_ACTION_TAG)
        val dismissMenuItem = bubbleExpandedView.menuView()
            .actionViewWithText(context.getString(R.string.bubble_dismiss_text))
        assertThat(dismissMenuItem).isNotNull()
        getInstrumentation().runOnMainSync { dismissMenuItem.performClick() }
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
@@ -228,6 +230,42 @@ class BubbleBarExpandedViewTest {
        assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble)
    }

    @Test
    fun testEventLogging_openAppSettings() {
        getInstrumentation().runOnMainSync { bubbleExpandedView.handleView.performClick() }
        val appMenuItem = bubbleExpandedView.menuView()
            .actionViewWithText(context.getString(R.string.bubbles_app_settings, bubble.appName))
        getInstrumentation().runOnMainSync { appMenuItem.performClick() }
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
        assertThat(uiEventLoggerFake.logs[0].eventId)
            .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_APP_MENU_GO_TO_SETTINGS.id)
        assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble)
    }

    @Test
    fun testEventLogging_unBubbleConversation() {
        getInstrumentation().runOnMainSync { bubbleExpandedView.handleView.performClick() }
        val menuItem = bubbleExpandedView.menuView()
            .actionViewWithText(context.getString(R.string.bubbles_dont_bubble_conversation))
        getInstrumentation().runOnMainSync { menuItem.performClick() }
        assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
        assertThat(uiEventLoggerFake.logs[0].eventId)
            .isEqualTo(BubbleLogger.Event.BUBBLE_BAR_APP_MENU_OPT_OUT.id)
        assertThat(uiEventLoggerFake.logs[0]).hasBubbleInfo(bubble)
    }

    private fun BubbleBarExpandedView.menuView(): BubbleBarMenuView {
        return findViewByPredicate { it is BubbleBarMenuView }
    }

    private fun BubbleBarMenuView.actionViewWithText(text: CharSequence): View {
        val views = ArrayList<View>()
        findViewsWithText(views, text, View.FIND_VIEWS_WITH_TEXT)
        assertWithMessage("Expecting a single action with text '$text'").that(views).hasSize(1)
        // findViewsWithText returns the TextView, but the click listener is on the parent container
        return views.first().parent as View
    }

    private inner class FakeBubbleTaskViewFactory : BubbleTaskViewFactory {
        override fun create(): BubbleTaskView {
            val taskViewTaskController = mock<TaskViewTaskController>()
+2 −0
Original line number Diff line number Diff line
@@ -241,12 +241,14 @@ public class BubbleBarExpandedView extends FrameLayout implements BubbleTaskView
                if (mListener != null) {
                    mListener.onUnBubbleConversation(bubble.getKey());
                }
                mBubbleLogger.log(bubble, BubbleLogger.Event.BUBBLE_BAR_APP_MENU_OPT_OUT);
            }

            @Override
            public void onOpenAppSettings(Bubble bubble) {
                mManager.collapseStack();
                mContext.startActivityAsUser(bubble.getSettingsIntent(mContext), bubble.getUser());
                mBubbleLogger.log(bubble, BubbleLogger.Event.BUBBLE_BAR_APP_MENU_GO_TO_SETTINGS);
            }

            @Override
+0 −17
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package com.android.wm.shell.bubbles.bar;

import android.annotation.ColorInt;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
@@ -43,8 +42,6 @@ import java.util.ArrayList;
 */
public class BubbleBarMenuView extends LinearLayout {

    public static final Object DISMISS_ACTION_TAG = new Object();

    private ViewGroup mBubbleSectionView;
    private ViewGroup mActionsSectionView;
    private ImageView mBubbleIconView;
@@ -123,9 +120,6 @@ public class BubbleBarMenuView extends LinearLayout {
                    R.layout.bubble_bar_menu_item, mActionsSectionView, false);
            itemView.update(action.mIcon, action.mTitle, action.mTint);
            itemView.setOnClickListener(action.mOnClick);
            if (action.mTag != null) {
                itemView.setTag(action.mTag);
            }
            mActionsSectionView.addView(itemView);
        }
    }
@@ -166,8 +160,6 @@ public class BubbleBarMenuView extends LinearLayout {
        private Icon mIcon;
        private @ColorInt int mTint;
        private String mTitle;
        @Nullable
        private Object mTag;
        private OnClickListener mOnClick;

        MenuAction(Icon icon, String title, OnClickListener onClick) {
@@ -180,14 +172,5 @@ public class BubbleBarMenuView extends LinearLayout {
            this.mTint = tint;
            this.mOnClick = onClick;
        }

        MenuAction(Icon icon, String title, @ColorInt int tint, @Nullable Object tag,
                OnClickListener onClick) {
            this.mIcon = icon;
            this.mTitle = title;
            this.mTint = tint;
            this.mTag = tag;
            this.mOnClick = onClick;
        }
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -212,7 +212,6 @@ class BubbleBarMenuViewController {
                Icon.createWithResource(resources, R.drawable.ic_remove_no_shadow),
                resources.getString(R.string.bubble_dismiss_text),
                tintColor,
                BubbleBarMenuView.DISMISS_ACTION_TAG,
                view -> {
                    hideMenu(true /* animated */);
                    if (mListener != null) {