Search in sources :

Example 26 with WebView

use of android.webkit.WebView in project android_frameworks_base by ResurrectionRemix.

the class WebViewFragment method onCreateView.

/**
     * Called to instantiate the view. Creates and returns the WebView.
     */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mWebView != null) {
        mWebView.destroy();
    }
    mWebView = new WebView(getContext());
    mIsWebViewAvailable = true;
    return mWebView;
}
Also used : WebView(android.webkit.WebView)

Example 27 with WebView

use of android.webkit.WebView in project android_frameworks_base by ResurrectionRemix.

the class CaptivePortalLoginActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mCm = ConnectivityManager.from(this);
    mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
    mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
    mUserAgent = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT);
    mUrl = getUrl();
    if (mUrl == null) {
        // getUrl() failed to parse the url provided in the intent: bail out in a way that
        // at least provides network access.
        done(Result.WANTED_AS_IS);
        return;
    }
    if (DBG) {
        Log.d(TAG, String.format("onCreate for %s", mUrl.toString()));
    }
    // Also initializes proxy system properties.
    mCm.bindProcessToNetwork(mNetwork);
    // Proxy system properties must be initialized before setContentView is called because
    // setContentView initializes the WebView logic which in turn reads the system properties.
    setContentView(R.layout.activity_captive_portal_login);
    getActionBar().setDisplayShowHomeEnabled(false);
    // Exit app if Network disappears.
    final NetworkCapabilities networkCapabilities = mCm.getNetworkCapabilities(mNetwork);
    if (networkCapabilities == null) {
        finishAndRemoveTask();
        return;
    }
    mNetworkCallback = new NetworkCallback() {

        @Override
        public void onLost(Network lostNetwork) {
            if (mNetwork.equals(lostNetwork))
                done(Result.UNWANTED);
        }
    };
    final NetworkRequest.Builder builder = new NetworkRequest.Builder();
    for (int transportType : networkCapabilities.getTransportTypes()) {
        builder.addTransportType(transportType);
    }
    mCm.registerNetworkCallback(builder.build(), mNetworkCallback);
    final WebView myWebView = (WebView) findViewById(R.id.webview);
    myWebView.clearCache(true);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    mWebViewClient = new MyWebViewClient();
    myWebView.setWebViewClient(mWebViewClient);
    myWebView.setWebChromeClient(new MyWebChromeClient());
    // Start initial page load so WebView finishes loading proxy settings.
    // Actual load of mUrl is initiated by MyWebViewClient.
    myWebView.loadData("", "text/html", null);
}
Also used : WebSettings(android.webkit.WebSettings) Network(android.net.Network) NetworkRequest(android.net.NetworkRequest) WebView(android.webkit.WebView) NetworkCapabilities(android.net.NetworkCapabilities) NetworkCallback(android.net.ConnectivityManager.NetworkCallback)

Example 28 with WebView

use of android.webkit.WebView in project android_frameworks_base by ResurrectionRemix.

the class LooperAcceleration method makeView.

private View makeView() {
    LinearLayout layout = new LinearLayout(this);
    layout.addView(new IsAcceleratedView(this), LayoutParams.MATCH_PARENT, 60);
    if (INCLUDE_WEBVIEW) {
        WebView wv = new WebView(this);
        wv.setWebViewClient(new WebViewClient());
        wv.setWebChromeClient(new WebChromeClient());
        wv.loadUrl("http://www.webkit.org/blog-files/3d-transforms/poster-circle.html");
        layout.addView(wv, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    }
    return layout;
}
Also used : WebChromeClient(android.webkit.WebChromeClient) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout) WebViewClient(android.webkit.WebViewClient)

Example 29 with WebView

use of android.webkit.WebView in project android_frameworks_base by ResurrectionRemix.

the class ScrollableWebViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WebView webView = new WebView(this);
    webView.loadData(sHtml, "text/html", null);
    webView.setVerticalScrollBarEnabled(true);
    setContentView(webView);
}
Also used : WebView(android.webkit.WebView)

Example 30 with WebView

use of android.webkit.WebView in project Rocket.Chat.Android by RocketChat.

the class AbstractOAuthFragment method showWebView.

private void showWebView() {
    if (TextUtils.isEmpty(url)) {
        finish();
        return;
    }
    final WebView webView = getWebview();
    if (webView == null) {
        finish();
        return;
    }
    resultOK = false;
    webView.getSettings().setUserAgentString("Chrome/56.0.0.0 Mobile");
    webView.loadUrl(url);
    webView.addJavascriptInterface(new JSInterface(result -> {
        if (resultOK) {
            return;
        }
        presenter.login(result);
    }), "_rocketchet_hook");
}
Also used : JavascriptInterface(android.webkit.JavascriptInterface) Bundle(android.os.Bundle) TextUtils(android.text.TextUtils) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) Charset(java.nio.charset.Charset) AbstractWebViewFragment(chat.rocket.android.fragment.AbstractWebViewFragment) Base64(android.util.Base64) RealmLoginServiceConfigurationRepository(chat.rocket.persistence.realm.repositories.RealmLoginServiceConfigurationRepository) Nullable(android.support.annotation.Nullable) WebView(android.webkit.WebView) LoginServiceConfiguration(chat.rocket.core.models.LoginServiceConfiguration) WebView(android.webkit.WebView)

Aggregations

WebView (android.webkit.WebView)594 WebViewClient (android.webkit.WebViewClient)214 View (android.view.View)176 WebSettings (android.webkit.WebSettings)103 Intent (android.content.Intent)87 SuppressLint (android.annotation.SuppressLint)79 WebChromeClient (android.webkit.WebChromeClient)77 TextView (android.widget.TextView)61 Bitmap (android.graphics.Bitmap)55 LinearLayout (android.widget.LinearLayout)39 DialogInterface (android.content.DialogInterface)36 ImageView (android.widget.ImageView)35 WebResourceRequest (android.webkit.WebResourceRequest)32 Uri (android.net.Uri)31 Test (org.junit.Test)27 Bundle (android.os.Bundle)26 AlertDialog (android.app.AlertDialog)24 Activity (android.app.Activity)22 Handler (android.os.Handler)20 IOException (java.io.IOException)20