Skip to content
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

If keyboard toggle is enable/disable, you have to press it twice after keyboard is auto closed #2111

Closed
trygveaa opened this issue Jun 5, 2021 · 5 comments · Fixed by #2114

Comments

@trygveaa
Copy link
Contributor

trygveaa commented Jun 5, 2021

Problem description
With the option introduced in e4e638b for #1098, I'm having some issues with the keyboard auto closing. When this happens, and I press the keyboard toggle, nothing happens until I press it a second time (because the keyboard is disabled on the first press even though it's closed). Personally, I don't think the keyboard should auto close when having this option set, it should always be shown when the keyboard enabled.

Steps to reproduce

  1. Set soft-keyboard-toggle-behaviour = enable/disable.
  2. Open Termux and have the keyboard open.
  3. Lock the screen.
  4. Unlock the screen.

Alternatively:

  1. Set soft-keyboard-toggle-behaviour = enable/disable.
  2. Open Termux and have the keyboard open.
  3. Open a URL.
  4. Press back in the browser to return to Termux.

Expected behavior
The keyboard should still be open in Termux after these steps. Currently, it's closed which causes the issue mentioned initially about having to press the keyboard toggle twice.

Additional information
When the back-key option is default/back, the keyboard is closed on back. This causes the same issue that you have to press the keyboard toggle twice. I think when the keyboard is set to enable/disable, the back key should either take you straight out of the app without closing the keyboard (like when you press back after the keyboard is closed), or alternatively disable the keyboard.

  • Termux application version: 0.113
  • Android OS version: 11
  • Device model: OnePlus 9 Pro
@agnostic-apollo
Copy link
Member

How soft-keyboard-toggle-behaviour = enable/disable works is by updating the SharedPreferences of termux with the new soft keyboard state when you press the keyboard toggle in extra keys or left drawer. So if you disable the keyboard by pressing the toggle, it will retain that state, even on app restarts or switches. This state is the same as Termux Settings -> Termux -> Terminal I/O -> Soft Keyboard Enabled.

nothing happens until I press it a second time

Yes, that's confirmed to be a bug as you described in #2112.

it should always be shown when the keyboard enabled.

As I said, if you disable keyboard and exit termux and come back later, termux will still consider it in a disabled state at startup. It will only enable it again if you press the toggle in extra keys/drawer/settings. You can check the logcat to see behaviour after setting log level to Verbose in Termux Settings with logcat | grep -i keyboard

I think when the keyboard is set to enable/disable, the back key should either take you straight out of the app without closing the keyboard (like when you press back after the keyboard is closed)

Why should it do that? Back button is to hide the keyboard, not disable it. That will just take people out of the app when they don't want to, like to close keyboard to increase size of terminal view or to scroll.

, or alternatively disable the keyboard.

Then users will be forced to use extra key button instead of tapping on terminal view to open keyboard again.

@trygveaa
Copy link
Contributor Author

trygveaa commented Jun 5, 2021

How soft-keyboard-toggle-behaviour = enable/disable works is by updating the SharedPreferences of termux with the new soft keyboard state when you press the keyboard toggle in extra keys or left drawer. So if you disable the keyboard by pressing the toggle, it will retain that state, even on app restarts or switches. This state is the same as Termux Settings -> Termux -> Terminal I/O -> Soft Keyboard Enabled.

Yes, that's not the issue here.

Yes, that's confirmed to be a bug as you described in #2112.

I wondered if I should open one or two issues, but it didn't seem like the same issue to me. This issue is about the keyboard being hidden after returning to Termux and the toggle button disabling it instead of showing it. #2112 is that it doesn't always open the keyboard when it enables it.

As I said, if you disable keyboard and exit termux and come back later, termux will still consider it in a disabled state at startup. It will only enable it again if you press the toggle in extra keys/drawer/settings. You can check the logcat to see behaviour after setting log level to Verbose in Termux Settings with logcat | grep -i keyboard

None of the steps involves exiting Termux, so that's irrelevant and the issue here is about what happens when the keyboard is enabled, not when it is disabled. The point is that if the keyboard is open, I want it to still be open after returning to Termux. Currently, if you lock the screen or open a URL and come back to Termux the keyboard is hidden, even though it was enabled and shown before.

When I think about it, there is an inconsistency here even if you don't use the toggle button. If you go to the home screen and back to Termux, the keyboard will open, regardless if it was open or closed before. However, if you lock the screen or open a URL and go back to Termux, the keyboard will be closed, regardless if it was open or closed before. I think these should behave the same way, and that the keyboard should always be in the same state it was previously when you return to Termux.

I think when the keyboard is set to enable/disable, the back key should either take you straight out of the app without closing the keyboard (like when you press back after the keyboard is closed)

Why should it do that? Back button is to hide the keyboard, not disable it. That will just take people out of the app when they don't want to, like to close keyboard to increase size of terminal view or to scroll.

, or alternatively disable the keyboard.

Then users will be forced to use extra key button instead of tapping on terminal view to open keyboard again.

I thought it would be more useful if the keyboard is always open when enabled if the option is set to enable/disable. But okay, if the bug that it doesn't open when the toggle is pressed is fixed, it's fine, so you can disregard this part about the back button.

@agnostic-apollo
Copy link
Member

I wondered if I should open one or two issues, but it didn't seem like the same issue to me.

They are different issues, so two issues is fine.

When I think about it, there is an inconsistency here even if you don't use the toggle button. However, if you lock the screen or open a URL and go back to Termux, the keyboard will be closed, regardless if it was open or closed before.

Yeah, this is confirmed to be a bug too. I have fixed this issue, as well as "press toggle twice to show keyboard" locally, will send a pull request soon. Do you use debug builds or F-Droid? If there are no testers available using debug builds, then might as well push to master directly. The keyboard logic is very complex with so many cases that it's hard to know if something will break when I make changes, can't test every possible case, cause neither do I remember what they all are, nor do I have the time.

@trygveaa
Copy link
Contributor Author

trygveaa commented Jun 5, 2021

Great, thanks! I'm building Termux myself, so I can test it as long as the code is pushed somewhere.

@agnostic-apollo
Copy link
Member

Welcome, I guess I'll send a pull request then.

agnostic-apollo added a commit to agnostic-apollo/termux-app that referenced this issue Jun 6, 2021
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.

Fixes termux#2111, Fixes termux#2112
agnostic-apollo added a commit to agnostic-apollo/termux-app that referenced this issue Jun 6, 2021
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
agnostic-apollo added a commit to agnostic-apollo/termux-app that referenced this issue Jun 6, 2021
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
AdamMickiewich pushed a commit to VolyaTeam/dzida-app that referenced this issue Aug 8, 2022
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
shrihankp pushed a commit to reisxd/termux-app that referenced this issue Oct 20, 2022
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants