Update dependencies and fix some warnings

This commit is contained in:
Koitharu
2022-03-23 09:39:01 +02:00
parent d3e9dc2ea4
commit ae0aa370b2
23 changed files with 69 additions and 72 deletions

View File

@@ -8,11 +8,12 @@ indent_style = tab
insert_final_newline = false insert_final_newline = false
max_line_length = 120 max_line_length = 120
tab_width = 4 tab_width = 4
# noinspection EditorConfigKeyCorrectness
disabled_rules=no-wildcard-imports,no-unused-imports disabled_rules=no-wildcard-imports,no-unused-imports
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] [{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
ij_continuation_indent_size = 4 ij_continuation_indent_size = 4
[{*.gradle.kts,*.kt,*.kts,*.main.kts}] [{*.kt,*.kts}]
ij_kotlin_allow_trailing_comma = true ij_kotlin_allow_trailing_comma = true
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL

View File

@@ -28,12 +28,12 @@ Download APK from Github Releases:
### Screenshots ### Screenshots
| ![Screenshot_20200226-210337](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/1.png) | ![](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/2.png) | ![Screenshot_20200226-210232](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/3.png) | | ![Screenshot_20200226-210337](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/1.png) | ![](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/2.png) | ![Screenshot_20200226-210232](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/3.png) |
|---|---|---| |-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| ![Screenshot_20200226-210405](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/4.png) | ![Screenshot_20200226-210151](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/5.png) | ![Screenshot_20200226-210223](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/6.png) | | ![Screenshot_20200226-210405](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/4.png) | ![Screenshot_20200226-210151](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/5.png) | ![Screenshot_20200226-210223](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/phoneScreenshots/6.png) |
| ![](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/tenInchScreenshots/1.png) | ![](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/tenInchScreenshots/2.png) | | ![](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/tenInchScreenshots/1.png) | ![](https://github.com/nv95/Kotatsu/raw/devel/metadata/en-US/images/tenInchScreenshots/2.png) |
|---|---| |-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
### License ### License
[![GNU GPLv3 Image](https://www.gnu.org/graphics/gplv3-127x51.png)](http://www.gnu.org/licenses/gpl-3.0.en.html) [![GNU GPLv3 Image](https://www.gnu.org/graphics/gplv3-127x51.png)](http://www.gnu.org/licenses/gpl-3.0.en.html)

View File

@@ -6,14 +6,14 @@ plugins {
} }
android { android {
compileSdkVersion 31 compileSdkVersion 32
buildToolsVersion '30.0.3' buildToolsVersion '32.0.0'
namespace 'org.koitharu.kotatsu' namespace 'org.koitharu.kotatsu'
defaultConfig { defaultConfig {
applicationId 'org.koitharu.kotatsu' applicationId 'org.koitharu.kotatsu'
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 31 targetSdkVersion 32
versionCode 399 versionCode 399
versionName '3.0-alpha1' versionName '3.0-alpha1'
generatedDensities = [] generatedDensities = []
@@ -49,10 +49,9 @@ android {
kotlinOptions { kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString() jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs += [ freeCompilerArgs += [
'-Xjvm-default=enable', '-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
'-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi', '-opt-in=kotlinx.coroutines.FlowPreview',
'-Xopt-in=kotlinx.coroutines.FlowPreview', '-opt-in=kotlin.contracts.ExperimentalContracts',
'-Xopt-in=kotlin.contracts.ExperimentalContracts',
] ]
} }
lint { lint {
@@ -108,7 +107,6 @@ dependencies {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20211205'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0' testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0'
testImplementation 'io.insert-koin:koin-test-junit4:3.1.5' testImplementation 'io.insert-koin:koin-test-junit4:3.1.5'

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources xmlns:tools="http://schemas.android.com/tools">
<bool name="leak_canary_add_launcher_icon">false</bool> <bool name="leak_canary_add_launcher_icon" tools:node="replace">false</bool>
</resources> </resources>

View File

@@ -8,7 +8,10 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application <application

View File

@@ -42,4 +42,4 @@ abstract class AlertDialogFragment<B : ViewBinding> : DialogFragment() {
protected fun bindingOrNull(): B? = viewBinding protected fun bindingOrNull(): B? = viewBinding
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
} }

View File

@@ -3,11 +3,11 @@ package org.koitharu.kotatsu.base.ui
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlinx.coroutines.* import kotlinx.coroutines.*
import org.koitharu.kotatsu.BuildConfig import org.koitharu.kotatsu.BuildConfig
import org.koitharu.kotatsu.utils.SingleLiveEvent import org.koitharu.kotatsu.utils.SingleLiveEvent
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
abstract class BaseViewModel : ViewModel() { abstract class BaseViewModel : ViewModel() {
@@ -33,7 +33,7 @@ abstract class BaseViewModel : ViewModel() {
} }
} }
protected fun createErrorHandler() = CoroutineExceptionHandler { _, throwable -> private fun createErrorHandler() = CoroutineExceptionHandler { _, throwable ->
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
throwable.printStackTrace() throwable.printStackTrace()
} }

View File

@@ -4,7 +4,6 @@ import android.webkit.WebChromeClient
import android.webkit.WebView import android.webkit.WebView
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.google.android.material.progressindicator.BaseProgressIndicator import com.google.android.material.progressindicator.BaseProgressIndicator
import org.koitharu.kotatsu.utils.ext.setIndeterminateCompat
private const val PROGRESS_MAX = 100 private const val PROGRESS_MAX = 100
@@ -22,10 +21,10 @@ class ProgressChromeClient(
return return
} }
if (newProgress in 1 until PROGRESS_MAX) { if (newProgress in 1 until PROGRESS_MAX) {
progressIndicator.setIndeterminateCompat(false) progressIndicator.isIndeterminate = false
progressIndicator.setProgressCompat(newProgress.coerceAtMost(PROGRESS_MAX), true) progressIndicator.setProgressCompat(newProgress.coerceAtMost(PROGRESS_MAX), true)
} else { } else {
progressIndicator.setIndeterminateCompat(true) progressIndicator.setIndeterminate(true)
} }
} }
} }

View File

@@ -1,6 +1,8 @@
package org.koitharu.kotatsu.core.backup package org.koitharu.kotatsu.core.backup
import android.content.Context import android.content.Context
import java.io.File
import java.util.*
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runInterruptible import kotlinx.coroutines.runInterruptible
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@@ -8,8 +10,6 @@ import org.json.JSONArray
import org.koitharu.kotatsu.R import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.utils.MutableZipFile import org.koitharu.kotatsu.utils.MutableZipFile
import org.koitharu.kotatsu.utils.ext.format import org.koitharu.kotatsu.utils.ext.format
import java.io.File
import java.util.*
class BackupArchive(file: File) : MutableZipFile(file) { class BackupArchive(file: File) : MutableZipFile(file) {
@@ -40,7 +40,7 @@ class BackupArchive(file: File) : MutableZipFile(file) {
} }
dir.mkdirs() dir.mkdirs()
val filename = buildString { val filename = buildString {
append(context.getString(R.string.app_name).toLowerCase(Locale.ROOT)) append(context.getString(R.string.app_name).lowercase(Locale.ROOT))
append('_') append('_')
append(Date().format("ddMMyyyy")) append(Date().format("ddMMyyyy"))
append(".bak") append(".bak")

View File

@@ -18,7 +18,8 @@ import org.koitharu.kotatsu.suggestions.data.SuggestionEntity
MangaEntity::class, TagEntity::class, HistoryEntity::class, MangaTagsEntity::class, MangaEntity::class, TagEntity::class, HistoryEntity::class, MangaTagsEntity::class,
FavouriteCategoryEntity::class, FavouriteEntity::class, MangaPrefsEntity::class, FavouriteCategoryEntity::class, FavouriteEntity::class, MangaPrefsEntity::class,
TrackEntity::class, TrackLogEntity::class, SuggestionEntity::class TrackEntity::class, TrackLogEntity::class, SuggestionEntity::class
], version = 9 ],
version = 9
) )
abstract class MangaDatabase : RoomDatabase() { abstract class MangaDatabase : RoomDatabase() {

View File

@@ -21,6 +21,7 @@ fun downloadItemAD(
) { ) {
var job: Job? = null var job: Job? = null
val percentPattern = context.resources.getString(R.string.percent_string_pattern)
bind { bind {
job?.cancel() job?.cancel()
@@ -37,21 +38,21 @@ fun downloadItemAD(
when (state) { when (state) {
is DownloadManager.State.Cancelling -> { is DownloadManager.State.Cancelling -> {
binding.textViewStatus.setText(R.string.cancelling_) binding.textViewStatus.setText(R.string.cancelling_)
binding.progressBar.setIndeterminateCompat(true) binding.progressBar.isIndeterminate = true
binding.progressBar.isVisible = true binding.progressBar.isVisible = true
binding.textViewPercent.isVisible = false binding.textViewPercent.isVisible = false
binding.textViewDetails.isVisible = false binding.textViewDetails.isVisible = false
} }
is DownloadManager.State.Done -> { is DownloadManager.State.Done -> {
binding.textViewStatus.setText(R.string.download_complete) binding.textViewStatus.setText(R.string.download_complete)
binding.progressBar.setIndeterminateCompat(false) binding.progressBar.isIndeterminate = false
binding.progressBar.isVisible = false binding.progressBar.isVisible = false
binding.textViewPercent.isVisible = false binding.textViewPercent.isVisible = false
binding.textViewDetails.isVisible = false binding.textViewDetails.isVisible = false
} }
is DownloadManager.State.Error -> { is DownloadManager.State.Error -> {
binding.textViewStatus.setText(R.string.error_occurred) binding.textViewStatus.setText(R.string.error_occurred)
binding.progressBar.setIndeterminateCompat(false) binding.progressBar.isIndeterminate = false
binding.progressBar.isVisible = false binding.progressBar.isVisible = false
binding.textViewPercent.isVisible = false binding.textViewPercent.isVisible = false
binding.textViewDetails.text = state.error.getDisplayMessage(context.resources) binding.textViewDetails.text = state.error.getDisplayMessage(context.resources)
@@ -59,38 +60,38 @@ fun downloadItemAD(
} }
is DownloadManager.State.PostProcessing -> { is DownloadManager.State.PostProcessing -> {
binding.textViewStatus.setText(R.string.processing_) binding.textViewStatus.setText(R.string.processing_)
binding.progressBar.setIndeterminateCompat(true) binding.progressBar.isIndeterminate = true
binding.progressBar.isVisible = true binding.progressBar.isVisible = true
binding.textViewPercent.isVisible = false binding.textViewPercent.isVisible = false
binding.textViewDetails.isVisible = false binding.textViewDetails.isVisible = false
} }
is DownloadManager.State.Preparing -> { is DownloadManager.State.Preparing -> {
binding.textViewStatus.setText(R.string.preparing_) binding.textViewStatus.setText(R.string.preparing_)
binding.progressBar.setIndeterminateCompat(true) binding.progressBar.isIndeterminate = true
binding.progressBar.isVisible = true binding.progressBar.isVisible = true
binding.textViewPercent.isVisible = false binding.textViewPercent.isVisible = false
binding.textViewDetails.isVisible = false binding.textViewDetails.isVisible = false
} }
is DownloadManager.State.Progress -> { is DownloadManager.State.Progress -> {
binding.textViewStatus.setText(R.string.manga_downloading_) binding.textViewStatus.setText(R.string.manga_downloading_)
binding.progressBar.setIndeterminateCompat(false) binding.progressBar.isIndeterminate = false
binding.progressBar.isVisible = true binding.progressBar.isVisible = true
binding.progressBar.max = state.max binding.progressBar.max = state.max
binding.progressBar.setProgressCompat(state.progress, true) binding.progressBar.setProgressCompat(state.progress, true)
binding.textViewPercent.text = (state.percent * 100f).format(1) + "%" binding.textViewPercent.text = percentPattern.format((state.percent * 100f).format(1))
binding.textViewPercent.isVisible = true binding.textViewPercent.isVisible = true
binding.textViewDetails.isVisible = false binding.textViewDetails.isVisible = false
} }
is DownloadManager.State.Queued -> { is DownloadManager.State.Queued -> {
binding.textViewStatus.setText(R.string.queued) binding.textViewStatus.setText(R.string.queued)
binding.progressBar.setIndeterminateCompat(false) binding.progressBar.isIndeterminate = false
binding.progressBar.isVisible = false binding.progressBar.isVisible = false
binding.textViewPercent.isVisible = false binding.textViewPercent.isVisible = false
binding.textViewDetails.isVisible = false binding.textViewDetails.isVisible = false
} }
is DownloadManager.State.WaitingForNetwork -> { is DownloadManager.State.WaitingForNetwork -> {
binding.textViewStatus.setText(R.string.waiting_for_network) binding.textViewStatus.setText(R.string.waiting_for_network)
binding.progressBar.setIndeterminateCompat(false) binding.progressBar.isIndeterminate = false
binding.progressBar.isVisible = false binding.progressBar.isVisible = false
binding.textViewPercent.isVisible = false binding.textViewPercent.isVisible = false
binding.textViewDetails.isVisible = false binding.textViewDetails.isVisible = false

View File

@@ -1,10 +1,12 @@
package org.koitharu.kotatsu.reader.ui.pager.reversed package org.koitharu.kotatsu.reader.ui.pager.reversed
import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.children import androidx.core.view.children
import kotlin.math.absoluteValue
import kotlinx.coroutines.async import kotlinx.coroutines.async
import org.koin.android.ext.android.get import org.koin.android.ext.android.get
import org.koitharu.kotatsu.databinding.FragmentReaderStandardBinding import org.koitharu.kotatsu.databinding.FragmentReaderStandardBinding
@@ -17,7 +19,6 @@ import org.koitharu.kotatsu.utils.ext.doOnPageChanged
import org.koitharu.kotatsu.utils.ext.recyclerView import org.koitharu.kotatsu.utils.ext.recyclerView
import org.koitharu.kotatsu.utils.ext.resetTransformations import org.koitharu.kotatsu.utils.ext.resetTransformations
import org.koitharu.kotatsu.utils.ext.viewLifecycleScope import org.koitharu.kotatsu.utils.ext.viewLifecycleScope
import kotlin.math.absoluteValue
class ReversedReaderFragment : BaseReader<FragmentReaderStandardBinding>() { class ReversedReaderFragment : BaseReader<FragmentReaderStandardBinding>() {
@@ -28,6 +29,7 @@ class ReversedReaderFragment : BaseReader<FragmentReaderStandardBinding>() {
container: ViewGroup? container: ViewGroup?
) = FragmentReaderStandardBinding.inflate(inflater, container, false) ) = FragmentReaderStandardBinding.inflate(inflater, container, false)
@SuppressLint("NotifyDataSetChanged")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
pagerAdapter = ReversedPagesAdapter(viewModel.pageLoader, get(), exceptionResolver) pagerAdapter = ReversedPagesAdapter(viewModel.pageLoader, get(), exceptionResolver)

View File

@@ -1,5 +1,6 @@
package org.koitharu.kotatsu.reader.ui.pager.standard package org.koitharu.kotatsu.reader.ui.pager.standard
import android.annotation.SuppressLint
import android.graphics.PointF import android.graphics.PointF
import android.net.Uri import android.net.Uri
import android.view.View import android.view.View
@@ -27,10 +28,12 @@ open class PageHolder(
init { init {
binding.ssiv.setOnImageEventListener(delegate) binding.ssiv.setOnImageEventListener(delegate)
@Suppress("LeakingThis")
binding.buttonRetry.setOnClickListener(this) binding.buttonRetry.setOnClickListener(this)
binding.textViewNumber.isVisible = settings.isPagesNumbersEnabled binding.textViewNumber.isVisible = settings.isPagesNumbersEnabled
} }
@SuppressLint("SetTextI18n")
override fun onBind(data: ReaderPage) { override fun onBind(data: ReaderPage) {
delegate.onBind(data.toMangaPage()) delegate.onBind(data.toMangaPage())
binding.textViewNumber.text = (data.index + 1).toString() binding.textViewNumber.text = (data.index + 1).toString()

View File

@@ -1,10 +1,12 @@
package org.koitharu.kotatsu.reader.ui.pager.standard package org.koitharu.kotatsu.reader.ui.pager.standard
import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.children import androidx.core.view.children
import kotlin.math.absoluteValue
import kotlinx.coroutines.async import kotlinx.coroutines.async
import org.koin.android.ext.android.get import org.koin.android.ext.android.get
import org.koitharu.kotatsu.databinding.FragmentReaderStandardBinding import org.koitharu.kotatsu.databinding.FragmentReaderStandardBinding
@@ -16,7 +18,6 @@ import org.koitharu.kotatsu.utils.ext.doOnPageChanged
import org.koitharu.kotatsu.utils.ext.recyclerView import org.koitharu.kotatsu.utils.ext.recyclerView
import org.koitharu.kotatsu.utils.ext.resetTransformations import org.koitharu.kotatsu.utils.ext.resetTransformations
import org.koitharu.kotatsu.utils.ext.viewLifecycleScope import org.koitharu.kotatsu.utils.ext.viewLifecycleScope
import kotlin.math.absoluteValue
class PagerReaderFragment : BaseReader<FragmentReaderStandardBinding>() { class PagerReaderFragment : BaseReader<FragmentReaderStandardBinding>() {
@@ -27,6 +28,7 @@ class PagerReaderFragment : BaseReader<FragmentReaderStandardBinding>() {
container: ViewGroup? container: ViewGroup?
) = FragmentReaderStandardBinding.inflate(inflater, container, false) ) = FragmentReaderStandardBinding.inflate(inflater, container, false)
@SuppressLint("NotifyDataSetChanged")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
pagesAdapter = PagesAdapter(viewModel.pageLoader, get(), exceptionResolver) pagesAdapter = PagesAdapter(viewModel.pageLoader, get(), exceptionResolver)

View File

@@ -17,15 +17,14 @@ class SearchBehavior(context: Context?, attrs: AttributeSet?) :
child: SearchToolbar, child: SearchToolbar,
dependency: View, dependency: View,
): Boolean { ): Boolean {
return if (dependency is AppBarLayout) { return when (dependency) {
true is AppBarLayout -> true
} else is LinearLayout, is BottomNavigationView -> {
if (dependency is LinearLayout || dependency is BottomNavigationView) {
dependency.z = child.z + 1 dependency.z = child.z + 1
true true
} else {
super.layoutDependsOn(parent, child, dependency)
} }
else -> super.layoutDependsOn(parent, child, dependency)
}
} }
override fun onDependentViewChanged( override fun onDependentViewChanged(

View File

@@ -14,7 +14,6 @@ import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.base.ui.AlertDialogFragment import org.koitharu.kotatsu.base.ui.AlertDialogFragment
import org.koitharu.kotatsu.databinding.DialogProgressBinding import org.koitharu.kotatsu.databinding.DialogProgressBinding
import org.koitharu.kotatsu.utils.ext.getDisplayMessage import org.koitharu.kotatsu.utils.ext.getDisplayMessage
import org.koitharu.kotatsu.utils.ext.setIndeterminateCompat
import org.koitharu.kotatsu.utils.progress.Progress import org.koitharu.kotatsu.utils.progress.Progress
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
@@ -65,7 +64,7 @@ class BackupDialogFragment : AlertDialogFragment<DialogProgressBinding>() {
private fun onProgressChanged(progress: Progress?) { private fun onProgressChanged(progress: Progress?) {
with(binding.progressBar) { with(binding.progressBar) {
setIndeterminateCompat(progress == null) isIndeterminate = progress == null
isVisible = true isVisible = true
if (progress != null) { if (progress != null) {
this.max = progress.total this.max = progress.total

View File

@@ -11,7 +11,7 @@ import java.io.File
class BackupViewModel( class BackupViewModel(
private val repository: BackupRepository, private val repository: BackupRepository,
private val context: Context context: Context
) : BaseViewModel() { ) : BaseViewModel() {
val progress = MutableLiveData<Progress?>(null) val progress = MutableLiveData<Progress?>(null)

View File

@@ -3,6 +3,8 @@ package org.koitharu.kotatsu.settings.backup
import android.content.Context import android.content.Context
import android.net.Uri import android.net.Uri
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import java.io.File
import java.io.FileNotFoundException
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.runInterruptible import kotlinx.coroutines.runInterruptible
@@ -14,13 +16,11 @@ import org.koitharu.kotatsu.core.backup.CompositeResult
import org.koitharu.kotatsu.core.backup.RestoreRepository import org.koitharu.kotatsu.core.backup.RestoreRepository
import org.koitharu.kotatsu.utils.SingleLiveEvent import org.koitharu.kotatsu.utils.SingleLiveEvent
import org.koitharu.kotatsu.utils.progress.Progress import org.koitharu.kotatsu.utils.progress.Progress
import java.io.File
import java.io.FileNotFoundException
class RestoreViewModel( class RestoreViewModel(
uri: Uri?, uri: Uri?,
private val repository: RestoreRepository, private val repository: RestoreRepository,
private val context: Context context: Context
) : BaseViewModel() { ) : BaseViewModel() {
val progress = MutableLiveData<Progress?>(null) val progress = MutableLiveData<Progress?>(null)
@@ -35,8 +35,7 @@ class RestoreViewModel(
val backup = runInterruptible(Dispatchers.IO) { val backup = runInterruptible(Dispatchers.IO) {
val tempFile = File.createTempFile("backup_", ".tmp") val tempFile = File.createTempFile("backup_", ".tmp")
(contentResolver.openInputStream(uri) (contentResolver.openInputStream(uri) ?: throw FileNotFoundException()).use { input ->
?: throw FileNotFoundException()).use { input ->
tempFile.outputStream().use { output -> tempFile.outputStream().use { output ->
input.copyTo(output) input.copyTo(output)
} }

View File

@@ -5,8 +5,8 @@ import android.net.ConnectivityManager
import android.net.Network import android.net.Network
import android.net.NetworkRequest import android.net.NetworkRequest
import android.net.Uri import android.net.Uri
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlin.coroutines.resume import kotlin.coroutines.resume
import kotlinx.coroutines.suspendCancellableCoroutine
val Context.connectivityManager: ConnectivityManager val Context.connectivityManager: ConnectivityManager
get() = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager get() = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager

View File

@@ -14,7 +14,6 @@ import androidx.core.view.children
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.progressindicator.BaseProgressIndicator
import com.google.android.material.slider.Slider import com.google.android.material.slider.Slider
import com.hannesdorfmann.adapterdelegates4.dsl.AdapterDelegateViewBindingViewHolder import com.hannesdorfmann.adapterdelegates4.dsl.AdapterDelegateViewBindingViewHolder
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -138,19 +137,6 @@ inline fun <reified T> RecyclerView.ViewHolder.getItem(): T? {
return ((this as? AdapterDelegateViewBindingViewHolder<*, *>)?.item as? T) return ((this as? AdapterDelegateViewBindingViewHolder<*, *>)?.item as? T)
} }
@Deprecated("Useless")
fun BaseProgressIndicator<*>.setIndeterminateCompat(indeterminate: Boolean) {
if (isIndeterminate != indeterminate) {
if (indeterminate && visibility == View.VISIBLE) {
visibility = View.INVISIBLE
isIndeterminate = indeterminate
visibility = View.VISIBLE
} else {
isIndeterminate = indeterminate
}
}
}
fun Slider.setValueRounded(newValue: Float) { fun Slider.setValueRounded(newValue: Float) {
val step = stepSize val step = stepSize
value = (newValue / step).roundToInt() * step value = (newValue / step).roundToInt() * step

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical"
tools:context=".core.ui.CrashActivity" tools:context=".core.ui.CrashActivity">
android:orientation="vertical">
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -31,6 +31,7 @@
android:text="@string/report_github" /> android:text="@string/report_github" />
<LinearLayout <LinearLayout
style="?buttonBarStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
@@ -38,6 +39,7 @@
<Button <Button
android:id="@+id/button_close" android:id="@+id/button_close"
style="?buttonBarButtonStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
@@ -48,6 +50,7 @@
<Button <Button
android:id="@+id/button_restart" android:id="@+id/button_restart"
style="?buttonBarButtonStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"

View File

@@ -269,4 +269,5 @@
<string name="various_languages">Various languages</string> <string name="various_languages">Various languages</string>
<string name="search_chapters">Find chapter</string> <string name="search_chapters">Find chapter</string>
<string name="chapters_empty">No chapters in this manga</string> <string name="chapters_empty">No chapters in this manga</string>
<string name="percent_string_pattern">%1$s%%</string>
</resources> </resources>

View File

@@ -5,8 +5,8 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.1.0' classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20-M1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files