Commit 66110381 authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[SharingHub] Remove IS_FIRST_PARTY item property

This property is no longer needed since switching to vector icons.

Bug: None
Change-Id: I01e92a838c2bba16516b77f10572e3a9f7875fac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2219350
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Reviewed-by: default avatarTravis Skare <skare@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796123}
parent 91da7b30
......@@ -178,9 +178,7 @@ class ChromeProvidedSharingOptionsProvider {
private FirstPartyOption createScreenshotFirstPartyOption() {
PropertyModel propertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(mActivity, R.drawable.screenshot),
mActivity.getResources().getString(R.string.sharing_screenshot),
(view)
-> {
mActivity.getResources().getString(R.string.sharing_screenshot), (view) -> {
RecordUserAction.record("SharingHubAndroid.ScreenshotSelected");
recordTimeToShare(mShareStartTime);
mScreenshotCoordinator = new ScreenshotCoordinator(mActivity,
......@@ -189,8 +187,7 @@ class ChromeProvidedSharingOptionsProvider {
// observer will then remove itself.
mBottomSheetController.addObserver(mSheetObserver);
mBottomSheetController.hideContent(mBottomSheetContent, true);
},
/*isFirstParty=*/true);
});
return new FirstPartyOption(propertyModel,
Arrays.asList(ContentType.LINK_PAGE_VISIBLE, ContentType.TEXT,
ContentType.HIGHLIGHTED_TEXT, ContentType.IMAGE));
......@@ -199,9 +196,7 @@ class ChromeProvidedSharingOptionsProvider {
private FirstPartyOption createCopyLinkFirstPartyOption() {
PropertyModel propertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(mActivity, R.drawable.ic_content_copy_black),
mActivity.getResources().getString(R.string.sharing_copy_url),
(view)
-> {
mActivity.getResources().getString(R.string.sharing_copy_url), (view) -> {
RecordUserAction.record("SharingHubAndroid.CopyURLSelected");
recordTimeToShare(mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true);
......@@ -210,8 +205,7 @@ class ChromeProvidedSharingOptionsProvider {
clipboard.setPrimaryClip(
ClipData.newPlainText(mShareParams.getTitle(), mShareParams.getUrl()));
Toast.makeText(mActivity, R.string.link_copied, Toast.LENGTH_SHORT).show();
},
/*isFirstParty=*/true);
});
return new FirstPartyOption(propertyModel,
Arrays.asList(ContentType.LINK_PAGE_VISIBLE, ContentType.LINK_PAGE_NOT_VISIBLE));
}
......@@ -219,9 +213,7 @@ class ChromeProvidedSharingOptionsProvider {
private FirstPartyOption createCopyImageFirstPartyOption() {
PropertyModel propertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(mActivity, R.drawable.ic_content_copy_black),
mActivity.getResources().getString(R.string.sharing_copy_image),
(view)
-> {
mActivity.getResources().getString(R.string.sharing_copy_image), (view) -> {
RecordUserAction.record("SharingHubAndroid.CopyImageSelected");
recordTimeToShare(mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true);
......@@ -229,17 +221,14 @@ class ChromeProvidedSharingOptionsProvider {
Clipboard.getInstance().setImageUri(mShareParams.getFileUris().get(0));
Toast.makeText(mActivity, R.string.image_copied, Toast.LENGTH_SHORT).show();
}
},
/*isFirstParty=*/true);
});
return new FirstPartyOption(propertyModel, Arrays.asList(ContentType.IMAGE));
}
private FirstPartyOption createCopyTextFirstPartyOption() {
PropertyModel propertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(mActivity, R.drawable.ic_content_copy_black),
mActivity.getResources().getString(R.string.sharing_copy_text),
(view)
-> {
mActivity.getResources().getString(R.string.sharing_copy_text), (view) -> {
RecordUserAction.record("SharingHubAndroid.CopyTextSelected");
recordTimeToShare(mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true);
......@@ -248,8 +237,7 @@ class ChromeProvidedSharingOptionsProvider {
clipboard.setPrimaryClip(
ClipData.newPlainText(mShareParams.getTitle(), mShareParams.getText()));
Toast.makeText(mActivity, R.string.text_copied, Toast.LENGTH_SHORT).show();
},
/*isFirstParty=*/true);
});
return new FirstPartyOption(
propertyModel, Arrays.asList(ContentType.TEXT, ContentType.HIGHLIGHTED_TEXT));
}
......@@ -258,8 +246,7 @@ class ChromeProvidedSharingOptionsProvider {
PropertyModel propertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(mActivity, R.drawable.send_tab),
mActivity.getResources().getString(R.string.send_tab_to_self_share_activity_title),
(view)
-> {
(view) -> {
RecordUserAction.record("SharingHubAndroid.SendTabToSelfSelected");
recordTimeToShare(mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true);
......@@ -271,8 +258,7 @@ class ChromeProvidedSharingOptionsProvider {
.getVisibleEntry()
.getTimestamp(),
mBottomSheetController);
},
/*isFirstParty=*/true);
});
return new FirstPartyOption(propertyModel,
Arrays.asList(ContentType.LINK_PAGE_VISIBLE, ContentType.LINK_PAGE_NOT_VISIBLE,
ContentType.IMAGE));
......@@ -281,16 +267,13 @@ class ChromeProvidedSharingOptionsProvider {
private FirstPartyOption createQrCodeFirstPartyOption() {
PropertyModel propertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(mActivity, R.drawable.qr_code),
mActivity.getResources().getString(R.string.qr_code_share_icon_label),
(view)
-> {
mActivity.getResources().getString(R.string.qr_code_share_icon_label), (view) -> {
RecordUserAction.record("SharingHubAndroid.QRCodeSelected");
recordTimeToShare(mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true);
QrCodeCoordinator qrCodeCoordinator = new QrCodeCoordinator(mActivity, mUrl);
qrCodeCoordinator.show();
},
/*isFirstParty=*/true);
});
return new FirstPartyOption(propertyModel,
Arrays.asList(ContentType.LINK_PAGE_VISIBLE, ContentType.LINK_PAGE_NOT_VISIBLE,
ContentType.IMAGE));
......@@ -299,15 +282,12 @@ class ChromeProvidedSharingOptionsProvider {
private FirstPartyOption createPrintingFirstPartyOption() {
PropertyModel propertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(mActivity, R.drawable.sharing_print),
mActivity.getResources().getString(R.string.print_share_activity_title),
(view)
-> {
mActivity.getResources().getString(R.string.print_share_activity_title), (view) -> {
RecordUserAction.record("SharingHubAndroid.PrintSelected");
recordTimeToShare(mShareStartTime);
mBottomSheetController.hideContent(mBottomSheetContent, true);
mPrintTabCallback.onResult(mTabProvider.get());
},
/*isFirstParty=*/true);
});
return new FirstPartyOption(
propertyModel, Collections.singleton(ContentType.LINK_PAGE_VISIBLE));
}
......@@ -316,8 +296,7 @@ class ChromeProvidedSharingOptionsProvider {
PropertyModel propertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(mActivity, R.drawable.link),
mActivity.getResources().getString(R.string.sharing_highlights),
(currentActivity)
-> {
(currentActivity) -> {
RecordUserAction.record("SharingHubAndroid.LinkToTextSelected");
recordTimeToShare(mShareStartTime);
LinkToTextCoordinator linkToTextCoordinator = new LinkToTextCoordinator(
......@@ -325,8 +304,7 @@ class ChromeProvidedSharingOptionsProvider {
mChromeOptionShareCallback, mShareParams.getUrl(),
mShareParams.getText());
mBottomSheetController.hideContent(mBottomSheetContent, true);
},
/*isFirstParty=*/true);
});
return new FirstPartyOption(
propertyModel, Collections.singleton(ContentType.HIGHLIGHTED_TEXT));
}
......
......@@ -163,13 +163,11 @@ public class ShareSheetCoordinator
PropertyModel morePropertyModel = ShareSheetPropertyModelBuilder.createPropertyModel(
AppCompatResources.getDrawable(activity, R.drawable.sharing_more),
activity.getResources().getString(R.string.sharing_more_icon_label),
(shareParams)
-> {
(shareParams) -> {
RecordUserAction.record("SharingHubAndroid.MoreSelected");
mBottomSheetController.hideContent(mBottomSheet, true);
ShareHelper.showDefaultShareUi(params, saveLastUsed);
},
/*isFirstParty=*/true);
});
models.add(morePropertyModel);
return models;
......
......@@ -22,9 +22,5 @@ final class ShareSheetItemViewProperties {
public static final WritableObjectPropertyKey<OnClickListener> CLICK_LISTENER =
new WritableObjectPropertyKey<>();
/** True if this share sheet item is provided by Chrome. **/
public static final WritableObjectPropertyKey<Boolean> IS_FIRST_PARTY =
new WritableObjectPropertyKey<>();
public static final PropertyKey[] ALL_KEYS = {ICON, LABEL, CLICK_LISTENER, IS_FIRST_PARTY};
public static final PropertyKey[] ALL_KEYS = {ICON, LABEL, CLICK_LISTENER};
}
......@@ -179,8 +179,7 @@ public class ShareSheetPropertyModelBuilder {
};
PropertyModel propertyModel =
createPropertyModel(ShareHelper.loadIconForResolveInfo(info, mPackageManager),
(String) info.loadLabel(mPackageManager), onClickListener,
/*isFirstParty=*/false);
(String) info.loadLabel(mPackageManager), onClickListener);
models.add(propertyModel);
}
......@@ -245,12 +244,11 @@ public class ShareSheetPropertyModelBuilder {
}
static PropertyModel createPropertyModel(
Drawable icon, String label, OnClickListener listener, boolean isFirstParty) {
Drawable icon, String label, OnClickListener listener) {
return new PropertyModel.Builder(ShareSheetItemViewProperties.ALL_KEYS)
.with(ShareSheetItemViewProperties.ICON, icon)
.with(ShareSheetItemViewProperties.LABEL, label)
.with(ShareSheetItemViewProperties.CLICK_LISTENER, listener)
.with(ShareSheetItemViewProperties.IS_FIRST_PARTY, isFirstParty)
.build();
}
......
......@@ -41,7 +41,6 @@ import org.chromium.components.user_prefs.UserPrefsJni;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.test.util.DummyUiActivity;
import java.util.Collection;
import java.util.List;
/**
......@@ -106,7 +105,6 @@ public class ChromeProvidedSharingOptionsProviderTest {
mActivity.getResources().getString(
R.string.send_tab_to_self_share_activity_title),
mActivity.getResources().getString(R.string.qr_code_share_icon_label)));
assertModelsAreFirstParty(propertyModels);
}
@Test
......@@ -125,7 +123,6 @@ public class ChromeProvidedSharingOptionsProviderTest {
ImmutableList.of(mActivity.getResources().getString(R.string.sharing_copy_url),
mActivity.getResources().getString(
R.string.send_tab_to_self_share_activity_title)));
assertModelsAreFirstParty(propertyModels);
}
@Test
......@@ -145,7 +142,6 @@ public class ChromeProvidedSharingOptionsProviderTest {
mActivity.getResources().getString(
R.string.send_tab_to_self_share_activity_title),
mActivity.getResources().getString(R.string.print_share_activity_title)));
assertModelsAreFirstParty(propertyModels);
}
@Test
......@@ -165,7 +161,6 @@ public class ChromeProvidedSharingOptionsProviderTest {
Assert.assertEquals("Incorrect number of property models.", 1, propertyModels.size());
assertModelsAreInTheRightOrder(propertyModels,
ImmutableList.of(mActivity.getResources().getString(R.string.sharing_copy_text)));
assertModelsAreFirstParty(propertyModels);
}
@Test
......@@ -186,7 +181,6 @@ public class ChromeProvidedSharingOptionsProviderTest {
mActivity.getResources().getString(
R.string.send_tab_to_self_share_activity_title),
mActivity.getResources().getString(R.string.qr_code_share_icon_label)));
assertModelsAreFirstParty(propertyModels);
}
@Test
......@@ -208,7 +202,6 @@ public class ChromeProvidedSharingOptionsProviderTest {
mActivity.getResources().getString(
R.string.send_tab_to_self_share_activity_title),
mActivity.getResources().getString(R.string.qr_code_share_icon_label)));
assertModelsAreFirstParty(propertyModels);
}
@Test
......@@ -222,7 +215,6 @@ public class ChromeProvidedSharingOptionsProviderTest {
ImmutableSet.of(ContentType.TEXT));
Assert.assertEquals("Incorrect number of property models.", 0, propertyModels.size());
assertModelsAreFirstParty(propertyModels);
}
@Test
......@@ -240,7 +232,6 @@ public class ChromeProvidedSharingOptionsProviderTest {
assertModelsAreInTheRightOrder(propertyModels,
ImmutableList.of(mActivity.getResources().getString(R.string.sharing_copy_text),
mActivity.getResources().getString(R.string.sharing_highlights)));
assertModelsAreFirstParty(propertyModels);
}
@Test
......@@ -289,12 +280,4 @@ public class ChromeProvidedSharingOptionsProviderTest {
assertEquals(
"Property models in the wrong order.", expectedOrder, actualLabelOrder.build());
}
private void assertModelsAreFirstParty(Collection<PropertyModel> propertyModels) {
for (PropertyModel propertyModel : propertyModels) {
assertEquals(propertyModel.get(ShareSheetItemViewProperties.LABEL)
+ " isn't marked as first party.",
true, propertyModel.get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
}
}
}
......@@ -73,13 +73,11 @@ public final class ShareSheetCoordinatorTest {
.with(ShareSheetItemViewProperties.ICON, null)
.with(ShareSheetItemViewProperties.LABEL, "testModel1")
.with(ShareSheetItemViewProperties.CLICK_LISTENER, null)
.with(ShareSheetItemViewProperties.IS_FIRST_PARTY, false)
.build();
PropertyModel testModel2 = new PropertyModel.Builder(ShareSheetItemViewProperties.ALL_KEYS)
.with(ShareSheetItemViewProperties.ICON, null)
.with(ShareSheetItemViewProperties.LABEL, "testModel2")
.with(ShareSheetItemViewProperties.CLICK_LISTENER, null)
.with(ShareSheetItemViewProperties.IS_FIRST_PARTY, false)
.build();
ArrayList<PropertyModel> thirdPartyPropertyModels =
......@@ -115,16 +113,10 @@ public final class ShareSheetCoordinatorTest {
assertEquals("Incorrect number of property models.", 3, propertyModels.size());
assertEquals("First property model isn't testModel1.", "testModel1",
propertyModels.get(0).get(ShareSheetItemViewProperties.LABEL));
assertEquals("First property model is marked as first party.", false,
propertyModels.get(0).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
assertEquals("Second property model isn't testModel2.", "testModel2",
propertyModels.get(1).get(ShareSheetItemViewProperties.LABEL));
assertEquals("Second property model is marked as first party.", false,
propertyModels.get(1).get(ShareSheetItemViewProperties.IS_FIRST_PARTY));
assertEquals("Third property model isn't More.",
activity.getResources().getString(R.string.sharing_more_icon_label),
propertyModels.get(2).get(ShareSheetItemViewProperties.LABEL));
assertEquals("Third property model isn't marked as first party.", true,
propertyModels.get(2).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