replace vibration with haptic feedback at the pin tab
This commit is contained in:
parent
4d9d9ff461
commit
bbd06e8598
2 changed files with 16 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.simplemobiletools.commons.extensions
|
||||
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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…
Reference in a new issue