Skip to content

Commit

Permalink
Save book inside the library if we have are opening via it fileDescri…
Browse files Browse the repository at this point in the history
…ptor.
  • Loading branch information
MohitMaliDeveloper committed Feb 8, 2024
1 parent 0373ac6 commit f982f53
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.core.utils.TAG_CURRENT_FILE
import org.kiwix.kiwixmobile.core.utils.TAG_KIWIX
import org.kiwix.kiwixmobile.core.utils.files.FileUtils
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
import java.io.File

private const val HIDE_TAB_SWITCHER_DELAY: Long = 300
Expand Down Expand Up @@ -287,6 +288,7 @@ class KiwixReaderFragment : CoreReaderFragment() {
newMainPageTab()
}

@SuppressWarnings("NestedBlockDepth")
override fun onNewIntent(
intent: Intent,
activity: AppCompatActivity
Expand All @@ -298,6 +300,17 @@ class KiwixReaderFragment : CoreReaderFragment() {
"content" -> {
val zimReaderSource = ZimFileDescriptor(it)
if (zimReaderSource.canOpenInLibkiwix()) {
zimReaderContainer?.let { zimReaderContainer ->
zimReaderContainer.setZimReaderSource(zimReaderSource)

zimReaderContainer.zimFileReader?.let { zimFileReader ->
BooksOnDiskListItem.BookOnDisk(zimFileReader).also { bookOnDisk ->
// save the book in the library
repositoryActions?.saveBook(bookOnDisk)
zimFileReader.dispose()
}
}
}
openZimFile(ZimFileDescriptor(it))
} else {
activity.toast(R.string.cannot_open_file)
Expand Down

0 comments on commit f982f53

Please sign in to comment.