Fix kb behavior after returning from an external app.

This commit is contained in:
Alex Hart
2026-09-17 13:16:43 -03:00
parent 4581a60dfe
commit d408b487cf
3 changed files with 18 additions and 7 deletions
@@ -82,7 +82,6 @@ import java.util.concurrent.TimeUnit;
public class InputPanel extends ConstraintLayout
implements AudioRecordingHandler,
KeyboardAwareLinearLayout.OnKeyboardShownListener,
EmojiEventListener,
ConversationStickerSuggestionAdapter.EventListener
{
@@ -398,6 +397,15 @@ public class InputPanel extends ConstraintLayout
return mediaKeyboard.isStickerMode();
}
/** True only while a keyboard of ours is the one on screen. */
public void setMediaKeyboardToggleOffersIme(boolean offersIme) {
if (offersIme) {
mediaKeyboard.setToIme();
} else {
mediaKeyboard.setToMedia();
}
}
public View getMediaKeyboardToggleAnchorView() {
return mediaKeyboard;
}
@@ -711,11 +719,6 @@ public class InputPanel extends ConstraintLayout
return elapsedTime;
}
@Override
public void onKeyboardShown() {
mediaKeyboard.setToMedia();
}
@Override
public void onKeyEvent(KeyEvent keyEvent) {
composeText.dispatchKeyEvent(keyEvent);
@@ -136,7 +136,9 @@ class ChatInputController(
* @param showSoftKeyOnHide Whether the system keyboard replaces [key] when it is taken away.
*/
fun toggleInput(key: MediaKeyboardKey, imeTarget: EditText, showSoftKeyOnHide: Boolean = wasKeyboardVisibleBeforeToggle) {
if (controller.current == key) {
// Ours can sit behind the system keyboard rather than in place of it, where hiding it would act
// on something the user cannot see. The system keyboard goes instead.
if (controller.current == key && !isKeyboardShowing) {
if (showSoftKeyOnHide) {
showSoftkey(imeTarget)
} else {
@@ -5368,12 +5368,18 @@ class ConversationFragment :
}
override fun onKeyboardShown() {
// The toggle follows what is on screen: the system keyboard can cover one of ours, not just
// replace it.
inputPanel.setMediaKeyboardToggleOffersIme(false)
if (searchMenuItem?.isActionViewExpanded == true && searchMenuItem?.actionView?.hasFocus() == false) {
searchMenuItem?.actionView?.requestFocus()
}
}
override fun onKeyboardHidden() {
inputPanel.setMediaKeyboardToggleOffersIme(container.isInputShowing)
if (searchMenuItem?.isActionViewExpanded == true && searchMenuItem?.actionView?.hasFocus() == true) {
searchMenuItem?.actionView?.clearFocus()
}