From 738bd98ac09d359c3fede4601b0d90f2d564726b Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 21 Jan 2022 22:27:10 +0100 Subject: [PATCH] removing the possibly useles function resize --- .../keyboard/helpers/MyKeyboard.kt | 50 ------------------- .../keyboard/views/MyKeyboardView.kt | 7 --- 2 files changed, 57 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt index fb6b7403..833ebc55 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/MyKeyboard.kt @@ -17,22 +17,7 @@ import java.util.* /** * Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard * consists of rows of keys. - * - * The layout file for a keyboard contains XML that looks like the following snippet: - *
- * <Keyboard
- * android:keyWidth="%10p"
- * android:keyHeight="50px"
- * android:horizontalGap="2px"
- * <Row android:keyWidth="32px" >
- * <Key android:keyLabel="A" />
- * ...
- * </Row>
- * ...
- * </Keyboard>
-
* * @attr ref android.R.styleable#Keyboard_keyWidth - * @attr ref android.R.styleable#Keyboard_keyHeight * @attr ref android.R.styleable#Keyboard_horizontalGap */ class MyKeyboard { @@ -67,7 +52,6 @@ class MyKeyboard { private var mEnterKeyType = IME_ACTION_NONE /** Keyboard mode, or zero, if none. */ - private var mKeyboardMode = 0 private var mCellWidth = 0 private var mCellHeight = 0 private var mGridNeighbors: SparseArray? = null @@ -343,7 +327,6 @@ class MyKeyboard { mDefaultHeight = mDefaultWidth mKeys = ArrayList() mEnterKeyType = enterKeyType - mKeyboardMode = modeId loadKeyboard(context, context.resources.getXml(xmlLayoutResId)) } @@ -397,39 +380,6 @@ class MyKeyboard { mRows.add(row) } - fun resize(newWidth: Int, newHeight: Int) { - val numRows = mRows.size - for (rowIndex in 0 until numRows) { - val row = mRows[rowIndex] ?: continue - val numKeys: Int = row.mKeys.size - var totalGap = 0 - var totalWidth = 0 - for (keyIndex in 0 until numKeys) { - val key: Key = row.mKeys.get(keyIndex) - if (keyIndex > 0) { - totalGap += key.gap - } - totalWidth += key.width - } - - if (totalGap + totalWidth > newWidth) { - var x = 0 - val scaleFactor = (newWidth - totalGap).toFloat() / totalWidth - for (keyIndex in 0 until numKeys) { - val key = row.mKeys[keyIndex] - key.width *= scaleFactor.toInt() - key.x = x - x += key.width + key.gap - } - } - } - - mMinWidth = newWidth - // TODO: This does not adjust the vertical placement according to the new size. - // The main problem in the previous code was horizontal placement/size, but we should - // also recalculate the vertical sizes/positions when we get this resize call. - } - fun setShifted(shiftState: Int): Boolean { if (this.mShiftState != shiftState) { this.mShiftState = shiftState diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index aa77f3cc..62977341 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -361,13 +361,6 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut mProximityThreshold *= mProximityThreshold // Square it } - public override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { - super.onSizeChanged(w, h, oldw, oldh) - mKeyboard?.resize(w, h) - // Release the buffer, if any and it will be reallocated on the next draw - mBuffer = null - } - public override fun onDraw(canvas: Canvas) { super.onDraw(canvas) if (mDrawPending || mBuffer == null || mKeyboardChanged) {