From 19b4c2d09df6269c95d918f66c6d2ddd2ea34a0f Mon Sep 17 00:00:00 2001 From: "Silas S. Brown" <ssb22@cam.ac.uk> Date: Thu, 21 Jun 2018 07:24:19 +0100 Subject: [PATCH] Update Web Adjuster, Annotator Generator --- adjuster.py | 2 +- annogen.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/adjuster.py b/adjuster.py index 44c2062..9c27aca 100755 --- a/adjuster.py +++ b/adjuster.py @@ -584,7 +584,7 @@ def preprocessOptions(): try: import multiprocessing # Python 2.6 except ImportError: # can't do it then options.js_multiprocess = False - if int(tornado.version.split('.')[0]) > 4: errExit("js_interpreter not yet working on Tornado versions above 4.\nTornado "+tornado.version+" detected.\nPlease downgrade to 4.x, e.g.: pip install tornado==4.5.3 --upgrade") + if int(tornado.version.split('.')[0]) > 4 and options.js_429 and options.multicore: errExit("js_429 with multicore not yet working on Tornado versions above 4.\nTornado "+tornado.version+" detected.\nPlease downgrade to 4.x, e.g.: pip install tornado==4.5.3 --upgrade") elif options.js_upstream: errExit("js_upstream requires a js_interpreter to be set") if options.js_timeout2 <= options.js_timeout1: errExit("js_timeout2 must be greater than js_timeout1") assert not (options.js_upstream and set_window_onerror), "Must have set_window_onerror==False when using options.js_upstream" diff --git a/annogen.py b/annogen.py index e51c537..78bafe2 100755 --- a/annogen.py +++ b/annogen.py @@ -1297,9 +1297,6 @@ android_src += r""" setContentView(R.layout.activity_main); browser = (WebView)findViewById(R.id.browser); // --------------------------------------------- - // Delete the following long line if you DON'T want caching on Android 2.1+ (caching is useful for persistence if app is removed from memory and then switched back to while user is offline) - if(Integer.valueOf(Build.VERSION.SDK) >= 7) { browser.getSettings().setAppCachePath(getApplicationContext().getCacheDir().getAbsolutePath()); browser.getSettings().setAppCacheMaxSize(10*1048576) /* if API==7 i.e. exactly Android 2.1 (deprecated in API 8) */ ; browser.getSettings().setAppCacheEnabled(true); if(Integer.valueOf(Build.VERSION.SDK)<=19 && savedInstanceState==null) browser.clearCache(true); } // (Android 4.4 has Chrome 33 which has Issue 333804 XMLHttpRequest not revalidating, which breaks some sites, so clear cache when we 'cold start' on 4.4 or below) - // --------------------------------------------- // Delete the following line if you DON'T want to be able to use chrome://inspect in desktop Chromium when connected via USB to Android 4.4+ if(Integer.valueOf(Build.VERSION.SDK) >= 19) WebView.setWebContentsDebuggingEnabled(true); // --------------------------------------------- @@ -1308,6 +1305,8 @@ android_src += r""" // Delete the following long line if you DON'T want to link pop-ups to Hanping (when installed) if not linking to Pleco (there's room for only one of the two in the AlertDialog) if(!gotPleco && Integer.valueOf(Build.VERSION.SDK) >= 11) for(int i=0; i<3; i++) try { hanpingPackage="com.embermitre.hanping.cantodict.app.pro com.embermitre.hanping.app.pro com.embermitre.hanping.app.lite".split(" ")[i]; hanpingVersion=getApplicationContext().getPackageManager().getPackageInfo(hanpingPackage, 0).versionCode; break; } catch (android.content.pm.PackageManager.NameNotFoundException e) {} // --------------------------------------------- + if(Integer.valueOf(Build.VERSION.SDK) >= 7) { browser.getSettings().setAppCachePath(getApplicationContext().getCacheDir().getAbsolutePath()); browser.getSettings().setAppCacheMaxSize(10*1048576) /* if API==7 i.e. exactly Android 2.1 (deprecated in API 8) */ ; browser.getSettings().setAppCacheEnabled(true); } // not to be confused with the normal browser cache + if(Integer.valueOf(Build.VERSION.SDK)<=19 && savedInstanceState==null) browser.clearCache(true); // (Android 4.4 has Chrome 33 which has Issue 333804 XMLHttpRequest not revalidating, which breaks some sites, so clear cache when we 'cold start' on 4.4 or below. We're now clearing cache anyway in onDestroy on Android 5 or below due to Chromium bug 245549, but do it here as well in case onDestroy wasn't called last time e.g. reboot) browser.getSettings().setJavaScriptEnabled(true); browser.setWebChromeClient(new WebChromeClient()); @TargetApi(1) @@ -1546,6 +1545,7 @@ android_src += r""" return ""; } @Override protected void onSaveInstanceState(Bundle outState) { browser.saveState(outState); } + @Override protected void onDestroy() { if(isFinishing() && Integer.valueOf(Build.VERSION.SDK)<23 && browser!=null) browser.clearCache(true); } // (Chromium bug 245549 needed this workaround to stop taking up too much 'data' (not counted as cache) on old phones; it MIGHT be OK in API 22, or even API 20 with updates, but let's set the threshold at 23 just to be sure) WebView browser; } """ -- GitLab