List of usage examples for android.webkit WebChromeClient WebChromeClient
WebChromeClient
From source file:ml.hepolise.vkaudiosave.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); permissions();/*from w w w.j a v a 2 s . c om*/ try { version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { } mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); String token = sharedPreferences.getString(QuickstartPreferences.TOKEN, ""); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { setContentView(R.layout.webview); mWebView = (WebView) findViewById(R.id.activity_main_webview); mWebView.setWebChromeClient(new WebChromeClient()); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.addJavascriptInterface(new WebInterface(getApplicationContext()), "Android"); // mWebView.clearCache(true); // mWebView.clearHistory(); // clearCookies(getApplicationContext()); mWebView.loadUrl("https://vk-as.tk/?app=" + token + "&version=" + version + "&debug=0"); mWebView.setWebViewClient(new webview()); mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } }); } else { mInformationTextView.setText(getString(R.string.token_error_message)); } } }; registerReceiver(); if (checkPlayServices()) { Intent intent = new Intent(this, ml.hepolise.vkaudiosave.RegistrationIntentService.class); startService(intent); } }
From source file:de.geeksfactory.opacclient.frontend.InfoFragment.java
@SuppressWarnings("deprecation") @SuppressLint("SetJavaScriptEnabled") @Override/* ww w .jav a 2s .c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); view = inflater.inflate(R.layout.fragment_info, container, false); app = (OpacClient) getActivity().getApplication(); setHasOptionsMenu(true); load(); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); wvInfo = (WebView) view.findViewById(R.id.wvInfo); wvInfo.getSettings().setSupportZoom(true); wvInfo.getSettings().setJavaScriptEnabled(true); wvInfo.getSettings().setAppCacheMaxSize(5 * 1024 * 1024); wvInfo.getSettings().setAppCacheEnabled(true); wvInfo.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); wvInfo.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView v, int progress) { ProgressBar Pbar = (ProgressBar) view.findViewById(R.id.pbWebProgress); if (progress < 100 && Pbar.getVisibility() == View.GONE) { Pbar.setVisibility(View.VISIBLE); } Pbar.setProgress(progress); if (progress == 100) { Pbar.setVisibility(View.GONE); } } }); wvInfo.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains(app.getLibrary().getData().optString("webviewcontain", "NOPE"))) { return false; } if (getActivity() == null) { return false; } Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } }); return view; }
From source file:com.rickendirk.rsgwijzigingen.WebFragment.java
@Nullable @Override/*ww w . ja v a 2s . com*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable final Bundle savedInstanceState) { View mainView = inflater.inflate(R.layout.fragment_web, container, false); if (savedInstanceState != null) { is1eKeerGenegeerd = true; } progressBar = (ProgressBar) getActivity().findViewById(R.id.progressBar); webView = (NestedWebView) mainView.findViewById(R.id.webView); webView.setNestedScrollingEnabled(true); WebSettings webSettings = webView.getSettings(); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { isLoading = true; isFinished = false; progressBar.setVisibility(View.VISIBLE); } @Override public void onPageFinished(WebView view, String url) { isFinished = true; isLoading = false; //Ondestaande if voorkomt weergeven "pagina is vernieuwd" bij orintatie-verandering if (is1eKeerGenegeerd) { is1eKeerGenegeerd = false; } else Toast.makeText(getActivity(), "Pagina is vernieuwd", Toast.LENGTH_LONG).show(); progressBar.setVisibility(View.GONE); swipeLayout.setRefreshing(false); } }); webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { progressBar.setProgress(newProgress); super.onProgressChanged(view, newProgress); } }); swipeLayout = (SwipeRefreshLayout) mainView.findViewById(R.id.swipeLayout); swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { refresh(); } }); swipeLayout.setColorSchemeResources(R.color.gmailRood, R.color.orange, R.color.lighter_blue, R.color.green); setRetainInstance(true); return mainView; }
From source file:com.remdo.app.WebViewActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_web_view); // Get the uri from the intent Intent intent = getIntent();//from w ww. jav a 2s . com String uriToDisplay = intent.getStringExtra("DEVICE_URL"); String usr = intent.getStringExtra("DEVICE_USER"); String pwd = intent.getStringExtra("DEVICE_PASSWORD"); Integer odTypeId = intent.getIntExtra("DEVICE_ODTYPEID", -1); if (odTypeId == 1)//ODNetWork { if (!uriToDisplay.contains("cgi-bin/od.cgi")) { uriToDisplay = uriToDisplay.concat("/cgi-bin/od.cgi"); } //initialize WebView webView = (WebView) findViewById(R.id.webView1); //we should define a webview client to get user navigation inside our webview otherwise //defaul behaviour will open a webbrowser on first click webView.setWebViewClient(new WebViewClient()); try { byte[] post = EncodingUtils.getBytes("USERNAME=" + usr + "&PASSWORD=" + pwd, "BASE64"); webView.postUrl(uriToDisplay, post); } catch (Exception e) { String message = e.getMessage(); } } else//ODControl { webView = (WebView) findViewById(R.id.webView1); webView.setHttpAuthUsernamePassword(uriToDisplay, "/", "user@opendomo.com", "opendomo"); webView.setWebChromeClient(new WebChromeClient()); webView.setWebViewClient(new MyWebViewClient()); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl("http://local.opendomo.com"); } }
From source file:com.tomeokin.lspush.biz.base.BaseWebViewActivity.java
private void setupWebView() { mProgressBar.setMax(100);// w ww. j a v a 2s . com mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { mProgressBar.setVisibility(View.GONE); } else { mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setProgress(newProgress); } } @Override public void onReceivedTitle(WebView view, String title) { mTitle.setText(title); mTitle.requestLayout(); mTitleLayout.requestLayout(); } }); onPrepareWebView(mWebView); mWebView.loadUrl(onPrepareUrl()); }
From source file:com.btmura.android.reddit.app.LoginFragment.java
private void setupWebView() { // Clear reddit cookie to present a fresh login form. CookieManager.getInstance().setCookie(".reddit.com", "reddit_session="); WebSettings settings = webView.getSettings(); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setLoadWithOverviewMode(true); settings.setSupportZoom(true);/* ww w. j a v a 2 s .c om*/ settings.setUseWideViewPort(true); // Don't save usernames entered into the login forms. settings.setSaveFormData(false); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (progressBar != null) { progressBar.setVisibility(View.VISIBLE); } } @Override public void onPageFinished(WebView view, String url) { if (progressBar != null) { progressBar.setVisibility(View.GONE); } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // WebView will show an unrecognized scheme error unless we intercept // the OAuth callback URL and fire off an intent instead. return url != null && url.startsWith(Urls.OAUTH_REDIRECT_URL) && handleOAuthRedirectUrl(url); } }); webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (progressBar != null) { progressBar.setProgress(newProgress); } } }); }
From source file:gov.whitehouse.ui.fragments.app.ArticleViewerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.article_view, container, false); mWebView = (WebView) v.findViewById(R.id.webview); mProgressBar = (ProgressBar) v.findViewById(R.id.progress); mWebView.getSettings().setJavaScriptEnabled(true); // enabling plugins may yield a better result for YouTube videos mWebView.getSettings().setPluginState(WebSettings.PluginState.ON); mWebView.setWebChromeClient(new WebChromeClient() { public boolean onConsoleMessage(ConsoleMessage cm) { Log.d(TAG, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId()); return true; }/* ww w . ja v a 2 s . c o m*/ }); mWebView.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.e(TAG, "Error in WebView: " + failingUrl + "; " + description); } @Override public void onPageFinished(WebView view, String url) { mProgressBar.setVisibility(View.INVISIBLE); mWebView.setVisibility(View.VISIBLE); Log.d(TAG, "page finished: " + url); if (url.equals(PAGE_TEMPLATE_URL)) { view.loadUrl(String.format("javascript:WhiteHouse.loadPage(%s);", mPageInfo.toString())); } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("youtube.com/")) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } return false; } }); return v; }
From source file:de.trier.infsec.koch.droidsheep.activities.HijackActivity.java
private void setupWebView() { webview = (WebView) findViewById(R.id.webviewhijack); webview.setWebViewClient(new MyWebViewClient()); WebSettings webSettings = webview.getSettings(); webSettings.setUserAgentString("foo"); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(false); webSettings.setBuiltInZoomControls(true); webview.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { HijackActivity.this.setProgress(progress * 100); }//w w w . j a v a2 s. com }); }
From source file:com.zbrown.droidsteal.activities.HijackActivity.java
private void setupWebView() { webview = (WebView) findViewById(R.id.webviewhijack); webview.setWebViewClient(new MyWebViewClient()); WebSettings webSettings = webview.getSettings(); webSettings.setUserAgentString(//from w w w . j a v a 2 s.c o m "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"); webSettings.setJavaScriptEnabled(true); //Blah blah JavaScript is scary blah blah webSettings.setAppCacheEnabled(false); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webview.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { HijackActivity.this.setProgress(progress * 100); int fprogress = (Window.PROGRESS_END) / 100 * progress; setProgress(fprogress); if (progress == 100) { setProgressBarIndeterminateVisibility(false); } } }); }
From source file:com.johnny.gank.ui.activity.WebviewActivity.java
private void setUpWebView() { WebSettings settings = vWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setLoadWithOverviewMode(true); vWebView.setWebViewClient(new WebViewClient() { @Override/*from w w w. j av a 2 s . c o m*/ public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); vRefreshLayout.setRefreshing(true); } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); vRefreshLayout.setRefreshing(false); } @Override public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { super.onReceivedError(view, request, error); vRefreshLayout.setRefreshing(false); } }); vWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress >= 80) { vRefreshLayout.setRefreshing(false); } } }); }