You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Added (partially) settings screen
Most importantly added design and functionality backing for these items
This commit is contained in:
@@ -296,18 +296,24 @@ fun TextSwitcher.setTextBinding(text: CharSequence) {
|
||||
"android:layout_marginTop",
|
||||
"android:layout_marginRight",
|
||||
"android:layout_marginBottom",
|
||||
"android:layout_marginStart",
|
||||
"android:layout_marginEnd",
|
||||
requireAll = false
|
||||
)
|
||||
fun View.setMargins(
|
||||
marginLeft: Int?,
|
||||
marginTop: Int?,
|
||||
marginRight: Int?,
|
||||
marginBottom: Int?
|
||||
marginBottom: Int?,
|
||||
marginStart: Int?,
|
||||
marginEnd: Int?
|
||||
) = updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
marginLeft?.let { leftMargin = it }
|
||||
marginTop?.let { topMargin = it }
|
||||
marginRight?.let { rightMargin = it }
|
||||
marginBottom?.let { bottomMargin = it }
|
||||
marginStart?.let { this.marginStart = it }
|
||||
marginEnd?.let { this.marginEnd = it }
|
||||
}
|
||||
|
||||
@BindingAdapter("nestedScrollingEnabled")
|
||||
@@ -455,9 +461,4 @@ fun View.setRotationNotAnimated(rotation: Int) {
|
||||
@BindingAdapter("android:text")
|
||||
fun TextView.setTextSafe(text: Int) {
|
||||
if (text == 0) this.text = null else setText(text)
|
||||
}
|
||||
|
||||
@BindingAdapter("android:theme")
|
||||
fun View.setThemeCompat(theme: Int) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.BindingAdapter
|
||||
import androidx.databinding.InverseBindingAdapter
|
||||
|
||||
sealed class TransitiveText {
|
||||
|
||||
abstract val isEmpty: Boolean
|
||||
abstract fun getText(resources: Resources): CharSequence
|
||||
|
||||
// ---
|
||||
|
||||
class String(
|
||||
private val value: CharSequence
|
||||
) : TransitiveText() {
|
||||
|
||||
override val isEmpty = value.isEmpty()
|
||||
override fun getText(resources: Resources) = value
|
||||
|
||||
}
|
||||
|
||||
class Res(
|
||||
private val value: Int,
|
||||
private vararg val params: Any
|
||||
) : TransitiveText() {
|
||||
|
||||
override val isEmpty = value == 0
|
||||
override fun getText(resources: Resources) =
|
||||
resources.getString(value, *params)
|
||||
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
companion object {
|
||||
val empty = String("")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun Int.asTransitive(vararg params: Any) = TransitiveText.Res(this, *params)
|
||||
fun CharSequence.asTransitive() = TransitiveText.String(this)
|
||||
|
||||
|
||||
@BindingAdapter("android:text")
|
||||
fun TextView.setText(text: TransitiveText) {
|
||||
this.text = text.getText(resources)
|
||||
}
|
||||
|
||||
@InverseBindingAdapter(attribute = "android:text", event = "android:textAttrChanged")
|
||||
fun TextView.getTransitiveText() = text.asTransitive()
|
||||
Reference in New Issue
Block a user