diff --git a/app/src/main/assets/layouts/clip_bottom_row.json b/app/src/main/assets/layouts/clip_bottom_row.json new file mode 100644 index 000000000..2a7c8f6b1 --- /dev/null +++ b/app/src/main/assets/layouts/clip_bottom_row.json @@ -0,0 +1,7 @@ +[ + [ + { "label": "alpha", "width": 0.15 }, + { "label": "space", "width": -1 }, + { "label": "delete", "width": 0.15 } + ] +] diff --git a/app/src/main/assets/layouts/emoji_bottom_row.json b/app/src/main/assets/layouts/emoji_bottom_row.json new file mode 100644 index 000000000..2a7c8f6b1 --- /dev/null +++ b/app/src/main/assets/layouts/emoji_bottom_row.json @@ -0,0 +1,7 @@ +[ + [ + { "label": "alpha", "width": 0.15 }, + { "label": "space", "width": -1 }, + { "label": "delete", "width": 0.15 } + ] +] diff --git a/app/src/main/java/helium314/keyboard/keyboard/KeyboardId.java b/app/src/main/java/helium314/keyboard/keyboard/KeyboardId.java index f7b855a33..ac39680a8 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/KeyboardId.java +++ b/app/src/main/java/helium314/keyboard/keyboard/KeyboardId.java @@ -63,7 +63,8 @@ public final class KeyboardId { public static final int ELEMENT_EMOJI_CATEGORY16 = 26; public static final int ELEMENT_CLIPBOARD = 27; public static final int ELEMENT_NUMPAD = 28; - public static final int ELEMENT_CLIP_EMOJI_BOTTOM_ROW = 29; // todo: maybe separate for customization + public static final int ELEMENT_EMOJI_BOTTOM_ROW = 29; + public static final int ELEMENT_CLIPBOARD_BOTTOM_ROW = 30; public final RichInputMethodSubtype mSubtype; public final int mWidth; @@ -192,6 +193,10 @@ public boolean isEmojiKeyboard() { return mElementId >= ELEMENT_EMOJI_RECENTS && mElementId <= ELEMENT_EMOJI_CATEGORY16; } + public boolean isEmojiClipBottomRow() { + return mElementId == ELEMENT_CLIPBOARD_BOTTOM_ROW || mElementId == ELEMENT_EMOJI_BOTTOM_ROW; + } + public int imeAction() { return InputTypeUtils.getImeOptionsActionIdFromEditorInfo(mEditorInfo); } diff --git a/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt b/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt index 9ccc6e5be..846ce19ee 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt @@ -140,7 +140,7 @@ class ClipboardHistoryView @JvmOverloads constructor( PointerTracker.switchTo(keyboardView) keyboardView.visibility = View.VISIBLE val kls = KeyboardLayoutSet.Builder.buildEmojiClipBottomRow(context, editorInfo) - val keyboard = kls.getKeyboard(KeyboardId.ELEMENT_CLIP_EMOJI_BOTTOM_ROW) + val keyboard = kls.getKeyboard(KeyboardId.ELEMENT_CLIPBOARD_BOTTOM_ROW) keyboardView.setKeyboard(keyboard) clipboardLayoutParams.setActionBarProperties(keyboardView) // todo: rename to bottomRowKeyboard } diff --git a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.java b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.java index 8feee4a79..b3645c633 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.java +++ b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.java @@ -287,7 +287,7 @@ private void setupBottomRowKeyboard(final EditorInfo editorInfo) { PointerTracker.switchTo(keyboardView); keyboardView.setVisibility(View.VISIBLE); final KeyboardLayoutSet kls = KeyboardLayoutSet.Builder.buildEmojiClipBottomRow(getContext(), editorInfo); - final Keyboard keyboard = kls.getKeyboard(KeyboardId.ELEMENT_CLIP_EMOJI_BOTTOM_ROW); + final Keyboard keyboard = kls.getKeyboard(KeyboardId.ELEMENT_EMOJI_BOTTOM_ROW); keyboardView.setKeyboard(keyboard); mEmojiLayoutParams.setActionBarProperties(keyboardView); // todo: rename to bottomRowKeyboard } diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardBuilder.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardBuilder.kt index f5d46f699..fb246e06f 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardBuilder.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/KeyboardBuilder.kt @@ -50,26 +50,6 @@ open class KeyboardBuilder(protected val mContext: Context, mParams.mAllowRedundantPopupKeys = true readAttributes(R.xml.kbd_emoji) keysInRows = EmojiParser(mParams, mContext).parse() - } else if (id.mElementId == KeyboardId.ELEMENT_CLIP_EMOJI_BOTTOM_ROW) { - // try catch, single row check, customizable layout, maybe set up other stuff, ... - // possibly some things could be determined automatically and the parser used normally? - addLocaleKeyTextsToParams(mContext, mParams, Settings.getInstance().current.mShowMorePopupKeys) - mParams.readAttributes(mContext, null) - mParams.mTopPadding /= 4 // not perfect, may cause 1 pixel offsets because it's already been converted to int once - val baseKeys = RawKeyboardParser.parseJsonString(""" -[ - [ - { "label": "alpha", "width": 0.15 }, - { "label": "space", "width": -1 }, - { "label": "delete", "width": 0.15 } - ] -] - """.trimIndent()) - keysInRows = KeyboardParser(mParams, mContext).createRows(baseKeys.map { it.mapNotNull { it.compute(mParams) }.toMutableList() } - .take(1).toMutableList()) // we set the height for a single row only (in emoji and clipboard params), so we only use one! - if (Settings.getInstance().current.mShowsNumberRow) - keysInRows.first().forEach { it.mHeight *= 0.8f } - determineAbsoluteValues() } else { try { setupParams() diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt index 40d39be37..21c07fe50 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt @@ -50,8 +50,15 @@ class KeyboardParser(private val params: KeyboardParams, private val context: Co val baseKeys = RawKeyboardParser.parseLayout(params, context) val keysInRows = createRows(baseKeys) - // rescale height if we have anything but the usual 4 rows - val heightRescale = if (keysInRows.size != 4) 4f / keysInRows.size else 1f + val heightRescale: Float + if (params.mId.isEmojiClipBottomRow) { + // rescale height if number row is enabled + heightRescale = if (Settings.getInstance().current.mShowsNumberRow) 0.8f else 1f + params.mTopPadding /= 4 // not perfect, may cause 1 pixel offsets because it's already been converted to int once + } else { + // rescale height if we have anything but the usual 4 rows + heightRescale = if (keysInRows.size != 4) 4f / keysInRows.size else 1f + } if (heightRescale != 1f) { keysInRows.forEach { row -> row.forEach { it.mHeight *= heightRescale } } } @@ -314,3 +321,5 @@ const val LAYOUT_NUMBER = "number" const val LAYOUT_PHONE = "phone" const val LAYOUT_PHONE_SYMBOLS = "phone_symbols" const val LAYOUT_NUMBER_ROW = "number_row" +const val LAYOUT_EMOJI_BOTTOM_ROW = "emoji_bottom_row" +const val LAYOUT_CLIPBOARD_BOTTOM_ROW = "clip_bottom_row" diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/RawKeyboardParser.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/RawKeyboardParser.kt index 248d80fd4..9a9793747 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/RawKeyboardParser.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/RawKeyboardParser.kt @@ -137,6 +137,8 @@ object RawKeyboardParser { KeyboardId.ELEMENT_NUMBER -> LAYOUT_NUMBER KeyboardId.ELEMENT_PHONE -> LAYOUT_PHONE KeyboardId.ELEMENT_PHONE_SYMBOLS -> LAYOUT_PHONE_SYMBOLS + KeyboardId.ELEMENT_EMOJI_BOTTOM_ROW -> LAYOUT_EMOJI_BOTTOM_ROW + KeyboardId.ELEMENT_CLIPBOARD_BOTTOM_ROW -> LAYOUT_CLIPBOARD_BOTTOM_ROW else -> params.mId.mSubtype.keyboardLayoutSetName.substringBeforeLast("+") } diff --git a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/TextKeyData.kt b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/TextKeyData.kt index 587fac7be..6688797df 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/TextKeyData.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/floris/TextKeyData.kt @@ -110,7 +110,7 @@ sealed interface KeyData : AbstractKeyData { } private fun getSpaceLabel(params: KeyboardParams): String = - if (params.mId.isAlphaOrSymbolKeyboard || params.mId.mElementId == KeyboardId.ELEMENT_CLIP_EMOJI_BOTTOM_ROW) + if (params.mId.isAlphaOrSymbolKeyboard || params.mId.isEmojiClipBottomRow) "!icon/space_key|!code/key_space" else "!icon/space_key_for_number_layout|!code/key_space"