diff --git a/app/src/main/java/be/scri/extensions/ContextStyling.kt b/app/src/main/java/be/scri/extensions/ContextStyling.kt index c7e5e8d..95923bb 100644 --- a/app/src/main/java/be/scri/extensions/ContextStyling.kt +++ b/app/src/main/java/be/scri/extensions/ContextStyling.kt @@ -6,7 +6,7 @@ import android.graphics.Color import be.scri.R import be.scri.helpers.DARK_GREY -// handle system default theme (Material You) specially as the color is taken from the system, not hardcoded by us +// Handle system default theme (Material You) specially as the color is taken from the system, not hardcoded by us. fun Context.getProperTextColor() = if (baseConfig.isUsingSystemTheme) { resources.getColor(R.color.you_neutral_text_color, theme) diff --git a/app/src/main/java/be/scri/extensions/Int.kt b/app/src/main/java/be/scri/extensions/Int.kt index c97013d..2827164 100644 --- a/app/src/main/java/be/scri/extensions/Int.kt +++ b/app/src/main/java/be/scri/extensions/Int.kt @@ -30,7 +30,7 @@ fun Int.adjustAlpha(factor: Float): Int { fun ClosedRange.random() = Random().nextInt(endInclusive - start) + start -// taken from https://stackoverflow.com/a/40964456/1967672 +// Taken from https://stackoverflow.com/a/40964456/1967672. private const val HSV_COMPONENT_COUNT = 3 private const val DEFAULT_DARKEN_FACTOR = 8 private const val FACTOR_DIVIDER = 100 diff --git a/app/src/main/java/be/scri/helpers/AlphanumericComparator.kt b/app/src/main/java/be/scri/helpers/AlphanumericComparator.kt index a027a82..987416e 100644 --- a/app/src/main/java/be/scri/helpers/AlphanumericComparator.kt +++ b/app/src/main/java/be/scri/helpers/AlphanumericComparator.kt @@ -1,7 +1,7 @@ package be.scri.helpers -// taken from https://gist.github.com/MichaelRocks/1b94bb44c7804e999dbf31dac86955ec -// make IMG_5.jpg come before IMG_10.jpg +// Taken from https://gist.github.com/MichaelRocks/1b94bb44c7804e999dbf31dac86955ec. +// Make IMG_5.jpg come before IMG_10.jpg. class AlphanumericComparator { fun compare( string1: String, diff --git a/app/src/main/java/be/scri/helpers/CommonsConstants.kt b/app/src/main/java/be/scri/helpers/CommonsConstants.kt index c562782..967ae19 100644 --- a/app/src/main/java/be/scri/helpers/CommonsConstants.kt +++ b/app/src/main/java/be/scri/helpers/CommonsConstants.kt @@ -2,7 +2,7 @@ package be.scri.helpers val DARK_GREY = 0xFF333333.toInt() -// shared preferences +// Shared preferences. const val PREFS_KEY = "Prefs" const val TEXT_COLOR = "text_color" const val KEY_COLOR = "key_color" diff --git a/app/src/main/java/be/scri/helpers/Constants.kt b/app/src/main/java/be/scri/helpers/Constants.kt index f261b8c..2d29800 100644 --- a/app/src/main/java/be/scri/helpers/Constants.kt +++ b/app/src/main/java/be/scri/helpers/Constants.kt @@ -4,10 +4,10 @@ const val SHIFT_OFF = 0 const val SHIFT_ON_ONE_CHAR = 1 const val SHIFT_ON_PERMANENT = 2 -// limit the count of alternative characters that show up at long pressing a key +// Limit the count of alternative characters that show up at long pressing a key. const val MAX_KEYS_PER_MINI_ROW = 9 -// shared prefs +// Shared preferences. const val VIBRATE_ON_KEYPRESS = "vibrate_on_keypress" const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress" const val DARK_THEME = "dark_theme" diff --git a/app/src/main/java/be/scri/services/SimpleKeyboardIME.kt b/app/src/main/java/be/scri/services/SimpleKeyboardIME.kt index 93d5d68..faebf58 100644 --- a/app/src/main/java/be/scri/services/SimpleKeyboardIME.kt +++ b/app/src/main/java/be/scri/services/SimpleKeyboardIME.kt @@ -62,7 +62,7 @@ abstract class SimpleKeyboardIME( private var emojiSpaceTablet2: View? = null private var emojiBtnTablet3: Button? = null - // how quickly do we have to doubletap shift to enable permanent caps lock + // How quickly do we have to doubletap shift to enable permanent caps lock. private val shiftPermToggleSpeed: Int = DEFAULT_SHIFT_PERM_TOGGLE_SPEED private lateinit var dbHelper: DatabaseHelper lateinit var emojiKeywords: HashMap> @@ -630,7 +630,7 @@ abstract class SimpleKeyboardIME( commandBar.text = newText } } else { - // Handling space key logic + // Handling space key logic. if (keyboardMode != keyboardLetters && code == MyKeyboard.KEYCODE_SPACE) { binding?.commandBar?.text = " " val originalText = inputConnection.getExtractedText(ExtractedTextRequest(), 0).text diff --git a/app/src/main/java/be/scri/views/MyKeyboardView.kt b/app/src/main/java/be/scri/views/MyKeyboardView.kt index e644f16..351c19f 100644 --- a/app/src/main/java/be/scri/views/MyKeyboardView.kt +++ b/app/src/main/java/be/scri/views/MyKeyboardView.kt @@ -175,7 +175,7 @@ class MyKeyboardView private var mToolbarHolder: View? = null - // For multi-tap + // For multi-tap. private var mLastTapTime = 0L /** Whether the keyboard bitmap needs to be redrawn before it's blitted. */ @@ -222,7 +222,7 @@ class MyKeyboardView private const val MSG_LONGPRESS = 3 private const val DELAY_AFTER_PREVIEW = 100 private const val DEBOUNCE_TIME = 70 - private const val REPEAT_INTERVAL = 50 // ~20 keys per second + private const val REPEAT_INTERVAL = 50 // ~20 keys per second private const val REPEAT_START_DELAY = 400 private const val DOUBLE_TAP_DELAY = 300L private const val NUMBER_OF_KEYS = 12 @@ -445,10 +445,10 @@ class MyKeyboardView invalidateAllKeys() computeProximityThreshold(keyboard) mMiniKeyboardCache.clear() - // Not really necessary to do every time, but will free up views + // Not really necessary to do every time, but will free up views. // Switching to a different keyboard should abort any pending keys so that the key up - // doesn't get delivered to the old or new keyboard - mAbortKey = true // Until the next ACTION_DOWN + // doesn't get delivered to the old or new keyboard. + mAbortKey = true // until the next ACTION_DOWN } /** Sets the top row above the keyboard containing Scribe command buttons **/ @@ -543,7 +543,7 @@ class MyKeyboardView } mProximityThreshold = (dimensionSum * PROXIMITY_SCALING_FACTOR / length).toInt() - mProximityThreshold *= mProximityThreshold // Square it + mProximityThreshold *= mProximityThreshold // square it } public override fun onDraw(canvas: Canvas) { @@ -560,7 +560,7 @@ class MyKeyboardView val shadowOffset = SHADOW_OFFSET if (mBuffer == null || mKeyboardChanged) { if (mBuffer?.let { buffer -> buffer.width != width || buffer.height != height } != false) { - // Make sure our bitmap is at least 1x1 + // Make sure our bitmap is at least 1x1. val width = 1.coerceAtLeast(width) val height = 1.coerceAtLeast(height) mBuffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) @@ -659,7 +659,7 @@ class MyKeyboardView canvas.drawRoundRect(shadowRect, rectRadius, rectRadius, shadowPaint) canvas.drawRoundRect(keyRect, rectRadius, rectRadius, keyBackgroundPaint) - // Switch the character to uppercase if shift is pressed + // Switch the character to uppercase if shift is pressed. val label = adjustCase(key.label)?.toString() if (key.focused || code == KEYCODE_ENTER) { @@ -775,7 +775,7 @@ class MyKeyboardView val oldKeyIndex = mCurrentKeyIndex val previewPopup = mPreviewPopup mCurrentKeyIndex = keyIndex - // Release the old key and press the new key + // Release the old key and press the new key. val keys = mKeys if (oldKeyIndex != mCurrentKeyIndex) { if (oldKeyIndex != NOT_A_KEY && keys.size > oldKeyIndex) { @@ -808,7 +808,7 @@ class MyKeyboardView } } - // If key changed and preview is on ... + // If key changed and preview is on. if (oldKeyIndex != mCurrentKeyIndex) { if (previewPopup.isShowing) { if (keyIndex == NOT_A_KEY) { @@ -885,10 +885,10 @@ class MyKeyboardView mHandler!!.removeMessages(MSG_REMOVE_PREVIEW) getLocationInWindow(mCoordinates) - mCoordinates[0] += mMiniKeyboardOffsetX // Offset may be zero - mCoordinates[1] += mMiniKeyboardOffsetY // Offset may be zero + mCoordinates[0] += mMiniKeyboardOffsetX // offset may be zero + mCoordinates[1] += mMiniKeyboardOffsetY // offset may be zero - // Set the preview background state + // Set the preview background state. mPreviewText!!.background.state = if (key.popupResId != 0) { LONG_PRESSABLE_STATE_SET @@ -899,7 +899,7 @@ class MyKeyboardView mPopupPreviewX += mCoordinates[0] mPopupPreviewY += mCoordinates[1] - // If the popup cannot be shown above the key, put it on the side + // If the popup cannot be shown above the key, put it on the side. getLocationOnScreen(mCoordinates) if (mPopupPreviewY + mCoordinates[1] < 0) { // If the key you're pressing is on the left side of the keyboard, show the popup on @@ -1095,8 +1095,8 @@ class MyKeyboardView val xOffset = Math.max(0, x) mMiniKeyboard!!.setPopupOffset(xOffset, y) - // make sure we highlight the proper key right after long pressing it, - // before any ACTION_MOVE event occurs + // Make sure we highlight the proper key right after long pressing it, + // before any ACTION_MOVE event occurs. val miniKeyboardX = if (xOffset + mMiniKeyboard!!.measuredWidth <= measuredWidth) { xOffset @@ -1138,7 +1138,7 @@ class MyKeyboardView if (action == MotionEvent.ACTION_UP) { ignoreTouches = false - // fix a glitch with long pressing backspace, then clicking some letter + // Fix a glitch with long pressing backspace, then clicking some letter. if (mRepeatKeyIndex != NOT_A_KEY) { val key = mKeys[mRepeatKeyIndex] if (key.code == KEYCODE_DELETE) { @@ -1150,7 +1150,7 @@ class MyKeyboardView return true } - // handle moving between alternative popup characters by swiping + // Handle moving between alternative popup characters by swiping. if (mPopupKeyboard.isShowing) { when (action) { MotionEvent.ACTION_MOVE -> { @@ -1226,16 +1226,16 @@ class MyKeyboardView return true } - // Needs to be called after the gesture detector gets a turn, as it may have displayed the mini keyboard + // Needs to be called after the gesture detector gets a turn, as it may have displayed the mini keyboard. if (mMiniKeyboardOnScreen && action != MotionEvent.ACTION_CANCEL) { return true } when (action) { MotionEvent.ACTION_POINTER_DOWN -> { - // if the user presses a key while still holding down the previous, - // type in both chars and ignore the later gestures - // can happen at fast typing, easier to reproduce by increasing LONGPRESS_TIMEOUT + // If the user presses a key while still holding down the previous, + // type in both chars and ignore the later gestures. + // Can happen at fast typing, easier to reproduce by increasing LONGPRESS_TIMEOUT. ignoreTouches = true mHandler!!.removeMessages(MSG_LONGPRESS) dismissPopupKeyboard() @@ -1282,14 +1282,14 @@ class MyKeyboardView val msg = mHandler!!.obtainMessage(MSG_REPEAT) mHandler!!.sendMessageDelayed(msg, REPEAT_START_DELAY.toLong()) - // if the user long presses Space, move the cursor after swipine left/right + // if the user long presses Space, move the cursor after swipine left/right. if (mKeys[mCurrentKey].code == KEYCODE_SPACE) { mLastSpaceMoveX = -1 } else { repeatKey(true) } - // Delivering the key could have caused an abort + // Delivering the key could have caused an abort. if (mAbortKey) { mRepeatKeyIndex = NOT_A_KEY wasHandled = true @@ -1344,9 +1344,9 @@ class MyKeyboardView mLastSpaceMoveX = mLastX } } else if (!continueLongPress) { - // Cancel old longpress + // Cancel old longpress. mHandler!!.removeMessages(MSG_LONGPRESS) - // Start new longpress if key has changed + // Start new longpress if key has changed. if (keyIndex != NOT_A_KEY) { val msg = mHandler!!.obtainMessage(MSG_LONGPRESS, me) mHandler!!.sendMessageDelayed(msg, LONGPRESS_TIMEOUT.toLong()) @@ -1377,7 +1377,7 @@ class MyKeyboardView } showPreview(NOT_A_KEY) Arrays.fill(mKeyIndices, NOT_A_KEY) - // If we're not on a repeating key (which sends on a DOWN event) + // If we're not on a repeating key (which sends on a DOWN event). if (mRepeatKeyIndex == NOT_A_KEY && !mMiniKeyboardOnScreen && !mAbortKey) { detectAndSendKey(mCurrentKey, touchX, touchY, eventTime) }