From 6a2acbe92928545c9077df47fcc6ae2c60aca5d7 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Mon, 6 Jan 2020 19:31:06 +0100 Subject: [PATCH] Added tiny hint that magisk can be uninstalled using the icon --- .../topjohnwu/magisk/utils/DataBindingAdapters.kt | 14 ++++++++++++++ app/src/main/res/layout/fragment_home_md2.xml | 9 +++++++++ app/src/main/res/values/ids.xml | 1 + 3 files changed, 24 insertions(+) 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" /> + + +