Java Code Examples for android.webkit.WebSettings#setRenderPriority()
The following examples show how to use
android.webkit.WebSettings#setRenderPriority() .
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
Source File: FullScreenWebViewDialog.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
private void buildSetting(WebView webView) { webView.clearCache(true); webView.clearHistory(); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setDefaultTextEncodingName("utf-8");// 避免中文乱码 webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); webSettings.setJavaScriptEnabled(true); webSettings.setNeedInitialFocus(false); // webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); // webSettings.setBlockNetworkLoads(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);//1、提高渲染的优先级 // webSettings.setBlockNetworkImage(true);//把图片加载放在最后来加载渲染 webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setSupportZoom(false); }
Example 2
Source File: FullScreenWebViewDialog.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
private void buildSetting(WebView webView) { webView.clearCache(true); webView.clearHistory(); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setDefaultTextEncodingName("utf-8");// 避免中文乱码 webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); webSettings.setJavaScriptEnabled(true); webSettings.setNeedInitialFocus(false); // webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); // webSettings.setBlockNetworkLoads(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);//1、提高渲染的优先级 // webSettings.setBlockNetworkImage(true);//把图片加载放在最后来加载渲染 webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setSupportZoom(false); }
Example 3
Source File: PKDialog.java From letv with Apache License 2.0 | 6 votes |
@SuppressLint({"SetJavaScriptEnabled"}) private void initViews() { this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.setWebViewClient(new FbWebViewClient()); this.mWebView.setWebChromeClient(this.mChromeClient); this.mWebView.clearFormData(); WebSettings settings = this.mWebView.getSettings(); settings.setSavePassword(false); settings.setSaveFormData(false); settings.setCacheMode(-1); settings.setNeedInitialFocus(false); settings.setBuiltInZoomControls(true); settings.setSupportZoom(true); settings.setRenderPriority(RenderPriority.HIGH); settings.setJavaScriptEnabled(true); if (!(this.mWeakContext == null || this.mWeakContext.get() == null)) { settings.setDatabaseEnabled(true); settings.setDatabasePath(((Context) this.mWeakContext.get()).getApplicationContext().getDir("databases", 0).getPath()); } settings.setDomStorageEnabled(true); this.jsBridge.a(new JsListener(), "sdk_js_if"); this.mWebView.clearView(); this.mWebView.loadUrl(this.mUrl); this.mWebView.getSettings().setSavePassword(false); }
Example 4
Source File: WebViewActivity.java From LQRWeChat with MIT License | 6 votes |
@Override public void initView() { mIbToolbarMore.setVisibility(View.VISIBLE); //设置webView WebSettings settings = mWebView.getSettings(); settings.setRenderPriority(WebSettings.RenderPriority.HIGH); settings.setSupportMultipleWindows(true); settings.setJavaScriptEnabled(true); settings.setSavePassword(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setMinimumFontSize(settings.getMinimumLogicalFontSize() + 8); settings.setAllowFileAccess(false); settings.setTextSize(WebSettings.TextSize.NORMAL); mWebView.setVerticalScrollbarOverlay(true); mWebView.setWebViewClient(new MyWebViewClient()); mWebView.loadUrl(mUrl); setToolbarTitle(TextUtils.isEmpty(mTitle) ? mWebView.getTitle() : mTitle); }
Example 5
Source File: TDialog.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private void d() { j.setVerticalScrollBarEnabled(false); j.setHorizontalScrollBarEnabled(false); j.setWebViewClient(new m(this, null)); j.setWebChromeClient(mChromeClient); j.clearFormData(); WebSettings websettings = j.getSettings(); websettings.setSavePassword(false); websettings.setSaveFormData(false); websettings.setCacheMode(-1); websettings.setNeedInitialFocus(false); websettings.setBuiltInZoomControls(true); websettings.setSupportZoom(true); websettings.setRenderPriority(android.webkit.WebSettings.RenderPriority.HIGH); websettings.setJavaScriptEnabled(true); if (c != null && c.get() != null) { websettings.setDatabaseEnabled(true); websettings.setDatabasePath(((Context)c.get()).getApplicationContext().getDir("databases", 0).getPath()); } websettings.setDomStorageEnabled(true); jsBridge.a(new n(this, null), "sdk_js_if"); j.loadUrl(f); j.setLayoutParams(a); j.setVisibility(4); j.getSettings().setSavePassword(false); }
Example 6
Source File: PKDialog.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private void d() { n.setVerticalScrollBarEnabled(false); n.setHorizontalScrollBarEnabled(false); n.setWebViewClient(new e(this, null)); n.setWebChromeClient(mChromeClient); n.clearFormData(); WebSettings websettings = n.getSettings(); websettings.setSavePassword(false); websettings.setSaveFormData(false); websettings.setCacheMode(-1); websettings.setNeedInitialFocus(false); websettings.setBuiltInZoomControls(true); websettings.setSupportZoom(true); websettings.setRenderPriority(android.webkit.WebSettings.RenderPriority.HIGH); websettings.setJavaScriptEnabled(true); if (o != null && o.get() != null) { websettings.setDatabaseEnabled(true); websettings.setDatabasePath(((Context)o.get()).getApplicationContext().getDir("databases", 0).getPath()); } websettings.setDomStorageEnabled(true); jsBridge.a(new f(this, null), "sdk_js_if"); n.clearView(); n.loadUrl(i); n.getSettings().setSavePassword(false); }
Example 7
Source File: JSWebView.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @SuppressLint({"SetJavaScriptEnabled", "NewApi", "ObsoleteSdkInt"}) public void initializeSettings(WebSettings settings) { settings.setJavaScriptEnabled(true); addJavascriptInterface(new JavaScriptUtil(), "DappJsBridge"); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { settings.setAppCacheMaxSize(Long.MAX_VALUE); } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { settings.setEnableSmoothTransition(true); } if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) { settings.setMediaPlaybackRequiresUserGesture(true); } WebView.setWebContentsDebuggingEnabled(true); settings.setDomStorageEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setAppCacheEnabled(true); settings.setCacheMode(WebSettings.LOAD_DEFAULT); settings.setLoadsImagesAutomatically(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setDatabaseEnabled(true); settings.setDisplayZoomControls(false); settings.setAllowContentAccess(true); settings.setAllowFileAccess(false); settings.setRenderPriority(WebSettings.RenderPriority.LOW); setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); settings.setDefaultTextEncodingName("utf-8"); settings.setAllowFileAccessFromFileURLs(false); settings.setAllowUniversalAccessFromFileURLs(false); // 特别注意:5.1以上默认禁止了https和http混用,以下方式是开启 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW); } }
Example 8
Source File: WebPlayerView.java From mv-android-client with Apache License 2.0 | 5 votes |
private void init(Context context) { mPlayer = new WebPlayer(this); setBackgroundColor(Color.BLACK); enableJavascript(); WebSettings webSettings = getSettings(); webSettings.setAllowContentAccess(true); webSettings.setAllowFileAccess(true); webSettings.setAppCacheEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDatabasePath(context.getDir("database", Context.MODE_PRIVATE).getPath()); webSettings.setDomStorageEnabled(true); webSettings.setLoadsImagesAutomatically(true); webSettings.setSupportMultipleWindows(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { webSettings.setMediaPlaybackRequiresUserGesture(false); } } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); } setWebChromeClient(new ChromeClient()); setWebViewClient(new ViewClient()); }
Example 9
Source File: OAuthActivity.java From iBeebo with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.oauth_activity_layout); this.mIsAuthPro = getIntent().getBooleanExtra(Ext.KEY_IS_HACK, false); this.mAccountBean = getIntent().getParcelableExtra(Ext.KEY_ACCOUNT); Toolbar mToolbar = ViewUtility.findViewById(this, R.id.oauthToolbar); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); getSupportActionBar().setTitle(mIsAuthPro ? R.string.oauth_senior_title : R.string.oauth_normal_title); mWebView = (WebView) findViewById(R.id.webView); mInjectJS = new InjectJS(mWebView); mWebView.setWebViewClient(new WeiboWebViewClient()); mCircleProgressBar = (CircleProgressBar) findViewById(R.id.oauthProgress); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setSaveFormData(true); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setRenderPriority(WebSettings.RenderPriority.HIGH); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); refresh(); }
Example 10
Source File: WebSettingsCompat.java From Android_Skin_2.0 with Apache License 2.0 | 4 votes |
@Override public void setRenderPriority(WebSettings settings, RenderPriority priority) { settings.setRenderPriority(priority); }
Example 11
Source File: AuthDialog.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
private void e() { k.setVerticalScrollBarEnabled(false); k.setHorizontalScrollBarEnabled(false); k.setWebViewClient(new l(this, null)); k.setWebChromeClient(new WebChromeClient()); k.clearFormData(); WebSettings websettings = k.getSettings(); websettings.setSavePassword(false); websettings.setSaveFormData(false); websettings.setCacheMode(-1); websettings.setNeedInitialFocus(false); websettings.setBuiltInZoomControls(true); websettings.setSupportZoom(true); websettings.setRenderPriority(android.webkit.WebSettings.RenderPriority.HIGH); websettings.setJavaScriptEnabled(true); if (a != null && a.get() != null) { websettings.setDatabaseEnabled(true); websettings.setDatabasePath(((Context)a.get()).getApplicationContext().getDir("databases", 0).getPath()); } websettings.setDomStorageEnabled(true); try { Method method = android/webkit/WebView.getMethod("addJavascriptInterface", new Class[] { java/lang/Object, java/lang/String }); WebView webview = k; Object aobj[] = new Object[2]; aobj[0] = new k(this, null); aobj[1] = "sdk_js_if"; method.invoke(webview, aobj); } catch (NoSuchMethodException nosuchmethodexception) { nosuchmethodexception.printStackTrace(); } catch (IllegalArgumentException illegalargumentexception) { illegalargumentexception.printStackTrace(); } catch (IllegalAccessException illegalaccessexception) { illegalaccessexception.printStackTrace(); } catch (InvocationTargetException invocationtargetexception) { invocationtargetexception.printStackTrace(); } catch (Exception exception) { Log.e("AuthDialog", exception.getMessage()); } k.loadUrl(b); k.setVisibility(4); k.getSettings().setSavePassword(false); }
Example 12
Source File: KCWebView.java From kerkee_android with GNU General Public License v3.0 | 4 votes |
/** * @param aWebView * **/ public static void setupWebViewAttributes(KCWebView aWebView) { try { WebSettings webSettings = aWebView.getSettings(); setCustomizedUA(webSettings); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } webSettings.setJavaScriptEnabled(true); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); webSettings.setBuiltInZoomControls(false); webSettings.setSupportZoom(true); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); webSettings.setAppCachePath(aWebView.getWebPath().getRootPath() + "/webcache"); webSettings.setAppCacheEnabled(true); // webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); webSettings.setLoadsImagesAutomatically(true); webSettings.setLightTouchEnabled(false); webSettings.setDomStorageEnabled(true); // supports local storage webSettings.setDatabaseEnabled(true); // supports local storage webSettings.setDatabasePath(aWebView.getWebPath().getRootPath() + "/localstorage"); // we are using ApplicationContext when creaing KCWebView, without disabling the "Save Password" dialog // there will be an exception that would cause crash: "Unable to add window -- token null is not for an application" webSettings.setSavePassword(false); aWebView.setHorizontalScrollBarEnabled(false); // mWebView.setVerticalScrollBarEnabled(false); aWebView.setScrollbarFadingEnabled(true); aWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); } catch (Exception e) { KCLog.e(e); } }
Example 13
Source File: WebView.java From unity-ads-android with Apache License 2.0 | 4 votes |
public WebView(Context context) { super(context); WebSettings settings = getSettings(); if(Build.VERSION.SDK_INT >= 16) { settings.setAllowFileAccessFromFileURLs(true); settings.setAllowUniversalAccessFromFileURLs(true); } if (Build.VERSION.SDK_INT >= 19) { try { _evaluateJavascript = android.webkit.WebView.class.getMethod("evaluateJavascript", String.class, ValueCallback.class); } catch(NoSuchMethodException e) { DeviceLog.exception("Method evaluateJavascript not found", e); _evaluateJavascript = null; } } settings.setAppCacheEnabled(false); settings.setBlockNetworkImage(false); settings.setBlockNetworkLoads(false); settings.setBuiltInZoomControls(false); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setDatabaseEnabled(false); if(Build.VERSION.SDK_INT >= 11) { settings.setDisplayZoomControls(false); } settings.setDomStorageEnabled(false); if(Build.VERSION.SDK_INT >= 11) { settings.setEnableSmoothTransition(false); } settings.setGeolocationEnabled(false); settings.setJavaScriptCanOpenWindowsAutomatically(false); settings.setJavaScriptEnabled(true); settings.setLightTouchEnabled(false); settings.setLoadWithOverviewMode(false); settings.setLoadsImagesAutomatically(true); if(Build.VERSION.SDK_INT >= 17) { settings.setMediaPlaybackRequiresUserGesture(false); } if(Build.VERSION.SDK_INT >= 21) { settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW); } settings.setNeedInitialFocus(true); settings.setPluginState(WebSettings.PluginState.OFF); settings.setRenderPriority(WebSettings.RenderPriority.NORMAL); settings.setSaveFormData(false); settings.setSavePassword(false); settings.setSupportMultipleWindows(false); settings.setSupportZoom(false); settings.setUseWideViewPort(true); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); setInitialScale(0); setBackgroundColor(Color.TRANSPARENT); ViewUtilities.setBackground(this, new ColorDrawable(Color.TRANSPARENT)); setBackgroundResource(0); addJavascriptInterface(new WebViewBridgeInterface(), "webviewbridge"); }
Example 14
Source File: MainActivity.java From 2048-android with MIT License | 4 votes |
@SuppressLint({"SetJavaScriptEnabled", "ShowToast", "ClickableViewAccessibility"}) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Don't show an action bar or title requestWindowFeature(Window.FEATURE_NO_TITLE); // Enable hardware acceleration getWindow().setFlags(LayoutParams.FLAG_HARDWARE_ACCELERATED, LayoutParams.FLAG_HARDWARE_ACCELERATED); // Apply previous setting about showing status bar or not applyFullScreen(isFullScreen()); // Check if screen rotation is locked in settings boolean isOrientationEnabled = false; try { isOrientationEnabled = Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION) == 1; } catch (SettingNotFoundException e) { Log.d(MAIN_ACTIVITY_TAG, "Settings could not be loaded"); } // If rotation isn't locked and it's a LARGE screen then add orientation changes based on sensor int screenLayout = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if (((screenLayout == Configuration.SCREENLAYOUT_SIZE_LARGE) || (screenLayout == Configuration.SCREENLAYOUT_SIZE_XLARGE)) && isOrientationEnabled) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } setContentView(R.layout.activity_main); DialogChangeLog changeLog = DialogChangeLog.newInstance(this); if (changeLog.isFirstRun()) { changeLog.getLogDialog().show(); } // Load webview with game mWebView = findViewById(R.id.mainWebView); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setRenderPriority(RenderPriority.HIGH); settings.setDatabasePath(getFilesDir().getParentFile().getPath() + "/databases"); // If there is a previous instance restore it in the webview if (savedInstanceState != null) { mWebView.restoreState(savedInstanceState); } else { // Load webview with current Locale language mWebView.loadUrl("file:///android_asset/2048/index.html?lang=" + Locale.getDefault().getLanguage()); } Toast.makeText(getApplication(), R.string.toggle_fullscreen, Toast.LENGTH_SHORT).show(); // Set fullscreen toggle on webview LongClick mWebView.setOnTouchListener((v, event) -> { // Implement a long touch action by comparing // time between action up and action down long currentTime = System.currentTimeMillis(); if ((event.getAction() == MotionEvent.ACTION_UP) && (Math.abs(currentTime - mLastTouch) > mTouchThreshold)) { boolean toggledFullScreen = !isFullScreen(); saveFullScreen(toggledFullScreen); applyFullScreen(toggledFullScreen); } else if (event.getAction() == MotionEvent.ACTION_DOWN) { mLastTouch = currentTime; } // return so that the event isn't consumed but used // by the webview as well return false; }); pressBackToast = Toast.makeText(getApplicationContext(), R.string.press_back_again_to_exit, Toast.LENGTH_SHORT); }
Example 15
Source File: AuthActivity.java From letv with Apache License 2.0 | 4 votes |
protected void onCreate(Bundle bundle) { super.onCreate(bundle); try { Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } try { this.d = extras.getString(b); String string = extras.getString("params"); if (k.a(string)) { Method method; super.requestWindowFeature(1); this.f = new Handler(getMainLooper()); View linearLayout = new LinearLayout(getApplicationContext()); LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1); linearLayout.setOrientation(1); setContentView(linearLayout, layoutParams); this.c = new WebView(getApplicationContext()); layoutParams.weight = 1.0f; this.c.setVisibility(0); linearLayout.addView(this.c, layoutParams); WebSettings settings = this.c.getSettings(); settings.setUserAgentString(settings.getUserAgentString() + k.c(getApplicationContext())); settings.setRenderPriority(RenderPriority.HIGH); settings.setSupportMultipleWindows(true); settings.setJavaScriptEnabled(true); settings.setSavePassword(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setMinimumFontSize(settings.getMinimumFontSize() + 8); settings.setAllowFileAccess(false); settings.setTextSize(TextSize.NORMAL); this.c.setVerticalScrollbarOverlay(true); this.c.setWebViewClient(new b()); this.c.setWebChromeClient(new a()); this.c.setDownloadListener(new a(this)); this.c.loadUrl(string); if (VERSION.SDK_INT >= 7) { try { method = this.c.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE}); if (method != null) { method.invoke(this.c.getSettings(), new Object[]{Boolean.valueOf(true)}); } } catch (Exception e) { } } try { method = this.c.getClass().getMethod("removeJavascriptInterface", new Class[0]); if (method != null) { method.invoke(this.c, new Object[]{"searchBoxJavaBridge_"}); return; } return; } catch (Exception e2) { return; } } finish(); } catch (Exception e3) { finish(); } } catch (Exception e4) { finish(); } }
Example 16
Source File: H5PayActivity.java From letv with Apache License 2.0 | 4 votes |
protected void onCreate(Bundle bundle) { super.onCreate(bundle); try { Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } try { String string = extras.getString("url"); if (k.a(string)) { Method method; super.requestWindowFeature(1); this.c = new Handler(getMainLooper()); Object string2 = extras.getString("cookie"); if (!TextUtils.isEmpty(string2)) { CookieSyncManager.createInstance(getApplicationContext()).sync(); CookieManager.getInstance().setCookie(string, string2); CookieSyncManager.getInstance().sync(); } View linearLayout = new LinearLayout(getApplicationContext()); LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1); linearLayout.setOrientation(1); setContentView(linearLayout, layoutParams); this.a = new WebView(getApplicationContext()); layoutParams.weight = 1.0f; this.a.setVisibility(0); linearLayout.addView(this.a, layoutParams); WebSettings settings = this.a.getSettings(); settings.setUserAgentString(settings.getUserAgentString() + k.c(getApplicationContext())); settings.setRenderPriority(RenderPriority.HIGH); settings.setSupportMultipleWindows(true); settings.setJavaScriptEnabled(true); settings.setSavePassword(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setMinimumFontSize(settings.getMinimumFontSize() + 8); settings.setAllowFileAccess(false); settings.setTextSize(TextSize.NORMAL); this.a.setVerticalScrollbarOverlay(true); this.a.setWebViewClient(new a()); this.a.loadUrl(string); if (VERSION.SDK_INT >= 7) { try { method = this.a.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE}); if (method != null) { method.invoke(this.a.getSettings(), new Object[]{Boolean.valueOf(true)}); } } catch (Exception e) { } } try { method = this.a.getClass().getMethod("removeJavascriptInterface", new Class[0]); if (method != null) { method.invoke(this.a, new Object[]{"searchBoxJavaBridge_"}); return; } return; } catch (Exception e2) { return; } } finish(); } catch (Exception e3) { finish(); } } catch (Exception e4) { finish(); } }
Example 17
Source File: H5AuthActivity.java From letv with Apache License 2.0 | 4 votes |
protected void onCreate(Bundle bundle) { super.onCreate(bundle); try { Bundle extras = getIntent().getExtras(); if (extras == null) { finish(); return; } try { String string = extras.getString("url"); if (k.a(string)) { Method method; super.requestWindowFeature(1); this.c = new Handler(getMainLooper()); View linearLayout = new LinearLayout(getApplicationContext()); LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1); linearLayout.setOrientation(1); setContentView(linearLayout, layoutParams); this.a = new WebView(getApplicationContext()); layoutParams.weight = 1.0f; this.a.setVisibility(0); linearLayout.addView(this.a, layoutParams); WebSettings settings = this.a.getSettings(); settings.setUserAgentString(settings.getUserAgentString() + k.c(getApplicationContext())); settings.setRenderPriority(RenderPriority.HIGH); settings.setSupportMultipleWindows(true); settings.setJavaScriptEnabled(true); settings.setSavePassword(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setMinimumFontSize(settings.getMinimumFontSize() + 8); settings.setAllowFileAccess(false); settings.setTextSize(TextSize.NORMAL); this.a.setVerticalScrollbarOverlay(true); this.a.setWebViewClient(new a()); this.a.setDownloadListener(new a(this)); this.a.loadUrl(string); if (VERSION.SDK_INT >= 7) { try { method = this.a.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE}); if (method != null) { method.invoke(this.a.getSettings(), new Object[]{Boolean.valueOf(true)}); } } catch (Exception e) { } } try { method = this.a.getClass().getMethod("removeJavascriptInterface", new Class[0]); if (method != null) { method.invoke(this.a, new Object[]{"searchBoxJavaBridge_"}); return; } return; } catch (Exception e2) { return; } } finish(); } catch (Exception e3) { finish(); } } catch (Exception e4) { finish(); } }
Example 18
Source File: OAuthActivity.java From iBeebo with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.oauth_activity_layout); this.mIsAuthPro = getIntent().getBooleanExtra(Ext.KEY_IS_HACK, false); this.mAccountBean = getIntent().getParcelableExtra(Ext.KEY_ACCOUNT); Toolbar mToolbar = ViewUtility.findViewById(this, R.id.oauthToolbar); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); getSupportActionBar().setTitle(mIsAuthPro ? R.string.oauth_senior_title : R.string.oauth_normal_title); mWebView = (WebView) findViewById(R.id.webView); mInjectJS = new InjectJS(mWebView); mWebView.setWebViewClient(new WeiboWebViewClient()); mCircleProgressBar = (CircleProgressBar) findViewById(R.id.oauthProgress); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setSaveFormData(true); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setRenderPriority(WebSettings.RenderPriority.HIGH); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); refresh(); }
Example 19
Source File: MyWebView.java From DoraemonKit with Apache License 2.0 | 4 votes |
private void init(Context context) { if (!(context instanceof Activity)) { throw new RuntimeException("only support Activity context"); } else { this.mContainerActivity = (Activity) context; WebSettings webSettings = this.getSettings(); webSettings.setPluginState(WebSettings.PluginState.ON); webSettings.setJavaScriptEnabled(true); webSettings.setAllowFileAccess(false); webSettings.setLoadsImagesAutomatically(true); webSettings.setUseWideViewPort(true); webSettings.setBuiltInZoomControls(false); webSettings.setDefaultTextEncodingName("UTF-8"); webSettings.setDomStorageEnabled(true); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); webSettings.setJavaScriptCanOpenWindowsAutomatically(false); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setWebContentsDebuggingEnabled(true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { webSettings.setMixedContentMode(0); } if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1 && Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { this.removeJavascriptInterface("searchBoxJavaBridge_"); this.removeJavascriptInterface("accessibilityTraversal"); this.removeJavascriptInterface("accessibility"); } mMyWebViewClient = new MyWebViewClient(); this.setWebViewClient(mMyWebViewClient); this.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress < 100) { showLoadProgress(newProgress); } else { hideLoadProgress(); } } }); addProgressView(); } }
Example 20
Source File: BitWebViewFragment.java From tysq-android with GNU General Public License v3.0 | 4 votes |
private void initWebViewSetting(WebSettings settings) { //支持js脚本 settings.setJavaScriptEnabled(true); //支持缩放 settings.setSupportZoom(true); //支持缩放 settings.setBuiltInZoomControls(true); //去除缩放按钮 settings.setDisplayZoomControls(false); //扩大比例的缩放 settings.setUseWideViewPort(true); //自适应屏幕 settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setLoadWithOverviewMode(true); //多窗口 settings.supportMultipleWindows(); //关闭webview中缓存 settings.setCacheMode(WebSettings.LOAD_NO_CACHE); //设置可以访问文件 settings.setAllowFileAccess(true); //当webview调用requestFocus时为webview设置节点 settings.setNeedInitialFocus(true); //支持通过JS打开新窗口 settings.setJavaScriptCanOpenWindowsAutomatically(true); //支持自动加载图片 settings.setLoadsImagesAutomatically(true); //启用地理定位 // settings.setGeolocationEnabled(true); //设置渲染优先级 settings.setRenderPriority(WebSettings.RenderPriority.HIGH); // 设置支持本地存储 settings.setDatabaseEnabled(true); //设置支持DomStorage settings.setDomStorageEnabled(true); addJavascriptInterface(); }