package com.marshalchen.common.commonUtils.moduleUtils;

import android.content.Context;
import android.webkit.*;
import com.marshalchen.common.commonUtils.logUtils.Logs;

/**
 * Some default value of webview
 * User: cym
 * Date: 13-10-31
 */
//WebViewUtils
public class WebViewUtils {
    private static WebView webView;

    public static WebView getCustomWebView(Context context, String appCacheDir) {
        webView = new WebView(context);

        WebSettings wSet = webView.getSettings();
        // wSet.setAppCacheMaxSize();
        wSet.setJavaScriptEnabled(true);
        wSet.setDomStorageEnabled(true);
        // String appCacheDir = this.getActivity().getApplicationContext().getDir("cache", Context.MODE_PRIVATE).getPath();
        wSet.setAppCachePath(appCacheDir);
        wSet.setAllowFileAccess(true);
        wSet.setAppCacheEnabled(true);
        return webView;
    }

    ;

    public static WebSettings getWebSettings(WebView webView, String appCacheDir) {
        WebSettings wSet = webView.getSettings();
        // wSet.setAppCacheMaxSize();
        wSet.setJavaScriptEnabled(true);
        wSet.setDomStorageEnabled(true);
        // String appCacheDir = this.getActivity().getApplicationContext().getDir("cache", Context.MODE_PRIVATE).getPath();
        wSet.setAppCachePath(appCacheDir);
        wSet.setAllowFileAccess(true);
        wSet.setAppCacheEnabled(true);
        wSet.setCacheMode(WebSettings.LOAD_DEFAULT);
        return wSet;

    }

    public static void syncCookie(Context context, String domainNameUrl, String... strings) {
        CookieSyncManager.createInstance(context);
        //CookieSyncManager.getInstance().startSync();
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        cookieManager.removeAllCookie();
        for (String s : strings) {
            cookieManager.setCookie(domainNameUrl, s);

        }
        Logs.d(cookieManager.getCookie(domainNameUrl));
        CookieSyncManager.getInstance().sync();
        //    CookieSyncManager.getInstance().stopSync();
    }

    public static WebBackForwardList getHistoricalList(WebView webView) {
        return webView.copyBackForwardList();
    }

    public static String getHistoricalUrl(WebView webView) {
        WebBackForwardList webBackForwardList = getHistoricalList(webView);
        return webBackForwardList.getItemAtIndex(webBackForwardList.getCurrentIndex() - 1).getUrl();

    }
}

@@ -181,723 +181,215 @@
 ome 
-default value
+utils
  of 
-webv
+WebV
 iew%0A *
- User: cym%0A * Date: 13-10-31%0A */%0A//WebViewUtils%0Apublic class WebViewUtils %7B%0A    private static WebView webView;%0A%0A    public static WebView getCustomWebView(Context context, String appCacheDir) %7B
+/%0A%0Apublic class WebViewUtils %7B%0A%0A    /**
 %0A     
-  
+* A
  web
-V
+v
 iew 
-= new WebView(context);%0A%0A        WebS
+s
 etting
-s
  w
-Set = webView.getSettings();%0A        // wSet.setAppCacheMaxSize();%0A        wSet.setJavaScriptEnabled(true);%0A        wSet.setDomStorageEnabled(true);%0A        // String appCacheDir = this.getActivity().getApplicationContext().getDir(%22cache%22, Context.MODE_PRIVATE).getPath();%0A        wSet.setAppCachePath(appCacheDir);%0A        wSet.setAllowFileAccess(true);%0A        wSet.setAppCacheEnabled(true);
+hich enable JavaScript ,DomStorage and file access.%0A     * @param webView%0A     * @param appCacheDir
 %0A     
-   
+* @
 return
- webView;%0A    %7D%0A%0A    ;%0A
+%0A     */
 %0A   
@@ -958,32 +958,178 @@
 n wSet;%0A%0A    %7D%0A%0A
+    /**%0A     * @deprecated%0A     * Forces sync manager to sync now%0A     * @param context%0A     * @param domainNameUrl%0A     * @param strings%0A     */%0A
     public stati
@@ -1678,68 +1678,103 @@
     
+%7D%0A%0A
     /
-/
+**%0A
     
-CookieSyncManager.getInstance().stopSync();
+ * Get a historical list of webview%0A     * @param webView%0A     * @return
 %0A    
-%7D%0A
+ */
 %0A   
@@ -1893,24 +1893,114 @@
 t();%0A    %7D%0A%0A
+    /**%0A     * Get the latest url of webview%0A     * @param webView%0A     * @return%0A     */%0A
     public s

Update WebviewUtils