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

[SharingHub] Add Copy URL button

Add the Copy URL option to the sharing hub. Also update all options so that the
share sheet is closed before opening the specific sharing feature.

screenshot: http://screen/Rr6LdXLb9W6.png

Bug: 1009124
Change-Id: If31000fc8e49e59a2a305a8471f740178982b242
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1951770
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarJeffrey Cohen <jeffreycohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#725665}
parent 89d78cd2
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
package org.chromium.chrome.browser.share; package org.chromium.chrome.browser.share;
import android.app.Activity; import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.v7.content.res.AppCompatResources; import android.support.v7.content.res.AppCompatResources;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
...@@ -13,11 +16,14 @@ import org.chromium.chrome.R; ...@@ -13,11 +16,14 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.send_tab_to_self.SendTabToSelfShareActivity; import org.chromium.chrome.browser.send_tab_to_self.SendTabToSelfShareActivity;
import org.chromium.chrome.browser.share.qrcode.QrCodeCoordinator; import org.chromium.chrome.browser.share.qrcode.QrCodeCoordinator;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType; import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabCreatorManager; import org.chromium.chrome.browser.tabmodel.TabCreatorManager;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController; import org.chromium.chrome.browser.widget.bottomsheet.BottomSheetController;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationEntry;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -91,6 +97,26 @@ public class ShareSheetCoordinator { ...@@ -91,6 +97,26 @@ public class ShareSheetCoordinator {
mBottomSheetController); mBottomSheetController);
}); });
models.add(sttsPropertyModel); models.add(sttsPropertyModel);
// Copy URL
PropertyModel copyPropertyModel = createPropertyModel(
AppCompatResources.getDrawable(activity, R.drawable.ic_content_copy_black),
activity.getResources().getString(R.string.sharing_copy_url), (params) -> {
mBottomSheetController.hideContent(bottomSheet, true);
Tab tab = mActivityTabProvider.get();
NavigationEntry entry =
tab.getWebContents().getNavigationController().getVisibleEntry();
ClipboardManager clipboard =
(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();
});
models.add(copyPropertyModel);
return models; return models;
} }
......
...@@ -4079,10 +4079,19 @@ The site does NOT gain access to the camera. The camera images are only visible ...@@ -4079,10 +4079,19 @@ The site does NOT gain access to the camera. The camera images are only visible
Download Download
</message> </message>
<!-- Sharing Hub -->
<message name="IDS_SHARING_MORE_ICON_LABEL" desc="Icon label for the More button in the sharing hub."> <message name="IDS_SHARING_MORE_ICON_LABEL" desc="Icon label for the More button in the sharing hub.">
More More
</message> </message>
<message name="IDS_SHARING_COPY_URL" desc="Label for the Copy URL button in the sharing hub.">
Copy link
</message>
<message name="IDS_LINK_COPIED" desc="Text shown in the toast notification when Copy Link is selected in the sharing hub.">
Link Copied
</message>
<!-- Chime DFM module strings --> <!-- Chime DFM module strings -->
<message name="IDS_CHIME_MODULE_TITLE" desc="Text shown when the chime module is referenced in install start, success, failure UI (e.g. in IDS_MODULE_INSTALL_START_TEXT, which will expand to 'Installing Google Notifications Platform for Chrome…')."> <message name="IDS_CHIME_MODULE_TITLE" desc="Text shown when the chime module is referenced in install start, success, failure UI (e.g. in IDS_MODULE_INSTALL_START_TEXT, which will expand to 'Installing Google Notifications Platform for Chrome…').">
Google Notifications Platform Google Notifications Platform
......
a1a67b055fa3286aa7b5823a4897e6c4e96e7b91
\ No newline at end of file
78f987076df36886fd258a9b1c4d79db957e823f
\ No newline at end of file
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