From 4429d83039a40f5f39150002cee6e4b8aadc93e4 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 27 Oct 2025 11:52:31 +0100 Subject: [PATCH 1/2] fix: Mic and suggestion If suggestions are turned off the mic is visible which is good but it's not working as when the user taps on it, it taps in the app behind instead. The touch area is not available when the suggestion bar is not displayed. Addition of a new touch area dedicated to the microphone to handle this case. REF: https://gitlab.e.foundation/e/os/backlog/-/issues/3329 --- .../android/inputmethod/latin/LatinIME.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index cdd3a7244d..e796e7e3f3 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -33,6 +33,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.inputmethodservice.InputMethodService; @@ -51,6 +52,7 @@ import android.view.Display; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; +import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.Window; import android.view.WindowManager; @@ -219,6 +221,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public final UIHandler mHandler = new UIHandler(this); private ImageButton floatingButton; + private final Rect mFloatingButtonTouchableBounds = new Rect(); public static final class UIHandler extends LeakGuardHandlerWrapper { private static final int MSG_UPDATE_SHIFT_STATE = 0; @@ -1336,12 +1339,31 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final int touchBottom = inputHeight; outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION; outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom); + extendTouchableRegionForFloatingButton(outInsets); } outInsets.contentTopInsets = visibleTopY; outInsets.visibleTopInsets = visibleTopY; mInsetsUpdater.setInsets(outInsets); } + private void extendTouchableRegionForFloatingButton(final InputMethodService.Insets outInsets) { + if (floatingButton == null || floatingButton.getVisibility() != View.VISIBLE) { + return; + } + if (!(mInputView instanceof ViewGroup)) { + return; + } + final int width = floatingButton.getWidth(); + final int height = floatingButton.getHeight(); + if (width <= 0 || height <= 0) { + return; + } + mFloatingButtonTouchableBounds.set(0, 0, width, height); + ((ViewGroup) mInputView).offsetDescendantRectToMyCoords( + floatingButton, mFloatingButtonTouchableBounds); + outInsets.touchableRegion.union(mFloatingButtonTouchableBounds); + } + public void startShowingInputView(final boolean needsToLoadKeyboard) { mIsExecutingStartShowingInputView = true; // This {@link #showWindow(boolean)} will eventually call back -- GitLab From 3322b1bff735e39827e4262efe35a99ce6c08b14 Mon Sep 17 00:00:00 2001 From: frankpreel Date: Mon, 27 Oct 2025 16:49:38 +0100 Subject: [PATCH 2/2] feat: refactor floatingButton by mFloatingButton to be consistent with all member variables. --- .../android/inputmethod/latin/LatinIME.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e796e7e3f3..f497258870 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -220,7 +220,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public final UIHandler mHandler = new UIHandler(this); - private ImageButton floatingButton; + private ImageButton mFloatingButton; private final Rect mFloatingButtonTouchableBounds = new Rect(); public static final class UIHandler extends LeakGuardHandlerWrapper { @@ -898,8 +898,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mSuggestionStripView.setListener(this, view); } - floatingButton = mInputView.findViewById(R.id.floating_button); - floatingButton.setOnClickListener(new View.OnClickListener() { + mFloatingButton = mInputView.findViewById(R.id.floating_button); + mFloatingButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switchToSttIme(); @@ -912,9 +912,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final SettingsValues currentSettingsValues = mSettings.getCurrent(); if (shouldShowFloatingButton() && currentSettingsValues.mInputAttributes.mShouldShowSuggestions) { - floatingButton.setVisibility(View.VISIBLE); + mFloatingButton.setVisibility(View.VISIBLE); } else { - floatingButton.setVisibility(View.GONE); + mFloatingButton.setVisibility(View.GONE); } } @@ -938,7 +938,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mHandler.onStartInputView(editorInfo, restarting); mStatsUtilsManager.onStartInputView(); - if (floatingButton != null) { + if (mFloatingButton != null) { manageFloatingButtonVisibility(); } } @@ -1347,20 +1347,20 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } private void extendTouchableRegionForFloatingButton(final InputMethodService.Insets outInsets) { - if (floatingButton == null || floatingButton.getVisibility() != View.VISIBLE) { + if (mFloatingButton == null || mFloatingButton.getVisibility() != View.VISIBLE) { return; } if (!(mInputView instanceof ViewGroup)) { return; } - final int width = floatingButton.getWidth(); - final int height = floatingButton.getHeight(); + final int width = mFloatingButton.getWidth(); + final int height = mFloatingButton.getHeight(); if (width <= 0 || height <= 0) { return; } mFloatingButtonTouchableBounds.set(0, 0, width, height); ((ViewGroup) mInputView).offsetDescendantRectToMyCoords( - floatingButton, mFloatingButtonTouchableBounds); + mFloatingButton, mFloatingButtonTouchableBounds); outInsets.touchableRegion.union(mFloatingButtonTouchableBounds); } -- GitLab