mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 03:54:18 -04:00
Improved the exporting of bookmarks.
* Improved the location of exporting the bookmarks. * Improved the messages that will clearly shows where and in which file bookmarks are exported.
This commit is contained in:
parent
be1369f805
commit
20925efb60
@ -19,6 +19,7 @@
|
||||
package org.kiwix.kiwixmobile.core.dao
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.util.Base64
|
||||
import io.reactivex.BackpressureStrategy
|
||||
import io.reactivex.BackpressureStrategy.LATEST
|
||||
@ -28,9 +29,7 @@ import io.reactivex.subjects.BehaviorSubject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.kiwix.kiwixmobile.core.CoreApp
|
||||
import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.core.extensions.deleteFile
|
||||
import org.kiwix.kiwixmobile.core.extensions.isFileExist
|
||||
import org.kiwix.kiwixmobile.core.extensions.toast
|
||||
import org.kiwix.kiwixmobile.core.page.adapter.Page
|
||||
@ -287,7 +286,7 @@ class LibkiwixBookmarks @Inject constructor(
|
||||
sharedPreferenceUtil.context.toast(
|
||||
sharedPreferenceUtil.context.getString(
|
||||
R.string.export_bookmark_saved,
|
||||
"${bookmarkDestinationFile.parent}/"
|
||||
bookmarkDestinationFile.name
|
||||
)
|
||||
)
|
||||
} catch (ignore: Exception) {
|
||||
@ -297,12 +296,21 @@ class LibkiwixBookmarks @Inject constructor(
|
||||
}
|
||||
|
||||
private fun exportedFile(fileName: String): File {
|
||||
val rootFolder = CoreApp.instance.externalMediaDirs[0]
|
||||
val rootFolder = File(
|
||||
"${Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)}" +
|
||||
"/org.kiwix"
|
||||
)
|
||||
if (!rootFolder.isFileExist()) rootFolder.mkdir()
|
||||
val file = File(rootFolder, fileName)
|
||||
if (file.isFileExist()) file.deleteFile()
|
||||
file.createNewFile()
|
||||
return file
|
||||
return sequence {
|
||||
yield(File(rootFolder, fileName))
|
||||
yieldAll(
|
||||
generateSequence(1) { it + 1 }.map {
|
||||
File(
|
||||
rootFolder, fileName.replace(".", "_$it.")
|
||||
)
|
||||
}
|
||||
)
|
||||
}.first { !it.isFileExist() }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -79,7 +79,7 @@
|
||||
<string name="pref_permission">Permissions</string>
|
||||
<string name="pref_export_bookmark_title">Export Bookmarks</string>
|
||||
<string name="pref_export_bookmark_summary">Export all saved bookmarks</string>
|
||||
<string name="export_bookmark_saved">Bookmarks are exported in %s folder</string>
|
||||
<string name="export_bookmark_saved">Bookmarks are exported in %s file</string>
|
||||
<string name="all_history_cleared">All History Cleared</string>
|
||||
<string name="pref_clear_all_bookmarks_title">Clear bookmarks</string>
|
||||
<string name="clear_all_history_dialog_title">Clear All History?</string>
|
||||
@ -295,7 +295,7 @@
|
||||
<string name="delete_bookmarks">Delete All Bookmarks?</string>
|
||||
<string name="delete_selected_bookmarks">Delete Selected Bookmarks?</string>
|
||||
<string name="export_all_bookmarks_dialog_title">Export All Bookmarks?</string>
|
||||
<string name="export_all_bookmarks_dialog_message">Exporting will generate bookmark.xml file in the Android/media/org.kiwix…/ folder. To import bookmarks, simply copy this file into the Android/data/org.kiwix…/files/Bookmarks/ folder.</string>
|
||||
<string name="export_all_bookmarks_dialog_message">Exporting will generate bookmark.xml file in the Download/org.kiwix…/ folder.</string>
|
||||
<string name="on">On</string>
|
||||
<string name="off">Off</string>
|
||||
<string name="auto">Auto</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user