Minor cleanups

Pulling out some of the smaller changes that aren't related to the manga controller changes in #7244

(cherry picked from commit 7fdbf40cd2)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/MigrationFlags.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersSettingsSheet.kt
This commit is contained in:
arkon
2022-06-04 16:01:49 -04:00
committed by Jobobby04
parent 44ea254f52
commit 571d1f29ca
25 changed files with 82 additions and 63 deletions
@@ -4,9 +4,11 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.platform.LocalLayoutDirection
@Composable
@ReadOnlyComposable
operator fun PaddingValues.plus(other: PaddingValues): PaddingValues {
val layoutDirection = LocalLayoutDirection.current
return PaddingValues(
@@ -4,6 +4,8 @@ import android.content.res.Resources
import androidx.annotation.DrawableRes
import androidx.annotation.PluralsRes
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.platform.LocalContext
@@ -18,6 +20,7 @@ import androidx.core.graphics.drawable.toBitmap
* @return the string data associated with the resource
*/
@Composable
@ReadOnlyComposable
fun quantityStringResource(@PluralsRes id: Int, quantity: Int): String {
val context = LocalContext.current
return context.resources.getQuantityString(id, quantity, quantity)
@@ -32,6 +35,7 @@ fun quantityStringResource(@PluralsRes id: Int, quantity: Int): String {
* @return the string data associated with the resource
*/
@Composable
@ReadOnlyComposable
fun quantityStringResource(@PluralsRes id: Int, quantity: Int, vararg formatArgs: Any): String {
val context = LocalContext.current
return context.resources.getQuantityString(id, quantity, *formatArgs)
@@ -46,9 +50,11 @@ fun quantityStringResource(@PluralsRes id: Int, quantity: Int, vararg formatArgs
* @return the bitmap associated with the resource
*/
@Composable
fun bitmapPainterResource(@DrawableRes id: Int): BitmapPainter {
fun rememberResourceBitmapPainter(@DrawableRes id: Int): BitmapPainter {
val context = LocalContext.current
val drawable = ContextCompat.getDrawable(context, id)
?: throw Resources.NotFoundException()
return BitmapPainter(drawable.toBitmap().asImageBitmap())
return remember(id) {
val drawable = ContextCompat.getDrawable(context, id)
?: throw Resources.NotFoundException()
BitmapPainter(drawable.toBitmap().asImageBitmap())
}
}