[STG] Add activity log menu options
https://drive.google.com/file/d/1XZzBUNJqBrm2wwftdcLixDrS48UE_HZs/view?usp=sharing&resourcekey=0-VVdFA3P-wUg036krv0OzrQ
Update: https://screenshot.googleplex.com/98A3hGEk8YXVk7p
Bug: 412366795
Change-Id: Ic0aeebf73cdc432a7ba244a49403bff134492313
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6490737
Commit-Queue: Hailey Wang <[email protected]>
Reviewed-by: Siddhartha S <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1452271}
diff --git a/chrome/browser/data_sharing/BUILD.gn b/chrome/browser/data_sharing/BUILD.gn
index 2c5fd44ef..c7a994e 100644
--- a/chrome/browser/data_sharing/BUILD.gn
+++ b/chrome/browser/data_sharing/BUILD.gn
@@ -57,6 +57,7 @@
"android/java/res/layout/shared_image_tiles_icon.xml",
"android/java/res/values/colors.xml",
"android/java/res/values/dimens.xml",
+ "android/java/res/values/ids.xml",
"android/java/res/values/styles.xml",
]
deps = [ "//components/browser_ui/styles/android:java_resources" ]
@@ -128,6 +129,8 @@
"//base:supplier_java",
"//chrome/browser/ui/android/strings:ui_strings_grd",
"//components/browser_ui/bottomsheet/android:java",
+ "//components/browser_ui/bottomsheet/android:java_resources",
+ "//components/browser_ui/widget/android:java",
"//components/browser_ui/widget/android:java_resources",
"//components/collaboration/public:messaging_java",
"//components/data_sharing/public:public_java",
diff --git a/chrome/browser/data_sharing/android/java/res/layout/recent_activity_bottom_sheet.xml b/chrome/browser/data_sharing/android/java/res/layout/recent_activity_bottom_sheet.xml
index 09911cd..bab9c42f 100644
--- a/chrome/browser/data_sharing/android/java/res/layout/recent_activity_bottom_sheet.xml
+++ b/chrome/browser/data_sharing/android/java/res/layout/recent_activity_bottom_sheet.xml
@@ -14,14 +14,33 @@
<include layout="@layout/bottom_sheet_handlebar"/>
- <TextView
- android:id="@+id/title"
- android:textAppearance="@style/TextAppearance.Headline2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/recent_activity_title_top_margin"
- android:layout_marginStart="@dimen/list_item_default_margin"
- android:text="@string/data_sharing_recent_activity_bottom_sheet_title"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:layout_marginTop="@dimen/recent_activity_title_top_margin"
+ android:paddingStart="@dimen/list_item_default_margin"
+ android:paddingEnd="@dimen/list_item_default_margin">
+
+ <TextView
+ android:id="@+id/title"
+ android:textAppearance="@style/TextAppearance.Headline2"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/data_sharing_recent_activity_bottom_sheet_title"/>
+
+ <org.chromium.ui.listmenu.ListMenuButton
+ android:id="@+id/recent_activity_menu_button"
+ android:layout_width="@dimen/min_touch_target_size"
+ android:layout_height="@dimen/min_touch_target_size"
+ android:background="@null"
+ android:src="@drawable/ic_more_vert_24dp"
+ android:contentDescription="@string/collaboration_recent_activity_menu_option"
+ app:tint="@color/default_icon_color_tint_list" />
+
+ </LinearLayout>
<FrameLayout
android:layout_width="match_parent"
diff --git a/chrome/browser/data_sharing/android/java/res/values/dimens.xml b/chrome/browser/data_sharing/android/java/res/values/dimens.xml
index 790d2be..78adafc 100644
--- a/chrome/browser/data_sharing/android/java/res/values/dimens.xml
+++ b/chrome/browser/data_sharing/android/java/res/values/dimens.xml
@@ -23,7 +23,7 @@
<dimen name="recent_activity_avatar_size">40dp</dimen>
<dimen name="recent_activity_avatar_radius">20dp</dimen>
<dimen name="recent_activity_avatar_margin_end">16dp</dimen>
- <dimen name="recent_activity_title_top_margin">14dp</dimen>
+ <dimen name="recent_activity_title_top_margin">2dp</dimen>
<dimen name="recent_activity_recycler_view_top_margin">7dp</dimen>
<dimen name="recent_activity_empty_view_top_margin">80dp</dimen>
<dimen name="recent_activity_content_area_min_height">200dp</dimen>
diff --git a/chrome/browser/data_sharing/android/java/res/values/ids.xml b/chrome/browser/data_sharing/android/java/res/values/ids.xml
new file mode 100644
index 0000000..108c0845
--- /dev/null
+++ b/chrome/browser/data_sharing/android/java/res/values/ids.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+Copyright 2025 The Chromium Authors
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+
+<resources>
+ <!-- Menu IDs -->
+ <item type="id" name="see_full_activity" />
+</resources>
diff --git a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingTabManager.java b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingTabManager.java
index 73b799b..d4ec3e8 100644
--- a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingTabManager.java
+++ b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/DataSharingTabManager.java
@@ -886,6 +886,12 @@
collaborationId,
assumeNonNull(existingGroup.syncId),
manageSharingCallback);
+
+ Runnable showFullActivityRunnable =
+ () -> {
+ mDataSharingTabGroupsDelegate.openUrlInChromeCustomTab(
+ activity, new GURL(ACTIVITY_LOGS_URL));
+ };
RecentActivityListCoordinator recentActivityListCoordinator =
new RecentActivityListCoordinator(
collaborationId,
@@ -895,7 +901,8 @@
tabGroupSyncService,
new DataSharingFaviconProvider(activity, mProfile, mBulkFaviconUtil),
avatarProvider,
- recentActivityActionHandler);
+ recentActivityActionHandler,
+ showFullActivityRunnable);
recentActivityListCoordinator.requestShowUI();
}
diff --git a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityContainerProperties.java b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityContainerProperties.java
index 77bd90f2..3e40569 100644
--- a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityContainerProperties.java
+++ b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityContainerProperties.java
@@ -4,9 +4,12 @@
package org.chromium.chrome.browser.data_sharing.ui.recent_activity;
+import android.view.View.OnClickListener;
+
import org.chromium.build.annotations.NullMarked;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel.WritableBooleanPropertyKey;
+import org.chromium.ui.modelutil.PropertyModel.WritableObjectPropertyKey;
/** Properties for the recent activity list container view. */
@NullMarked
@@ -14,5 +17,8 @@
public static final WritableBooleanPropertyKey EMPTY_STATE_VISIBLE =
new WritableBooleanPropertyKey();
- public static final PropertyKey[] ALL_KEYS = {EMPTY_STATE_VISIBLE};
+ public static final WritableObjectPropertyKey<OnClickListener> MENU_CLICK_LISTENER =
+ new WritableObjectPropertyKey<>();
+
+ public static final PropertyKey[] ALL_KEYS = {EMPTY_STATE_VISIBLE, MENU_CLICK_LISTENER};
}
diff --git a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityContainerViewBinder.java b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityContainerViewBinder.java
index 2e40d09..84c3b665 100644
--- a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityContainerViewBinder.java
+++ b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityContainerViewBinder.java
@@ -7,6 +7,7 @@
import android.view.View;
import org.chromium.build.annotations.NullMarked;
+import org.chromium.ui.listmenu.ListMenuButton;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
@@ -21,6 +22,10 @@
View recyclerView = view.findViewById(R.id.recent_activity_recycler_view);
emptyView.setVisibility(isEmptyState ? View.VISIBLE : View.GONE);
recyclerView.setVisibility(isEmptyState ? View.GONE : View.VISIBLE);
+ } else if (propertyKey == RecentActivityContainerProperties.MENU_CLICK_LISTENER) {
+ ListMenuButton menuButton = view.findViewById(R.id.recent_activity_menu_button);
+ menuButton.setOnClickListener(
+ model.get(RecentActivityContainerProperties.MENU_CLICK_LISTENER));
}
}
}
diff --git a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListCoordinator.java b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListCoordinator.java
index 7988a82..910b2be 100644
--- a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListCoordinator.java
+++ b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListCoordinator.java
@@ -10,6 +10,7 @@
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnClickListener;
import androidx.recyclerview.widget.RecyclerView;
@@ -18,14 +19,22 @@
import org.chromium.build.annotations.Nullable;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
import org.chromium.components.browser_ui.bottomsheet.EmptyBottomSheetObserver;
+import org.chromium.components.browser_ui.widget.BrowserUiListMenuUtils;
import org.chromium.components.collaboration.messaging.MessagingBackendService;
import org.chromium.components.data_sharing.GroupMember;
import org.chromium.components.tab_group_sync.TabGroupSyncService;
+import org.chromium.ui.listmenu.BasicListMenu;
+import org.chromium.ui.listmenu.ListMenu;
+import org.chromium.ui.listmenu.ListMenuButton;
+import org.chromium.ui.listmenu.ListMenuDelegate;
+import org.chromium.ui.listmenu.ListMenuItemProperties;
import org.chromium.ui.modelutil.LayoutViewBuilder;
import org.chromium.ui.modelutil.MVCListAdapter.ModelList;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import org.chromium.ui.modelutil.SimpleRecyclerViewAdapter;
+import org.chromium.ui.widget.RectProvider;
+import org.chromium.ui.widget.ViewRectProvider;
import org.chromium.url.GURL;
/**
@@ -64,12 +73,14 @@
@Nullable GroupMember member, Callback<Drawable> avatarDrawableCallback);
}
+ private final Context mContext;
private final BottomSheetController mBottomSheetController;
private final ModelList mModelList;
private final View mContentContainer;
private final RecyclerView mContentRecyclerView;
private final RecentActivityListMediator mMediator;
private @Nullable RecentActivityBottomSheetContent mBottomSheetContent;
+ private final Runnable mShowFullActivityRunnable;
/**
* Constructor.
@@ -81,6 +92,7 @@
* @param faviconProvider The backend for providing favicon for URLs.
* @param avatarProvider The backend for providing avatars for users.
* @param recentActivityActionHandler Click event handler for activity rows.
+ * @param showFullActivityRunnable Runnable to show the full activity log.
*/
public RecentActivityListCoordinator(
String collaborationId,
@@ -90,13 +102,20 @@
TabGroupSyncService tabGroupSyncService,
FaviconProvider faviconProvider,
AvatarProvider avatarProvider,
- RecentActivityActionHandler recentActivityActionHandler) {
+ RecentActivityActionHandler recentActivityActionHandler,
+ Runnable showFullActivityRunnable) {
+ mContext = context;
mBottomSheetController = bottomSheetController;
+ mShowFullActivityRunnable = showFullActivityRunnable;
mContentContainer =
LayoutInflater.from(context)
.inflate(R.layout.recent_activity_bottom_sheet, /* root= */ null);
PropertyModel propertyModel =
- new PropertyModel.Builder(RecentActivityContainerProperties.ALL_KEYS).build();
+ new PropertyModel.Builder(RecentActivityContainerProperties.ALL_KEYS)
+ .with(
+ RecentActivityContainerProperties.MENU_CLICK_LISTENER,
+ createRecentActivityMenuButtonClickListener())
+ .build();
PropertyModelChangeProcessor.create(
propertyModel, mContentContainer, RecentActivityContainerViewBinder::bind);
@@ -134,6 +153,53 @@
this::closeBottomSheet);
}
+ private OnClickListener createRecentActivityMenuButtonClickListener() {
+ return view -> {
+ ListMenuButton menuView = view.findViewById(R.id.recent_activity_menu_button);
+ ModelList modelList = new ModelList();
+ modelList.add(
+ BrowserUiListMenuUtils.buildMenuListItem(
+ R.string.data_sharing_recent_activity_show_all,
+ R.id.see_full_activity,
+ 0,
+ /* enabled= */ true));
+ ListMenu.Delegate delegate =
+ (model) -> {
+ int textId = model.get(ListMenuItemProperties.TITLE_ID);
+ if (textId == R.string.data_sharing_recent_activity_show_all) {
+ mShowFullActivityRunnable.run();
+ }
+ };
+
+ BasicListMenu listMenu =
+ BrowserUiListMenuUtils.getBasicListMenu(mContext, modelList, delegate);
+
+ ListMenuDelegate listMenuDelegate =
+ new ListMenuDelegate() {
+ @Override
+ public ListMenu getListMenu() {
+ return listMenu;
+ }
+
+ @Override
+ public RectProvider getRectProvider(View listMenuButton) {
+ ViewRectProvider rectProvider = new ViewRectProvider(listMenuButton);
+ rectProvider.setIncludePadding(true);
+
+ int handleBarHeight =
+ mContentContainer.findViewById(R.id.handlebar).getHeight();
+ int buttonHeight = listMenuButton.getHeight();
+ rectProvider.setInsetPx(0, handleBarHeight + buttonHeight, 0, 0);
+ return rectProvider;
+ }
+ };
+
+ menuView.setDelegate(listMenuDelegate);
+ menuView.tryToFitLargestItem(true);
+ menuView.showMenu();
+ };
+ }
+
/**
* Called to create the UI creation. Builds the list UI and after the list is created pulls up
* the bottom sheet UI.
diff --git a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListCoordinatorUnitTest.java b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListCoordinatorUnitTest.java
index 768127c..5000e30 100644
--- a/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListCoordinatorUnitTest.java
+++ b/chrome/browser/data_sharing/android/java/src/org/chromium/chrome/browser/data_sharing/ui/recent_activity/RecentActivityListCoordinatorUnitTest.java
@@ -27,6 +27,7 @@
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
+import org.chromium.base.CallbackUtils;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.chrome.browser.data_sharing.ui.recent_activity.RecentActivityListCoordinator.AvatarProvider;
import org.chromium.chrome.browser.data_sharing.ui.recent_activity.RecentActivityListCoordinator.FaviconProvider;
@@ -92,7 +93,8 @@
mTabGroupSyncService,
mFaviconProvider,
mAvatarProvider,
- mRecentActivityActionHandler);
+ mRecentActivityActionHandler,
+ CallbackUtils.emptyRunnable());
verify(mBottomSheetController).addObserver(any());
}