This commit is contained in:
Yaroslav Berezanskyi 2015-08-28 20:42:56 +03:00
commit 4b50c62858
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.PreferenceFragment;
import android.preference.PreferenceManager; 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 java.util.List;
import io.syng.R; import io.syng.R;
@ -41,6 +46,21 @@ public class SettingsActivity extends PreferenceActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setupSimplePreferencesScreen(); 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(); webView.getView().requestFocusFromTouch();
cordovaInterface.onCordovaInit(webView.getPluginManager()); cordovaInterface.onCordovaInit(webView.getPluginManager());
webView.clearCache(); //webView.clearCache();
android.webkit.CookieManager.getInstance().removeAllCookie(); android.webkit.CookieManager.getInstance().removeAllCookie();
// Wire the hardware volume controls to control media if desired. // 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:summary="@string/pref_description_sync_only_on_wifi"
android:title="@string/pref_title_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> </PreferenceScreen>