Fix page image saving
This commit is contained in:
@@ -44,7 +44,8 @@ enum class MangaSource(
|
||||
;
|
||||
|
||||
@get:Throws(NoBeanDefFoundException::class)
|
||||
@Deprecated("")
|
||||
@Deprecated("", ReplaceWith("MangaRepository(this)",
|
||||
"org.koitharu.kotatsu.core.parser.MangaRepository"))
|
||||
val repository: MangaRepository
|
||||
get() = GlobalContext.get().get(named(this))
|
||||
}
|
||||
@@ -13,7 +13,10 @@ import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.Insets
|
||||
import androidx.core.view.*
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.postDelayed
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.fragment.app.commit
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
@@ -192,6 +195,7 @@ class ReaderActivity : BaseFullscreenActivity<ActivityReaderBinding>(),
|
||||
|
||||
override fun onActivityResult(result: Boolean) {
|
||||
if (result) {
|
||||
viewModel.saveCurrentState(reader?.getCurrentState())
|
||||
viewModel.saveCurrentPage(contentResolver)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.koitharu.kotatsu.core.model.Manga
|
||||
import org.koitharu.kotatsu.core.model.MangaChapter
|
||||
import org.koitharu.kotatsu.core.model.MangaPage
|
||||
import org.koitharu.kotatsu.core.os.ShortcutsRepository
|
||||
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.core.prefs.ReaderMode
|
||||
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||
@@ -27,7 +28,9 @@ import org.koitharu.kotatsu.reader.ui.pager.ReaderPage
|
||||
import org.koitharu.kotatsu.reader.ui.pager.ReaderUiState
|
||||
import org.koitharu.kotatsu.utils.MediaStoreCompat
|
||||
import org.koitharu.kotatsu.utils.SingleLiveEvent
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
import org.koitharu.kotatsu.utils.ext.IgnoreErrors
|
||||
import org.koitharu.kotatsu.utils.ext.asLiveDataDistinct
|
||||
import org.koitharu.kotatsu.utils.ext.processLifecycleScope
|
||||
|
||||
class ReaderViewModel(
|
||||
intent: MangaIntent,
|
||||
@@ -154,7 +157,7 @@ class ReaderViewModel(
|
||||
val page = content.value?.pages?.find {
|
||||
it.chapterId == state.chapterId && it.index == state.page
|
||||
}?.toMangaPage() ?: error("Page not found")
|
||||
val repo = page.source.repository
|
||||
val repo = MangaRepository(page.source)
|
||||
val pageUrl = repo.getPageUrl(page)
|
||||
val file = get<PagesCache>()[pageUrl] ?: error("Page not found in cache")
|
||||
val uri = file.inputStream().use { input ->
|
||||
|
||||
@@ -12,7 +12,10 @@ import org.koitharu.kotatsu.reader.ui.ReaderState
|
||||
import org.koitharu.kotatsu.reader.ui.pager.BaseReader
|
||||
import org.koitharu.kotatsu.reader.ui.pager.BaseReaderAdapter
|
||||
import org.koitharu.kotatsu.reader.ui.pager.ReaderPage
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
import org.koitharu.kotatsu.utils.ext.doOnPageChanged
|
||||
import org.koitharu.kotatsu.utils.ext.recyclerView
|
||||
import org.koitharu.kotatsu.utils.ext.resetTransformations
|
||||
import org.koitharu.kotatsu.utils.ext.viewLifecycleScope
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
class PagerReaderFragment : BaseReader<FragmentReaderStandardBinding>() {
|
||||
@@ -37,8 +40,8 @@ class PagerReaderFragment : BaseReader<FragmentReaderStandardBinding>() {
|
||||
val transformer = if (it) PageAnimTransformer() else null
|
||||
binding.pager.setPageTransformer(transformer)
|
||||
if (transformer == null) {
|
||||
binding.pager.recyclerView?.children?.forEach {
|
||||
it.resetTransformations()
|
||||
binding.pager.recyclerView?.children?.forEach { view ->
|
||||
view.resetTransformations()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,9 @@ class MediaStoreCompat(private val contentResolver: ContentResolver) {
|
||||
MediaStore.Images.Media.MIME_TYPE,
|
||||
MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileName.substringAfterLast('.'))
|
||||
)
|
||||
cv.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis())
|
||||
cv.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis() / 1_000)
|
||||
cv.put(MediaStore.Images.Media.DATE_MODIFIED, System.currentTimeMillis())
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
cv.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis())
|
||||
cv.put(MediaStore.Images.Media.IS_PENDING, 1)
|
||||
}
|
||||
var uri: Uri? = null
|
||||
|
||||
Reference in New Issue
Block a user