Merge code

This commit is contained in:
2022-03-28 13:57:32 +08:00
parent efabb726ba
commit cfb0c06a6a
2 changed files with 6 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ import android.util.AttributeSet
import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.SwitchCompat
import com.fankes.coloros.notify.utils.drawable.drawabletoolbox.DrawableBuilder import com.fankes.coloros.notify.utils.drawable.drawabletoolbox.DrawableBuilder
import com.fankes.coloros.notify.utils.factory.dp import com.fankes.coloros.notify.utils.factory.dp
import com.fankes.coloros.notify.utils.factory.isSystemInDarkMode
class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(context, attrs) { class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(context, attrs) {
@@ -44,6 +45,8 @@ class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(cont
return ColorStateList(states, colors) return ColorStateList(states, colors)
} }
private val thumbColor get() = if (isSystemInDarkMode) 0xFF7C7C7C else 0xFFCCCCCC
init { init {
trackDrawable = DrawableBuilder() trackDrawable = DrawableBuilder()
.rectangle() .rectangle()
@@ -63,8 +66,8 @@ class MaterialSwitch(context: Context, attrs: AttributeSet?) : SwitchCompat(cont
.build() .build()
trackTintList = toColors( trackTintList = toColors(
0xFF656565.toInt(), 0xFF656565.toInt(),
0xFFCCCCCC.toInt(), thumbColor.toInt(),
0xFFCCCCCC.toInt() thumbColor.toInt()
) )
isSingleLine = true isSingleLine = true
ellipsize = TextUtils.TruncateAt.END ellipsize = TextUtils.TruncateAt.END

View File

@@ -360,7 +360,7 @@ inline fun <reified T : Activity> Service.navigate() =
fun Context.snake(msg: String, actionText: String = "", it: () -> Unit = {}) = fun Context.snake(msg: String, actionText: String = "", it: () -> Unit = {}) =
Snackbar.make((this as Activity).findViewById(android.R.id.content), msg, Snackbar.LENGTH_LONG).apply { Snackbar.make((this as Activity).findViewById(android.R.id.content), msg, Snackbar.LENGTH_LONG).apply {
if (actionText.isBlank()) return@apply if (actionText.isBlank()) return@apply
setActionTextColor(Color.WHITE) setActionTextColor(if (isSystemInDarkMode) Color.BLACK else Color.WHITE)
setAction(actionText) { it() } setAction(actionText) { it() }
}.show() }.show()