mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-10 05:22:07 +00:00
Updated flash screen with new arch
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
@@ -9,10 +10,15 @@ import androidx.databinding.BindingAdapter
|
||||
import androidx.databinding.InverseBindingAdapter
|
||||
import androidx.databinding.InverseBindingListener
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
import com.skoumal.teanity.extensions.subscribeK
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.model.entity.state.IndeterminateState
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
@BindingAdapter("onNavigationClick")
|
||||
@@ -80,4 +86,28 @@ fun setPositionChangedListener(view: ViewPager, listener: InverseBindingListener
|
||||
positionOffsetPixels: Int
|
||||
) = listener.onChange()
|
||||
})
|
||||
}
|
||||
|
||||
@BindingAdapter("invisibleScale")
|
||||
fun setInvisibleWithScale(view: View, isInvisible: Boolean) {
|
||||
view.animate()
|
||||
.scaleX(if (isInvisible) 0f else 1f)
|
||||
.scaleY(if (isInvisible) 0f else 1f)
|
||||
.setInterpolator(FastOutSlowInInterpolator())
|
||||
.start()
|
||||
}
|
||||
|
||||
@BindingAdapter("movieBehavior", "movieBehaviorText")
|
||||
fun setMovieBehavior(view: TextView, isMovieBehavior: Boolean, text: String) {
|
||||
(view.tag as? Disposable)?.dispose()
|
||||
if (isMovieBehavior) {
|
||||
val observer = Observable
|
||||
.interval(150, TimeUnit.MILLISECONDS)
|
||||
.subscribeK {
|
||||
view.text = text.replaceRandomWithSpecial()
|
||||
}
|
||||
view.tag = observer
|
||||
} else {
|
||||
view.text = text
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,49 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import androidx.databinding.ObservableList
|
||||
import com.skoumal.teanity.extensions.subscribeK
|
||||
import com.skoumal.teanity.util.DiffObservableList
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
fun <T> MutableList<T>.update(newList: List<T>) {
|
||||
clear()
|
||||
addAll(newList)
|
||||
}
|
||||
|
||||
fun <T1, T2> ObservableList<T1>.sendUpdatesTo(
|
||||
target: DiffObservableList<T2>,
|
||||
mapper: (List<T1>) -> List<T2>
|
||||
) {
|
||||
addOnListChangedCallback(object :
|
||||
ObservableList.OnListChangedCallback<ObservableList<T1>>() {
|
||||
override fun onChanged(sender: ObservableList<T1>?) {
|
||||
updateAsync(sender ?: return)
|
||||
}
|
||||
|
||||
override fun onItemRangeRemoved(sender: ObservableList<T1>?, p0: Int, p1: Int) {
|
||||
updateAsync(sender ?: return)
|
||||
}
|
||||
|
||||
override fun onItemRangeMoved(sender: ObservableList<T1>?, p0: Int, p1: Int, p2: Int) {
|
||||
updateAsync(sender ?: return)
|
||||
}
|
||||
|
||||
override fun onItemRangeInserted(sender: ObservableList<T1>?, p0: Int, p1: Int) {
|
||||
updateAsync(sender ?: return)
|
||||
}
|
||||
|
||||
override fun onItemRangeChanged(sender: ObservableList<T1>?, p0: Int, p1: Int) {
|
||||
updateAsync(sender ?: return)
|
||||
}
|
||||
|
||||
private var updater: Disposable? = null
|
||||
|
||||
private fun updateAsync(sender: List<T1>) {
|
||||
updater?.dispose()
|
||||
updater = sender.toSingle()
|
||||
.map { mapper(it) }
|
||||
.map { it to target.calculateDiff(it) }
|
||||
.subscribeK { target.update(it.first, it.second) }
|
||||
}
|
||||
})
|
||||
}
|
||||
11
app/src/main/java/com/topjohnwu/magisk/utils/XString.kt
Normal file
11
app/src/main/java/com/topjohnwu/magisk/utils/XString.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
val specialChars = arrayOf('!', '@', '#', '$', '%', '&', '?')
|
||||
|
||||
fun String.replaceRandomWithSpecial(): String {
|
||||
var random: Char
|
||||
do {
|
||||
random = random()
|
||||
} while (random == '.')
|
||||
return replace(random, specialChars.random())
|
||||
}
|
||||
18
app/src/main/java/com/topjohnwu/magisk/utils/XTime.kt
Normal file
18
app/src/main/java/com/topjohnwu/magisk/utils/XTime.kt
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
val now get() = System.currentTimeMillis()
|
||||
|
||||
fun Long.toTime(format: SimpleDateFormat) = format.format(this).orEmpty()
|
||||
fun String.toTime(format: SimpleDateFormat) = try {
|
||||
format.parse(this)?.time ?: -1
|
||||
} catch (e: ParseException) {
|
||||
-1L
|
||||
}
|
||||
|
||||
private val locale get() = Locale.getDefault()
|
||||
val timeFormatFull by lazy { SimpleDateFormat("YYYY/MM/DD_HH:mm:ss", locale) }
|
||||
val timeFormatStandard by lazy { SimpleDateFormat("YYYY-MM-DD'T'HH:mm:ss'Z'", locale) }
|
||||
Reference in New Issue
Block a user