package com.rhomobile.rhodes.webview;

import android.annotation.SuppressLint;
import android.webkit.WebSettings;

import com.rhomobile.rhodes.Logger;
import com.rhomobile.rhodes.extmanager.IRhoWebViewConfig;

public class WebSettingsProviderBase implements IWebSettingsProvider {
    protected static final String TAG = "WebSettingsProvider";
    
    @SuppressLint("SetJavaScriptEnabled")
    public void fillSettings(WebSettings settings, IRhoWebViewConfig config) {
        settings.setSavePassword(false);
        settings.setSaveFormData(false);
        settings.setJavaScriptEnabled(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(false);
        settings.setSupportZoom(config != null && config.getBool("enableZoom"));
        settings.setBuiltInZoomControls(config != null && config.getBool("enableZoom"));
        
        Logger.T(TAG, "Enable Zoom: " + (config != null && config.getBool("enableZoom")));
        
        if (config != null && config.getBool("enableCache")) {
            settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        } else {
            settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        }
        settings.setSupportMultipleWindows(false);

        setWebPlugins(settings, config);
    }
    
    @SuppressWarnings("deprecation")
    protected void setWebPlugins(WebSettings settings, IRhoWebViewConfig config) {
        settings.setPluginsEnabled(config != null && config.getBool("enableWebPlugins"));
        
        Logger.T(TAG, "Enable Web Plugins: " + settings.getPluginsEnabled());
    }
}
@@ -32,16 +32,50 @@
 bview;%0A%0A
+import java.lang.reflect.Method;%0A%0A
 import a
@@ -1301,45 +1301,8 @@
    %0A
-    @SuppressWarnings(%22deprecation%22)%0A
     
@@ -1392,35 +1392,218 @@
     
-settings.setPluginsEnabled(
+%0A        try %7B%0A            Class%3CWebSettings%3E clazz = WebSettings.class;%0A            Method methodSetPlugins = clazz.getMethod(%22setPluginsEnabled%22, boolean.class);%0A            methodSetPlugins.invoke(settings, 
 conf
@@ -1657,33 +1657,58 @@
 ));%0A        
-%0A
+%7D catch (Throwable e) %7B%0A  
         
 Logger.T(TAG
@@ -1699,56 +1699,37 @@
     
+  
 Logger.
-T
+W
 (TAG, %22
-Enable Web Plugins: %22 + s
+WebS
 ettings.
 getP
@@ -1724,17 +1724,17 @@
 ettings.
-g
+s
 etPlugin
@@ -1742,19 +1742,65 @@
 Enabled(
-));
+bool) is removed from API by Google.%22);%0A        %7D
 %0A    %7D%0A%7D

Fix build with Android 4.3 API