mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
#2303 Impossible to surf on 3D printing SE ZIM file - push example branch
This commit is contained in:
parent
222c0627a1
commit
3f8fc9e52b
@ -26,6 +26,29 @@ import androidx.webkit.WebViewFeature
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
|
||||
import javax.inject.Inject
|
||||
|
||||
const val UNREGISTER_SERVICE_WORKER_JS =
|
||||
"""
|
||||
console.log('Commencing deregistration');
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
if (!registrations.length) {
|
||||
console.log('No serviceWorker registrations found.')
|
||||
return
|
||||
}
|
||||
for(let registration of registrations) {
|
||||
alert('Attempting to unregister Service Worker' + registration.index);
|
||||
registration.unregister().then(function (boolean) {
|
||||
console.log(
|
||||
(boolean ? 'Successfully unregistered' : 'Failed to unregister'), 'ServiceWorkerRegistration\n' +
|
||||
(registration.installing ? ' .installing.scriptURL = ' + registration.installing.scriptURL + '\n' : '') +
|
||||
(registration.waiting ? ' .waiting.scriptURL = ' + registration.waiting.scriptURL + '\n' : '') +
|
||||
(registration.active ? ' .active.scriptURL = ' + registration.active.scriptURL + '\n' : '') +
|
||||
' .scope: ' + registration.scope + '\n'
|
||||
)
|
||||
})
|
||||
}
|
||||
}).catch(function(err) { console.error(err); });
|
||||
"""
|
||||
|
||||
class ServiceWorkerInitialiser @Inject constructor(zimReaderContainer: ZimReaderContainer) {
|
||||
init {
|
||||
if (WebViewFeature.isFeatureSupported(WebViewFeature.SERVICE_WORKER_BASIC_USAGE)) {
|
||||
|
@ -124,6 +124,7 @@ import org.kiwix.kiwixmobile.core.utils.files.FileUtils;
|
||||
import static android.app.Activity.RESULT_CANCELED;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static org.kiwix.kiwixmobile.core.ServiceWorkerInitialiserKt.UNREGISTER_SERVICE_WORKER_JS;
|
||||
import static org.kiwix.kiwixmobile.core.downloader.fetch.FetchDownloadNotificationManagerKt.DOWNLOAD_NOTIFICATION_TITLE;
|
||||
import static org.kiwix.kiwixmobile.core.page.history.HistoryFragmentKt.USER_CLEARED_HISTORY;
|
||||
import static org.kiwix.kiwixmobile.core.page.history.adapter.HistoryListItem.HistoryItem;
|
||||
@ -729,6 +730,11 @@ public abstract class CoreReaderFragment extends BaseFragment
|
||||
tabCallback = null;
|
||||
hideBackToTopTimer.cancel();
|
||||
hideBackToTopTimer = null;
|
||||
for (KiwixWebView kiwixWebView : webViewList) {
|
||||
kiwixWebView.evaluateJavascript(UNREGISTER_SERVICE_WORKER_JS,
|
||||
value -> Log.e("SERVICE_WORKER_UNREGISTER", value));
|
||||
kiwixWebView.loadUrl("javascript:"+UNREGISTER_SERVICE_WORKER_JS);
|
||||
}
|
||||
webViewList.clear();
|
||||
actionBar = null;
|
||||
mainMenu = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user