android.webkit.WebSettings.PluginState Java Examples

The following examples show how to use android.webkit.WebSettings.PluginState. 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: WebSettingsCompatFroyo.java    From Android_Skin_2.0 with Apache License 2.0 6 votes vote down vote up
public static void setPluginState(WebSettings settings, PluginStateCompat state) {
	switch (state) {
	case ON: {
		settings.setPluginState(PluginState.ON);
		break;
	}
	case ON_DEMAND: {
		settings.setPluginState(PluginState.ON_DEMAND);
		break;
	}
	case OFF: {
		settings.setPluginState(PluginState.OFF);
		break;
	}
	default: {
		break;
	}
	}
}
 
Example #2
Source File: PluginWebViewActivity.java    From Android-Plugin-Framework with MIT License 6 votes vote down vote up
private void setUpWebViewSetting() {
	WebSettings webSettings = web.getSettings();

	webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);// 根据cache-control决定是否从网络上取数据
	webSettings.setSupportZoom(true);
	webSettings.setBuiltInZoomControls(true);// 显示放大缩小
	webSettings.setJavaScriptEnabled(true);
	// webSettings.setPluginsEnabled(true);
	webSettings.setPluginState(PluginState.ON);
	webSettings.setUserAgentString(webSettings.getUserAgentString());
	webSettings.setDomStorageEnabled(true);
	webSettings.setAppCacheEnabled(true);
	webSettings.setAppCachePath(getCacheDir().getPath());
	webSettings.setUseWideViewPort(true);// 影响默认满屏和双击缩放
	webSettings.setLoadWithOverviewMode(true);// 影响默认满屏和手势缩放

}
 
Example #3
Source File: EBrowserSetting7.java    From appcan-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void initBaseSetting(boolean webApp) {
    super.initBaseSetting(webApp);
    mWebSetting.setAppCacheEnabled(true);
    mWebSetting.setAppCachePath(mBrwView.getContext().getDir("cache", 0).getPath());
    mWebSetting.setDatabaseEnabled(true);
    mWebSetting.setDomStorageEnabled(true);
    mWebSetting.setLoadWithOverviewMode(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        mWebSetting.setAllowFileAccessFromFileURLs(true);
        mWebSetting.setAllowUniversalAccessFromFileURLs(true);
    }

    mWebSetting.setDatabasePath(mBrwView.getContext().getDir("database", 0).getPath());
    if (Build.VERSION.SDK_INT >= 8) {
        try {
            mWebSetting.setPluginState(PluginState.ON);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (Build.VERSION.SDK_INT > 10) {
        invoke();
    }
}
 
Example #4
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * See {@link android.webkit.WebSettings#setPluginState}.
 */
public void setPluginState(PluginState state) {
    synchronized (mAwSettingsLock) {
        if (mPluginState != state) {
            mPluginState = state;
            mEventHandler.updateWebkitPreferencesLocked();
        }
    }
}
 
Example #5
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * See {@link android.webkit.WebSettings#setPluginState}.
 */
public void setPluginState(PluginState state) {
    synchronized (mAwSettingsLock) {
        if (mPluginState != state) {
            mPluginState = state;
            mEventHandler.updateWebkitPreferencesLocked();
        }
    }
}
 
Example #6
Source File: Utils.java    From uservoice-android-sdk with 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 #7
Source File: BaseWebView.java    From dcs-sdk-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void init(Context context) {
    this.setVerticalScrollBarEnabled(false);
    this.setHorizontalScrollBarEnabled(false);
    if (Build.VERSION.SDK_INT < 19) {
        removeJavascriptInterface("searchBoxJavaBridge_");
    }

    WebSettings localWebSettings = this.getSettings();
    try {
        // 禁用file协议,http://www.tuicool.com/articles/Q36ZfuF, 防止Android WebView File域攻击
        localWebSettings.setAllowFileAccess(false);
        localWebSettings.setSupportZoom(false);
        localWebSettings.setBuiltInZoomControls(false);
        localWebSettings.setUseWideViewPort(true);
        localWebSettings.setDomStorageEnabled(true);
        localWebSettings.setLoadWithOverviewMode(true);
        localWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        localWebSettings.setPluginState(PluginState.ON);
        // 启用数据库
        localWebSettings.setDatabaseEnabled(true);
        // 设置定位的数据库路径
        String dir = context.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
        localWebSettings.setGeolocationDatabasePath(dir);
        localWebSettings.setGeolocationEnabled(true);
        localWebSettings.setJavaScriptEnabled(true);
        localWebSettings.setSavePassword(false);
        String agent = localWebSettings.getUserAgentString();

        localWebSettings.setUserAgentString(agent);
        // setCookie(context, ".baidu.com", bdussCookie);

    } catch (Exception e1) {
        e1.printStackTrace();
    }
    this.setWebViewClient(new BridgeWebViewClient());
}
 
Example #8
Source File: PostDetailFragment.java    From Broadsheet.ie-Android with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_post_detail, container, false);

    mWebview = (WebView) rootView.findViewById(R.id.webview);

    mWebview.getSettings().setJavaScriptEnabled(true);
    mWebview.setWebViewClient(new MyWebViewClient(this.getActivity()));
    if (android.os.Build.VERSION.SDK_INT < 8) {
        mWebview.getSettings().setPluginsEnabled(true);
    } else {
        mWebview.getSettings().setPluginState(PluginState.ON);
    }

    mNext = (Button) rootView.findViewById(R.id.next);
    mPrevious = (Button) rootView.findViewById(R.id.previous);

    mNext.setOnClickListener(this);
    mPrevious.setOnClickListener(this);

    if (mPostIndex == -1) {
        mNext.setVisibility(View.GONE);
        mPrevious.setVisibility(View.GONE);
    }

    if (mPost != null) {
        layoutView();
    }

    return rootView;
}
 
Example #9
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 #10
Source File: Browser.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化浏览器设置信息
 */
private void initWebView() {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true); // 启用支持javascript
    webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);// 优先使用缓存
    webSettings.setAllowFileAccess(true);// 可以访问文件
    webSettings.setBuiltInZoomControls(true);// 支持缩放
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        webSettings.setPluginState(PluginState.ON);
        webSettings.setDisplayZoomControls(false);// 支持缩放
    }
    mWebView.setWebViewClient(new MyWebViewClient());
    mWebView.setWebChromeClient(new MyWebChromeClient());
}
 
Example #11
Source File: Utils.java    From android-discourse with 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 #12
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * See {@link android.webkit.WebSettings#setPluginsEnabled}.
 */
public void setPluginsEnabled(boolean flag) {
    setPluginState(flag ? PluginState.ON : PluginState.OFF);
}
 
Example #13
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * See {@link android.webkit.WebSettings#getPluginsEnabled}.
 */
public boolean getPluginsEnabled() {
    synchronized (mAwSettingsLock) {
        return mPluginState == PluginState.ON;
    }
}
 
Example #14
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * See {@link android.webkit.WebSettings#getPluginState}.
 */
public PluginState getPluginState() {
    synchronized (mAwSettingsLock) {
        return mPluginState;
    }
}
 
Example #15
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * See {@link android.webkit.WebSettings#setPluginsEnabled}.
 */
public void setPluginsEnabled(boolean flag) {
    setPluginState(flag ? PluginState.ON : PluginState.OFF);
}
 
Example #16
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * See {@link android.webkit.WebSettings#getPluginsEnabled}.
 */
public boolean getPluginsEnabled() {
    synchronized (mAwSettingsLock) {
        return mPluginState == PluginState.ON;
    }
}
 
Example #17
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * See {@link android.webkit.WebSettings#getPluginState}.
 */
public PluginState getPluginState() {
    synchronized (mAwSettingsLock) {
        return mPluginState;
    }
}
 
Example #18
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Return true if plugins are disabled.
 * @return True if plugins are disabled.
 * @hide
 */
@CalledByNative
private boolean getPluginsDisabledLocked() {
    return mPluginState == PluginState.OFF;
}
 
Example #19
Source File: AwSettings.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Return true if plugins are disabled.
 * @return True if plugins are disabled.
 * @hide
 */
@CalledByNative
private boolean getPluginsDisabledLocked() {
    return mPluginState == PluginState.OFF;
}