mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 04:33:54 -04:00
Merge pull request #1462 from kiwix/feature/macgills/#1126-remove-deleted-file-from-webview
Feature/macgills/#1126 remove deleted file from webview
This commit is contained in:
commit
5ec0135531
@ -28,6 +28,7 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.os.ParcelFileDescriptor.AutoCloseOutputStream;
|
||||
import android.util.Log;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import androidx.annotation.NonNull;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@ -94,7 +95,7 @@ public class ZimContentProvider extends ContentProvider {
|
||||
return file;
|
||||
}
|
||||
|
||||
public synchronized static String setZimFile(String fileName) {
|
||||
public synchronized static String setZimFile(@NonNull String fileName) {
|
||||
if (!new File(fileName).exists()) {
|
||||
Log.e(TAG_KIWIX, "Unable to find the ZIM file " + fileName);
|
||||
zimFileName = null;
|
||||
|
@ -1307,6 +1307,10 @@ public class MainActivity extends BaseActivity implements WebViewCallback,
|
||||
recreate();
|
||||
}
|
||||
presenter.loadCurrentZimBookmarksUrl();
|
||||
if (ZimContentProvider.zimFileName == null &&
|
||||
!HOME_URL.equals(getCurrentWebView().getUrl())) {
|
||||
showHomePage();
|
||||
}
|
||||
if (getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE) {
|
||||
if (menu != null) {
|
||||
menu.getItem(4).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
|
@ -2,6 +2,7 @@ package org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects
|
||||
|
||||
import android.app.Activity
|
||||
import org.kiwix.kiwixmobile.R.string
|
||||
import org.kiwix.kiwixmobile.data.ZimContentProvider
|
||||
import org.kiwix.kiwixmobile.database.newdb.dao.NewBookDao
|
||||
import org.kiwix.kiwixmobile.extensions.toast
|
||||
import org.kiwix.kiwixmobile.utils.DialogShower
|
||||
@ -21,6 +22,9 @@ class DeleteFiles(private val booksOnDiskListItem: List<BookOnDisk>) :
|
||||
booksOnDiskListItem.forEach {
|
||||
dialogShower.show(DeleteZim(it), {
|
||||
if (deleteSpecificZimFile(it)) {
|
||||
if (it.file.absolutePath.equals(ZimContentProvider.zimFileName)) {
|
||||
ZimContentProvider.setZimFile("")
|
||||
}
|
||||
activity.toast(string.delete_specific_zim_toast)
|
||||
} else {
|
||||
activity.toast(string.delete_zim_failed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user