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

The following examples show how to use android.webkit.WebSettings#setAppCacheMaxSize() . 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: BaseWebView.java    From RichWebList with Apache License 2.0 6 votes vote down vote up
private void initWebViewSettings() {
	WebSettings webSetting = this.getSettings();
	webSetting.setJavaScriptEnabled(true);
	webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
	webSetting.setAllowFileAccess(true);
	webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
	webSetting.setSupportZoom(true);
	webSetting.setBuiltInZoomControls(true);
	webSetting.setUseWideViewPort(true);
	webSetting.setSupportMultipleWindows(true);
	// webSetting.setLoadWithOverviewMode(true);
	webSetting.setAppCacheEnabled(true);
	// webSetting.setDatabaseEnabled(true);
	webSetting.setDomStorageEnabled(true);
	webSetting.setGeolocationEnabled(true);
	webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
	// webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
	webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
	// webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
	webSetting.setCacheMode(WebSettings.LOAD_NO_CACHE);

	// this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension
	// settings 的设计
}
 
Example 2
Source File: WebConfigImpl.java    From PoupoLayer with MIT License 5 votes vote down vote up
/**
 * 默认webview设置
 * @param settings
 */
private void initSetting(WebSettings settings, Context context){
    //5.0以上开启混合模式加载
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    //允许js代码 在Android 4.3版本调用WebSettings.setJavaScriptEnabled()方法时会调用一下reload方法,同时会回调多次WebChromeClient.onJsPrompt()
    settings.setJavaScriptEnabled(true);
    //允许SessionStorage/LocalStorage存储
    settings.setDomStorageEnabled(true);
    //禁用放缩
    settings.setDisplayZoomControls(false);
    settings.setBuiltInZoomControls(false);
    //禁用文字缩放
    settings.setTextZoom(100);
    //10M缓存,api 18后,系统自动管理。
    settings.setAppCacheMaxSize(10 * 1024 * 1024);
    //允许缓存,设置缓存位置 缓存位置由用户指定
    settings.setAppCacheEnabled(true);
    settings.setAppCachePath(context.getDir("appcache", 0).getPath());
    //允许WebView使用File协议
    settings.setAllowFileAccess(true);
    //不保存密码
    settings.setSavePassword(false);
    //自动加载图片
    settings.setLoadsImagesAutomatically(true);
}
 
Example 3
Source File: WebViewActivity.java    From movienow with GNU General Public License v3.0 5 votes vote down vote up
private void initWebSettings() {
    WebSettings webSettings = webViewT.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setSupportZoom(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setDefaultTextEncodingName("UTF-8");
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setAppCacheMaxSize(1024 * 1024 * 8);
    String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
    webSettings.setAppCachePath(appCachePath);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCacheEnabled(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int mDensity = metrics.densityDpi;
    if (mDensity == 240) {
        webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
    } else if (mDensity == 160) {
        webSettings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
    } else if (mDensity == 120) {
        webSettings.setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
    } else if (mDensity == DisplayMetrics.DENSITY_XHIGH) {
        webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
    } else if (mDensity == DisplayMetrics.DENSITY_TV) {
        webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
    } else {
        webSettings.setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
    }
}
 
Example 4
Source File: JSWebView.java    From AndroidWallet with GNU General Public License v3.0 5 votes vote down vote up
@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 5
Source File: WebFragment.java    From MangoBloggerAndroidApp with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Function to enable caching
 */
private void enableCache() {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setAppCacheMaxSize(5 * 1024 * 1024); // 5MB
    webSettings.setAppCachePath(getContext().getCacheDir().getAbsolutePath());
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); // load online by default

    if (!AppUtils.isNetworkConnected(getContext())) { // loading offline
        webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    }
}
 
Example 6
Source File: WebViewActivity.java    From mattermost-android-classic with Apache License 2.0 5 votes vote down vote up
protected void initWebView(WebView view) {
    webView = view;
    setProgressBarVisibility(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    WebSettings settings = view.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setUserAgentString(settings.getUserAgentString() + " Web-Atoms-Mobile-WebView");
    settings.setDatabaseEnabled(true);
    settings.setMediaPlaybackRequiresUserGesture(false);

    final File dir = this.getExternalCacheDir();
    settings.setAppCacheMaxSize(1024*1024*20);
    settings.setAppCachePath(dir.getAbsolutePath());
    settings.setAllowFileAccess(true);
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    view.setDownloadListener(getDownloadListener());

    CookieManager cookies = CookieManager.getInstance();
    cookies.setAcceptCookie(true);

    setWebViewClient(view);
    setWebChromeClient(view);
}
 
Example 7
Source File: RexxarWebViewCore.java    From rexxar-android with MIT License 5 votes vote down vote up
@TargetApi(16)
@SuppressLint("SetJavaScriptEnabled")
protected void setupWebSettings(WebSettings ws) {
    ws.setAppCacheEnabled(true);
    WebViewCompatUtils.enableJavaScriptForWebView(getContext(), ws);
    ws.setJavaScriptEnabled(true);
    ws.setGeolocationEnabled(true);
    ws.setBuiltInZoomControls(true);
    ws.setDisplayZoomControls(false);

    ws.setAllowFileAccess(true);
    if (Utils.hasJellyBean()) {
        ws.setAllowFileAccessFromFileURLs(true);
        ws.setAllowUniversalAccessFromFileURLs(true);
    }

    // enable html cache
    ws.setDomStorageEnabled(true);
    ws.setAppCacheEnabled(true);
    // Set cache size to 8 mb by default. should be more than enough
    ws.setAppCacheMaxSize(1024 * 1024 * 8);
    // This next one is crazy. It's the DEFAULT location for your app's cache
    // But it didn't work for me without this line
    ws.setAppCachePath("/data/data/" + getContext().getPackageName() + "/cache");
    ws.setAllowFileAccess(true);
    ws.setCacheMode(WebSettings.LOAD_DEFAULT);

    String ua = ws.getUserAgentString() + " " + Rexxar.getUserAgent();
    ws.setUserAgentString(ua);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        ws.setUseWideViewPort(true);
    }

    if (Utils.hasLollipop()) {
        ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
}
 
Example 8
Source File: BaseWebSetting.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void initWebSettings() {
    WebSettings webSettings = mBaseWebView.getSettings();
    if (webSettings == null) return;
    //设置字体缩放倍数,默认100
    webSettings.setTextZoom(100);
    // 支持 Js 使用
    webSettings.setJavaScriptEnabled(true);
    // 开启DOM缓存
    webSettings.setDomStorageEnabled(true);
    // 开启数据库缓存
    webSettings.setDatabaseEnabled(true);
    // 支持自动加载图片
    webSettings.setLoadsImagesAutomatically(hasKitkat());
    if (isCache) {
        // 设置 WebView 的缓存模式
        webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
        // 支持启用缓存模式
        webSettings.setAppCacheEnabled(true);
        // 设置 AppCache 最大缓存值(现在官方已经不提倡使用,已废弃)
        webSettings.setAppCacheMaxSize(8 * 1024 * 1024);
        // Android 私有缓存存储,如果你不调用setAppCachePath方法,WebView将不会产生这个目录
        webSettings.setAppCachePath(mContext.getCacheDir().getAbsolutePath());
    }
    // 数据库路径
    if (!hasKitkat()) {
        webSettings.setDatabasePath(mContext.getDatabasePath("html").getPath());
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    // 关闭密码保存提醒功能
    webSettings.setSavePassword(false);
    // 支持缩放
    webSettings.setSupportZoom(true);
    // 设置 UserAgent 属性
    webSettings.setUserAgentString("");
    // 允许加载本地 html 文件/false
    webSettings.setAllowFileAccess(true);
    // 允许通过 file url 加载的 Javascript 读取其他的本地文件,Android 4.1 之前默认是true,在 Android 4.1 及以后默认是false,也就是禁止
    webSettings.setAllowFileAccessFromFileURLs(false);
    // 允许通过 file url 加载的 Javascript 可以访问其他的源,包括其他的文件和 http,https 等其他的源,
    // Android 4.1 之前默认是true,在 Android 4.1 及以后默认是false,也就是禁止
    // 如果此设置是允许,则 setAllowFileAccessFromFileURLs 不起做用
    webSettings.setAllowUniversalAccessFromFileURLs(false);

}
 
Example 9
Source File: LightningView.java    From browser with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
public void initializeSettings(WebSettings settings, Context context) {
	//setPageCacheCapacity2(settings);
	if (API < 18) {
		settings.setAppCacheMaxSize(Long.MAX_VALUE);
	}
	if (API < 17) {
		settings.setEnableSmoothTransition(true);
	}
	if (API > 16) {
		settings.setMediaPlaybackRequiresUserGesture(true);
	}
	if (API >= Build.VERSION_CODES.LOLLIPOP && !mBrowserController.isIncognito()) {
		settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
	} else if (API >= Build.VERSION_CODES.LOLLIPOP) {
		// We're in Incognito mode, reject
		settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
	}
	settings.setDomStorageEnabled(true);
	settings.setAppCacheEnabled(true);
	settings.setCacheMode(WebSettings.LOAD_DEFAULT);
	settings.setDatabaseEnabled(true);
	settings.setSupportZoom(true);
	settings.setBuiltInZoomControls(true);
	settings.setDisplayZoomControls(false);
	settings.setAllowContentAccess(true);
	settings.setAllowFileAccess(true);
	settings.setDefaultTextEncodingName("utf-8");
	if (API > 16) {
		settings.setAllowFileAccessFromFileURLs(false);
		settings.setAllowUniversalAccessFromFileURLs(false);
	}

	settings.setAppCachePath(context.getDir("appcache", 0).getPath());
	settings.setGeolocationDatabasePath(context.getDir("geolocation", 0).getPath());
	if (API < Build.VERSION_CODES.KITKAT) {
		settings.setDatabasePath(context.getDir("databases", 0).getPath());
	}


}
 
Example 10
Source File: SystemWebViewEngine.java    From keemob with MIT License 4 votes vote down vote up
@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
@SuppressWarnings("deprecation")
private void initWebViewSettings() {
    webView.setInitialScale(0);
    webView.setVerticalScrollBarEnabled(false);
    // Enable JavaScript
    final WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

    String manufacturer = android.os.Build.MANUFACTURER;
    LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);

    //We don't save any form data in the application
    settings.setSaveFormData(false);
    settings.setSavePassword(false);

    // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
    // while we do this
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setMediaPlaybackRequiresUserGesture(false);

    // Enable database
    // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
    String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    settings.setDatabaseEnabled(true);
    settings.setDatabasePath(databasePath);


    //Determine whether we're in debug or release mode, and turn on Debugging!
    ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
    if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        enableRemoteDebugging();
    }

    settings.setGeolocationDatabasePath(databasePath);

    // Enable DOM storage
    settings.setDomStorageEnabled(true);

    // Enable built-in geolocation
    settings.setGeolocationEnabled(true);

    // Enable AppCache
    // Fix for CB-2282
    settings.setAppCacheMaxSize(5 * 1048576);
    settings.setAppCachePath(databasePath);
    settings.setAppCacheEnabled(true);

    // Fix for CB-1405
    // Google issue 4641
    String defaultUserAgent = settings.getUserAgentString();

    // Fix for CB-3360
    String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
    if (overrideUserAgent != null) {
        settings.setUserAgentString(overrideUserAgent);
    } else {
        String appendUserAgent = preferences.getString("AppendUserAgent", null);
        if (appendUserAgent != null) {
            settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent);
        }
    }
    // End CB-3360

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                settings.getUserAgentString();
            }
        };
        webView.getContext().registerReceiver(this.receiver, intentFilter);
    }
    // end CB-1405
}
 
Example 11
Source File: SystemWebViewEngine.java    From keemob with MIT License 4 votes vote down vote up
@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
@SuppressWarnings("deprecation")
private void initWebViewSettings() {
    webView.setInitialScale(0);
    webView.setVerticalScrollBarEnabled(false);
    // Enable JavaScript
    final WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

    String manufacturer = android.os.Build.MANUFACTURER;
    LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);

    //We don't save any form data in the application
    settings.setSaveFormData(false);
    settings.setSavePassword(false);

    // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
    // while we do this
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setMediaPlaybackRequiresUserGesture(false);

    // Enable database
    // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
    String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    settings.setDatabaseEnabled(true);
    settings.setDatabasePath(databasePath);


    //Determine whether we're in debug or release mode, and turn on Debugging!
    ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
    if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        enableRemoteDebugging();
    }

    settings.setGeolocationDatabasePath(databasePath);

    // Enable DOM storage
    settings.setDomStorageEnabled(true);

    // Enable built-in geolocation
    settings.setGeolocationEnabled(true);

    // Enable AppCache
    // Fix for CB-2282
    settings.setAppCacheMaxSize(5 * 1048576);
    settings.setAppCachePath(databasePath);
    settings.setAppCacheEnabled(true);

    // Fix for CB-1405
    // Google issue 4641
    String defaultUserAgent = settings.getUserAgentString();

    // Fix for CB-3360
    String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
    if (overrideUserAgent != null) {
        settings.setUserAgentString(overrideUserAgent);
    } else {
        String appendUserAgent = preferences.getString("AppendUserAgent", null);
        if (appendUserAgent != null) {
            settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent);
        }
    }
    // End CB-3360

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                settings.getUserAgentString();
            }
        };
        webView.getContext().registerReceiver(this.receiver, intentFilter);
    }
    // end CB-1405
}
 
Example 12
Source File: EditAreaView.java    From 920-text-editor-v2 with Apache License 2.0 4 votes vote down vote up
public EditAreaView(Context context, AttributeSet attrs) {
        super(context, attrs);

        if (L.debug) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                setWebContentsDebuggingEnabled(true);
            }
        }

        setLongClickable(false);
        setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                return true;
            }
        });

        WebSettings ws = getSettings();
        ws.setDefaultZoom(WebSettings.ZoomDensity.FAR);
        ws.setAllowContentAccess(true);
        ws.setAllowFileAccess(true);
        ws.setBuiltInZoomControls(false);
        ws.setDefaultTextEncodingName("utf-8");
        ws.setDisplayZoomControls(false);
        ws.setSupportZoom(false);
        ws.setLoadWithOverviewMode(false);

        ws.setJavaScriptEnabled(true);
        ws.setAppCacheEnabled(false);
        ws.setDomStorageEnabled(true);
        ws.setAppCacheMaxSize(1024*1024*80);
        ws.setAppCachePath(context.getCacheDir().getPath());
//        ws.setAllowFileAccess(true);
        ws.setCacheMode(WebSettings.LOAD_DEFAULT);

        addJavascriptInterface(new JavascriptApi(), "AndroidEditor");

        setWebViewClient(new EditorViewClient());
        setWebChromeClient(new EditorViewChromeClient());

        pref = Pref.getInstance(getContext());
        ThemeList.Theme theme = pref.getThemeInfo();
        boolean isDark = false;
        if (theme != null) {
            isDark = theme.isDark;
        }

        String html = null;

        try {
            InputStream is = getContext().getAssets().open("editor.html");
            html = IOUtils.readFile(is, "utf-8");
            is.close();
        } catch (Exception e) {
            L.e(e);
            UIUtils.toast(getContext(), R.string.editor_create_unknown_exception);
            return;
        }

        if (!isDark)
            html = html.replaceAll("<\\!\\-\\-\\{DARK\\-START\\}\\-\\->[\\w\\W]+?<\\!\\-\\-\\{DARK\\-END\\}\\-\\->", "");

        loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", "file:///android_asset/");
        //fix dark theme background spark
        setBackgroundColor(Color.TRANSPARENT);

        pref.registerOnSharedPreferenceChangeListener(this);
        onSharedPreferenceChanged(null, Pref.KEY_FONT_SIZE);
        onSharedPreferenceChanged(null, Pref.KEY_CURSOR_WIDTH);
        onSharedPreferenceChanged(null, Pref.KEY_SHOW_LINE_NUMBER);
        onSharedPreferenceChanged(null, Pref.KEY_WORD_WRAP);
        onSharedPreferenceChanged(null, Pref.KEY_SHOW_WHITESPACE);
        onSharedPreferenceChanged(null, Pref.KEY_TAB_SIZE);
        onSharedPreferenceChanged(null, Pref.KEY_AUTO_INDENT);
        onSharedPreferenceChanged(null, Pref.KEY_AUTO_CAPITALIZE);
        onSharedPreferenceChanged(null, Pref.KEY_INSERT_SPACE_FOR_TAB);
        onSharedPreferenceChanged(null, Pref.KEY_THEME);
        onSharedPreferenceChanged(null, Pref.KEY_TOUCH_TO_ADJUST_TEXT_SIZE);
        enableHighlight(pref.isHighlight());
        setReadOnly(pref.isReadOnly());
    }
 
Example 13
Source File: WebSettingsCompatEclairMr1.java    From Android_Skin_2.0 with Apache License 2.0 4 votes vote down vote up
public static void setAppCacheMaxSize(WebSettings settings, long appCacheMaxSize) {
	settings.setAppCacheMaxSize(appCacheMaxSize);
}
 
Example 14
Source File: SystemWebViewEngine.java    From pychat with MIT License 4 votes vote down vote up
@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
@SuppressWarnings("deprecation")
private void initWebViewSettings() {
    webView.setInitialScale(0);
    webView.setVerticalScrollBarEnabled(false);
    // Enable JavaScript
    final WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

    String manufacturer = android.os.Build.MANUFACTURER;
    LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);

    //We don't save any form data in the application
    settings.setSaveFormData(false);
    settings.setSavePassword(false);

    // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
    // while we do this
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setMediaPlaybackRequiresUserGesture(false);

    // Enable database
    // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
    String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    settings.setDatabaseEnabled(true);
    settings.setDatabasePath(databasePath);


    //Determine whether we're in debug or release mode, and turn on Debugging!
    ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
    if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        enableRemoteDebugging();
    }

    settings.setGeolocationDatabasePath(databasePath);

    // Enable DOM storage
    settings.setDomStorageEnabled(true);

    // Enable built-in geolocation
    settings.setGeolocationEnabled(true);

    // Enable AppCache
    // Fix for CB-2282
    settings.setAppCacheMaxSize(5 * 1048576);
    settings.setAppCachePath(databasePath);
    settings.setAppCacheEnabled(true);

    // Fix for CB-1405
    // Google issue 4641
    String defaultUserAgent = settings.getUserAgentString();

    // Fix for CB-3360
    String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
    if (overrideUserAgent != null) {
        settings.setUserAgentString(overrideUserAgent);
    } else {
        String appendUserAgent = preferences.getString("AppendUserAgent", null);
        if (appendUserAgent != null) {
            settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent);
        }
    }
    // End CB-3360

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                settings.getUserAgentString();
            }
        };
        webView.getContext().registerReceiver(this.receiver, intentFilter);
    }
    // end CB-1405
}
 
Example 15
Source File: SystemWebViewEngine.java    From lona with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
@SuppressWarnings("deprecation")
private void initWebViewSettings() {
    webView.setInitialScale(0);
    webView.setVerticalScrollBarEnabled(false);
    // Enable JavaScript
    final WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

    String manufacturer = android.os.Build.MANUFACTURER;
    LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);

    //We don't save any form data in the application
    settings.setSaveFormData(false);
    settings.setSavePassword(false);

    // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
    // while we do this
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setMediaPlaybackRequiresUserGesture(false);

    // Enable database
    // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
    String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    settings.setDatabaseEnabled(true);
    settings.setDatabasePath(databasePath);


    //Determine whether we're in debug or release mode, and turn on Debugging!
    ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
    if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        enableRemoteDebugging();
    }

    settings.setGeolocationDatabasePath(databasePath);

    // Enable DOM storage
    settings.setDomStorageEnabled(true);

    // Enable built-in geolocation
    settings.setGeolocationEnabled(true);

    // Enable AppCache
    // Fix for CB-2282
    settings.setAppCacheMaxSize(5 * 1048576);
    settings.setAppCachePath(databasePath);
    settings.setAppCacheEnabled(true);

    // Fix for CB-1405
    // Google issue 4641
    String defaultUserAgent = settings.getUserAgentString();

    // Fix for CB-3360
    String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
    if (overrideUserAgent != null) {
        settings.setUserAgentString(overrideUserAgent);
    } else {
        String appendUserAgent = preferences.getString("AppendUserAgent", null);
        if (appendUserAgent != null) {
            settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent);
        }
    }
    // End CB-3360

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                settings.getUserAgentString();
            }
        };
        webView.getContext().registerReceiver(this.receiver, intentFilter);
    }
    // end CB-1405
}
 
Example 16
Source File: SystemWebViewEngine.java    From countly-sdk-cordova with MIT License 4 votes vote down vote up
@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
@SuppressWarnings("deprecation")
private void initWebViewSettings() {
    webView.setInitialScale(0);
    webView.setVerticalScrollBarEnabled(false);
    // Enable JavaScript
    final WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

    String manufacturer = android.os.Build.MANUFACTURER;
    LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);

    //We don't save any form data in the application
    settings.setSaveFormData(false);
    settings.setSavePassword(false);

    // Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
    // while we do this
    settings.setAllowUniversalAccessFromFileURLs(true);
    settings.setMediaPlaybackRequiresUserGesture(false);

    // Enable database
    // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
    String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
    settings.setDatabaseEnabled(true);
    settings.setDatabasePath(databasePath);


    //Determine whether we're in debug or release mode, and turn on Debugging!
    ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
    if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        enableRemoteDebugging();
    }

    settings.setGeolocationDatabasePath(databasePath);

    // Enable DOM storage
    settings.setDomStorageEnabled(true);

    // Enable built-in geolocation
    settings.setGeolocationEnabled(true);

    // Enable AppCache
    // Fix for CB-2282
    settings.setAppCacheMaxSize(5 * 1048576);
    settings.setAppCachePath(databasePath);
    settings.setAppCacheEnabled(true);

    // Fix for CB-1405
    // Google issue 4641
    String defaultUserAgent = settings.getUserAgentString();

    // Fix for CB-3360
    String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
    if (overrideUserAgent != null) {
        settings.setUserAgentString(overrideUserAgent);
    } else {
        String appendUserAgent = preferences.getString("AppendUserAgent", null);
        if (appendUserAgent != null) {
            settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent);
        }
    }
    // End CB-3360

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                settings.getUserAgentString();
            }
        };
        webView.getContext().registerReceiver(this.receiver, intentFilter);
    }
    // end CB-1405
}