Commit 8517d120 authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[Sharing Hub] Reorder 1P share features

Reorder the first party share options to match the spec.

Bug: 1009124
Change-Id: I0f90f6c2cc7edad008b2d49f67943fc49c366804
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062574
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Reviewed-by: default avatarKristi Park <kristipark@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744124}
parent e90c1748
...@@ -74,19 +74,41 @@ public class ShareSheetCoordinator { ...@@ -74,19 +74,41 @@ public class ShareSheetCoordinator {
ArrayList<PropertyModel> createTopRowPropertyModels( ArrayList<PropertyModel> createTopRowPropertyModels(
ShareSheetBottomSheetContent bottomSheet, Activity activity) { ShareSheetBottomSheetContent bottomSheet, Activity activity) {
ArrayList<PropertyModel> models = new ArrayList<>(); ArrayList<PropertyModel> models = new ArrayList<>();
// QR Codes // ScreenShot
PropertyModel qrcodePropertyModel = mPropertyModelBuilder.createPropertyModel( PropertyModel screenshotPropertyModel = null;
AppCompatResources.getDrawable(activity, R.drawable.qr_code), if (ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARE_SCREENSHOT)) {
activity.getResources().getString(R.string.qr_code_share_icon_label), screenshotPropertyModel = mPropertyModelBuilder.createPropertyModel(
(currentActivity) AppCompatResources.getDrawable(activity, R.drawable.screenshot),
-> { activity.getResources().getString(R.string.sharing_screenshot),
RecordUserAction.record("SharingHubAndroid.QRCodeSelected"); (shareParams)
-> {
mBottomSheetController.hideContent(bottomSheet, true);
Tab tab = mActivityTabProvider.get();
ScreenshotCoordinator screenshotCoordinator =
new ScreenshotCoordinator(activity, tab);
screenshotCoordinator.handleScreenshot();
},
/*isFirstParty=*/true);
models.add(screenshotPropertyModel);
}
// Copy URL
PropertyModel copyPropertyModel = mPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(activity, R.drawable.ic_content_copy_black),
activity.getResources().getString(R.string.sharing_copy_url), (params) -> {
mBottomSheetController.hideContent(bottomSheet, true); mBottomSheetController.hideContent(bottomSheet, true);
QrCodeCoordinator qrCodeCoordinator = new QrCodeCoordinator(activity); Tab tab = mActivityTabProvider.get();
qrCodeCoordinator.show(); NavigationEntry entry =
}, tab.getWebContents().getNavigationController().getVisibleEntry();
/*isFirstParty=*/true); ClipboardManager clipboard =
models.add(qrcodePropertyModel); (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(entry.getTitle(), entry.getUrl());
clipboard.setPrimaryClip(clip);
Toast toast =
Toast.makeText(activity, R.string.link_copied, Toast.LENGTH_SHORT);
toast.show();
}, /*isFirstParty=*/true);
models.add(copyPropertyModel);
// Send Tab To Self // Send Tab To Self
PropertyModel sttsPropertyModel = PropertyModel sttsPropertyModel =
...@@ -110,43 +132,18 @@ public class ShareSheetCoordinator { ...@@ -110,43 +132,18 @@ public class ShareSheetCoordinator {
/*isFirstParty=*/true); /*isFirstParty=*/true);
models.add(sttsPropertyModel); models.add(sttsPropertyModel);
// Copy URL // QR Codes
PropertyModel copyPropertyModel = mPropertyModelBuilder.createPropertyModel( PropertyModel qrcodePropertyModel = mPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(activity, R.drawable.ic_content_copy_black), AppCompatResources.getDrawable(activity, R.drawable.qr_code),
activity.getResources().getString(R.string.sharing_copy_url), (params) -> { activity.getResources().getString(R.string.qr_code_share_icon_label),
RecordUserAction.record("SharingHubAndroid.CopyURLSelected"); (currentActivity)
-> {
mBottomSheetController.hideContent(bottomSheet, true); mBottomSheetController.hideContent(bottomSheet, true);
Tab tab = mActivityTabProvider.get(); QrCodeCoordinator qrCodeCoordinator = new QrCodeCoordinator(activity);
NavigationEntry entry = qrCodeCoordinator.show();
tab.getWebContents().getNavigationController().getVisibleEntry(); },
ClipboardManager clipboard = /*isFirstParty=*/true);
(ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); models.add(qrcodePropertyModel);
ClipData clip = ClipData.newPlainText(entry.getTitle(), entry.getUrl());
clipboard.setPrimaryClip(clip);
Toast toast =
Toast.makeText(activity, R.string.link_copied, Toast.LENGTH_SHORT);
toast.show();
}, /*isFirstParty=*/true);
models.add(copyPropertyModel);
// ScreenShot
PropertyModel screenshotPropertyModel = null;
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_SHARE_SCREENSHOT)) {
screenshotPropertyModel = mPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(activity, R.drawable.screenshot),
activity.getResources().getString(R.string.sharing_screenshot),
(shareParams)
-> {
RecordUserAction.record("SharingHubAndroid.ScreenshotSelected");
mBottomSheetController.hideContent(bottomSheet, true);
Tab tab = mActivityTabProvider.get();
ScreenshotCoordinator screenshotCoordinator =
new ScreenshotCoordinator(activity, tab);
screenshotCoordinator.handleScreenshot();
},
/*isFirstParty=*/true);
models.add(screenshotPropertyModel);
}
return models; return models;
} }
......
file://chrome/android/java/src/org/chromium/chrome/browser/share/OWNERS file://chrome/android/java/src/org/chromium/chrome/browser/share/OWNERS
per-file ShareButton*=file://components/send_tab_to_self/OWNERS
per-file ShareDelegate*=file://components/send_tab_to_self/OWNERS
per-file ShareSheet*=file://components/send_tab_to_self/OWNERS
...@@ -86,8 +86,8 @@ public final class ShareSheetCoordinatorTest { ...@@ -86,8 +86,8 @@ public final class ShareSheetCoordinatorTest {
ArrayList<PropertyModel> propertyModels = ArrayList<PropertyModel> propertyModels =
coordinator.createTopRowPropertyModels(bottomSheet, activity); coordinator.createTopRowPropertyModels(bottomSheet, activity);
Assert.assertEquals("Incorrect number of property models.", 3, propertyModels.size()); Assert.assertEquals("Incorrect number of property models.", 3, propertyModels.size());
Assert.assertEquals("First property model isn't QR Code.", Assert.assertEquals("First property model isn't Copy URL.",
activity.getResources().getString(R.string.qr_code_share_icon_label), activity.getResources().getString(R.string.sharing_copy_url),
propertyModels.get(0).get(ShareSheetItemViewProperties.LABEL)); propertyModels.get(0).get(ShareSheetItemViewProperties.LABEL));
Assert.assertEquals("First property model isn't marked as first party.", true, Assert.assertEquals("First property model isn't marked as first party.", true,
propertyModels.get(0).get(ShareSheetItemViewProperties.IS_FIRST_PARTY)); propertyModels.get(0).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
...@@ -96,8 +96,8 @@ public final class ShareSheetCoordinatorTest { ...@@ -96,8 +96,8 @@ public final class ShareSheetCoordinatorTest {
propertyModels.get(1).get(ShareSheetItemViewProperties.LABEL)); propertyModels.get(1).get(ShareSheetItemViewProperties.LABEL));
Assert.assertEquals("Second property model isn't marked as first party.", true, Assert.assertEquals("Second property model isn't marked as first party.", true,
propertyModels.get(1).get(ShareSheetItemViewProperties.IS_FIRST_PARTY)); propertyModels.get(1).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
Assert.assertEquals("Third property model isn't Copy URL.", Assert.assertEquals("Third property model isn't QR Code.",
activity.getResources().getString(R.string.sharing_copy_url), activity.getResources().getString(R.string.qr_code_share_icon_label),
propertyModels.get(2).get(ShareSheetItemViewProperties.LABEL)); propertyModels.get(2).get(ShareSheetItemViewProperties.LABEL));
Assert.assertEquals("Third property model isn't marked as first party.", true, Assert.assertEquals("Third property model isn't marked as first party.", true,
propertyModels.get(2).get(ShareSheetItemViewProperties.IS_FIRST_PARTY)); propertyModels.get(2).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
...@@ -115,23 +115,23 @@ public final class ShareSheetCoordinatorTest { ...@@ -115,23 +115,23 @@ public final class ShareSheetCoordinatorTest {
ArrayList<PropertyModel> propertyModels = ArrayList<PropertyModel> propertyModels =
coordinator.createTopRowPropertyModels(bottomSheet, activity); coordinator.createTopRowPropertyModels(bottomSheet, activity);
Assert.assertEquals("Incorrect number of property models.", 4, propertyModels.size()); Assert.assertEquals("Incorrect number of property models.", 4, propertyModels.size());
Assert.assertEquals("First property model isn't QR Code.", Assert.assertEquals("First property model isn't Screenshotz.",
activity.getResources().getString(R.string.qr_code_share_icon_label), activity.getResources().getString(R.string.sharing_screenshot),
propertyModels.get(0).get(ShareSheetItemViewProperties.LABEL)); propertyModels.get(0).get(ShareSheetItemViewProperties.LABEL));
Assert.assertEquals("First property model isn't marked as first party.", true, Assert.assertEquals("First property model isn't marked as first party.", true,
propertyModels.get(0).get(ShareSheetItemViewProperties.IS_FIRST_PARTY)); propertyModels.get(0).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
Assert.assertEquals("Second property model isn't SendTabToSelf.", Assert.assertEquals("Second property model isn't Copy URL.",
activity.getResources().getString(R.string.send_tab_to_self_share_activity_title), activity.getResources().getString(R.string.sharing_copy_url),
propertyModels.get(1).get(ShareSheetItemViewProperties.LABEL)); propertyModels.get(1).get(ShareSheetItemViewProperties.LABEL));
Assert.assertEquals("Second property model isn't marked as first party.", true, Assert.assertEquals("Second property model isn't marked as first party.", true,
propertyModels.get(1).get(ShareSheetItemViewProperties.IS_FIRST_PARTY)); propertyModels.get(1).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
Assert.assertEquals("Third property model isn't Copy URL.", Assert.assertEquals("Third property model isn't SendTabToSelf.",
activity.getResources().getString(R.string.sharing_copy_url), activity.getResources().getString(R.string.send_tab_to_self_share_activity_title),
propertyModels.get(2).get(ShareSheetItemViewProperties.LABEL)); propertyModels.get(2).get(ShareSheetItemViewProperties.LABEL));
Assert.assertEquals("Third property model isn't marked as first party.", true, Assert.assertEquals("Third property model isn't marked as first party.", true,
propertyModels.get(2).get(ShareSheetItemViewProperties.IS_FIRST_PARTY)); propertyModels.get(2).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
Assert.assertEquals("Fourth property model isn't Screenshotz.", Assert.assertEquals("Fourth property model isn't QR Code.",
activity.getResources().getString(R.string.sharing_screenshot), activity.getResources().getString(R.string.qr_code_share_icon_label),
propertyModels.get(3).get(ShareSheetItemViewProperties.LABEL)); propertyModels.get(3).get(ShareSheetItemViewProperties.LABEL));
Assert.assertEquals("Fourth property model isn't marked as first party.", true, Assert.assertEquals("Fourth property model isn't marked as first party.", true,
propertyModels.get(3).get(ShareSheetItemViewProperties.IS_FIRST_PARTY)); propertyModels.get(3).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment