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 Jan 31, 2024
1 parent 9cd103d commit 425880a
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)

Check warning on line 301 in app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt#L301

Added line #L301 was not covered by tests
if (zimReaderSource.canOpenInLibkiwix()) {
zimReaderContainer?.let { zimReaderContainer ->
zimReaderContainer.setZimReaderSource(zimReaderSource)

Check warning on line 304 in app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt#L304

Added line #L304 was not covered by tests

zimReaderContainer.zimFileReader?.let { zimFileReader ->
BooksOnDiskListItem.BookOnDisk(zimFileReader).also { bookOnDisk ->

Check warning on line 307 in app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt#L307

Added line #L307 was not covered by tests
// save the book in the library
repositoryActions?.saveBook(bookOnDisk)
zimFileReader.dispose()
}

Check warning on line 311 in app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt#L310-L311

Added lines #L310 - L311 were not covered by tests
}
}
openZimFile(ZimFileDescriptor(it))

Check warning on line 314 in app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt#L314

Added line #L314 was not covered by tests
} else {
activity.toast(R.string.cannot_open_file)
Expand Down

0 comments on commit 425880a

Please sign in to comment.