Java Code Examples for android.webkit.WebChromeClient

The following examples show how to use android.webkit.WebChromeClient. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void initListener() {
    mWebView.setWebChromeClient(new WebChromeClient() {

        //For Android5.0+
        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
            if (mFilePathCallback != null) {
                mFilePathCallback.onReceiveValue(null);
            }
            mFilePathCallback = filePathCallback;

            showChooserDialog();
            return true;
        }
    });

}
 
Example 2
Source Project: L.TileLayer.Cordova   Source File: CordovaWebView.java    License: MIT License 6 votes vote down vote up
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }
    
    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;
    
    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
    
    // Hide the content view.
    this.setVisibility(View.GONE);
    
    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}
 
Example 3
Source Project: android-post-webview   Source File: MainActivity.java    License: The Unlicense 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mAddressView = (EditText) findViewById(R.id.addressView);
    mWebView = (WebView) findViewById(R.id.webView);

    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);

    mWebView.setWebViewClient(new InterceptingWebViewClient(this, mWebView));
    mWebView.setWebChromeClient(new WebChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    loadOnEnter();
}
 
Example 4
Source Project: JsBridge   Source File: CustomWebViewActivity.java    License: Apache License 2.0 6 votes vote down vote up
public CustomWebView(Context context) {
    super(context);
    this.webView = new WebView(context);
    this.webView.getSettings().setJavaScriptEnabled(true);
    addView(this.webView);
    this.webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public boolean onJsPrompt(WebView view, String url,
                                  String message, String defaultValue, JsPromptResult result) {
            if (callback != null) {
                callback.onResult(message, new PromptResultImpl(result));
            }
            return true;
        }

        @Override
        public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
            Log.d(JsBridge.TAG, consoleMessage.message());
            return true;
        }
    });
}
 
Example 5
Source Project: reader   Source File: CordovaWebView.java    License: MIT License 6 votes vote down vote up
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }
    
    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;
    
    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
    
    // Hide the content view.
    this.setVisibility(View.GONE);
    
    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}
 
Example 6
Source Project: Mobike   Source File: MessageDetailActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initWebView() {
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        /*使webview能够加载图片*/
        webSettings.setBlockNetworkImage(false);
        webSettings.setAppCacheEnabled(true);
        mDialog=new SpotsDialog(this);
        mDialog.show();
        mWebView.loadUrl(mMessage.getClickUrl());
//        mWebAppInterface = new WebAppInterface(this);
//        mWebView.addJavascriptInterface(mWebAppInterface, "appInterface");
        mWebView.setWebViewClient(new MyWebChromeC());
        mWebView.setWebChromeClient(new WebChromeClient(){

        });

    }
 
Example 7
Source Project: timecat   Source File: PreviewFragment.java    License: Apache License 2.0 6 votes vote down vote up
public void configWebView() {
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);

    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress == 100) {
                pageFinish = true;
            }
        }
    });
    webView.loadUrl("file:///android_asset/markdown.html");
}
 
Example 8
Source Project: alpha-wallet-android   Source File: DappBrowserFragment.java    License: MIT License 6 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
    if (requestCode >= SignTransactionDialog.REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS && requestCode <= SignTransactionDialog.REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS + 10)
    {
        GotAuthorisation(resultCode == RESULT_OK);
    }
    else if (requestCode == UPLOAD_FILE && uploadMessage != null)
    {
        if (resultCode == RESULT_OK)
        {
            uploadMessage.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
        }
        uploadMessage = null;
    }
    else if (requestCode == REQUEST_FILE_ACCESS)
    {
        if (resultCode == RESULT_OK)
        {
            requestUpload();
        }
    }
}
 
Example 9
Source Project: bluemix-parking-meter   Source File: CordovaWebView.java    License: MIT License 6 votes vote down vote up
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }
    
    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;
    
    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
    
    // Hide the content view.
    this.setVisibility(View.GONE);
    
    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}
 
Example 10
Source Project: mua   Source File: PreviewFragment.java    License: MIT License 6 votes vote down vote up
public void configWebView() {
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);

    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress == 100) {
                pageFinish = true;
            }
        }
    });
    webView.loadUrl("file:///android_asset/markdown.html");
}
 
Example 11
Source Project: react-native-web3-webview   Source File: Web3WebviewModule.java    License: MIT License 6 votes vote down vote up
private Uri[] getSelectedFiles(Intent data, int resultCode) {
    if (data == null) {
        return null;
    }

    // we have one file selected
    if (data.getData() != null) {
        if (resultCode == RESULT_OK && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            return WebChromeClient.FileChooserParams.parseResult(resultCode, data);
        } else {
            return null;
        }
    }

    // we have multiple files selected
    if (data.getClipData() != null) {
        final int numSelectedFiles = data.getClipData().getItemCount();
        Uri[] result = new Uri[numSelectedFiles];
        for (int i = 0; i < numSelectedFiles; i++) {
            result[i] = data.getClipData().getItemAt(i).getUri();
        }
        return result;
    }
    return null;
}
 
Example 12
Source Project: cordova-android-chromeview   Source File: CordovaWebView.java    License: Apache License 2.0 6 votes vote down vote up
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }
    
    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;
    
    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
    
    // Hide the content view.
    this.setVisibility(View.GONE);
    
    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}
 
Example 13
Source Project: android-profile   Source File: SoomlaTwitterWebView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param parentActivity the parent activity of the web-view, which will
 *                       be used as a context
 */
public SoomlaTwitterWebView(Activity parentActivity) {
    super(parentActivity);

    this.getSettings().setJavaScriptEnabled(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        this.getSettings().setAllowUniversalAccessFromFileURLs(true);
    }

    this.mHandler = new Handler(Looper.getMainLooper());

    this.setWebChromeClient(new WebChromeClient() {
        public boolean onConsoleMessage(ConsoleMessage cm) {
            Log.d(TAG, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
        }
    });

    this.setBackgroundColor(0x00000000);
    this.mTranslucent = true;
    postInvalidate();
}
 
Example 14
@Override
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_3dsecure);

    // init toolbar
    toolbar = findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(view -> onBackPressed());

    // init web view
    webView = findViewById(R.id.webview);
    webView.setWebChromeClient(new WebChromeClient());
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(buildWebViewClient());

    init();
}
 
Example 15
Source Project: XDroid   Source File: WebActivity.java    License: MIT License 6 votes vote down vote up
private void initWebView() {
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                if (contentLayout != null)
                    contentLayout.showContent();
                if (webView != null)
                    url = webView.getUrl();
            } else {
                if (contentLayout != null)
                    contentLayout.showLoading();
            }
        }
    });
    webView.setWebViewClient(new WebViewClient());
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setDatabaseEnabled(true);
    webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webView.getSettings().setAppCacheEnabled(true);

    webView.loadUrl(url);
}
 
Example 16
Source Project: ListItemFold   Source File: DetailFragment.java    License: MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_blank, container, false);

    mWebview = (WebView) view.findViewById(R.id.h5_web);
    WebSettings webSettings = mWebview.getSettings();
    webSettings.setSupportZoom(false);
    webSettings.setPluginState(WebSettings.PluginState.ON);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setJavaScriptEnabled(true);
    mWebview.setWebChromeClient(new WebChromeClient());
    mWebview.setWebViewClient(new WebViewClient());
    mWebview.loadUrl(mUrl);
    DetailAnimViewGroup wrapper = new DetailAnimViewGroup(inflater.getContext(), view, 0);
    wrapper.setReversed(false);
    return wrapper;
}
 
Example 17
Source Project: XDroid-Databinding   Source File: WebActivity.java    License: MIT License 6 votes vote down vote up
private void initWebView() {
    getBinding().webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                if (getBinding().contentLayout != null)
                    getBinding().contentLayout.showContent();
                if (getBinding().webView != null)
                    url = getBinding().webView.getUrl();
            } else {
                if (getBinding().contentLayout != null)
                    getBinding().contentLayout.showLoading();
            }
        }
    });
    getBinding().webView.setWebViewClient(new WebViewClient());
    getBinding().webView.getSettings().setBuiltInZoomControls(true);
    getBinding().webView.getSettings().setJavaScriptEnabled(true);
    getBinding().webView.getSettings().setDomStorageEnabled(true);
    getBinding().webView.getSettings().setDatabaseEnabled(true);
    getBinding().webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    getBinding().webView.getSettings().setAppCacheEnabled(true);

    getBinding().webView.loadUrl(url);
}
 
Example 18
Source Project: a2cardboard   Source File: CordovaWebViewImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }

    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;

    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) engine.getView().getParent();
    parent.addView(view, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT,
            Gravity.CENTER));

    // Hide the content view.
    engine.getView().setVisibility(View.GONE);

    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}
 
Example 19
Source Project: XQuickEnergy   Source File: HtmlViewerActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_html_viewer);

 mWebView = (MyWebView) findViewById(R.id.mwv_webview);
 pgb = (ProgressBar) findViewById(R.id.pgb_webview);

 mWebView.setWebChromeClient(
  new WebChromeClient()
  {
   @Override
   public void onProgressChanged(WebView view, int progress)
   {
    pgb.setProgress(progress);
    if(progress < 100)
    {
     setTitle("Loading...");
     pgb.setVisibility(View.VISIBLE);
    }else
    {
     setTitle(mWebView.getTitle());
     pgb.setVisibility(View.GONE);
    }
   }
  });
 mWebView.loadUrl(getIntent().getData().toString());
}
 
Example 20
Source Project: XDroidMvp   Source File: WebActivity.java    License: MIT License 5 votes vote down vote up
private void initWebView() {
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress == 100) {
                swipeRefreshLayout.setRefreshing(false);
                if (contentLayout != null)
                    contentLayout.showContent();
                if (webView != null)
                    url = webView.getUrl();
            } else {
                if (contentLayout != null)
                    contentLayout.showLoading();
            }
        }
    });
    webView.setWebViewClient(new WebViewClient());
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setDatabaseEnabled(true);
    webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webView.getSettings().setAppCacheEnabled(true);

    webView.loadUrl(url);
}
 
Example 21
Source Project: materialistic   Source File: SubmitActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppUtils.setStatusBarColor(getWindow(), ContextCompat.getColor(this, R.color.blackT12));
    setContentView(R.layout.activity_submit);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
            ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);
    mTitleLayout = (TextInputLayout) findViewById(R.id.textinput_title);
    mContentLayout = (TextInputLayout) findViewById(R.id.textinput_content);
    mTitleEditText = (TextView) findViewById(R.id.edittext_title);
    mContentEditText = (TextView) findViewById(R.id.edittext_content);
    String text, subject;
    if (savedInstanceState == null) {
        subject = getIntent().getStringExtra(Intent.EXTRA_SUBJECT);
        text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
    } else {
        subject = savedInstanceState.getString(STATE_SUBJECT);
        text = savedInstanceState.getString(STATE_TEXT);
    }
    mTitleEditText.setText(subject);
    mContentEditText.setText(text);
    if (TextUtils.isEmpty(subject)) {
        if (isUrl(text)) {
            WebView webView = new WebView(this);
            webView.setWebChromeClient(new WebChromeClient() {
                @Override
                public void onReceivedTitle(WebView view, String title) {
                    if (mTitleEditText.length() == 0) {
                        mTitleEditText.setText(title);
                    }
                }
            });
            webView.loadUrl(text);
        } else if (!TextUtils.isEmpty(text)) {
            extractUrl(text);
        }
    }
}
 
Example 22
Source Project: STUer-client   Source File: StuWebViewActivity.java    License: MIT License 5 votes vote down vote up
private void webViewProgressSetting() {
    mWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (newProgress == 100) {
                mProgressBar.setVisibility(View.INVISIBLE);
            } else {
                if (mProgressBar.getVisibility() == View.INVISIBLE) {
                    mProgressBar.setVisibility(View.VISIBLE);
                }
                mProgressBar.setProgress(newProgress);
            }
        }
    });
}
 
Example 23
/** Asynchronously open an AppEngine channel. */
@SuppressLint("SetJavaScriptEnabled")
public GAEChannelClient(
    Activity activity, String token, MessageHandler handler) {
  webView = new WebView(activity);
  webView.getSettings().setJavaScriptEnabled(true);
  webView.setWebChromeClient(new WebChromeClient() {  // Purely for debugging.
      public boolean onConsoleMessage (ConsoleMessage msg) {
        Log.d(TAG, "console: " + msg.message() + " at " +
            msg.sourceId() + ":" + msg.lineNumber());
        return false;
      }
    });
  webView.setWebViewClient(new WebViewClient() {  // Purely for debugging.
      public void onReceivedError(
          WebView view, int errorCode, String description,
          String failingUrl) {
        Log.e(TAG, "JS error: " + errorCode + " in " + failingUrl +
            ", desc: " + description);
      }
    });
  proxyingMessageHandler =
      new ProxyingMessageHandler(activity, handler, token);
  webView.addJavascriptInterface(
      proxyingMessageHandler, "androidMessageHandler");
  webView.loadUrl("file:///android_asset/channel.html");
}
 
Example 24
Source Project: turbolinks-android   Source File: TurbolinksHelper.java    License: MIT License 5 votes vote down vote up
/**
 * <p>Configures basic settings of the webView (Javascript enabled, DOM storage enabled,
 * database enabled).</p>
 *
 * @param webView The shared webView.
 */
@SuppressLint("SetJavaScriptEnabled")
private static void configureWebViewDefaults(WebView webView) {
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);

    webView.setWebChromeClient(new WebChromeClient());
}
 
Example 25
Source Project: imsdk-android   Source File: RichEditor.java    License: MIT License 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public RichEditor(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    setVerticalScrollBarEnabled(false);
    setHorizontalScrollBarEnabled(false);
    getSettings().setJavaScriptEnabled(true);
    setWebChromeClient(new WebChromeClient());
    setWebViewClient(createWebviewClient());
    loadUrl(SETUP_HTML);

    applyAttributes(context, attrs);
}
 
Example 26
Source Project: uservoice-android-sdk   Source File: Utils.java    License: MIT License 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public static void displayArticle(WebView webView, Article article, Context context) {
    String styles = "iframe, img { max-width: 100%; }";
    if (isDarkTheme(context)) {
        webView.setBackgroundColor(Color.parseColor("#303030"));
        styles += "body { background-color: #303030; color: #F6F6F6; } a { color: #0099FF; }";
    }
    String html = String.format("<html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"http://cdn.uservoice.com/stylesheets/vendor/typeset.css\"/><style>%s</style></head><body class=\"typeset\" style=\"font-family: sans-serif; margin: 1em\"><h3>%s</h3><br>%s</body></html>", styles, article.getTitle(), article.getHtml());
    webView.setWebChromeClient(new WebChromeClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.loadUrl(String.format("data:text/html;charset=utf-8,%s", Uri.encode(html)));
}
 
Example 27
Source Project: weex-uikit   Source File: WXWebViewTest.java    License: MIT License 5 votes vote down vote up
@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");

}
 
Example 28
private void startFileChooser(WebChromeClient.FileChooserParams fileChooserParams) {
    final String[] acceptTypes = getSafeAcceptedTypes(fileChooserParams);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final boolean allowMultiple = fileChooserParams.getMode() == WebChromeClient.FileChooserParams.MODE_OPEN_MULTIPLE;

        Intent intent = fileChooserParams.createIntent();
        intent.setType("*/*");
        intent.putExtra(Intent.EXTRA_MIME_TYPES, getAcceptedMimeType(acceptTypes));
        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, allowMultiple);
        getCurrentActivity().startActivityForResult(intent, SELECT_FILE);
    }
}
 
Example 29
Source Project: android-discourse   Source File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public static void displayArticle(WebView webView, Article article, Context context) {
    String styles = "iframe, img { width: 100%; }";
    if (isDarkTheme(context)) {
        webView.setBackgroundColor(Color.BLACK);
        styles += "body { background-color: #000000; color: #F6F6F6; } a { color: #0099FF; }";
    }
    String html = String.format("<html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"http://cdn.uservoice.com/stylesheets/vendor/typeset.css\"/><style>%s</style></head><body class=\"typeset\" style=\"font-family: sans-serif; margin: 1em\"><h3>%s</h3>%s</body></html>", styles, article.getTitle(), article.getHtml());
    webView.setWebChromeClient(new WebChromeClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.loadUrl(String.format("data:text/html;charset=utf-8,%s", Uri.encode(html)));
}
 
Example 30
Source Project: alpha-wallet-android   Source File: Web3TokenView.java    License: MIT License 5 votes vote down vote up
public void setupWindowCallback(@NonNull FunctionCallback callback)
{
    setWebChromeClient(
            new WebChromeClient()
            {
                @Override
                public void onCloseWindow(WebView window)
                {
                    callback.functionSuccess();
                }
            }
    );
}