Loading commons/src/main/kotlin/com/simplemobiletools/commons/extensions/View.kt +12 −3 Original line number Diff line number Diff line package com.simplemobiletools.commons.extensions import android.view.HapticFeedbackConstants import android.view.View import android.view.ViewTreeObserver Loading @@ -9,11 +10,17 @@ fun View.beVisibleIf(beVisible: Boolean) = if (beVisible) beVisible() else beGon fun View.beGoneIf(beGone: Boolean) = beVisibleIf(!beGone) fun View.beInvisible() { visibility = View.INVISIBLE } fun View.beInvisible() { visibility = View.INVISIBLE } fun View.beVisible() { visibility = View.VISIBLE } fun View.beVisible() { visibility = View.VISIBLE } fun View.beGone() { visibility = View.GONE } fun View.beGone() { visibility = View.GONE } fun View.onGlobalLayout(callback: () -> Unit) { viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { Loading @@ -29,3 +36,5 @@ fun View.isVisible() = visibility == View.VISIBLE fun View.isInvisible() = visibility == View.INVISIBLE fun View.isGone() = visibility == View.GONE fun View.performHapticFeedback() = performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) commons/src/main/kotlin/com/simplemobiletools/commons/views/PinTab.kt +4 −6 Original line number Diff line number Diff line Loading @@ -2,11 +2,11 @@ package com.simplemobiletools.commons.views import android.content.Context import android.graphics.PorterDuff import android.os.Vibrator import android.util.AttributeSet import android.widget.RelativeLayout import com.simplemobiletools.commons.R import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.extensions.performHapticFeedback import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.helpers.PROTECTION_PIN Loading Loading @@ -52,12 +52,8 @@ class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, at if (pin.length < 10) { pin += number updatePinCode() val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator if (vibrator.hasVibrator()) { vibrator.vibrate(100) } } performHapticFeedback() } private fun clear() { Loading @@ -65,6 +61,7 @@ class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, at pin = pin.substring(0, pin.length - 1) updatePinCode() } performHapticFeedback() } private fun confirmPIN() { Loading @@ -85,6 +82,7 @@ class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, at pin_lock_title.setText(R.string.enter_pin) } } performHapticFeedback() } private fun resetPin() { Loading Loading
commons/src/main/kotlin/com/simplemobiletools/commons/extensions/View.kt +12 −3 Original line number Diff line number Diff line package com.simplemobiletools.commons.extensions import android.view.HapticFeedbackConstants import android.view.View import android.view.ViewTreeObserver Loading @@ -9,11 +10,17 @@ fun View.beVisibleIf(beVisible: Boolean) = if (beVisible) beVisible() else beGon fun View.beGoneIf(beGone: Boolean) = beVisibleIf(!beGone) fun View.beInvisible() { visibility = View.INVISIBLE } fun View.beInvisible() { visibility = View.INVISIBLE } fun View.beVisible() { visibility = View.VISIBLE } fun View.beVisible() { visibility = View.VISIBLE } fun View.beGone() { visibility = View.GONE } fun View.beGone() { visibility = View.GONE } fun View.onGlobalLayout(callback: () -> Unit) { viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { Loading @@ -29,3 +36,5 @@ fun View.isVisible() = visibility == View.VISIBLE fun View.isInvisible() = visibility == View.INVISIBLE fun View.isGone() = visibility == View.GONE fun View.performHapticFeedback() = performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
commons/src/main/kotlin/com/simplemobiletools/commons/views/PinTab.kt +4 −6 Original line number Diff line number Diff line Loading @@ -2,11 +2,11 @@ package com.simplemobiletools.commons.views import android.content.Context import android.graphics.PorterDuff import android.os.Vibrator import android.util.AttributeSet import android.widget.RelativeLayout import com.simplemobiletools.commons.R import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.extensions.performHapticFeedback import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.helpers.PROTECTION_PIN Loading Loading @@ -52,12 +52,8 @@ class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, at if (pin.length < 10) { pin += number updatePinCode() val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator if (vibrator.hasVibrator()) { vibrator.vibrate(100) } } performHapticFeedback() } private fun clear() { Loading @@ -65,6 +61,7 @@ class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, at pin = pin.substring(0, pin.length - 1) updatePinCode() } performHapticFeedback() } private fun confirmPIN() { Loading @@ -85,6 +82,7 @@ class PinTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, at pin_lock_title.setText(R.string.enter_pin) } } performHapticFeedback() } private fun resetPin() { Loading