From 36f7a65d21389acdec68cc7fc8ff447662164783 Mon Sep 17 00:00:00 2001 From: LeanBitLab Date: Mon, 16 Nov 2026 12:49:33 +0530 Subject: [PATCH 1/5] fix(spacebar): place incognito icon beside the language text The icon was pinned to the right edge at 15% alpha and could overlap the text on narrow space keys such as the numpad. With language text shown it now sits right before the text (sized from the text height), and falls back to the centered watermark when the key is too narrow for any text. --- .../keyboard/keyboard/MainKeyboardView.kt | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt b/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt index 226d5152a..9cf49c517 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt @@ -450,9 +450,12 @@ class MainKeyboardView @JvmOverloads constructor( if (key.altCodeWhileTyping() && key.isEnabled) params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE super.onDrawKeyTopVisuals(key, canvas, paint, params) if (key.code == Constants.CODE_SPACE) { - val isIncognito = (mSettingsValues ?: Settings.getValues()).mIncognitoModeEnabled - if (isIncognito && mIncognitoIcon != null) drawIncognitoOnSpacebar(key, canvas) - if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) drawLanguageOnSpacebar(key, canvas, paint) + val isIncognito = (mSettingsValues ?: Settings.getValues()).mIncognitoModeEnabled && mIncognitoIcon != null + val showLanguage = mLanguageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE + // with language text the incognito icon is placed next to it, so the text gets less room + val iconReserve = if (isIncognito && showLanguage) incognitoIconSizeBesideText() + incognitoIconGap() else 0 + val textWidth = if (showLanguage) drawLanguageOnSpacebar(key, canvas, paint, iconReserve) else 0f + if (isIncognito) drawIncognitoOnSpacebar(key, canvas, textWidth, iconReserve) if (key.isLongPressEnabled && mHasMultipleEnabledIMEsOrSubtypes) drawKeyPopupHint(key, canvas, paint, params) } else if (key.code == KeyCode.LANGUAGE_SWITCH) { drawKeyPopupHint(key, canvas, paint, params) @@ -511,9 +514,10 @@ class MainKeyboardView @JvmOverloads constructor( return newLocales } - private fun drawLanguageOnSpacebar(key: Key, canvas: Canvas, paint: Paint) { - val kb = keyboard ?: return - val width = key.width; val height = key.height + /** Draws the language (or custom) text, leaving [iconReserve] px for the incognito icon. Returns the drawn text width, 0 if nothing was drawn. */ + private fun drawLanguageOnSpacebar(key: Key, canvas: Canvas, paint: Paint, iconReserve: Int): Float { + val kb = keyboard ?: return 0f + val width = key.width - iconReserve; val height = key.height paint.textAlign = Paint.Align.CENTER paint.typeface = mTypeface ?: Typeface.DEFAULT paint.textSize = mLanguageOnSpacebarTextSize @@ -530,21 +534,36 @@ class MainKeyboardView @JvmOverloads constructor( val textWidth = TypefaceUtils.getStringWidth(spaceText, paint) paint.textScaleX = (width - mLanguageOnSpacebarHorizontalMargin * 2) / textWidth } - canvas.drawText(spaceText, width / 2f, baseline - descent, paint) + val drawnWidth = if (spaceText.isEmpty()) 0f else TypefaceUtils.getStringWidth(spaceText, paint) + canvas.drawText(spaceText, (key.width + iconReserve) / 2f, baseline - descent, paint) paint.clearShadowLayer() paint.textScaleX = 1.0f + return drawnWidth } - private fun drawIncognitoOnSpacebar(key: Key, canvas: Canvas) { + private fun incognitoIconSizeBesideText() = (mLanguageOnSpacebarTextSize * 1.2f).toInt() + private fun incognitoIconGap() = (incognitoIconSizeBesideText() * 0.3f).toInt() + + private fun drawIncognitoOnSpacebar(key: Key, canvas: Canvas, textWidth: Float, iconReserve: Int) { val width = key.width; val height = key.height - val iconSize = (height * 0.8f).toInt() - val iconY = (height - iconSize) / 2 - var iconX = (width - iconSize) / 2 - if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) iconX = width - iconSize - (width * 0.05f).toInt() - mIncognitoIcon?.alpha = 38 - mIncognitoIcon?.setBounds(iconX, iconY, iconX + iconSize, iconY + iconSize) - mIncognitoIcon?.draw(canvas) - mIncognitoIcon?.alpha = 255 + val icon = mIncognitoIcon ?: return + if (textWidth > 0f) { + // small icon right before the language text, the pair is centered on the key + val iconSize = iconReserve - incognitoIconGap() + val iconX = ((width - textWidth - iconReserve) / 2f).toInt() + val iconY = (height - iconSize) / 2 + icon.alpha = 110 + icon.setBounds(iconX, iconY, iconX + iconSize, iconY + iconSize) + } else { + // no language text: faint centered watermark + val iconSize = (height * 0.8f).toInt() + val iconX = (width - iconSize) / 2 + val iconY = (height - iconSize) / 2 + icon.alpha = 38 + icon.setBounds(iconX, iconY, iconX + iconSize, iconY + iconSize) + } + icon.draw(canvas) + icon.alpha = 255 } override fun deallocateMemory() { super.deallocateMemory(); dismissAllKeyPreviews(); mDrawingPreviewPlacerView.deallocateMemory() } From d22f5f5a32a6a945c5654f20a876bb787b00733b Mon Sep 17 00:00:00 2001 From: LeanBitLab Date: Mon, 16 Nov 2026 12:49:33 +0530 Subject: [PATCH 2/5] fix(spacebar): show language and custom text on clipboard and emoji bottom rows Only KeyboardSwitcher called startDisplayLanguageOnSpacebar, so the bottom row views of the clipboard and emoji pages kept the NONE format type and never drew the custom space bar text. Set it in MainKeyboardView.setKeyboard. --- .../main/java/helium314/keyboard/keyboard/MainKeyboardView.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt b/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt index 9cf49c517..a3381d0bc 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt @@ -198,6 +198,10 @@ class MainKeyboardView @JvmOverloads constructor( PointerTracker.setKeyDetector(mKeyDetector) mPopupKeysKeyboardCache.clear() mSpaceKey = keyboard.getKey(Constants.CODE_SPACE) + // clipboard and emoji bottom rows are not set up by KeyboardSwitcher (which calls startDisplayLanguageOnSpacebar for the main view) + mLanguageOnSpacebarFormatType = if (mLanguageOnSpacebarFadeoutAnimator == null) LanguageOnSpacebarUtils.FORMAT_TYPE_NONE + else LanguageOnSpacebarUtils.getLanguageOnSpacebarFormatType(keyboard.mId.mSubtype) + if (mLanguageOnSpacebarFadeoutAnimator?.isStarted != true) mLanguageOnSpacebarAnimAlpha = mLanguageOnSpacebarFinalAlpha mLanguageOnSpacebarTextSize = (keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap) * mLanguageOnSpacebarTextRatio val sv = Settings.getValues() val isAlpha = keyboard.mId.isAlphabetKeyboard From df22c4cdaad85bb702d9e132d8efa81f3ec4b46a Mon Sep 17 00:00:00 2001 From: LeanBitLab Date: Mon, 16 Nov 2026 12:50:02 +0530 Subject: [PATCH 3/5] fix(emoji): keep sub-category chip swipes from switching the emoji category The listener that blocks ViewPager2 interception was only set on the chip strip, so it never ran for touches that start on a chip (the chip consumes DOWN). Attach it to the chips as well. --- .../keyboard/keyboard/emoji/EmojiPalettesView.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.kt b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.kt index 0b3ac37a9..1ddb44843 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.kt @@ -1398,8 +1398,9 @@ class EmojiPalettesView @JvmOverloads constructor( scroll.visibility = View.VISIBLE mColors.setBackground(scroll, ColorType.STRIP_BACKGROUND) - // Disallow ViewPager2 horizontal intercept when touching or scrolling sub-categories - scroll.setOnTouchListener { v, event -> + // Disallow ViewPager2 horizontal intercept when touching or scrolling sub-categories. + // Also needed on the chips: a touch that starts on a chip is consumed by it and never reaches the scroll view's own listener on DOWN. + val blockPagerSwipe = View.OnTouchListener { v, event -> when (event.actionMasked) { MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE -> { v.parent?.requestDisallowInterceptTouchEvent(true) @@ -1410,6 +1411,7 @@ class EmojiPalettesView @JvmOverloads constructor( } false } + scroll.setOnTouchListener(blockPagerSwipe) val chipHeight = (30 * density).toInt() val marginH = (4 * density).toInt() @@ -1431,6 +1433,7 @@ class EmojiPalettesView @JvmOverloads constructor( gravity = android.view.Gravity.CENTER includeFontPadding = false setPadding(padH, 0, padH, 0) + setOnTouchListener(blockPagerSwipe) setOnClickListener { v -> if (categoryId == EmojiCategory.ID_UNICODE_SYMBOLS) { mEmojiCategory.setCurrentUnicodeSymbolGroup(index) @@ -1457,6 +1460,7 @@ class EmojiPalettesView @JvmOverloads constructor( (strip.getChildAt(index) as? TextView)?.apply { text = EmojiCategory.getEmoticonGroupDisplayName(context, group.name) setPadding(padH, 0, padH, 0) + setOnTouchListener(blockPagerSwipe) setOnClickListener { v -> if (categoryId == EmojiCategory.ID_UNICODE_SYMBOLS) { mEmojiCategory.setCurrentUnicodeSymbolGroup(index) From f64f3cd1619e86b3d6249250e96056c18c5a12dc Mon Sep 17 00:00:00 2001 From: LeanBitLab Date: Mon, 16 Nov 2026 13:19:02 +0530 Subject: [PATCH 4/5] fix(spacebar): make the incognito indicator more prominent Size the icon from the key height (65%) and draw it at full strength, both beside the language text and when no text is shown. The faint 15% alpha watermark was easy to miss, and the text-relative size was too small for multi-language setups. --- .../keyboard/keyboard/MainKeyboardView.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt b/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt index a3381d0bc..8f6db9720 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/MainKeyboardView.kt @@ -457,7 +457,7 @@ class MainKeyboardView @JvmOverloads constructor( val isIncognito = (mSettingsValues ?: Settings.getValues()).mIncognitoModeEnabled && mIncognitoIcon != null val showLanguage = mLanguageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE // with language text the incognito icon is placed next to it, so the text gets less room - val iconReserve = if (isIncognito && showLanguage) incognitoIconSizeBesideText() + incognitoIconGap() else 0 + val iconReserve = if (isIncognito && showLanguage) incognitoIconSize(key) + incognitoIconGap(key) else 0 val textWidth = if (showLanguage) drawLanguageOnSpacebar(key, canvas, paint, iconReserve) else 0f if (isIncognito) drawIncognitoOnSpacebar(key, canvas, textWidth, iconReserve) if (key.isLongPressEnabled && mHasMultipleEnabledIMEsOrSubtypes) drawKeyPopupHint(key, canvas, paint, params) @@ -545,25 +545,25 @@ class MainKeyboardView @JvmOverloads constructor( return drawnWidth } - private fun incognitoIconSizeBesideText() = (mLanguageOnSpacebarTextSize * 1.2f).toInt() - private fun incognitoIconGap() = (incognitoIconSizeBesideText() * 0.3f).toInt() + private fun incognitoIconSize(key: Key) = (key.height * 0.65f).toInt() + private fun incognitoIconGap(key: Key) = (incognitoIconSize(key) * 0.25f).toInt() private fun drawIncognitoOnSpacebar(key: Key, canvas: Canvas, textWidth: Float, iconReserve: Int) { val width = key.width; val height = key.height val icon = mIncognitoIcon ?: return if (textWidth > 0f) { - // small icon right before the language text, the pair is centered on the key - val iconSize = iconReserve - incognitoIconGap() + // icon right before the language text, the pair is centered on the key + val iconSize = incognitoIconSize(key) val iconX = ((width - textWidth - iconReserve) / 2f).toInt() val iconY = (height - iconSize) / 2 - icon.alpha = 110 + icon.alpha = 255 icon.setBounds(iconX, iconY, iconX + iconSize, iconY + iconSize) } else { - // no language text: faint centered watermark - val iconSize = (height * 0.8f).toInt() + // no language text: centered indicator, drawn as strong as the language text would be (the color already carries its alpha) + val iconSize = incognitoIconSize(key) val iconX = (width - iconSize) / 2 val iconY = (height - iconSize) / 2 - icon.alpha = 38 + icon.alpha = 255 icon.setBounds(iconX, iconY, iconX + iconSize, iconY + iconSize) } icon.draw(canvas) From 71595987452b59bcddb42e86fb87635475ee59f2 Mon Sep 17 00:00:00 2001 From: LeanBitLab Date: Mon, 16 Nov 2026 13:19:02 +0530 Subject: [PATCH 5/5] fix(emoji): let chip drags scroll the strip without switching the category The pager-blocking listener cleared the disallow-intercept flag on ACTION_CANCEL. When the strip takes over a drag that starts on a chip, the chip gets a CANCEL, which re-enabled the pager and let it take the swipe. Only set the flag (the framework resets it on every new touch), and remove the margin between chips so no swipe starts in a dead gap. --- .../keyboard/emoji/EmojiPalettesView.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.kt b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.kt index 1ddb44843..9749b06fd 100644 --- a/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.kt +++ b/app/src/main/java/helium314/keyboard/keyboard/emoji/EmojiPalettesView.kt @@ -1400,21 +1400,20 @@ class EmojiPalettesView @JvmOverloads constructor( // Disallow ViewPager2 horizontal intercept when touching or scrolling sub-categories. // Also needed on the chips: a touch that starts on a chip is consumed by it and never reaches the scroll view's own listener on DOWN. - val blockPagerSwipe = View.OnTouchListener { v, event -> - when (event.actionMasked) { - MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE -> { - v.parent?.requestDisallowInterceptTouchEvent(true) - } - MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { - v.parent?.requestDisallowInterceptTouchEvent(false) - } + // Always go through the scroll view's parent: disallowing from a chip's own parent would also stop the scroll view + // from intercepting, so the strip could not be scrolled by dragging on a chip. + // Never clear the flag here: when the scroll view takes over a drag that started on a chip, the chip gets ACTION_CANCEL, + // and clearing then lets the pager intercept the rest of the drag. The framework resets the flag on every new touch. + val blockPagerSwipe = View.OnTouchListener { _, event -> + if (event.actionMasked == MotionEvent.ACTION_DOWN || event.actionMasked == MotionEvent.ACTION_MOVE) { + scroll.parent?.requestDisallowInterceptTouchEvent(true) } false } scroll.setOnTouchListener(blockPagerSwipe) val chipHeight = (30 * density).toInt() - val marginH = (4 * density).toInt() + val marginH = 0 // chips sit flush, so a swipe never starts in a dead gap val padH = (15 * density).toInt() val currentGroup = if (categoryId == EmojiCategory.ID_UNICODE_SYMBOLS) { mEmojiCategory.getCurrentUnicodeSymbolGroup()