diff --git a/app/src/main/java/eu/kanade/presentation/components/SpinnerAdapter.kt b/app/src/main/java/eu/kanade/presentation/components/SpinnerAdapter.kt new file mode 100644 index 000000000..6fc948650 --- /dev/null +++ b/app/src/main/java/eu/kanade/presentation/components/SpinnerAdapter.kt @@ -0,0 +1,55 @@ +package eu.kanade.presentation.components + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ArrayAdapter +import android.widget.TextView +import androidx.annotation.LayoutRes +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme + +// KMK --> +internal class SpinnerAdapter( + context: Context, + @LayoutRes val resource: Int, + objects: List, + val colorScheme: AndroidViewColorScheme, +) : ArrayAdapter(context, resource, objects) { + private val mInflater = LayoutInflater.from(context) + + override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { + return createViewFromResource(mInflater, position, convertView, parent, resource) + } + + override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View { + return createViewFromResource(mInflater, position, convertView, parent, resource) + } + + private fun createViewFromResource( + inflater: LayoutInflater, + position: Int, + convertView: View?, + parent: ViewGroup, + resource: Int, + ): View { + val text: TextView + + val view = convertView ?: inflater.inflate(resource, parent, false) + + try { + // If no custom field is assigned, assume the whole resource is a TextView + text = view as TextView + } catch (e: ClassCastException) { + throw IllegalStateException("ArrayAdapter requires the resource ID to be a TextView", e) + } + + val item: String? = getItem(position) + if (item != null) text.text = item + + text.setTextColor(colorScheme.textColor) + text.setBackgroundColor(colorScheme.dropdownBgColor) + + return view + } +} diff --git a/app/src/main/java/eu/kanade/presentation/theme/colorscheme/CustomColorScheme.kt b/app/src/main/java/eu/kanade/presentation/theme/colorscheme/CustomColorScheme.kt index 7f97e191b..56dff82a6 100644 --- a/app/src/main/java/eu/kanade/presentation/theme/colorscheme/CustomColorScheme.kt +++ b/app/src/main/java/eu/kanade/presentation/theme/colorscheme/CustomColorScheme.kt @@ -2,9 +2,16 @@ package eu.kanade.presentation.theme.colorscheme import android.app.UiModeManager import android.content.Context +import android.content.res.ColorStateList import android.os.Build +import androidx.annotation.ColorInt +import androidx.compose.material3.ColorScheme +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.unit.dp import androidx.core.content.getSystemService +import com.google.android.material.progressindicator.LinearProgressIndicator import com.materialkolor.Contrast import com.materialkolor.PaletteStyle import com.materialkolor.dynamicColorScheme @@ -51,3 +58,179 @@ private class CustomCompatColorScheme( }, ) } + +class AndroidViewColorScheme( + colorScheme: ColorScheme, +) { + @ColorInt val primary: Int = colorScheme.primary.toArgb() + + @ColorInt val onPrimary: Int = colorScheme.onPrimary.toArgb() + + @ColorInt val primaryContainer: Int = colorScheme.primaryContainer.toArgb() + + @ColorInt val onPrimaryContainer: Int = colorScheme.onPrimaryContainer.toArgb() + + @ColorInt val inversePrimary: Int = colorScheme.inversePrimary.toArgb() + + @ColorInt val secondary: Int = colorScheme.secondary.toArgb() + + @ColorInt val onSecondary: Int = colorScheme.onSecondary.toArgb() + + @ColorInt val secondaryContainer: Int = colorScheme.secondaryContainer.toArgb() + + @ColorInt val onSecondaryContainer: Int = colorScheme.onSecondaryContainer.toArgb() + + @ColorInt val tertiary: Int = colorScheme.tertiary.toArgb() + + @ColorInt val onTertiary: Int = colorScheme.onTertiary.toArgb() + + @ColorInt val tertiaryContainer: Int = colorScheme.tertiaryContainer.toArgb() + + @ColorInt val onTertiaryContainer: Int = colorScheme.onTertiaryContainer.toArgb() + + @ColorInt val background: Int = colorScheme.background.toArgb() + + @ColorInt val onBackground: Int = colorScheme.onBackground.toArgb() + + @ColorInt val surface: Int = colorScheme.surface.toArgb() + + @ColorInt val onSurface: Int = colorScheme.onSurface.toArgb() + + @ColorInt val surfaceVariant: Int = colorScheme.surfaceVariant.toArgb() + + @ColorInt val onSurfaceVariant: Int = colorScheme.onSurfaceVariant.toArgb() + + @ColorInt val surfaceTint: Int = colorScheme.surfaceTint.toArgb() + + @ColorInt val inverseSurface: Int = colorScheme.inverseSurface.toArgb() + + @ColorInt val inverseOnSurface: Int = colorScheme.inverseOnSurface.toArgb() + + @ColorInt val error: Int = colorScheme.error.toArgb() + + @ColorInt val onError: Int = colorScheme.onError.toArgb() + + @ColorInt val errorContainer: Int = colorScheme.errorContainer.toArgb() + + @ColorInt val onErrorContainer: Int = colorScheme.onErrorContainer.toArgb() + + @ColorInt val outline: Int = colorScheme.outline.toArgb() + + @ColorInt val outlineVariant: Int = colorScheme.outlineVariant.toArgb() + + @ColorInt val scrim: Int = colorScheme.scrim.toArgb() + + @ColorInt val surfaceBright: Int = colorScheme.surfaceBright.toArgb() + + @ColorInt val surfaceDim: Int = colorScheme.surfaceDim.toArgb() + + @ColorInt val surfaceContainer: Int = colorScheme.surfaceContainer.toArgb() + + @ColorInt val surfaceContainerHigh: Int = colorScheme.surfaceContainerHigh.toArgb() + + @ColorInt val surfaceContainerHighest: Int = colorScheme.surfaceContainerHighest.toArgb() + + @ColorInt val surfaceContainerLow: Int = colorScheme.surfaceContainerLow.toArgb() + + @ColorInt val surfaceContainerLowest: Int = colorScheme.surfaceContainerLowest.toArgb() + + @ColorInt + val textColor: Int = onSurfaceVariant + + @ColorInt + val textHighlightColor: Int = inversePrimary + + @ColorInt + val iconColor: Int = primary + + @ColorInt + val tagColor: Int = outlineVariant + + @ColorInt + val tagTextColor: Int = onSurfaceVariant + + @ColorInt + val btnTextColor: Int = onPrimary + + @ColorInt + val btnBgColor: Int = surfaceTint + + @ColorInt + val dropdownBgColor: Int = surfaceContainerHighest + + @ColorInt + val dialogBgColor: Int = surfaceContainerHigh + + @ColorInt + val surfaceElevation = colorScheme.surfaceColorAtElevation(4.dp).toArgb() + + @ColorInt + val ratingBarColor = primary + + @ColorInt + val ratingBarSecondaryColor = outlineVariant + + /* MaterialSwitch */ + val trackTintList = ColorStateList( + arrayOf( + intArrayOf(android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_checked), + ), + intArrayOf( + primary, + surface, + ), + ) + val thumbTintList = ColorStateList( + arrayOf( + intArrayOf(android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_checked), + ), + intArrayOf( + onPrimary, + onSurface, + ), + ) + + val checkboxTintList = ColorStateList( + arrayOf( + intArrayOf(android.R.attr.state_checked), + intArrayOf(-android.R.attr.state_checked), + ), + intArrayOf( + primary, + onSurface, + ), + ) + + val editTextBackgroundTintList = ColorStateList( + arrayOf( + intArrayOf(android.R.attr.state_focused), + intArrayOf(-android.R.attr.state_focused), + ), + intArrayOf( + primary, + onSurface, + ), + ) + + val imageButtonTintList = ColorStateList( + arrayOf( + intArrayOf(android.R.attr.state_pressed), // Pressed state + intArrayOf(android.R.attr.state_focused), // Focused state + intArrayOf(), // Default state + ), + intArrayOf( + primary, // Pressed color + primary, // Focused color + primary, // Default color + ), + ) + + companion object { + fun LinearProgressIndicator.setColors(colorScheme: AndroidViewColorScheme) { + trackColor = colorScheme.secondaryContainer + setIndicatorColor(colorScheme.primary) + } + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/advanced/design/MigrationBottomSheetDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/advanced/design/MigrationBottomSheetDialog.kt index f15219dbb..8f31c0bde 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/advanced/design/MigrationBottomSheetDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/advanced/design/MigrationBottomSheetDialog.kt @@ -1,6 +1,5 @@ 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 @@ -15,10 +14,10 @@ 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 +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.databinding.MigrationBottomSheetBinding import eu.kanade.tachiyomi.ui.browse.migration.MigrationFlags import eu.kanade.tachiyomi.util.system.toast @@ -49,10 +48,7 @@ fun MigrationBottomSheetDialog( } // 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() + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) // KMK <-- AdaptiveSheet(onDismissRequest = onDismissRequest) { @@ -61,75 +57,48 @@ fun MigrationBottomSheetDialog( val binding = MigrationBottomSheetBinding.inflate(LayoutInflater.from(factoryContext)) state.initPreferences(binding) // KMK --> - binding.migrateBtn.setBackgroundColor(primaryColor) - binding.dataLabel.setTextColor(primaryColor) - binding.optionsLabel.setTextColor(primaryColor) + binding.migrateBtn.setBackgroundColor(colorScheme.primary) + binding.dataLabel.setTextColor(colorScheme.primary) + binding.optionsLabel.setTextColor(colorScheme.primary) - val buttonTintList = ColorStateList( - arrayOf( - intArrayOf(android.R.attr.state_checked), - intArrayOf(-android.R.attr.state_checked), - ), - intArrayOf( - primaryColor, - onSurface, - ), - ) + binding.migChapters.buttonTintList = colorScheme.checkboxTintList + binding.migCategories.buttonTintList = colorScheme.checkboxTintList + binding.migTracking.buttonTintList = colorScheme.checkboxTintList + binding.migCustomCover.buttonTintList = colorScheme.checkboxTintList + binding.migExtra.buttonTintList = colorScheme.checkboxTintList + binding.migDeleteDownloaded.buttonTintList = colorScheme.checkboxTintList - 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 = colorScheme.checkboxTintList + binding.radioButton2.buttonTintList = colorScheme.checkboxTintList - binding.radioButton.buttonTintList = buttonTintList - binding.radioButton2.buttonTintList = buttonTintList + binding.useSmartSearch.trackTintList = colorScheme.trackTintList + binding.extraSearchParam.trackTintList = colorScheme.trackTintList + binding.skipStep.trackTintList = colorScheme.trackTintList + binding.HideNotFoundManga.trackTintList = colorScheme.trackTintList + binding.OnlyShowUpdates.trackTintList = colorScheme.trackTintList - 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, - ), - ) + binding.useSmartSearch.thumbTintList = colorScheme.thumbTintList + binding.extraSearchParam.thumbTintList = colorScheme.thumbTintList + binding.skipStep.thumbTintList = colorScheme.thumbTintList + binding.HideNotFoundManga.thumbTintList = colorScheme.thumbTintList + binding.OnlyShowUpdates.thumbTintList = colorScheme.thumbTintList with(binding.extraSearchParamText) { - highlightColor = textHighlightColor - backgroundTintList = editTextBackgroundTintList + highlightColor = colorScheme.textHighlightColor + backgroundTintList = colorScheme.editTextBackgroundTintList if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - textCursorDrawable = ColorDrawable(primaryColor) + textCursorDrawable = ColorDrawable(colorScheme.primary) textSelectHandle?.let { drawable -> - drawable.setTint(primaryColor) + drawable.setTint(colorScheme.primary) setTextSelectHandle(drawable) } textSelectHandleLeft?.let { drawable -> - drawable.setTint(primaryColor) + drawable.setTint(colorScheme.primary) setTextSelectHandleLeft(drawable) } textSelectHandleRight?.let { drawable -> - drawable.setTint(primaryColor) + drawable.setTint(colorScheme.primary) setTextSelectHandleRight(drawable) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadAdapter.kt index 5573dd14f..45e4940c2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadAdapter.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.download import android.view.MenuItem import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.AbstractFlexibleItem +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme /** * Adapter storing a list of downloads. @@ -12,8 +13,7 @@ import eu.davidea.flexibleadapter.items.AbstractFlexibleItem class DownloadAdapter( val downloadItemListener: DownloadItemListener, // KMK --> - val progressIndicatorColor: Int, - val progressTrackColor: Int, + val colorScheme: AndroidViewColorScheme, // KMK <-- ) : FlexibleAdapter>( null, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadHolder.kt index ade4114dd..718c88f28 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadHolder.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.download import android.view.View import androidx.recyclerview.widget.ItemTouchHelper import eu.davidea.viewholders.FlexibleViewHolder +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme.Companion.setColors import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.databinding.DownloadItemBinding @@ -52,8 +53,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) : notifyDownloadedPages() } // KMK --> - binding.downloadProgress.trackColor = adapter.progressTrackColor - binding.downloadProgress.setIndicatorColor(adapter.progressIndicatorColor) + binding.downloadProgress.setColors(adapter.colorScheme) // KMK <-- } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt index 270a139ca..2e068715b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadQueueScreen.kt @@ -30,7 +30,6 @@ 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 @@ -51,6 +50,7 @@ import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.AppBarActions import eu.kanade.presentation.components.DropdownMenu import eu.kanade.presentation.components.NestedMenuItem +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.presentation.util.Screen import eu.kanade.tachiyomi.databinding.DownloadListBinding import kotlinx.collections.immutable.persistentListOf @@ -260,8 +260,7 @@ object DownloadQueueScreen : Screen() { val bottom = with(density) { contentPadding.calculateBottomPadding().toPx().roundToInt() } // KMK --> - val progressIndicatorColor = MaterialTheme.colorScheme.primary.toArgb() - val progressTrackColor = MaterialTheme.colorScheme.secondaryContainer.toArgb() + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) // KMK <-- Box(modifier = Modifier.nestedScroll(nestedScrollConnection)) { @@ -272,8 +271,7 @@ object DownloadQueueScreen : Screen() { screenModel.adapter = DownloadAdapter( screenModel.listener, // KMK --> - progressIndicatorColor = progressIndicatorColor, - progressTrackColor = progressTrackColor, + colorScheme, // KMK <-- ) screenModel.controllerBinding.root.adapter = screenModel.adapter diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt index 82fb43679..ddab3c203 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/EditMangaDialog.kt @@ -2,15 +2,12 @@ package eu.kanade.tachiyomi.ui.manga import android.content.Context import android.content.res.ColorStateList +import android.graphics.Color import android.os.Build import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup import android.widget.AdapterView -import android.widget.ArrayAdapter import android.widget.TextView -import androidx.annotation.ColorInt -import androidx.annotation.LayoutRes import androidx.appcompat.app.AlertDialog import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -32,7 +29,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import androidx.core.content.ContextCompat @@ -44,7 +40,9 @@ import com.google.android.material.chip.Chip import com.google.android.material.chip.ChipGroup import com.google.android.material.dialog.MaterialAlertDialogBuilder import eu.kanade.domain.ui.UiPreferences +import eu.kanade.presentation.components.SpinnerAdapter import eu.kanade.presentation.manga.components.RatioSwitchToPanorama +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.presentation.track.components.TrackLogoIcon import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.track.EnhancedTracker @@ -105,19 +103,11 @@ fun EditMangaDialog( val getTracks = remember { Injekt.get() } val trackerManager = remember { Injekt.get() } val tracks = remember { mutableStateOf(emptyList>()) } + // KMK --> - val colors = EditMangaDialogColors( - textColor = MaterialTheme.colorScheme.onSurfaceVariant.toArgb(), - textHighlightColor = MaterialTheme.colorScheme.inversePrimary.toArgb(), - iconColor = MaterialTheme.colorScheme.primary.toArgb(), - tagColor = MaterialTheme.colorScheme.outlineVariant.toArgb(), - tagTextColor = MaterialTheme.colorScheme.onSurfaceVariant.toArgb(), - btnTextColor = MaterialTheme.colorScheme.onPrimary.toArgb(), - btnBgColor = MaterialTheme.colorScheme.surfaceTint.toArgb(), - dropdownBgColor = MaterialTheme.colorScheme.surfaceVariant.toArgb(), - dialogBgColor = MaterialTheme.colorScheme.surfaceContainerHigh.toArgb(), - ) + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) // KMK <-- + AlertDialog( onDismissRequest = onDismissRequest, confirmButton = { @@ -176,7 +166,7 @@ fun EditMangaDialog( tracks, showTrackerSelectionDialogue, // KMK --> - colors, + colorScheme, coverRatio = coverRatio, // KMK <-- ) @@ -242,20 +232,6 @@ private fun TrackerSelectDialog( ) } -// KMK --> -data class EditMangaDialogColors( - @ColorInt val textColor: Int, - @ColorInt val textHighlightColor: Int, - @ColorInt val iconColor: Int, - @ColorInt val tagColor: Int, - @ColorInt val tagTextColor: Int, - @ColorInt val btnTextColor: Int, - @ColorInt val btnBgColor: Int, - @ColorInt val dropdownBgColor: Int, - @ColorInt val dialogBgColor: Int, -) -// KMK <-- - private fun onViewCreated( manga: Manga, context: Context, @@ -266,7 +242,7 @@ private fun onViewCreated( tracks: MutableState>>, showTrackerSelectionDialogue: MutableState, // KMK --> - colors: EditMangaDialogColors, + colorScheme: AndroidViewColorScheme, coverRatio: MutableFloatState, // KMK <-- ) { @@ -294,7 +270,7 @@ private fun onViewCreated( MR.strings.on_hiatus, ).map { context.stringResource(it) }, // KMK --> - colors, + colorScheme, // KMK <-- ) @@ -318,13 +294,13 @@ private fun onViewCreated( // Set Spinner's selected item's background color to transparent binding.status.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>, view: View?, pos: Int, id: Long) { - if (view != null) (view as TextView).setBackgroundColor(0x00000000) + if (view != null) (view as TextView).setBackgroundColor(Color.TRANSPARENT) } override fun onNothingSelected(parent: AdapterView<*>?) = Unit } // Set Spinner's dropdown caret color - binding.status.backgroundTintList = ColorStateList.valueOf(colors.iconColor) + binding.status.backgroundTintList = ColorStateList.valueOf(colorScheme.iconColor) // KMK if (manga.isLocal()) { @@ -337,7 +313,7 @@ private fun onViewCreated( binding.mangaArtist.setText(manga.artist.orEmpty()) binding.thumbnailUrl.setText(manga.thumbnailUrl.orEmpty()) binding.mangaDescription.setText(manga.description.orEmpty()) - binding.mangaGenresTags.setChips(manga.genre.orEmpty().dropBlank(), scope, colors) + binding.mangaGenresTags.setChips(manga.genre.orEmpty().dropBlank(), scope, colorScheme) } else { if (manga.title != manga.ogTitle) { binding.title.append(manga.title) @@ -354,7 +330,7 @@ private fun onViewCreated( if (manga.description != manga.ogDescription) { binding.mangaDescription.append(manga.description.orEmpty()) } - binding.mangaGenresTags.setChips(manga.genre.orEmpty().dropBlank(), scope, colors) + binding.mangaGenresTags.setChips(manga.genre.orEmpty().dropBlank(), scope, colorScheme) binding.title.hint = context.stringResource(SYMR.strings.title_hint, manga.ogTitle) @@ -383,20 +359,20 @@ private fun onViewCreated( binding.thumbnailUrl, binding.mangaDescription, ).forEach { - it.setTextColor(colors.textColor) - it.highlightColor = colors.textHighlightColor + it.setTextColor(colorScheme.textColor) + it.highlightColor = colorScheme.textHighlightColor if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { it.textSelectHandle?.let { drawable -> - drawable.setTint(colors.iconColor) + drawable.setTint(colorScheme.iconColor) it.setTextSelectHandle(drawable) } it.textSelectHandleLeft?.let { drawable -> - drawable.setTint(colors.iconColor) + drawable.setTint(colorScheme.iconColor) it.setTextSelectHandleLeft(drawable) } it.textSelectHandleRight?.let { drawable -> - drawable.setTint(colors.iconColor) + drawable.setTint(colorScheme.iconColor) it.setTextSelectHandleRight(drawable) } } @@ -408,23 +384,23 @@ private fun onViewCreated( binding.thumbnailUrlOutline, binding.mangaDescriptionOutline, ).forEach { - it.boxStrokeColor = colors.iconColor + it.boxStrokeColor = colorScheme.iconColor if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - it.cursorColor = ColorStateList.valueOf(colors.iconColor) + it.cursorColor = ColorStateList.valueOf(colorScheme.iconColor) } } - binding.autofillFromTracker.setTextColor(colors.btnTextColor) - binding.autofillFromTracker.setBackgroundColor(colors.btnBgColor) - binding.resetTags.setTextColor(colors.btnTextColor) - binding.resetTags.setBackgroundColor(colors.btnBgColor) - binding.resetInfo.setTextColor(colors.btnTextColor) - binding.resetInfo.setBackgroundColor(colors.btnBgColor) + binding.autofillFromTracker.setTextColor(colorScheme.btnTextColor) + binding.autofillFromTracker.setBackgroundColor(colorScheme.btnBgColor) + binding.resetTags.setTextColor(colorScheme.btnTextColor) + binding.resetTags.setBackgroundColor(colorScheme.btnBgColor) + binding.resetInfo.setTextColor(colorScheme.btnTextColor) + binding.resetInfo.setBackgroundColor(colorScheme.btnBgColor) // KMK <-- - binding.resetTags.setOnClickListener { resetTags(manga, binding, scope, colors) } - binding.resetInfo.setOnClickListener { resetInfo(manga, binding, scope, colors) } + binding.resetTags.setOnClickListener { resetTags(manga, binding, scope, colorScheme) } + binding.resetInfo.setOnClickListener { resetInfo(manga, binding, scope, colorScheme) } binding.autofillFromTracker.setOnClickListener { scope.launch { getTrackers(manga, binding, context, getTracks, trackerManager, tracks, showTrackerSelectionDialogue) @@ -481,13 +457,13 @@ private fun resetTags( binding: EditMangaDialogBinding, scope: CoroutineScope, // KMK --> - colors: EditMangaDialogColors, + colorScheme: AndroidViewColorScheme, // KMK <-- ) { if (manga.genre.isNullOrEmpty() || manga.isLocal()) { - binding.mangaGenresTags.setChips(emptyList(), scope, colors) + binding.mangaGenresTags.setChips(emptyList(), scope, colorScheme) } else { - binding.mangaGenresTags.setChips(manga.ogGenre.orEmpty(), scope, colors) + binding.mangaGenresTags.setChips(manga.ogGenre.orEmpty(), scope, colorScheme) } } @@ -518,7 +494,7 @@ private fun resetInfo( binding: EditMangaDialogBinding, scope: CoroutineScope, // KMK --> - colors: EditMangaDialogColors, + colorScheme: AndroidViewColorScheme, // KMK <-- ) { binding.title.text?.clear() @@ -526,33 +502,33 @@ private fun resetInfo( binding.mangaArtist.text?.clear() binding.thumbnailUrl.text?.clear() binding.mangaDescription.text?.clear() - resetTags(manga, binding, scope, colors) + resetTags(manga, binding, scope, colorScheme) } private fun ChipGroup.setChips( items: List, scope: CoroutineScope, // KMK --> - colors: EditMangaDialogColors, + colorScheme: AndroidViewColorScheme, // KMK <-- ) { removeAllViews() // KMK --> - val colorStateList = ColorStateList.valueOf(colors.tagColor) + val colorStateList = ColorStateList.valueOf(colorScheme.tagColor) // KMK <-- items.asSequence().map { item -> Chip(context).apply { text = item // KMK --> - setTextColor(colors.tagTextColor) + setTextColor(colorScheme.tagTextColor) // KMK <-- isCloseIconVisible = true // KMK --> // closeIcon?.setTint(context.getResourceColor(R.attr.colorAccent)) - closeIcon?.setTint(colors.iconColor) + closeIcon?.setTint(colorScheme.iconColor) // KMK <-- setOnCloseIconClickListener { removeView(this) @@ -569,14 +545,14 @@ private fun ChipGroup.setChips( val addTagChip = Chip(context).apply { text = SYMR.strings.add_tags.getString(context) // KMK --> - setTextColor(colors.tagTextColor) + setTextColor(colorScheme.tagTextColor) // KMK <-- chipIcon = ContextCompat.getDrawable(context, R.drawable.ic_add_24dp)?.apply { isChipIconVisible = true // KMK --> // setTint(context.getResourceColor(R.attr.colorAccent)) - setTint(colors.iconColor) + setTint(colorScheme.iconColor) // KMK <-- } @@ -597,7 +573,7 @@ private fun ChipGroup.setChips( // KMK <-- val newTags = it.trimOrNull() newTags?.let { tags -> - setChips(items + tags.split(",").mapNotNull { tag -> tag.trimOrNull() }, scope, colors) + setChips(items + tags.split(",").mapNotNull { tag -> tag.trimOrNull() }, scope, colorScheme) } // KMK --> } @@ -605,7 +581,7 @@ private fun ChipGroup.setChips( dialog?.dismissDialog() } .setTextEdit() - .setColors(colors) + .setColors(colorScheme) dialog = builder.create() dialog.setView(binding.root) @@ -623,49 +599,3 @@ private fun ChipGroup.getTextStrings(): List = children.mapNotNull { null } }.toList() - -// KMK --> -private class SpinnerAdapter( - context: Context, - @LayoutRes val resource: Int, - objects: List, - val colors: EditMangaDialogColors, -) : ArrayAdapter(context, resource, objects) { - private val mInflater = LayoutInflater.from(context) - - override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { - return createViewFromResource(mInflater, position, convertView, parent, resource) - } - - override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View { - return createViewFromResource(mInflater, position, convertView, parent, resource) - } - - private fun createViewFromResource( - inflater: LayoutInflater, - position: Int, - convertView: View?, - parent: ViewGroup, - resource: Int, - ): View { - val text: TextView - - val view = convertView ?: inflater.inflate(resource, parent, false) - - try { - // If no custom field is assigned, assume the whole resource is a TextView - text = view as TextView - } catch (e: ClassCastException) { - throw IllegalStateException("ArrayAdapter requires the resource ID to be a TextView", e) - } - - val item: String? = getItem(position) - if (item != null) text.text = item - - text.setTextColor(colors.textColor) - text.setBackgroundColor(colors.dropdownBgColor) - - return view - } -} -// KMK <-- diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedMangaAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedMangaAdapter.kt index 8cbef4c21..9d742fb56 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedMangaAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedMangaAdapter.kt @@ -1,14 +1,21 @@ package eu.kanade.tachiyomi.ui.manga.merged import eu.davidea.flexibleadapter.FlexibleAdapter +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme /** * Adapter storing a list of merged manga. * - * @param controller the context of the fragment containing this adapter. + * @param listener the context of the fragment containing this adapter. * @param isPriorityOrder if deduplication mode is based on priority */ -class EditMergedMangaAdapter(listener: EditMergedSettingsState, var isPriorityOrder: Boolean) : +class EditMergedMangaAdapter( + listener: EditMergedSettingsState, + var isPriorityOrder: Boolean, + // KMK --> + val colorScheme: AndroidViewColorScheme, + // KMK <-- +) : FlexibleAdapter(null, listener, true), EditMergedSettingsHeaderAdapter.SortingListener { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedMangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedMangaHolder.kt index 011f2cb70..1c3c2824c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedMangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedMangaHolder.kt @@ -5,10 +5,8 @@ import coil3.load import coil3.request.transformations import coil3.transform.RoundedCornersTransformation import eu.davidea.viewholders.FlexibleViewHolder -import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.EditMergedSettingsItemBinding import eu.kanade.tachiyomi.util.system.dpToPx -import exh.ui.metadata.adapters.MetadataUIUtil.getResourceColor import tachiyomi.domain.manga.model.MergedMangaReference import tachiyomi.domain.source.service.SourceManager import uy.kohesive.injekt.Injekt @@ -50,6 +48,11 @@ class EditMergedMangaHolder(view: View, val adapter: EditMergedMangaAdapter) : F binding.subtitle.text = item.mergedManga?.title updateDownloadChaptersIcon(item.mergedMangaReference.downloadChapters) updateChapterUpdatesIcon(item.mergedMangaReference.getChapterUpdates) + + // KMK --> + binding.holder.setCardBackgroundColor(adapter.colorScheme.surfaceElevation) + binding.remove.imageTintList = adapter.colorScheme.imageButtonTintList + // KMK <-- } fun setHandelAlpha(isPriorityOrder: Boolean) { @@ -61,9 +64,11 @@ class EditMergedMangaHolder(view: View, val adapter: EditMergedMangaAdapter) : F fun updateDownloadChaptersIcon(setTint: Boolean) { val color = if (setTint) { - itemView.context.getResourceColor(R.attr.colorAccent) + // KMK --> + adapter.colorScheme.secondary } else { - itemView.context.getResourceColor(R.attr.colorOnSurface) + adapter.colorScheme.onSurface + // KMK <-- } binding.download.drawable.setTint(color) @@ -71,9 +76,11 @@ class EditMergedMangaHolder(view: View, val adapter: EditMergedMangaAdapter) : F fun updateChapterUpdatesIcon(setTint: Boolean) { val color = if (setTint) { - itemView.context.getResourceColor(R.attr.colorAccent) + // KMK --> + adapter.colorScheme.secondary } else { - itemView.context.getResourceColor(R.attr.colorOnSurface) + adapter.colorScheme.onSurface + // KMK <-- } binding.getChapterUpdates.drawable.setTint(color) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedSettingsDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedSettingsDialog.kt index 484103597..8e4f05469 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedSettingsDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedSettingsDialog.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.AlertDialog +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable @@ -22,6 +23,7 @@ import androidx.compose.ui.window.DialogProperties import androidx.recyclerview.widget.ConcatAdapter import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.dialog.MaterialAlertDialogBuilder +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.databinding.EditMergedSettingsDialogBinding import eu.kanade.tachiyomi.ui.manga.MergedMangaData import eu.kanade.tachiyomi.util.system.toast @@ -49,6 +51,9 @@ class EditMergedSettingsState( binding: EditMergedSettingsDialogBinding, mergedManga: List, mergedReferences: List, + // KMK --> + colorScheme: AndroidViewColorScheme, + // KMK <-- ) { if (mergedReferences.isEmpty() || mergedReferences.size == 1) { context.toast(SYMR.strings.merged_references_invalid) @@ -62,8 +67,20 @@ class EditMergedSettingsState( val isPriorityOrder = mergeReference?.let { it.chapterSortMode == MergedMangaReference.CHAPTER_SORT_PRIORITY } ?: false - mergedMangaAdapter = EditMergedMangaAdapter(this, isPriorityOrder) - mergedMangaHeaderAdapter = EditMergedSettingsHeaderAdapter(this, mergedMangaAdapter!!) + mergedMangaAdapter = EditMergedMangaAdapter( + this, + isPriorityOrder, + // KMK --> + colorScheme, + // KMK <-- + ) + mergedMangaHeaderAdapter = EditMergedSettingsHeaderAdapter( + this, + mergedMangaAdapter!!, + // KMK --> + colorScheme, + // KMK <-- + ) binding.recycler.adapter = ConcatAdapter(mergedMangaHeaderAdapter, mergedMangaAdapter) binding.recycler.layoutManager = LinearLayoutManager(context) @@ -176,6 +193,10 @@ fun EditMergedSettingsDialog( onDeleteClick: (MergedMangaReference) -> Unit, onPositiveClick: (List) -> Unit, ) { + // KMK --> + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) + // KMK <-- + val context = LocalContext.current val state = remember { EditMergedSettingsState(context, onDeleteClick, onDismissRequest, onPositiveClick) @@ -201,7 +222,15 @@ fun EditMergedSettingsDialog( AndroidView( factory = { factoryContext -> val binding = EditMergedSettingsDialogBinding.inflate(LayoutInflater.from(factoryContext)) - state.onViewCreated(factoryContext, binding, mergedData.manga.values.toList(), mergedData.references) + state.onViewCreated( + factoryContext, + binding, + mergedData.manga.values.toList(), + mergedData.references, + // KMK --> + colorScheme, + // KMK <-- + ) binding.root }, modifier = Modifier.fillMaxWidth(), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedSettingsHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedSettingsHeaderAdapter.kt index 0b1111592..f469ac417 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedSettingsHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/merged/EditMergedSettingsHeaderAdapter.kt @@ -1,11 +1,15 @@ package eu.kanade.tachiyomi.ui.manga.merged +import android.content.res.ColorStateList +import android.graphics.Color import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.AdapterView -import android.widget.ArrayAdapter +import android.widget.TextView import androidx.recyclerview.widget.RecyclerView +import eu.kanade.presentation.components.SpinnerAdapter +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.databinding.EditMergedSettingsHeaderBinding import exh.log.xLogD import tachiyomi.core.common.i18n.stringResource @@ -14,7 +18,13 @@ import tachiyomi.domain.source.service.SourceManager import tachiyomi.i18n.sy.SYMR import uy.kohesive.injekt.injectLazy -class EditMergedSettingsHeaderAdapter(private val state: EditMergedSettingsState, adapter: EditMergedMangaAdapter) : RecyclerView.Adapter() { +class EditMergedSettingsHeaderAdapter( + private val state: EditMergedSettingsState, + adapter: EditMergedMangaAdapter, + // KMK --> + private val colorScheme: AndroidViewColorScheme, + // KMK <-- +) : RecyclerView.Adapter() { private val sourceManager: SourceManager by injectLazy() @@ -37,19 +47,24 @@ class EditMergedSettingsHeaderAdapter(private val state: EditMergedSettingsState holder.bind() } - inner class HeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) { + inner class HeaderViewHolder(val view: View) : RecyclerView.ViewHolder(view) { fun bind() { - val dedupeAdapter: ArrayAdapter = ArrayAdapter( - itemView.context, - android.R.layout.simple_spinner_item, + // KMK --> + // val dedupeAdapter: ArrayAdapter = ArrayAdapter( + val dedupeAdapter = SpinnerAdapter( + view.context, + android.R.layout.simple_spinner_dropdown_item, + // KMK <-- listOfNotNull( itemView.context.stringResource(SYMR.strings.no_dedupe), itemView.context.stringResource(SYMR.strings.dedupe_priority), itemView.context.stringResource(SYMR.strings.dedupe_most_chapters), itemView.context.stringResource(SYMR.strings.dedupe_highest_chapter), ), + // KMK --> + colorScheme, + // KMK <-- ) - dedupeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) binding.dedupeModeSpinner.adapter = dedupeAdapter state.mergeReference?.let { binding.dedupeModeSpinner.setSelection( @@ -62,6 +77,7 @@ class EditMergedSettingsHeaderAdapter(private val state: EditMergedSettingsState }, ) } + binding.dedupeModeSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected( parent: AdapterView<*>?, @@ -80,6 +96,9 @@ class EditMergedSettingsHeaderAdapter(private val state: EditMergedSettingsState ) xLogD(state.mergeReference?.chapterSortMode) editMergedMangaItemSortingListener.onSetPrioritySort(canMove()) + + // Set Spinner's selected item's background color to transparent + if (view != null) (view as TextView).setBackgroundColor(Color.TRANSPARENT) } override fun onNothingSelected(parent: AdapterView<*>?) { @@ -91,14 +110,19 @@ class EditMergedSettingsHeaderAdapter(private val state: EditMergedSettingsState val mergedMangas = state.mergedMangas - val mangaInfoAdapter: ArrayAdapter = ArrayAdapter( - itemView.context, - android.R.layout.simple_spinner_item, + // KMK --> + // val mangaInfoAdapter: ArrayAdapter = ArrayAdapter( + val mangaInfoAdapter = SpinnerAdapter( + view.context, + android.R.layout.simple_spinner_dropdown_item, + // KMK <-- mergedMangas.map { sourceManager.getOrStub(it.second.mangaSourceId).toString() + " " + it.first?.title }, + // KMK --> + colorScheme, + // KMK <-- ) - mangaInfoAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) binding.mangaInfoSpinner.adapter = mangaInfoAdapter mergedMangas.indexOfFirst { it.second.isInfoManga }.let { @@ -121,6 +145,9 @@ class EditMergedSettingsHeaderAdapter(private val state: EditMergedSettingsState isInfoManga = reference.id == mergedMangas.getOrNull(position)?.second?.id, ) } + + // Set Spinner's selected item's background color to transparent + if (view != null) (view as TextView).setBackgroundColor(Color.TRANSPARENT) } override fun onNothingSelected(parent: AdapterView<*>?) { @@ -158,6 +185,19 @@ class EditMergedSettingsHeaderAdapter(private val state: EditMergedSettingsState true -> 1F false -> 0.5F } + + // KMK --> + binding.dedupeSwitchLabel.setTextColor(colorScheme.textColor) + binding.dedupeModeLabel.setTextColor(colorScheme.primary) + binding.mangaInfoLabel.setTextColor(colorScheme.primary) + + binding.dedupeSwitch.trackTintList = colorScheme.trackTintList + binding.dedupeSwitch.thumbTintList = colorScheme.thumbTintList + + // Set Spinner's dropdown caret color + binding.dedupeModeSpinner.backgroundTintList = ColorStateList.valueOf(colorScheme.iconColor) + binding.mangaInfoSpinner.backgroundTintList = ColorStateList.valueOf(colorScheme.iconColor) + // KMK <-- } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/MaterialAlertDialogBuilderExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/MaterialAlertDialogBuilderExtensions.kt index 03e860b09..67a93a230 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/MaterialAlertDialogBuilderExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/materialdialogs/MaterialAlertDialogBuilderExtensions.kt @@ -15,8 +15,8 @@ import android.widget.TextView import androidx.appcompat.app.AlertDialog import androidx.core.content.getSystemService import com.google.android.material.dialog.MaterialAlertDialogBuilder +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.databinding.DialogStubTextinputBinding -import eu.kanade.tachiyomi.ui.manga.EditMangaDialogColors // KMK --> @Suppress("UnusedReceiverParameter") @@ -73,7 +73,7 @@ fun DialogStubTextinputBinding.setTextEdit(prefill: String? = null): DialogStubT return this } -fun DialogStubTextinputBinding.setColors(colors: EditMangaDialogColors): DialogStubTextinputBinding { +fun DialogStubTextinputBinding.setColors(colors: AndroidViewColorScheme): DialogStubTextinputBinding { textField.boxStrokeColor = colors.iconColor if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { diff --git a/app/src/main/java/exh/ui/metadata/adapters/EHentaiDescriptionAdapter.kt b/app/src/main/java/exh/ui/metadata/adapters/EHentaiDescriptionAdapter.kt index 8e0b16661..7296e804b 100644 --- a/app/src/main/java/exh/ui/metadata/adapters/EHentaiDescriptionAdapter.kt +++ b/app/src/main/java/exh/ui/metadata/adapters/EHentaiDescriptionAdapter.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DescriptionAdapterEhBinding import eu.kanade.tachiyomi.ui.manga.MangaScreenModel.State @@ -34,9 +35,11 @@ fun EHentaiDescription( ) { val context = LocalContext.current // KMK --> - val iconColor = MaterialTheme.colorScheme.primary.toArgb() + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) + val iconColor = colorScheme.iconColor + val ratingBarColor = colorScheme.ratingBarColor + val ratingBarSecondaryColor = colorScheme.ratingBarSecondaryColor val textColor = LocalContentColor.current.toArgb() - val ratingBarSecondaryColor = MaterialTheme.colorScheme.outlineVariant.toArgb() // KMK <-- AndroidView( modifier = Modifier.fillMaxWidth(), @@ -116,7 +119,7 @@ fun EHentaiDescription( binding.rating.text = (ratingFloat ?: 0F).toString() + " - " + MetadataUIUtil.getRatingString(context, ratingFloat?.times(2)) // KMK --> - binding.ratingBar.supportProgressTintList = ColorStateList.valueOf(iconColor) + binding.ratingBar.supportProgressTintList = ColorStateList.valueOf(ratingBarColor) binding.ratingBar.supportSecondaryProgressTintList = ColorStateList.valueOf(ratingBarSecondaryColor) binding.rating.setTextColor(textColor) diff --git a/app/src/main/java/exh/ui/metadata/adapters/EightMusesDescriptionAdapter.kt b/app/src/main/java/exh/ui/metadata/adapters/EightMusesDescriptionAdapter.kt index 2cf63286a..f3279d3bd 100644 --- a/app/src/main/java/exh/ui/metadata/adapters/EightMusesDescriptionAdapter.kt +++ b/app/src/main/java/exh/ui/metadata/adapters/EightMusesDescriptionAdapter.kt @@ -8,6 +8,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DescriptionAdapter8mBinding import eu.kanade.tachiyomi.ui.manga.MangaScreenModel.State @@ -22,8 +23,9 @@ import tachiyomi.i18n.sy.SYMR fun EightMusesDescription(state: State.Success, openMetadataViewer: () -> Unit) { val context = LocalContext.current // KMK --> + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) + val iconColor = colorScheme.iconColor val titleColor = MaterialTheme.colorScheme.primary.toArgb() - val iconColor = MaterialTheme.colorScheme.primary.toArgb() // KMK <-- AndroidView( modifier = Modifier.fillMaxWidth(), diff --git a/app/src/main/java/exh/ui/metadata/adapters/HBrowseDescriptionAdapter.kt b/app/src/main/java/exh/ui/metadata/adapters/HBrowseDescriptionAdapter.kt index 3ba4dccb6..b54d22a5c 100644 --- a/app/src/main/java/exh/ui/metadata/adapters/HBrowseDescriptionAdapter.kt +++ b/app/src/main/java/exh/ui/metadata/adapters/HBrowseDescriptionAdapter.kt @@ -9,6 +9,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DescriptionAdapterHbBinding import eu.kanade.tachiyomi.ui.manga.MangaScreenModel.State @@ -23,7 +24,8 @@ import tachiyomi.i18n.sy.SYMR fun HBrowseDescription(state: State.Success, openMetadataViewer: () -> Unit) { val context = LocalContext.current // KMK --> - val iconColor = MaterialTheme.colorScheme.primary.toArgb() + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) + val iconColor = colorScheme.iconColor val textColor = LocalContentColor.current.toArgb() // KMK <-- AndroidView( diff --git a/app/src/main/java/exh/ui/metadata/adapters/MangaDexDescriptionAdapter.kt b/app/src/main/java/exh/ui/metadata/adapters/MangaDexDescriptionAdapter.kt index 5c3e4ca39..d12a15bf3 100644 --- a/app/src/main/java/exh/ui/metadata/adapters/MangaDexDescriptionAdapter.kt +++ b/app/src/main/java/exh/ui/metadata/adapters/MangaDexDescriptionAdapter.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView import androidx.core.view.isVisible +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DescriptionAdapterMdBinding import eu.kanade.tachiyomi.ui.manga.MangaScreenModel.State @@ -27,9 +28,11 @@ import kotlin.math.round fun MangaDexDescription(state: State.Success, openMetadataViewer: () -> Unit) { val context = LocalContext.current // KMK --> - val iconColor = MaterialTheme.colorScheme.primary.toArgb() + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) + val iconColor = colorScheme.iconColor + val ratingBarColor = colorScheme.ratingBarColor + val ratingBarSecondaryColor = colorScheme.ratingBarSecondaryColor val textColor = LocalContentColor.current.toArgb() - val ratingBarSecondaryColor = MaterialTheme.colorScheme.outlineVariant.toArgb() // KMK <-- AndroidView( modifier = Modifier.fillMaxWidth(), @@ -50,7 +53,7 @@ fun MangaDexDescription(state: State.Success, openMetadataViewer: () -> Unit) { binding.rating.isVisible = ratingFloat != null binding.ratingBar.isVisible = ratingFloat != null // KMK --> - binding.ratingBar.supportProgressTintList = ColorStateList.valueOf(iconColor) + binding.ratingBar.supportProgressTintList = ColorStateList.valueOf(ratingBarColor) binding.ratingBar.supportSecondaryProgressTintList = ColorStateList.valueOf(ratingBarSecondaryColor) binding.rating.setTextColor(textColor) diff --git a/app/src/main/java/exh/ui/metadata/adapters/NHentaiDescriptionAdapter.kt b/app/src/main/java/exh/ui/metadata/adapters/NHentaiDescriptionAdapter.kt index dfe2d852d..6719a22e8 100644 --- a/app/src/main/java/exh/ui/metadata/adapters/NHentaiDescriptionAdapter.kt +++ b/app/src/main/java/exh/ui/metadata/adapters/NHentaiDescriptionAdapter.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DescriptionAdapterNhBinding import eu.kanade.tachiyomi.ui.manga.MangaScreenModel.State @@ -30,7 +31,8 @@ import java.time.ZonedDateTime fun NHentaiDescription(state: State.Success, openMetadataViewer: () -> Unit) { val context = LocalContext.current // KMK --> - val iconColor = MaterialTheme.colorScheme.primary.toArgb() + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) + val iconColor = colorScheme.iconColor val textColor = LocalContentColor.current.toArgb() // KMK <-- AndroidView( diff --git a/app/src/main/java/exh/ui/metadata/adapters/PururinDescriptionAdapter.kt b/app/src/main/java/exh/ui/metadata/adapters/PururinDescriptionAdapter.kt index 54feca665..cb324082d 100644 --- a/app/src/main/java/exh/ui/metadata/adapters/PururinDescriptionAdapter.kt +++ b/app/src/main/java/exh/ui/metadata/adapters/PururinDescriptionAdapter.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DescriptionAdapterPuBinding import eu.kanade.tachiyomi.ui.manga.MangaScreenModel.State @@ -28,9 +29,11 @@ import kotlin.math.round fun PururinDescription(state: State.Success, openMetadataViewer: () -> Unit) { val context = LocalContext.current // KMK --> - val iconColor = MaterialTheme.colorScheme.primary.toArgb() + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) + val iconColor = colorScheme.iconColor + val ratingBarColor = colorScheme.ratingBarColor + val ratingBarSecondaryColor = colorScheme.ratingBarSecondaryColor val textColor = LocalContentColor.current.toArgb() - val ratingBarSecondaryColor = MaterialTheme.colorScheme.outlineVariant.toArgb() // KMK <-- AndroidView( modifier = Modifier.fillMaxWidth(), @@ -78,7 +81,7 @@ fun PururinDescription(state: State.Success, openMetadataViewer: () -> Unit) { (round((ratingFloat ?: 0F) * 100.0) / 100.0).toString() + " - " + MetadataUIUtil.getRatingString(context, ratingFloat?.times(2)) // KMK --> - binding.ratingBar.supportProgressTintList = ColorStateList.valueOf(iconColor) + binding.ratingBar.supportProgressTintList = ColorStateList.valueOf(ratingBarColor) binding.ratingBar.supportSecondaryProgressTintList = ColorStateList.valueOf(ratingBarSecondaryColor) binding.rating.setTextColor(textColor) diff --git a/app/src/main/java/exh/ui/metadata/adapters/TsuminoDescriptionAdapter.kt b/app/src/main/java/exh/ui/metadata/adapters/TsuminoDescriptionAdapter.kt index 97cdf0681..bf14c5c4c 100644 --- a/app/src/main/java/exh/ui/metadata/adapters/TsuminoDescriptionAdapter.kt +++ b/app/src/main/java/exh/ui/metadata/adapters/TsuminoDescriptionAdapter.kt @@ -11,6 +11,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView +import eu.kanade.presentation.theme.colorscheme.AndroidViewColorScheme import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.databinding.DescriptionAdapterTsBinding import eu.kanade.tachiyomi.ui.manga.MangaScreenModel.State @@ -29,9 +30,11 @@ import kotlin.math.round fun TsuminoDescription(state: State.Success, openMetadataViewer: () -> Unit) { val context = LocalContext.current // KMK --> - val iconColor = MaterialTheme.colorScheme.primary.toArgb() + val colorScheme = AndroidViewColorScheme(MaterialTheme.colorScheme) + val iconColor = colorScheme.iconColor + val ratingBarColor = colorScheme.ratingBarColor + val ratingBarSecondaryColor = colorScheme.ratingBarSecondaryColor val textColor = LocalContentColor.current.toArgb() - val ratingBarSecondaryColor = MaterialTheme.colorScheme.outlineVariant.toArgb() // KMK <-- AndroidView( modifier = Modifier.fillMaxWidth(), @@ -81,7 +84,7 @@ fun TsuminoDescription(state: State.Success, openMetadataViewer: () -> Unit) { (round((meta.averageRating ?: 0F) * 100.0) / 100.0).toString() + " - " + MetadataUIUtil.getRatingString(context, meta.averageRating?.times(2)) // KMK --> - binding.ratingBar.supportProgressTintList = ColorStateList.valueOf(iconColor) + binding.ratingBar.supportProgressTintList = ColorStateList.valueOf(ratingBarColor) binding.ratingBar.supportSecondaryProgressTintList = ColorStateList.valueOf(ratingBarSecondaryColor) binding.rating.setTextColor(textColor) diff --git a/app/src/main/res/layout/download_header.xml b/app/src/main/res/layout/download_header.xml index 306f46174..65c2b57e9 100644 --- a/app/src/main/res/layout/download_header.xml +++ b/app/src/main/res/layout/download_header.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" - app:cardBackgroundColor="?android:attr/colorBackground" + app:cardBackgroundColor="@android:color/transparent" app:cardElevation="0dp" app:cardForegroundColor="@color/draggable_card_foreground"> diff --git a/app/src/main/res/layout/download_item.xml b/app/src/main/res/layout/download_item.xml index 92df1c370..ab4c6ef59 100644 --- a/app/src/main/res/layout/download_item.xml +++ b/app/src/main/res/layout/download_item.xml @@ -5,7 +5,7 @@ android:id="@+id/container" android:layout_width="match_parent" android:layout_height="wrap_content" - app:cardBackgroundColor="?android:attr/colorBackground" + app:cardBackgroundColor="@android:color/transparent" app:cardElevation="0dp" app:cardForegroundColor="@color/draggable_card_foreground"> diff --git a/app/src/main/res/layout/edit_merged_settings_header.xml b/app/src/main/res/layout/edit_merged_settings_header.xml index e069364b0..b310558c5 100644 --- a/app/src/main/res/layout/edit_merged_settings_header.xml +++ b/app/src/main/res/layout/edit_merged_settings_header.xml @@ -13,6 +13,7 @@ android:layout_gravity="center_horizontal"> + - + - + - - - - - + diff --git a/app/src/main/res/layout/edit_merged_settings_item.xml b/app/src/main/res/layout/edit_merged_settings_item.xml index f5352e73f..1a0fff420 100644 --- a/app/src/main/res/layout/edit_merged_settings_item.xml +++ b/app/src/main/res/layout/edit_merged_settings_item.xml @@ -5,7 +5,8 @@ android:id="@+id/holder" android:layout_width="match_parent" android:layout_height="wrap_content" - app:cardBackgroundColor="?android:attr/colorBackground" + android:layout_marginVertical="4dp" + app:cardBackgroundColor="@android:color/transparent" app:cardElevation="0dp" app:cardForegroundColor="@color/draggable_card_foreground"> @@ -16,38 +17,37 @@ + + - - - + app:srcCompat="@drawable/ic_delete_24dp" /> + app:srcCompat="@drawable/ic_get_app_24dp" /> + app:srcCompat="@drawable/ic_sync_24dp" /> diff --git a/app/src/main/res/layout/migration_source_item.xml b/app/src/main/res/layout/migration_source_item.xml index fd9503f77..c90a1eb80 100644 --- a/app/src/main/res/layout/migration_source_item.xml +++ b/app/src/main/res/layout/migration_source_item.xml @@ -2,6 +2,7 @@