android.webkit.WebSettings.RenderPriority Java Examples

The following examples show how to use android.webkit.WebSettings.RenderPriority. 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: PKDialog.java    From letv with Apache License 2.0 6 votes vote down vote up
@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 #2
Source File: TDialog.java    From letv with Apache License 2.0 5 votes vote down vote up
@SuppressLint({"SetJavaScriptEnabled"})
private void b() {
    this.i.setVerticalScrollBarEnabled(false);
    this.i.setHorizontalScrollBarEnabled(false);
    this.i.setWebViewClient(new FbWebViewClient());
    this.i.setWebChromeClient(this.mChromeClient);
    this.i.clearFormData();
    WebSettings settings = this.i.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.c == null || this.c.get() == null)) {
        settings.setDatabaseEnabled(true);
        settings.setDatabasePath(((Context) this.c.get()).getApplicationContext().getDir("databases", 0).getPath());
    }
    settings.setDomStorageEnabled(true);
    this.jsBridge.a(new JsListener(), "sdk_js_if");
    this.i.loadUrl(this.e);
    this.i.setLayoutParams(a);
    this.i.setVisibility(4);
    this.i.getSettings().setSavePassword(false);
}
 
Example #3
Source File: RLWebBrowser.java    From Roid-Library with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    this.context = context;
    View rootView = LayoutInflater.from(context).inflate(R.layout.web_browser, null);
    this.addView(rootView);
    layout_loading = (LinearLayout) rootView.findViewById(R.id.layout_loading);
    layout_loading.setVisibility(View.GONE);
    iv_refresh = (ImageView) rootView.findViewById(R.id.iv_refresh);
    iv_refresh.setOnClickListener(myClickListener);
    iv_stop = (ImageView) rootView.findViewById(R.id.iv_stop);
    iv_stop.setOnClickListener(myClickListener);
    iv_goback = (ImageView) rootView.findViewById(R.id.iv_goback);
    iv_goback.setOnClickListener(myClickListener);
    iv_more = (ImageView) rootView.findViewById(R.id.iv_more);
    iv_more.setOnClickListener(myClickListener);
    iv_goback.setEnabled(false);
    iv_goforward = (ImageView) rootView.findViewById(R.id.iv_goforward);
    iv_goforward.setOnClickListener(myClickListener);
    iv_goforward.setEnabled(false);
    webView = (WebView) rootView.findViewById(R.id.webView);
    webView.getSettings().setSupportZoom(true);
    webView.getSettings().setSaveFormData(false);
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setBlockNetworkLoads(false);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setRenderPriority(RenderPriority.HIGH);
    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    webView.setWebChromeClient(myWebChromeClient);
    webView.setWebViewClient(myWebViewClient);
    webView.setOnTouchListener(myTouchListener);
    webView.setDownloadListener(myDownLoadListener);
}
 
Example #4
Source File: H5AuthActivity.java    From letv with Apache License 2.0 4 votes vote down vote up
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 #5
Source File: H5PayActivity.java    From letv with Apache License 2.0 4 votes vote down vote up
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 #6
Source File: AuthActivity.java    From letv with Apache License 2.0 4 votes vote down vote up
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 #7
Source File: WebInitCompat.java    From Android_Skin_2.0 with Apache License 2.0 4 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
@Override
public void setDefaultSetting(WebView view) {
	WebSettingsCompat settings = WebSettingsCompat.get(view);

	// JavaScript 支持
	settings.setJavaScriptEnabled(true);
	settings.setJavaScriptCanOpenWindowsAutomatically(true); // 允许 JavaScript 弹出窗口
	
	// web 图片
	settings.setLoadsImagesAutomatically(true);

	// WebView 去除缩放功能但隐藏缩放控件
	settings.setSupportZoom(false);
	settings.setBuiltInZoomControls(false);
	settings.setDisplayZoomControls(false);

	// 自适应屏幕
	settings.setUseWideViewPort(true);

	// 加载模式
	settings.setLoadWithOverviewMode(true);

	// 保持表单和密码
	settings.setSaveFormData(false);
	settings.setSavePassword(false);

	// 线程优先级调整
	settings.setRenderPriority(RenderPriority.HIGH);

	// 用WebView显示图片,可使用这个参数
	settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
	
	settings.setSupportMultipleWindows(true);

	// LOAD_CACHE_ONLY: 不使用网络,只读取本地缓存数据
	// LOAD_DEFAULT: 根据cache-control决定是否从网络上取数据
	// LOAD_CACHE_NORMAL: API level 17中已经废弃, 从API level
	// 11开始作用同LOAD_DEFAULT模式
	// LOAD_NO_CACHE: 不使用缓存,只从网络获取数据
	// LOAD_CACHE_ELSE_NETWORK: 只要本地有,无论是否过期、或者no-cache,都使用缓存中的数据

	// www.taobao.com的cache-control为no-cache,在模式LOAD_DEFAULT下,无论如何都会从网络上取数据,如果没有网络,就会出现错误页面;
	// 在LOAD_CACHE_ELSE_NETWORK模式下,无论是否有网络,只要本地有缓存,都使用缓存。本地没有缓存时才从网络上获取
	settings.setCacheMode(WebSettings.LOAD_DEFAULT);
	// 开启 DOM storage API 功能
	settings.setDomStorageEnabled(true);
	// 开启 database storage API 功能
	settings.setDatabaseEnabled(true);
	// 开启 Application Caches 功能
	settings.setAppCacheEnabled(true);
	// 设置最大缓存值 8M
	settings.setAppCacheMaxSize(8 * 1024 * 1024);

	settings.setPluginState(PluginStateCompat.ON_DEMAND);

	// 可以读取内容缓存
	settings.setAllowContentAccess(true);
	// 可以读取文件缓存(manifest生效)
	settings.setAllowFileAccess(true);
	settings.setAllowFileAccessFromFileURLs(true);
	settings.setAllowUniversalAccessFromFileURLs(true);
}
 
Example #8
Source File: WebSettingsCompat.java    From Android_Skin_2.0 with Apache License 2.0 4 votes vote down vote up
@Override
public void setRenderPriority(WebSettings settings, RenderPriority priority) {
	settings.setRenderPriority(priority);
}
 
Example #9
Source File: WebSettingsCompat.java    From Android_Skin_2.0 with Apache License 2.0 4 votes vote down vote up
public void setRenderPriority(RenderPriority priority) {
	impl.setRenderPriority(settings, priority);
}
 
Example #10
Source File: MainActivity.java    From 2048-android with MIT License 4 votes vote down vote up
@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 #11
Source File: EBrowserSetting.java    From appcan-android with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void initBaseSetting(boolean webApp) {
        mWebApp = webApp;
        mWebSetting.setSaveFormData(false);
        mWebSetting.setSavePassword(false);
        mWebSetting.setLightTouchEnabled(false);
        mWebSetting.setJavaScriptEnabled(true);
        mWebSetting.setNeedInitialFocus(false);
        mWebSetting.setSupportMultipleWindows(false);
        mWebSetting.setGeolocationEnabled(true);
        // mWebSetting.setNavDump(false);
        //mWebSetting.setPluginsEnabled(true);
        mWebSetting.setJavaScriptCanOpenWindowsAutomatically(false);
        mWebSetting.setUseWideViewPort(false);
        mWebSetting.setLoadsImagesAutomatically(true);
        mWebSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
        mWebSetting.setUserAgentString(USERAGENT_NEW);
        mWebSetting.setRenderPriority(RenderPriority.HIGH);
        mWebSetting.setDefaultTextEncodingName("UTF-8");
        mWebSetting.setBuiltInZoomControls(true);
        mWebSetting.setDisplayZoomControls(false);
        mWebSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);
        mWebSetting.setDomStorageEnabled(true);//开启DOM storage API功能

        if (Build.VERSION.SDK_INT <= 7) {
            invokeHtml5(mWebSetting);
        }
        if (Build.VERSION.SDK_INT >= 14) {
            mWebSetting.setTextZoom(100);;
        }
        if (webApp) {
            mWebSetting.setUseWideViewPort(true);
//			mWebSetting.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
            //允许混合模式,解决个别页面或者视频无法正常显示和播放的问题(http与https)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mWebSetting.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
            }
            return;
        }
//		mWebSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);
        // disables the actual onscreen controls from showing up
        mWebSetting.setBuiltInZoomControls(false);
        // disables the ability to zoom
        mWebSetting.setSupportZoom(false);
        mWebSetting.setDefaultFontSize(ESystemInfo.getIntence().mDefaultFontSize);
        mWebSetting.setDefaultFixedFontSize(ESystemInfo.getIntence().mDefaultFontSize);
//		float sca = mBrwView.getScale();
//		if (sca != 1.0f) {
        if (Build.VERSION.SDK_INT <= 18) {
            mWebSetting.setDefaultZoom(ESystemInfo.getIntence().mDefaultzoom.getValue());
        }


//		}

    }
 
Example #12
Source File: WebSettingsCompat.java    From Android_Skin_2.0 with Apache License 2.0 2 votes vote down vote up
/**
 * 线程优先级调整
 */
public void setRenderPriority(WebSettings settings, RenderPriority priority);