diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt b/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt index a3fe1b070..919abc2a5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt +++ b/app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt @@ -253,9 +253,21 @@ fun TextInputLayout.setErrorString(error: String) { @BindingAdapter("onSelectClick", "onSelectReset", requireAll = false) fun View.setOnSelectClickListener(listener: View.OnClickListener, resetTime: Long) { + + fun getHideTarget() = (parent as? ViewGroup)?.findViewWithTag(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 { when { it.isSelected -> { + animateVisibility(false) listener.onClick(it) (it.tag as? Runnable)?.let { task -> it.handler.removeCallbacks(task) @@ -263,8 +275,10 @@ fun View.setOnSelectClickListener(listener: View.OnClickListener, resetTime: Lon it.isSelected = false } else -> { + animateVisibility(true) it.isSelected = true it.tag = it.postDelayed(resetTime) { + animateVisibility(false) it.tag = null it.isSelected = false } diff --git a/app/src/main/res/layout/fragment_home_md2.xml b/app/src/main/res/layout/fragment_home_md2.xml index 5c922ea50..023cec564 100644 --- a/app/src/main/res/layout/fragment_home_md2.xml +++ b/app/src/main/res/layout/fragment_home_md2.xml @@ -334,6 +334,15 @@ app:srcCompat="@drawable/ic_magisk_delete" app:tint="@color/color_primary_error_transient" /> + + +