public bool OnCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) { bool permission_requested = false; bool processed = false; // read and display inputContentInfo asynchronously if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.NMr1 && (flags & InputConnectionCompat.InputContentGrantReadUriPermission) != 0) { try { inputContentInfo.RequestPermission(); permission_requested = true; } catch (Exception) { return(processed); } } if (inputContentInfo.LinkUri != null) { string url = inputContentInfo.LinkUri.ToString(); Page p = App.Current.MainPage.Navigation.NavigationStack.Last(); if (p != null && p.GetType() == typeof(SingleChatPage)) { string rx_pattern = @"^https://[A-Za-z0-9]+\.(tenor|giphy)\.com/[A-Za-z0-9_/=%\?\-\.\&]+$"; if (Regex.IsMatch(url, rx_pattern)) { ((SingleChatPage)p).onSend(url); processed = true; } } } else { Logging.error("Error adding keyboard content, LinkUri is null"); } if (permission_requested) { inputContentInfo.ReleasePermission(); } return(processed); }
bool OnCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, string[] contentMimeTypes) { // Clear the temporary permission (if any). See below about why we do this here. try { if (mCurrentInputContentInfo != null) { mCurrentInputContentInfo.ReleasePermission(); } } catch (Java.Lang.Exception e) { Log.Error(Tag, "InputContentInfoCompat#releasePermission() failed.", e); } finally { mCurrentInputContentInfo = null; } mWebView.LoadUrl("about:blank"); mMimeTypes.Text = ""; mContentUri.Text = ""; mLabel.Text = ""; mLinkUri.Text = ""; mFlags.Text = ""; var supported = false; foreach (var contentMimeType in contentMimeTypes) { if (inputContentInfo.Description.HasMimeType(contentMimeType)) { supported = true; break; } } if (!supported) { return(false); } return(OnCommitContentInternal(inputContentInfo, flags)); }