Search in sources :

Example 41 with WebViewClient

use of android.webkit.WebViewClient in project UltimateAndroid by cymcsg.

the class Html5Webview method init.

private void init(Context context) {
    mContext = context;
    Activity mActivity = (Activity) mContext;
    mLayout = new FrameLayout(context);
    mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(mActivity).inflate(R.layout.custom_screen, null);
    mContentView = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.main_content);
    mCustomViewContainer = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.fullscreen_custom_content);
    mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
    // Configure the webview
    WebSettings s = getSettings();
    s.setBuiltInZoomControls(true);
    s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    s.setUseWideViewPort(true);
    s.setLoadWithOverviewMode(true);
    //  s.setSavePassword(true);
    s.setSaveFormData(true);
    s.setJavaScriptEnabled(true);
    mWebChromeClient = new MyWebChromeClient();
    setWebChromeClient(mWebChromeClient);
    setWebViewClient(new WebViewClient());
    setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    // enable navigator.geolocation
    // s.setGeolocationEnabled(true);
    // s.setGeolocationDatabasePath("/data/data/org.itri.html5webview/databases/");
    // enable Web Storage: localStorage, sessionStorage
    s.setDomStorageEnabled(true);
    mContentView.addView(this);
}
Also used : WebSettings(android.webkit.WebSettings) FrameLayout(android.widget.FrameLayout) Activity(android.app.Activity) WebViewClient(android.webkit.WebViewClient)

Example 42 with WebViewClient

use of android.webkit.WebViewClient in project AntennaPod by AntennaPod.

the class ItemFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View layout = inflater.inflate(R.layout.feeditem_fragment, container, false);
    root = (ViewGroup) layout.findViewById(R.id.content_root);
    LinearLayout header = (LinearLayout) root.findViewById(R.id.header);
    if (feedItems.length > 0) {
        header.setOnTouchListener((v, event) -> headerGestureDetector.onTouchEvent(event));
    }
    txtvPodcast = (TextView) layout.findViewById(R.id.txtvPodcast);
    txtvPodcast.setOnClickListener(v -> openPodcast());
    txtvTitle = (TextView) layout.findViewById(R.id.txtvTitle);
    if (Build.VERSION.SDK_INT >= 23) {
        txtvTitle.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
    }
    txtvDuration = (TextView) layout.findViewById(R.id.txtvDuration);
    txtvPublished = (TextView) layout.findViewById(R.id.txtvPublished);
    if (Build.VERSION.SDK_INT >= 14) {
        // ellipsize is causing problems on old versions, see #448
        txtvTitle.setEllipsize(TextUtils.TruncateAt.END);
    }
    webvDescription = (WebView) layout.findViewById(R.id.webvDescription);
    if (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) {
        if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            webvDescription.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
        webvDescription.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.black));
    }
    webvDescription.getSettings().setUseWideViewPort(false);
    webvDescription.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    webvDescription.getSettings().setLoadWithOverviewMode(true);
    if (feedItems.length > 0) {
        webvDescription.setOnLongClickListener(webViewLongClickListener);
    }
    webvDescription.setOnTouchListener((v, event) -> webviewGestureDetector.onTouchEvent(event));
    webvDescription.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            if (IntentUtils.isCallable(getActivity(), intent)) {
                startActivity(intent);
            }
            return true;
        }
    });
    registerForContextMenu(webvDescription);
    imgvCover = (ImageView) layout.findViewById(R.id.imgvCover);
    imgvCover.setOnClickListener(v -> openPodcast());
    progbarDownload = (ProgressBar) layout.findViewById(R.id.progbarDownload);
    progbarLoading = (ProgressBar) layout.findViewById(R.id.progbarLoading);
    butAction1 = (IconButton) layout.findViewById(R.id.butAction1);
    butAction2 = (IconButton) layout.findViewById(R.id.butAction2);
    butAction1.setOnClickListener(v -> {
        if (item == null) {
            return;
        }
        DefaultActionButtonCallback actionButtonCallback = new DefaultActionButtonCallback(getActivity());
        actionButtonCallback.onActionButtonPressed(item, item.isTagged(FeedItem.TAG_QUEUE) ? LongList.of(item.getId()) : new LongList(0));
        FeedMedia media = item.getMedia();
        if (media != null && media.isDownloaded()) {
            ((MainActivity) getActivity()).dismissChildFragment();
        }
    });
    butAction2.setOnClickListener(v -> {
        if (item == null) {
            return;
        }
        if (item.hasMedia()) {
            FeedMedia media = item.getMedia();
            if (!media.isDownloaded()) {
                DBTasks.playMedia(getActivity(), media, true, true, true);
                ((MainActivity) getActivity()).dismissChildFragment();
            } else {
                DBWriter.deleteFeedMediaOfItem(getActivity(), media.getId());
            }
        } else if (item.getLink() != null) {
            Uri uri = Uri.parse(item.getLink());
            getActivity().startActivity(new Intent(Intent.ACTION_VIEW, uri));
        }
    });
    return layout;
}
Also used : DefaultActionButtonCallback(de.danoeh.antennapod.adapter.DefaultActionButtonCallback) FeedMedia(de.danoeh.antennapod.core.feed.FeedMedia) Intent(android.content.Intent) LongList(de.danoeh.antennapod.core.util.LongList) MainActivity(de.danoeh.antennapod.activity.MainActivity) WebView(android.webkit.WebView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) Uri(android.net.Uri) LinearLayout(android.widget.LinearLayout) WebViewClient(android.webkit.WebViewClient)

Example 43 with WebViewClient

use of android.webkit.WebViewClient in project OneSignal-Android-SDK by OneSignal.

the class GreenActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_green);
    String openURL = getIntent().getStringExtra("openURL");
    final TextView textView = (TextView) findViewById(R.id.debug_view);
    textView.setText("URL from additionalData: " + openURL);
    Button onBackButton = (Button) (findViewById(R.id.back_button));
    onBackButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getApplicationContext(), MainActivity.class);
            startActivity(intent);
        }
    });
    WebView webView = (WebView) (findViewById(R.id.webview));
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient());
    if (openURL == null) {
        webView.loadUrl("https://google.com");
    } else {
        webView.loadUrl(openURL);
    }
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) Intent(android.content.Intent) WebView(android.webkit.WebView) TextView(android.widget.TextView) View(android.view.View) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 44 with WebViewClient

use of android.webkit.WebViewClient in project Rashr by DsLNeXuS.

the class SettingsFragment method showChangelog.

public static void showChangelog(Context AppContext) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(AppContext);
    dialog.setTitle(R.string.changelog);
    WebView changes = new WebView(AppContext);
    changes.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    changes.setWebViewClient(new WebViewClient());
    changes.loadUrl(Const.CHANGELOG_URL);
    changes.clearCache(true);
    dialog.setView(changes);
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 45 with WebViewClient

use of android.webkit.WebViewClient in project weex-example by KalicyZhou.

the class WXWebViewTest method testLoadUrl.

@Test
public void testLoadUrl() throws Exception {
    String url = "http://www.taobao.com";
    view.loadUrl(url);
    WebViewClient client = shadow.getWebViewClient();
    client.onPageStarted(webView, url, null);
    client.onPageFinished(webView, url);
    WebChromeClient chromeClient = shadow.getWebChromeClient();
    chromeClient.onProgressChanged(webView, 10);
    chromeClient.onProgressChanged(webView, 100);
    chromeClient.onReceivedTitle(webView, "test");
}
Also used : WebChromeClient(android.webkit.WebChromeClient) WebViewClient(android.webkit.WebViewClient) Test(org.junit.Test)

Aggregations

WebViewClient (android.webkit.WebViewClient)119 WebView (android.webkit.WebView)109 WebChromeClient (android.webkit.WebChromeClient)32 View (android.view.View)30 WebSettings (android.webkit.WebSettings)28 Intent (android.content.Intent)26 SuppressLint (android.annotation.SuppressLint)23 Bitmap (android.graphics.Bitmap)19 WebResourceRequest (android.webkit.WebResourceRequest)11 TextView (android.widget.TextView)11 Bundle (android.os.Bundle)9 LinearLayout (android.widget.LinearLayout)9 Uri (android.net.Uri)8 WebResourceError (android.webkit.WebResourceError)8 KeyEvent (android.view.KeyEvent)7 JsResult (android.webkit.JsResult)6 WebResourceResponse (android.webkit.WebResourceResponse)6 DialogInterface (android.content.DialogInterface)4 RelativeLayout (android.widget.RelativeLayout)4 Activity (android.app.Activity)3