fix color when using custom theme with AndroidView on DownloadQueue & MigrationBottomSheetDialog
close #401
This commit is contained in:
parent
e874092d3e
commit
7bc9f9ac06
6 changed files with 116 additions and 6 deletions
|
|
@ -1,16 +1,21 @@
|
|||
package eu.kanade.tachiyomi.ui.browse.migration.advanced.design
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Build
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.RadioButton
|
||||
import android.widget.RadioGroup
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.core.view.isVisible
|
||||
import eu.kanade.presentation.components.AdaptiveSheet
|
||||
|
|
@ -32,11 +37,94 @@ fun MigrationBottomSheetDialog(
|
|||
val state = remember {
|
||||
MigrationBottomSheetDialogState(startMigration)
|
||||
}
|
||||
|
||||
// KMK -->
|
||||
val primaryColor = MaterialTheme.colorScheme.primary.toArgb()
|
||||
val onSurface = MaterialTheme.colorScheme.onSurface.toArgb()
|
||||
val surface = MaterialTheme.colorScheme.surface.toArgb()
|
||||
val textHighlightColor = MaterialTheme.colorScheme.inversePrimary.toArgb()
|
||||
// KMK <--
|
||||
|
||||
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
||||
AndroidView(
|
||||
factory = { factoryContext ->
|
||||
val binding = MigrationBottomSheetBinding.inflate(LayoutInflater.from(factoryContext))
|
||||
state.initPreferences(binding)
|
||||
// KMK -->
|
||||
binding.migrateBtn.setBackgroundColor(primaryColor)
|
||||
binding.dataLabel.setTextColor(primaryColor)
|
||||
binding.optionsLabel.setTextColor(primaryColor)
|
||||
|
||||
val buttonTintList = ColorStateList(
|
||||
arrayOf(
|
||||
intArrayOf(android.R.attr.state_checked),
|
||||
intArrayOf(-android.R.attr.state_checked),
|
||||
),
|
||||
intArrayOf(
|
||||
primaryColor,
|
||||
onSurface,
|
||||
),
|
||||
)
|
||||
|
||||
binding.migChapters.buttonTintList = buttonTintList
|
||||
binding.migCategories.buttonTintList = buttonTintList
|
||||
binding.migTracking.buttonTintList = buttonTintList
|
||||
binding.migCustomCover.buttonTintList = buttonTintList
|
||||
binding.migExtra.buttonTintList = buttonTintList
|
||||
binding.migDeleteDownloaded.buttonTintList = buttonTintList
|
||||
|
||||
binding.radioButton.buttonTintList = buttonTintList
|
||||
binding.radioButton2.buttonTintList = buttonTintList
|
||||
|
||||
val trackTintList = ColorStateList(
|
||||
arrayOf(
|
||||
intArrayOf(android.R.attr.state_checked),
|
||||
intArrayOf(-android.R.attr.state_checked),
|
||||
),
|
||||
intArrayOf(
|
||||
primaryColor,
|
||||
surface,
|
||||
),
|
||||
)
|
||||
|
||||
binding.useSmartSearch.trackTintList = trackTintList
|
||||
binding.extraSearchParam.trackTintList = trackTintList
|
||||
binding.skipStep.trackTintList = trackTintList
|
||||
binding.HideNotFoundManga.trackTintList = trackTintList
|
||||
binding.OnlyShowUpdates.trackTintList = trackTintList
|
||||
|
||||
val editTextBackgroundTintList = ColorStateList(
|
||||
arrayOf(
|
||||
intArrayOf(android.R.attr.state_focused),
|
||||
intArrayOf(-android.R.attr.state_focused),
|
||||
),
|
||||
intArrayOf(
|
||||
primaryColor,
|
||||
onSurface,
|
||||
),
|
||||
)
|
||||
|
||||
with(binding.extraSearchParamText) {
|
||||
highlightColor = textHighlightColor
|
||||
backgroundTintList = editTextBackgroundTintList
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
textCursorDrawable = ColorDrawable(primaryColor)
|
||||
textSelectHandle?.let { drawable ->
|
||||
drawable.setTint(primaryColor)
|
||||
setTextSelectHandle(drawable)
|
||||
}
|
||||
textSelectHandleLeft?.let { drawable ->
|
||||
drawable.setTint(primaryColor)
|
||||
setTextSelectHandleLeft(drawable)
|
||||
}
|
||||
textSelectHandleRight?.let { drawable ->
|
||||
drawable.setTint(primaryColor)
|
||||
setTextSelectHandleRight(drawable)
|
||||
}
|
||||
}
|
||||
}
|
||||
// KMK <--
|
||||
binding.root
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,13 @@ import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
|||
*
|
||||
* @param downloadItemListener Listener called when an item of the list is released.
|
||||
*/
|
||||
class DownloadAdapter(val downloadItemListener: DownloadItemListener) : FlexibleAdapter<AbstractFlexibleItem<*>>(
|
||||
class DownloadAdapter(
|
||||
val downloadItemListener: DownloadItemListener,
|
||||
// KMK -->
|
||||
val progressIndicatorColor: Int,
|
||||
val progressTrackColor: Int,
|
||||
// KMK <--
|
||||
) : FlexibleAdapter<AbstractFlexibleItem<*>>(
|
||||
null,
|
||||
downloadItemListener,
|
||||
true,
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
|||
private lateinit var download: Download
|
||||
|
||||
/**
|
||||
* Binds this holder with the given category.
|
||||
* Binds this holder with the given download.
|
||||
*
|
||||
* @param category The category to bind.
|
||||
* @param download The download to bind.
|
||||
*/
|
||||
fun bind(download: Download) {
|
||||
this.download = download
|
||||
|
|
@ -51,6 +51,10 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
|||
notifyProgress()
|
||||
notifyDownloadedPages()
|
||||
}
|
||||
// KMK -->
|
||||
binding.downloadProgress.trackColor = adapter.progressTrackColor
|
||||
binding.downloadProgress.setIndicatorColor(adapter.progressIndicatorColor)
|
||||
// KMK <--
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
|
|
@ -258,12 +259,23 @@ object DownloadQueueScreen : Screen() {
|
|||
val right = with(density) { contentPadding.calculateRightPadding(layoutDirection).toPx().roundToInt() }
|
||||
val bottom = with(density) { contentPadding.calculateBottomPadding().toPx().roundToInt() }
|
||||
|
||||
// KMK -->
|
||||
val progressIndicatorColor = MaterialTheme.colorScheme.primary.toArgb()
|
||||
val progressTrackColor = MaterialTheme.colorScheme.secondaryContainer.toArgb()
|
||||
// KMK <--
|
||||
|
||||
Box(modifier = Modifier.nestedScroll(nestedScrollConnection)) {
|
||||
AndroidView(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
factory = { context ->
|
||||
screenModel.controllerBinding = DownloadListBinding.inflate(LayoutInflater.from(context))
|
||||
screenModel.adapter = DownloadAdapter(screenModel.listener)
|
||||
screenModel.adapter = DownloadAdapter(
|
||||
screenModel.listener,
|
||||
// KMK -->
|
||||
progressIndicatorColor = progressIndicatorColor,
|
||||
progressTrackColor = progressTrackColor,
|
||||
// KMK <--
|
||||
)
|
||||
screenModel.controllerBinding.root.adapter = screenModel.adapter
|
||||
screenModel.adapter?.isHandleDragEnabled = true
|
||||
screenModel.controllerBinding.root.layoutManager = LinearLayoutManager(context)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ fun EditMangaDialog(
|
|||
// KMK -->
|
||||
val colors = EditMangaDialogColors(
|
||||
textColor = MaterialTheme.colorScheme.onSurfaceVariant.toArgb(),
|
||||
textHighlightColor = MaterialTheme.colorScheme.outline.toArgb(),
|
||||
textHighlightColor = MaterialTheme.colorScheme.inversePrimary.toArgb(),
|
||||
iconColor = MaterialTheme.colorScheme.primary.toArgb(),
|
||||
tagColor = MaterialTheme.colorScheme.outlineVariant.toArgb(),
|
||||
tagTextColor = MaterialTheme.colorScheme.onSurfaceVariant.toArgb(),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<!-- Preferences -->
|
||||
<!-- Appearance section -->
|
||||
<string name="pref_custom_theme_style">Custom theme style</string>
|
||||
<string name="pref_details_page_theme">Details page</string>
|
||||
<string name="pref_details_page_theme">Manga details page</string>
|
||||
<string name="pref_theme_cover_based">Theme based on cover</string>
|
||||
<string name="pref_theme_cover_based_style">Cover based theme style</string>
|
||||
<string name="pref_theme_cover_based_style_tonalspot">Tonal Spot</string>
|
||||
|
|
|
|||
Loading…
Reference in a new issue