Java Code Examples for android.webkit.WebSettings#setNeedInitialFocus()

The following examples show how to use android.webkit.WebSettings#setNeedInitialFocus() . 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 vote down vote up
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 vote down vote up
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 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 4
Source File: AccountCreationWebview.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public AccountCreationWebview(BasePrefsWizard aParent, String url, OnAccountCreationDoneListener l){
    parent = aParent;
    creationListener = l;
    webCreationPage = url;
    
    settingsContainer = (ViewGroup) parent.findViewById(R.id.settings_container);
    validationBar = (ViewGroup) parent.findViewById(R.id.validation_bar);
    
    ViewGroup globalContainer = (ViewGroup) settingsContainer.getParent();
    
    parent.getLayoutInflater().inflate(R.layout.wizard_account_creation_webview, globalContainer);
    
    webView = (WebView) globalContainer.findViewById(R.id.webview);
    loadingProgressBar = (ProgressBar) globalContainer.findViewById(R.id.webview_progress);
    
    WebSettings webSettings = webView.getSettings();
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(false);
    webSettings.setCacheMode(WebSettings.LOAD_NORMAL);
    webSettings.setNeedInitialFocus(true);
    webView.addJavascriptInterface(new JSInterface(), "CSipSimpleWizard");
    
    // Adds Progress bar Support
    webView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            if(progress < 100) {
                loadingProgressBar.setVisibility(View.VISIBLE);
                loadingProgressBar.setProgress(progress); 
            }else {
                loadingProgressBar.setVisibility(View.GONE);
            }
        }
    });
}
 
Example 5
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 6
Source File: SubscriptionDetailsFragment.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
private void setupWebViewSettings() {
    final WebSettings webSettings = subredditDesc.getSettings();
    Resources res = getResources();
    float fontSize = res.getDimension(R.dimen.web_text);
    webSettings.setDefaultFontSize((int) fontSize);

    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setAppCacheEnabled(false);
    webSettings.setBlockNetworkImage(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setGeolocationEnabled(false);
    webSettings.setNeedInitialFocus(false);
    webSettings.setSaveFormData(false);
}
 
Example 7
Source File: PKDialog.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
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 8
Source File: TDialog.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
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 9
Source File: BrowserActivity.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSupportActionBar(R.id.browser_toolbar);
    final String url = getIntent().getStringExtra(EXTRA_URL);
    if (TextUtils.isEmpty(url)) {
        finish();
        return;
    }
    setTitle("");
    mVContent = findViewById(R.id.browser_wb_content);
    WebSettings webSettings = mVContent.getSettings();
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setSupportZoom(true);
    webSettings.setNeedInitialFocus(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setBlockNetworkImage(false);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setDomStorageEnabled(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    if (Build.VERSION.SDK_INT >= 21) {
        webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    webSettings.setDefaultTextEncodingName("utf-8");
    mVContent.setWebViewClient(new PowerfulWebView.StateWebViewClient());
    mVContent.setOnTitleListener(this);
    mVContent.loadUrl(url);
}
 
Example 10
Source File: LoginActivity.java    From android_packages_apps_GmsCore with Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private static void prepareWebViewSettings(WebSettings settings) {
    settings.setUserAgentString(settings.getUserAgentString() + MAGIC_USER_AGENT);
    settings.setJavaScriptEnabled(true);
    settings.setSupportMultipleWindows(false);
    settings.setSaveFormData(false);
    settings.setAllowFileAccess(false);
    settings.setDatabaseEnabled(false);
    settings.setNeedInitialFocus(false);
    settings.setUseWideViewPort(false);
    settings.setSupportZoom(false);
    settings.setJavaScriptCanOpenWindowsAutomatically(false);
}
 
Example 11
Source File: BitWebViewFragment.java    From tysq-android with GNU General Public License v3.0 4 votes vote down vote up
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();

    }
 
Example 12
Source File: MainActivity.java    From styT with Apache License 2.0 4 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void initWebSettings() {

    WebSettings settings = sMm.getSettings();
    settings.setUserAgentString("" + SPUtils.get(MainActivity.this, "if_7", ""));//UA
    //支持获取手势焦点
    sMm.requestFocusFromTouch();
    //支持JS
    settings.setJavaScriptEnabled((Boolean) SPUtils.get(MainActivity.this, "if_1", true));
    //支持插件

    // settings.setPluginState(WebSettings.PluginState.ON);
    //设置适应屏幕
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    //支持缩放
    settings.setSupportZoom((Boolean) SPUtils.get(MainActivity.this, "if_3", false)); // 支持缩放
    //隐藏原生的缩放控件
    settings.setDisplayZoomControls(false);
    //支持内容重新布局
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.supportMultipleWindows();
    settings.setSupportMultipleWindows(false);
    //设置缓存模式
    settings.setGeolocationEnabled((Boolean) SPUtils.get(MainActivity.this, "if_2", true));//允许地理位置可用
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled((Boolean) SPUtils.get(MainActivity.this, "if_4", true));
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    settings.setAppCacheEnabled(true);
    settings.setAppCachePath(sMm.getContext().getCacheDir().getAbsolutePath());
    //settings.setRenderPriority(WebSettings.RenderPriority.HIGH);  //提高渲染的优先级
    //设置可访问文件
    settings.setAllowFileAccess(true);
    //当webview调用requestFocus时为webview设置节点
    settings.setNeedInitialFocus(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }

    settings.setLoadsImagesAutomatically(false);

    // settings.setNeedInitialFocus(true);
    //设置编码格式
    //settings.setDefaultTextEncodingName("UTF-8");

}
 
Example 13
Source File: Main2Activity.java    From styT with Apache License 2.0 4 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void initWebSettings() {

    WebSettings settings = sMm.getSettings();
    settings.setUserAgentString("" + SPUtils.get(Main2Activity.this, "if_7", ""));//UA
    //支持获取手势焦点
    sMm.requestFocusFromTouch();
    //支持JS
    settings.setJavaScriptEnabled((Boolean) SPUtils.get(Main2Activity.this, "if_1", true));
    //支持插件

    // settings.setPluginState(WebSettings.PluginState.ON);
    //设置适应屏幕
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    //支持缩放
    settings.setSupportZoom((Boolean) SPUtils.get(Main2Activity.this, "if_3", false)); // 支持缩放
    //隐藏原生的缩放控件
    settings.setDisplayZoomControls(false);
    //支持内容重新布局
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.supportMultipleWindows();
    settings.setSupportMultipleWindows(false);
    //设置缓存模式
    settings.setGeolocationEnabled((Boolean) SPUtils.get(Main2Activity.this, "if_2", true));//允许地理位置可用
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled((Boolean) SPUtils.get(Main2Activity.this, "if_4", true));
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    settings.setAppCacheEnabled(true);
    settings.setAppCachePath(sMm.getContext().getCacheDir().getAbsolutePath());
    //settings.setRenderPriority(WebSettings.RenderPriority.HIGH);  //提高渲染的优先级
    //设置可访问文件
    settings.setAllowFileAccess(true);
    //当webview调用requestFocus时为webview设置节点
    settings.setNeedInitialFocus(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }

    //支持自动加载图片
    if (Build.VERSION.SDK_INT >= 19) {
        settings.setLoadsImagesAutomatically((Boolean) SPUtils.get(Main2Activity.this, "if_5", true));//图片
    } else {
        settings.setLoadsImagesAutomatically(false);
    }
    // settings.setNeedInitialFocus(true);
    //设置编码格式
    //settings.setDefaultTextEncodingName("UTF-8");

}
 
Example 14
Source File: WebView.java    From unity-ads-android with Apache License 2.0 4 votes vote down vote up
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 15
Source File: AuthDialog.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
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);
}