Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewTest.kt +40 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -147,6 +148,7 @@ class BubbleBarExpandedViewTest { @After fun tearDown() { testableRegionSamplingHelper?.stopAndDestroy() getInstrumentation().waitForIdleSync() } @Test Loading Loading @@ -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) Loading @@ -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>() Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuView.java +0 −17 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } } Loading Loading @@ -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) { Loading @@ -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; } } } libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuViewController.java +0 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedViewTest.kt +40 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -147,6 +148,7 @@ class BubbleBarExpandedViewTest { @After fun tearDown() { testableRegionSamplingHelper?.stopAndDestroy() getInstrumentation().waitForIdleSync() } @Test Loading Loading @@ -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) Loading @@ -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>() Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarExpandedView.java +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuView.java +0 −17 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } } Loading Loading @@ -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) { Loading @@ -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; } } }
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarMenuViewController.java +0 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading