richeditor-android icon indicating copy to clipboard operation
richeditor-android copied to clipboard

autoLink in XML?

Open jesichakirkland opened this issue 6 years ago • 10 comments

Hi, so is there any equivalent to android:autoLink in RichEditor? or anyone know how to open new webview when a link is clicked? Thankyou

jesichakirkland avatar Jul 02 '18 06:07 jesichakirkland

Were you able to resolve this issue ?

nikitrivedii avatar Dec 26 '19 09:12 nikitrivedii

no i didn't. i just set the text to be copyable in android so that the user can copy the link by themself...

jesichakirkland avatar Dec 26 '19 09:12 jesichakirkland

` @Override public boolean shouldOverrideUrlLoading(WebView view, String url) {

        String decode;
        try {
                **url = view.getHitTestResult().getExtra();**
            decode = URLDecoder.decode(url, AppConstants.ENCRYPTION_CHAR_FORMAT_UTF8);
        } catch (UnsupportedEncodingException e) {
            // No handling
            return false;
        }

        if (TextUtils.indexOf(url, CALLBACK_SCHEME) == 0) {
            callback(decode);
            return true;
        } else if (TextUtils.indexOf(url, STATE_SCHEME) == 0) {
            stateCheck(decode);
            return true;
        }

        if (url.startsWith("http://") || url.startsWith("https://")) {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            context.startActivity(i);
            return true;
        }

        if (url.startsWith("file:///android_asset/")) {
            String newUrl = url.substring("file:///android_asset/".length());
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("http://" + newUrl));
            context.startActivity(i);
            return true;
        }

        return super.shouldOverrideUrlLoading(view, url);
    }
}`

using this i was able to click the url and open it in webview

nikitrivedii avatar Dec 26 '19 13:12 nikitrivedii

thankyou for the info, i will try it soon i have the time 😄

jesichakirkland avatar Dec 27 '19 03:12 jesichakirkland

Where to write this code ? do I need to add this library as a module and change its override method ?

AkashAndi avatar Jul 31 '20 07:07 AkashAndi

I have implemented above tings but it didn't work!

AkashAndi avatar Aug 04 '20 05:08 AkashAndi

@nikitrivedii I am also facing the same issue. Please could you tell where to write this code?

Ann-Mobiz avatar Apr 16 '21 07:04 Ann-Mobiz

always trigger shouldOverrideUrlLoading(WebView view, WebResourceRequest request) not shouldOverrideUrlLoading(WebView view, String url), so i can not get url

fukemy avatar Nov 07 '21 12:11 fukemy

the request.url always return ://re-state

fukemy avatar Nov 07 '21 12:11 fukemy

Ảnh chụp Màn hình 2021-11-07 lúc 19 23 14

fukemy avatar Nov 07 '21 12:11 fukemy