Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -103,6 +105,7 @@ class MainActivity : AppCompatActivity() {
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
)


// Themes
val themes = Themes(this)
themes.applyDayNightOverride()
Expand All @@ -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

Expand Down Expand Up @@ -349,6 +355,55 @@ class MainActivity : AppCompatActivity() {
}
}

private fun setupButtonTouchListeners() {
applyVibrationToKey(binding.squareButton)
Copy link
Preview

Copilot AI Jul 18, 2025

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.

Suggested change
applyVibrationToKey(binding.squareButton)

Copilot uses AI. Check for mistakes.

applyVibrationToKey(binding.piButton)
Copy link
Preview

Copilot AI Jul 18, 2025

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.piButton). This button is configured twice on lines 330 and 334.

Suggested change
applyVibrationToKey(binding.piButton)

Copilot uses AI. Check for mistakes.

applyVibrationToKey(binding.exponentButton)
Copy link
Preview

Copilot AI Jul 18, 2025

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.exponentButton). This button is configured twice on lines 331 and 335.

Suggested change
applyVibrationToKey(binding.exponentButton)

Copilot uses AI. Check for mistakes.

applyVibrationToKey(binding.factorialButton)
Copy link
Preview

Copilot AI Jul 18, 2025

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.factorialButton). This button is configured twice on lines 332 and 336.

Suggested change
applyVibrationToKey(binding.factorialButton)

Copilot uses AI. Check for mistakes.

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)
Expand Down Expand Up @@ -1384,6 +1439,7 @@ class MainActivity : AppCompatActivity() {
val canShowOnLockScreen = MyPreferences(this).showOnLockScreen
handleOnLockScreenAppStatus(canShowOnLockScreen)
}
}

fun checkEmptyHistoryForNoHistoryLabel() {
if (historyAdapter.itemCount==0) {
Expand Down