-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue where soft keyboard would not show in some cases #2114
Fix issue where soft keyboard would not show in some cases #2114
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, now the keyboard opens after returning from a URL or locked screen. However, is there a reason that the keyboard should open even if it was hidden before? I think it would be better if the keyboard remained in the same state as it was previously when you return, so that if you hide the keyboard and change to another app, it's still hidden when you switch back to Termux.
Of course, if you use the disable toggle, it will be closed when you come back to Termux, but if it behaved the way described above, I would prefer using the toggle as show/hide instead of enable/disable.
There is also still one issue remaining with the enable/disable toggle. If you press back to hide the keyboard, you still have to press the toggle twice to open the keyboard.
Logger.logVerbose(LOG_TAG, "Enabling soft keyboard on toggle"); | ||
mActivity.getPreferences().setSoftKeyboardEnabled(true); | ||
KeyboardUtils.clearDisableSoftKeyboardFlags(mActivity); | ||
KeyboardUtils.showSoftKeyboard(mActivity, mActivity.getTerminalView()); | ||
mActivity.getTerminalView().postDelayed(getShowSoftKeyboardRunnable(), 300); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this delay necessary? Just requesting focus makes it works for me. I see no difference in behavior with or without the delay, except that toggling the keyboard now has a delay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as mentioned in the comment above it. It requires a delay after steps from #2112 on my device. It works with 100ms too, but may not work for other slower devices. I have no way to know the correct one unless multiple testers come and say it works for them, so better to set a looser delay, since releases are slow. And at least 300ms
may be required anyways. The setSoftKeyboardVisibility()
called by onFocusChange()
has it at 500ms
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, that's a bit surprising. I see that the delay is required when auto opening the keyboard after returning to Termux (the delay later down in this file), but here there would be some time between returning to Termux and pressing the button anyways (I don't think one would be able to press the button within a couple of hundred ms after returning to the app). I'm not doubting what you're saying, just wanted to make sure it's necessary in both cases.
The problem is not so much that there is a delay after returning to the app though, but that this also causes a delay when you haven't left the app. E.g. just press the toggle to disable and then press again to enable. This delay is not present in master, so I would assume it's not necessary in this case? Would it be possible to differentiate between these cases, so the delay is only used when you return to Termux, and not when you toggle the keyboard when Termux is active all the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, but here there would be some time between returning to Termux and pressing the button anyways
I was wondering about that too, I tried multiple configurations, but delays seems necessary.
Would it be possible to differentiate between these cases
Yeah, a boolean can be added, just like mShowSoftKeyboardIgnoreOnce
, delays seems to be required only after app changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, a boolean can be added, just like mShowSoftKeyboardIgnoreOnce, delays seems to be required only after app changes.
Great, or alternatively we could call it both immediately and with a delay? That would fix the issue when toggling when Termux is active, and it wouldn't introduce a delay after app switch for devices that don't need it. Or would that be too hacky?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some delay
Delay in what? Enabling keyboard with toggle if it was previously disabled?. onCreate
will always have its own delay to set up stuff, so showing keyboard automatically (which also has 300ms delay) or with toggle will have "some" delay anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delay between pressing the keyboard toggle and the keyboard appearing. That is after returning to the app when the keyboard is disabled, so not when it appears automatically.
These are the two cases:
With destroy:
- Press the toggle to disable the keyboard.
- Press back to leave (but not exit) the app.
- Return to the app by pressing it in recent apps or the launcher.
- Press the keyboard toggle to open the keyboard again.
- The keyboard will appear.
Here there is some delay between 4. and 5. even if I remove the delay from the code.
Without destroy:
- Press the toggle to disable the keyboard.
- Press home to go to the home screen.
- Return to the app by pressing it in recent apps or the launcher.
- Press the keyboard toggle to open the keyboard again.
- The keyboard will appear.
Here the only delay between 4. and 5. is the delay specified in the code. If I remove that delay the keyboard opens immediately.
I'm asking if the delay specified in the code is necessary in both cases for the keyboard to appear on your device, or if it is sufficient to have it in the first case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems its only required if onCreate
is called. I have made the changes, but if its also required even when onResume
is called without onCreate
on startup on some device, then we all know who will be coming after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks! Working great for me now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, welcome. Merging.
There is no reliable way for termux to know whether the soft keyboard is open or closed, so I can't save the state before leaving termux. It only works with
That's expected behaviour and won't change. There is a difference between hide and disable. When you hide, you should tap the terminal view for it to show. When you disable, you should press keyboard toggle to show it again. When you press the keyboard toggle in |
Oh, okay, too bad.
I think it would be more useful/practical if the toggle button always shows the keyboard when it's closed, so you don't have to know if it's disabled or just hidden. But the main reason I want this behavior is that I'm working on being able to open URLs by pressing on them directly, and I was thinking of making the tap action configurable so I don't accidentally open the keyboard if I miss a URL. But okay, if Termux can't know if the keyboard is open or not, I see that it wouldn't be possible. Did you see my comment about the delay that doesn't seem to be necessary? |
I guess for that case, as you suggested, the back key can disable the keyboard as well if a
Yeah, but if someone can come up with a hack that works for everybody, then that can be included.
Already replied to it. |
Alright, maybe I'll add that when I make a PR for the click on URL functionality then.
Fingers crossed, though from what you and the others have written in the issue you linked, it doesn't seem easy.
Sorry, I didn't see it. I think GitHub showed the one I replied to automatically, but not the other until I refreshed the page. Or I was just blind. |
5ad24c4
to
54513e3
Compare
Cool
Probably not or at least not on all devices.
Yeah, comments are not always refreshed. Sub comments probably don't either. But if you do find out that you are actually blind, please let us know. We require our testers to not be blind to test UI changes. Thanks ;) |
The two KB choices in Termux Settings are set to other values regardless of the selected one with each The double KB action is always repeatable with properties: |
1. If `soft-keyboard-toggle-behaviour=enable/disable` was set, then pressing keyboard toggle wouldn't show the keyboard after switching back from another app if keyboard was previously disabled by user. 2. If switching back from another app, like when opening url with context menu "Select URL" long press and returning to termux with back button, then soft keyboard wouldn't automatically open like it does on app startup. Also fixed issue where OnFocusChangeListener wasn't being set up if keyboard had to be hidden or disabled on startup. Fixes termux#2111, Fixes termux#2112
54513e3
to
1ad038e
Compare
Only 1
With |
You're right the So far I have tried to understand the OS-KB behavior without source analysis. I can only explain the condition described above by an init problem. Also by commenting:
I can not get back the OS-KB. The only chance is to edit with the PC in the Properties Addendum with BT-KB (SM-P610)With the
unwanted is every show/appear/raise of OS-KB by randomly touch on screen. On SM-P610 with Termux in background or in a big Picture and normal work speed, I get it about 20 times a minute and on Phones 5-10 times. @agnostic-apollo Unfortunately, with the If you want to repeat/understand that on a split-capable device/AVD, is P/B: top/bottom or right/left. VNC is not split-capable. |
@RalfWerner Sorry, I don't understand what you are saying, so can't help. May get someone who can understand your local language and can write readable english to write the comment for you. If someone else can understand the above comment and can explain, please do. |
Thanks for your response @agnostic-apollo. I assume it's also to my question here. I can understand the two (A: my and B: yours) commits above well when I translate in my local language. So I've prepared a Test with two sentences from above and translate them with google into German -> Spain -> French -> English. before: A: I find the behavior extremely confusing. OS-KB is never displayed or always or after various KEYBOARD actions after: The result is still understandable for me, even with the small differences. Split.mp4Here you see the behavior of Termux + X11 in Split mode on a real device. The effect is also repeatable to AVD and with other apps as X11. Since I know the effect, can repeat it and avoid, I will not suffice so often. Since you currently have no interest in troubleshooting is Ok and I'm waiting for others to annoy them and open Issues that you understand better. |
Understanding one or two sentences here and there does not mean I understand what you are trying to say overall. And I don't have time to decipher it all.
Fill following template (No stories!)
If for above
In this video the keyboard is showing so different from "OS-KB is never displayed". Anyways, did this start on termux I need the logs to figure out what is happening. Set log level to |
I also accepted that and that we cancel the common search for solutions now.
If it interests you: the video above shows my Huawei-Y7/Android 8, mirrored with scrcpy and filmed with apowersoft. A shot is not possible because the flickers then can not be seen. The Extra keys of both splits are sometimes there, sometimes away and sometimes twice on unexpected positions. The OS KB is once there and finally away. Due to my screen touches, it would have appeared and disappear should be about 5-10 times. The topic BT/USB and PiP is not treated in the video. It can be repeated on all AVD. So also on your and yourself can produce a few thousand logcat lines.
All checks with BT=Blue Tooth I have done with identical effects with USB. So BT-KB=USB-KB. You've used another term: Hardware KB, with which the PC keyboard is meant using Android device mirrored (scrcpy, TeamViewer) on a PC monitor. This have a different behavior. Most concerns I have with my PiP capable device. You have no and no emulator found so we continue talking different languages. It is as if I wanted to explain an Android device to my mother 40 years ago. She would not understand me, even though she taught me speak. Today and with some time and patience it is no problem anymore. That she do not want to understand and learn the |
…-not-showing-in-some-case Fix issue where soft keyboard would not show in some cases
…-not-showing-in-some-case Fix issue where soft keyboard would not show in some cases
soft-keyboard-toggle-behaviour=enable/disable
was set, then pressing keyboard toggle wouldn't show the keyboard after switching back from another app if keyboard was previously disabled by user.Fixes #2111, Fixes #2112
@trygveaa Here it is, kindly test. Thanks.