Skip to content

Commit

Permalink
add text resources for context menus
Browse files Browse the repository at this point in the history
  • Loading branch information
aschuhardt committed Jun 4, 2023
1 parent 025a6ef commit 0abf0e8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
18 changes: 18 additions & 0 deletions Resources/Localization/Text.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Resources/Localization/Text.resx
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,10 @@
<data name="SettingsPage_HidePullTab" xml:space="preserve">
<value>Hide menu pull tab</value>
</data>
<data name="BrowserView_BuildContextMenu_Copy_URL" xml:space="preserve">
<value>Copy URL</value>
</data>
<data name="BrowserView_BuildContextMenu_Share_URL" xml:space="preserve">
<value>Share URL</value>
</data>
</root>
6 changes: 3 additions & 3 deletions Views/BrowserView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -933,17 +933,17 @@ protected virtual void OnClearFindNext()


#if ANDROID
private void BuildContextMenu(IContextMenu menu, Android.Webkit.WebView view)
private static void BuildContextMenu(IMenu menu, Android.Webkit.WebView view)
{
var hitTest = view.GetHitTestResult();

if (hitTest.Type is HitTestResult.AnchorType or HitTestResult.SrcAnchorType or HitTestResult.SrcImageAnchorType &&
!string.IsNullOrWhiteSpace(hitTest.Extra))
{
menu.Add("Copy URL")?.SetOnMenuItemClickListener(
menu.Add(Text.BrowserView_BuildContextMenu_Copy_URL)?.SetOnMenuItemClickListener(
new ActionMenuClickHandler<string>(hitTest.Extra,
async uri => await Clipboard.Default.SetTextAsync(uri)));
menu.Add("Share URL")?.SetOnMenuItemClickListener(
menu.Add(Text.BrowserView_BuildContextMenu_Share_URL)?.SetOnMenuItemClickListener(
new ActionMenuClickHandler<string>(hitTest.Extra,
async uri => await Share.Default.RequestAsync(new ShareTextRequest(uri))));
}
Expand Down

0 comments on commit 0abf0e8

Please sign in to comment.