Added tiny hint that magisk can be uninstalled using the icon

This commit is contained in:
Viktor De Pasquale 2020-01-06 19:31:06 +01:00
parent 4cfff40475
commit 6a2acbe929
3 changed files with 24 additions and 0 deletions

View File

@ -253,9 +253,21 @@ fun TextInputLayout.setErrorString(error: String) {
@BindingAdapter("onSelectClick", "onSelectReset", requireAll = false) @BindingAdapter("onSelectClick", "onSelectReset", requireAll = false)
fun View.setOnSelectClickListener(listener: View.OnClickListener, resetTime: Long) { fun View.setOnSelectClickListener(listener: View.OnClickListener, resetTime: Long) {
fun getHideTarget() = (parent as? ViewGroup)?.findViewWithTag<View>(R.id.hideWhenSelected)
fun animateVisibility(hide: Boolean, target: View? = getHideTarget()) {
target ?: return
val targetScale = if (hide) 0f else 1f
target.animate()
.scaleY(targetScale)
.scaleX(targetScale)
.start()
}
setOnClickListener { setOnClickListener {
when { when {
it.isSelected -> { it.isSelected -> {
animateVisibility(false)
listener.onClick(it) listener.onClick(it)
(it.tag as? Runnable)?.let { task -> (it.tag as? Runnable)?.let { task ->
it.handler.removeCallbacks(task) it.handler.removeCallbacks(task)
@ -263,8 +275,10 @@ fun View.setOnSelectClickListener(listener: View.OnClickListener, resetTime: Lon
it.isSelected = false it.isSelected = false
} }
else -> { else -> {
animateVisibility(true)
it.isSelected = true it.isSelected = true
it.tag = it.postDelayed(resetTime) { it.tag = it.postDelayed(resetTime) {
animateVisibility(false)
it.tag = null it.tag = null
it.isSelected = false it.isSelected = false
} }

View File

@ -334,6 +334,15 @@
app:srcCompat="@drawable/ic_magisk_delete" app:srcCompat="@drawable/ic_magisk_delete"
app:tint="@color/color_primary_error_transient" /> app:tint="@color/color_primary_error_transient" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="@dimen/l1"
android:layout_height="@dimen/l1"
android:tag="@{@id/hideWhenSelected}"
app:layout_constraintEnd_toEndOf="@+id/home_magisk_icon"
app:layout_constraintTop_toTopOf="@+id/home_magisk_icon"
app:srcCompat="@drawable/ic_delete_md2"
app:tint="?colorPrimary" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/home_magisk_title" android:id="@+id/home_magisk_title"
android:layout_width="0dp" android:layout_width="0dp"

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<item name="hideWhenSelected" type="id" />
<item name="recyclerScrollListener" type="id" /> <item name="recyclerScrollListener" type="id" />
<item name="revealAnim" type="id" /> <item name="revealAnim" type="id" />