-
-
Notifications
You must be signed in to change notification settings - Fork 153
Improved vibration feedback on both ACTION_DOWN and ACTION_UP #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
190348b
8c2de6c
d62fbb6
d5b131a
1e7903d
ee8cb5c
91bbfb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -13,6 +13,8 @@ import android.text.Editable | |||
import android.text.TextWatcher | ||||
import android.view.HapticFeedbackConstants | ||||
import android.view.MenuItem | ||||
import android.view.MotionEvent | ||||
|
||||
import android.view.View | ||||
import android.view.WindowManager | ||||
import android.view.accessibility.AccessibilityEvent | ||||
|
@@ -103,6 +105,7 @@ class MainActivity : AppCompatActivity() { | |||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | ||||
) | ||||
|
||||
|
||||
// Themes | ||||
val themes = Themes(this) | ||||
themes.applyDayNightOverride() | ||||
|
@@ -121,6 +124,9 @@ class MainActivity : AppCompatActivity() { | |||
|
||||
setContentView(view) | ||||
|
||||
// set buttons on touch listener to get feedback vibration on touch | ||||
setupButtonTouchListeners() | ||||
|
||||
// Disable the keyboard on display EditText | ||||
binding.input.showSoftInputOnFocus = false | ||||
|
||||
|
@@ -349,6 +355,55 @@ class MainActivity : AppCompatActivity() { | |||
} | ||||
} | ||||
|
||||
private fun setupButtonTouchListeners() { | ||||
applyVibrationToKey(binding.squareButton) | ||||
applyVibrationToKey(binding.piButton) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate call to applyVibrationToKey(binding.piButton). This button is configured twice on lines 330 and 334.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
applyVibrationToKey(binding.exponentButton) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate call to applyVibrationToKey(binding.exponentButton). This button is configured twice on lines 331 and 335.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
applyVibrationToKey(binding.factorialButton) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate call to applyVibrationToKey(binding.factorialButton). This button is configured twice on lines 332 and 336.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
applyVibrationToKey(binding.degreeButton) | ||||
applyVibrationToKey(binding.sineButton) | ||||
applyVibrationToKey(binding.cosineButton) | ||||
applyVibrationToKey(binding.tangentButton) | ||||
applyVibrationToKey(binding.invButton) | ||||
applyVibrationToKey(binding.eButton) | ||||
applyVibrationToKey(binding.naturalLogarithmButton) | ||||
applyVibrationToKey(binding.logarithmButton) | ||||
binding.log2Button?.let { applyVibrationToKey(it) } | ||||
applyVibrationToKey(binding.clearButton) | ||||
applyVibrationToKey(binding.leftParenthesisButton) | ||||
applyVibrationToKey(binding.rightParenthesisButton) | ||||
applyVibrationToKey(binding.parenthesesButton) | ||||
applyVibrationToKey(binding.divideBy100Button) | ||||
applyVibrationToKey(binding.divideButton) | ||||
applyVibrationToKey(binding.sevenButton) | ||||
applyVibrationToKey(binding.eightButton) | ||||
applyVibrationToKey(binding.nineButton) | ||||
applyVibrationToKey(binding.multiplyButton) | ||||
applyVibrationToKey(binding.fourButton) | ||||
applyVibrationToKey(binding.fiveButton) | ||||
applyVibrationToKey(binding.sixButton) | ||||
applyVibrationToKey(binding.subtractButton) | ||||
applyVibrationToKey(binding.oneButton) | ||||
applyVibrationToKey(binding.twoButton) | ||||
applyVibrationToKey(binding.threeButton) | ||||
applyVibrationToKey(binding.addButton) | ||||
applyVibrationToKey(binding.zeroButton) | ||||
applyVibrationToKey(binding.pointButton) | ||||
applyVibrationToKey(binding.backspaceButton) | ||||
applyVibrationToKey(binding.equalsButton) | ||||
|
||||
} | ||||
|
||||
private fun applyVibrationToKey(button: View) { | ||||
button.setOnTouchListener { v, event -> | ||||
if (event.action == MotionEvent.ACTION_DOWN) { | ||||
keyVibration(v) | ||||
} | ||||
false // return false to allow normal click to continue | ||||
} | ||||
} | ||||
|
||||
|
||||
// Displays a popup menu with options to insert double zeros ("00") or triple zeros ("000") into the specified EditText when the zero button is long-pressed. | ||||
private fun showPopupMenu(zeroButton: Button) { | ||||
val popupMenu = PopupMenu(this, zeroButton) | ||||
|
@@ -1384,6 +1439,7 @@ class MainActivity : AppCompatActivity() { | |||
val canShowOnLockScreen = MyPreferences(this).showOnLockScreen | ||||
handleOnLockScreenAppStatus(canShowOnLockScreen) | ||||
} | ||||
} | ||||
|
||||
fun checkEmptyHistoryForNoHistoryLabel() { | ||||
if (historyAdapter.itemCount==0) { | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate call to applyVibrationToKey(binding.squareButton). This button is configured twice on lines 329 and 333.
Copilot uses AI. Check for mistakes.