fix: make InstallOptions serializable
This commit is contained in:
parent
932c583f9e
commit
e2c9472ce8
3 changed files with 51 additions and 10 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
package com.aliucord.manager.ui.screens.install
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
|
|
@ -30,9 +31,13 @@ import com.aliucord.manager.ui.components.back
|
|||
import com.aliucord.manager.ui.components.dialogs.InstallerAbortDialog
|
||||
import com.aliucord.manager.ui.screens.install.components.*
|
||||
import com.aliucord.manager.ui.screens.installopts.InstallOptions
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.koin.core.parameter.parametersOf
|
||||
|
||||
class InstallScreen(private val data: InstallOptions) : Screen {
|
||||
@Parcelize
|
||||
class InstallScreen(private val data: InstallOptions) : Screen, Parcelable {
|
||||
@IgnoredOnParcel
|
||||
override val key = "Install"
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
package com.aliucord.manager.ui.screens.installopts
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.aliucord.manager.util.ColorParceler
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.parcelize.TypeParceler
|
||||
|
||||
@Immutable
|
||||
@Parcelize
|
||||
data class InstallOptions(
|
||||
/**
|
||||
* The app name that's user-facing in launchers.
|
||||
|
|
@ -30,25 +35,39 @@ data class InstallOptions(
|
|||
* This is independent of [InstallOptions.iconReplacement]
|
||||
*/
|
||||
val monochromeIcon: Boolean,
|
||||
) {
|
||||
) : Parcelable {
|
||||
@Immutable
|
||||
sealed interface IconReplacement {
|
||||
@Parcelize
|
||||
sealed interface IconReplacement : Parcelable {
|
||||
/**
|
||||
* Keeps the original icons that are present in the APK.
|
||||
*/
|
||||
@Immutable
|
||||
@Parcelize
|
||||
data object Original : IconReplacement
|
||||
|
||||
/**
|
||||
* Replaces the foreground image of the icon entirely and sets the background to transparent.
|
||||
* This does not affect the monochrome icon.
|
||||
*/
|
||||
data class CustomImage(val imageBytes: ByteArray) : IconReplacement
|
||||
|
||||
/**
|
||||
* Changes the background of the icon to a specific color without
|
||||
* altering the foreground or monochrome variants.
|
||||
*/
|
||||
data class CustomColor(val color: Color) : IconReplacement
|
||||
@Immutable
|
||||
@Parcelize
|
||||
data class CustomColor(
|
||||
@TypeParceler<Color, ColorParceler>
|
||||
val color: Color,
|
||||
) : IconReplacement
|
||||
|
||||
/**
|
||||
* Replaces the foreground image of the icon entirely and sets the background to transparent.
|
||||
* This does not affect the monochrome icon.
|
||||
*/
|
||||
@Immutable
|
||||
@Parcelize
|
||||
data class CustomImage(val imageBytes: ByteArray) : IconReplacement {
|
||||
override fun hashCode() = imageBytes.contentHashCode()
|
||||
override fun equals(other: Any?) = this === other
|
||||
|| (javaClass == other?.javaClass && imageBytes.contentEquals((other as CustomImage).imageBytes))
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.aliucord.manager.util
|
||||
|
||||
import android.os.Parcel
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import kotlinx.parcelize.Parceler
|
||||
|
||||
/**
|
||||
* Parcelize Compose [Color] for reading and writing in ARGB representation for the sRGB color space.
|
||||
*/
|
||||
object ColorParceler : Parceler<Color> {
|
||||
override fun create(parcel: Parcel): Color =
|
||||
Color(parcel.readInt())
|
||||
|
||||
override fun Color.write(parcel: Parcel, flags: Int) =
|
||||
parcel.writeInt(toArgb())
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue