Misc ui fixes

pull/350/head
Koitharu 3 years ago
parent 259c845912
commit a308688a2e
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -15,8 +15,8 @@ android {
applicationId 'org.koitharu.kotatsu'
minSdkVersion 21
targetSdkVersion 33
versionCode 537
versionName '5.0-rc2'
versionCode 538
versionName '5.0'
generatedDensities = []
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -78,11 +78,11 @@ afterEvaluate {
}
dependencies {
//noinspection GradleDependency
implementation('com.github.KotatsuApp:kotatsu-parsers:e6511061a7') {
implementation('com.github.KotatsuApp:kotatsu-parsers:306d46ea93') {
exclude group: 'org.json', module: 'json'
}
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.20'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.21'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'androidx.appcompat:appcompat:1.6.1'

@ -61,6 +61,11 @@ abstract class BaseActivity<B : ViewBinding> :
putDataToExtras(intent)
}
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
onBackPressedDispatcher.addCallback(actionModeDelegate)
}
override fun onNewIntent(intent: Intent?) {
putDataToExtras(intent)
super.onNewIntent(intent)

@ -1,10 +1,11 @@
package org.koitharu.kotatsu.base.ui.util
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.view.ActionMode
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
class ActionModeDelegate {
class ActionModeDelegate : OnBackPressedCallback(false) {
private var activeActionMode: ActionMode? = null
private var listeners: MutableList<ActionModeListener>? = null
@ -12,13 +13,19 @@ class ActionModeDelegate {
val isActionModeStarted: Boolean
get() = activeActionMode != null
override fun handleOnBackPressed() {
activeActionMode?.finish()
}
fun onSupportActionModeStarted(mode: ActionMode) {
activeActionMode = mode
isEnabled = true
listeners?.forEach { it.onActionModeStarted(mode) }
}
fun onSupportActionModeFinished(mode: ActionMode) {
activeActionMode = null
isEnabled = false
listeners?.forEach { it.onActionModeFinished(mode) }
}

@ -16,7 +16,12 @@ class MangaTagHighlighter @Inject constructor(
private val dict by lazy {
context.resources.openRawResource(R.raw.tags_redlist).use {
val set = HashSet<String>()
it.bufferedReader().forEachLine { x -> set.add(x) }
it.bufferedReader().forEachLine { x ->
val line = x.trim()
if (line.isNotEmpty()) {
set.add(line)
}
}
set
}
}

@ -28,6 +28,7 @@ import org.koitharu.kotatsu.parsers.util.format
import org.koitharu.kotatsu.reader.domain.ReaderColorFilter
import org.koitharu.kotatsu.utils.ext.decodeRegion
import org.koitharu.kotatsu.utils.ext.enqueueWith
import org.koitharu.kotatsu.utils.ext.indicator
import org.koitharu.kotatsu.utils.ext.setValueRounded
import javax.inject.Inject
import com.google.android.material.R as materialR
@ -110,6 +111,7 @@ class ColorFilterConfigActivity :
.scale(Scale.FILL)
.decodeRegion()
.tag(preview.source)
.indicator(listOf(binding.progressBefore, binding.progressAfter))
.error(R.drawable.ic_error_placeholder)
.size(ViewSizeResolver(binding.imageViewBefore))
.allowRgb565(false)

@ -53,7 +53,11 @@ fun ImageResult.toBitmapOrNull() = when (this) {
}
fun ImageRequest.Builder.indicator(indicator: BaseProgressIndicator<*>): ImageRequest.Builder {
return listener(ImageRequestIndicatorListener(indicator))
return listener(ImageRequestIndicatorListener(listOf(indicator)))
}
fun ImageRequest.Builder.indicator(indicators: List<BaseProgressIndicator<*>>): ImageRequest.Builder {
return listener(ImageRequestIndicatorListener(indicators))
}
fun ImageRequest.Builder.decodeRegion(

@ -6,14 +6,22 @@ import coil.request.SuccessResult
import com.google.android.material.progressindicator.BaseProgressIndicator
class ImageRequestIndicatorListener(
private val indicator: BaseProgressIndicator<*>,
private val indicators: Collection<BaseProgressIndicator<*>>,
) : ImageRequest.Listener {
override fun onCancel(request: ImageRequest) = indicator.hide()
override fun onCancel(request: ImageRequest) = hide()
override fun onError(request: ImageRequest, result: ErrorResult) = indicator.hide()
override fun onError(request: ImageRequest, result: ErrorResult) = hide()
override fun onStart(request: ImageRequest) = indicator.show()
override fun onStart(request: ImageRequest) = show()
override fun onSuccess(request: ImageRequest, result: SuccessResult) = indicator.hide()
override fun onSuccess(request: ImageRequest, result: SuccessResult) = hide()
private fun hide() {
indicators.forEach { it.hide() }
}
private fun show() {
indicators.forEach { it.show() }
}
}

@ -53,6 +53,16 @@
app:strokeWidth="1dp"
tools:src="@sample/covers" />
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/progress_before"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="@id/imageView_before"
app:layout_constraintEnd_toEndOf="@id/imageView_before"
app:layout_constraintStart_toStartOf="@id/imageView_before"
app:layout_constraintTop_toTopOf="@id/imageView_before" />
<ImageView
android:id="@+id/imageView_arrow"
android:layout_width="wrap_content"
@ -80,6 +90,16 @@
app:strokeWidth="1dp"
tools:src="@sample/covers" />
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/progress_after"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="@id/imageView_after"
app:layout_constraintEnd_toEndOf="@id/imageView_after"
app:layout_constraintStart_toStartOf="@id/imageView_after"
app:layout_constraintTop_toTopOf="@id/imageView_after" />
<TextView
android:id="@+id/textView_brightness"
android:layout_width="0dp"

@ -40,7 +40,7 @@
<item
android:id="@+id/action_related"
android:orderInCategory="50"
android:title="@string/related"
android:title="@string/find_similar"
app:showAsAction="never" />
<item

@ -434,4 +434,5 @@
<string name="restore_backup_description">Import a previously created backup of user data</string>
<string name="show_on_shelf">Show on the Shelf</string>
<string name="sync_auth_hint">You can sign in into an existing account or create a new one</string>
<string name="find_similar">Find similar</string>
</resources>

Loading…
Cancel
Save