#33 Disabled automatic cordova webview cache clear.

Added 'Clear Cache' button in settings.
This commit is contained in:
Adrian Tiberius 2015-08-28 17:08:21 +02:00
parent 85a0ab95a9
commit ec23d1649d
3 changed files with 25 additions and 1 deletions

View File

@ -11,6 +11,11 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import org.apache.cordova.ConfigXmlParser;
import org.apache.cordova.CordovaPreferences;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CordovaWebViewImpl;
import java.util.List;
import io.syng.R;
@ -41,6 +46,21 @@ public class SettingsActivity extends PreferenceActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupSimplePreferencesScreen();
Preference button = (Preference)findPreference("clearCache");
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
ConfigXmlParser parser = new ConfigXmlParser();
parser.parse(SettingsActivity.this);
CordovaPreferences preferences = parser.getPreferences();
preferences.setPreferencesBundle(SettingsActivity.this.getIntent().getExtras());
CordovaWebView webView = new CordovaWebViewImpl(CordovaWebViewImpl.createEngine(SettingsActivity.this, preferences));
webView.clearCache();
return true;
}
});
}
/**

View File

@ -143,7 +143,7 @@ public class WebViewFragment extends Fragment {
}
webView.getView().requestFocusFromTouch();
cordovaInterface.onCordovaInit(webView.getPluginManager());
webView.clearCache();
//webView.clearCache();
android.webkit.CookieManager.getInstance().removeAllCookie();
// Wire the hardware volume controls to control media if desired.

View File

@ -29,4 +29,8 @@
android:summary="@string/pref_description_sync_only_on_wifi"
android:title="@string/pref_title_sync_only_on_wifi"/>
<Preference android:title="Clear Cache"
android:key="clearCache"
android:summary="Clears cordova webview cache"/>
</PreferenceScreen>