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

Improve keyboard switch #311

Open
J-Jamet opened this issue Aug 23, 2019 · 13 comments
Open

Improve keyboard switch #311

J-Jamet opened this issue Aug 23, 2019 · 13 comments

Comments

@J-Jamet
Copy link
Member

J-Jamet commented Aug 23, 2019

The keyboard switch when a new entry is integrated.

This is not possible at the moment because the Android operating system does not allow this change by the user. The automatic change of keyboard requires an elevation of the rights ('root' which is very dangerous on a device who manages the passwords)

https://stackoverflow.com/questions/38122702/android-change-keyboard-programmatically/38473659

or a specific adb command.

pm grant com.... android.permission.WRITE_SECURE_SETTINGS

Increasing the access rights of a component can have edge effects, if Google has chosen this level of security for the settings, it is not without reason. The various elements attached to it in the AOSP source code should be studied to see the implications.

To follow post : #230

@J-Jamet J-Jamet changed the title Improve keyboard change Improve keyboard switch Aug 23, 2019
@jed84
Copy link

jed84 commented Jan 19, 2020

Any updates regarding permission WRITE_SECURE_SETTINGS?

KeyboardSwap for Keepass2Android allows swapping keyboards automatically by giving that permission: https://play.google.com/store/apps/details?id=keepass2android.plugin.keyboardswap2&hl=en

Does Magikeyboard support this as well?

@J-Jamet
Copy link
Member Author

J-Jamet commented Jan 19, 2020

@jed84 Currently no. As described above, there is a need for the ADB command to increase privileges and access this permission. I have not yet looked at the security impact.
https://stackoverflow.com/questions/5034160/how-can-i-get-the-dreaded-write-secure-settings-permission-for-my-android-app

@chilliger
Copy link

chilliger commented Feb 26, 2020

I like the way KeyboardSwap is allowing it in keepass2android. Would love to see this feature implemented here. I really miss a fast way to switch to the Magikeyboard. But other than that Magikeyboard is way more usable than the one from keepass2android. Keep up the good work!

@poppypundit
Copy link

poppypundit commented Mar 21, 2020

Can there be a globe button that alternates between ALL keyboards added? Currently, I have two keyboards + Magic keyboard (three in total). When I swap between keyboards by pressing the globe near space bar, it goes from English>Mother tongue>Magic keyboard. Once Ive reached Magic keyboard, I lose the globe icon to alternate back to English.I now have to long press the spacebar and click the keyboard I need. This keeps happening, eventually having to disable the Magic keyboard.

Problem is that the Magic keyboard (closed database) bar comes in between me typing mixed text, alternating between two languages but once it reaches Magic keyboard, I can't alternate pressing the globe)

Note: non Latin based language, AOSP keyboard, No Google play services.

@OLLI-S
Copy link

OLLI-S commented Jun 9, 2020

In #588 (Auto-Switch Keyboard) I wrote the following text:

Is your feature request related to a problem? Please describe.
In KeePassDX I have to switch the keyboard very often:

  1. I open a website with a login form (with the default keyboard) and have to switch to the Magikeyboard to click on the "Key" icon that opens KeePassDX
  2. After unlicking the database I click on the search-icon and here I have to manually switch the keyboard again (yes, there is a button, but this is an additional klick)
  3. After selecting the entry in KeePassDX, the browser is shown and here I have to switch the keyboard again from the default keyboard to the Magikeyboard

Describe the solution you'd like
When I click the search icon in KeePassDX please switch automatically to the default keyboard (step number 2 in the list above).
After I selected the entry in KeePassDX and the browser is shown, please switch to the Magikeyboard (Step number 3 in the list above).

I posted this here, may be my suggestions (ways how this can be implemented) help.

@anon8675309
Copy link

In previous versions of KeePassDX, after switching to the Magikeyboard in a browser, clicking the lock, and selecting a key, the Magikeyboard would still be selected. I'm using 3.4.4 now (from F-Droid) and it now automatically switches me away from Magikeyboard after selecting the entry in KeePassDX.

To be clear, here is my use case:

  1. I open a website with a login form (with the default keyboard) and have to switch to the Magikeyboard to click on the "Key" icon that opens KeePassDX
  2. I select the entry in KeePassDX, never switching keyboards in the process
  3. The browser is shown and here I have to switch the keyboard again from the default keyboard to the Magikeyboard

Expected behavior is that if the magikeyboard was used to get into KeePassDX, then the magikeyboard would be selected when returning to the app. It seems like the behavior in #588 was partially implemented (to help out the users that use the search feature within KeePassDX).

I believe the text in the original issue is incorrect. My phone is not rooted, and I didn't run any adb commands to grant any extra permissions, yet the keyboard is clearly switching without an explicit user action.

Is there anything I can do to help resolve this issue?

@J-Jamet
Copy link
Member Author

J-Jamet commented Jun 7, 2022

@anon8675309 Let me put it in context:

  • it is possible to switch easily from Magikeyboard to the previous keyboard.
  • it is not possible to switch with the current versions from an external keyboard to the Magikeyboard (that's why this issue is open).

If for some reason the search is open, the cursor will move to the search field and the keyboard will return to the previous keyboard.
As it is not yet possible to switch automatically to the magikeyboard, you will have to switch back manually when you have the form to fill in.

I haven't studied the security impacts yet so I don't know if I will add the permissions for this feature.

@anon8675309
Copy link

Thank you for the explanation. Tapping the key icon now automatically places the focus in the search box, which automatically switches to the previous keyboard.

I'd like KeePassDX to not autofocus on the search. This would enhance the UX and users who want to search could still click into the search box and retain the "switch back to previous keyboard" functionality. Should I open a new ticket about that, or could that be handled under this one?

To others who find this ticket, a workaround is to always long press the key icon. This takes longer than it used to before to application filter was added, and it doesn't show the nice filtered view, but it does avoid the keyboard switching away from magikeyboard. Now you can just navigate to the group which has the entry you want and select it. No need to repeatedly switch to the Magikeyboard anymore! 🎉

As for the security risk of WRITE_SECURE_SETTINGS, it allows the app to do things that users would not expect. For example, an app with that permission could enable the GPS and start tracking the users movement, or enable the NFC feature and read the data of a tag that is within range. Android bundles all of these things together, which means there's no permission which would limit the app to be able to switch keyboards, but not do these other things.

As long as the app is neither malicious nor compromised, it shouldn't make any practical difference, but it's bad practice to give apps more permissions than they actually need. For me, there's absolutely no way I'd be willing to grant this permission to any app.

One option to attempt to serve everyone might be to detect if the app has this permission and do the force switch in that situation. If that's not possible (I'm not sure if apps can check to see what permissions they have), the switch could likely be put in a try/catch to switch for users who have this permission and silently fail for normal users. It seems like this would be a reasonable way to try to get everyone the functionality they wanr with thr security they are comfortable with.

@rugk
Copy link

rugk commented Jun 7, 2022

For me, there's absolutely no way I'd be willing to grant this permission to any app.

For me that would be fine given such an explanation of a usage that keyboard switching is a system setting which it needs permission for. Its floss and even if so doing things like enabling random settings it shouldnot is not such a big risk imho. You could mostly just annoy users.🙃🙃
After all yeah it could enable GPS but the app itself has no location permission so it could not track/usw the data by itself, so if would need a malicious cooperation of two apps. That's not a threat in my thread model tbh.🙃

After all, it can and should stay optional yeah, so no problem here.

@J-Jamet
Copy link
Member Author

J-Jamet commented Jun 7, 2022

Tapping the key icon now automatically places the focus in the search box, which automatically switches to the previous keyboard.

Only in some cases, if the search by domain name is performed and there are several entries that match then yes. But as you said ,if you do a long click on the key, the automatic search is not activated and the search field is not selected.

I can try to improve the concept when it's an automatic search to not open the keyboard automatically but I don't know if it's possible easily.

Should I open a new ticket about that, or could that be handled under this one?

New issue is good for the follow-up.

ChackCallingPermission method should help to know if permission is granted.
But yes, the most important thing will be to inform the user.

@onnag
Copy link

onnag commented Jan 14, 2023

I have the same problem as @poppypundit described. I have 3 input methods used by the system in this order:

  • AOSP Keyboard
  • Magikeyboard
  • Mozc (Japanese IME)

When I click globe icon on AOSP keyboard, it switches to the next input method, in this case Magikeyboard. Then when I press keyboard icon on Magikeyboard, it switches back to the AOSP keyboard, instead of the next input method (Mozc). If I try to click globe icon on AOSP keyboard again, it switches to Magikeyboard again and I'm stuck in this loop, where I can't switch to the third input method, without long pressing globe icon and manually selecting needed keyboard.

Possible solution
Keepass2Android's keyboard somehow doesn't show up when you cycle through input methods by clicking the globe icon. It only appears when you manually choose it by long pressing globe icon or when you click on corresponding Keepass2Android's notification with selected database entry.
It would be very nice if this was default or configurable behavior in Magikeyboard.

@vertigo220
Copy link

It seems a "simple," though not ideal, solution would be to add a very basic keyboard to Magikeyboard, so when tapping the keyboard icon, instead of switching back to the user's main keyboard, it opens its own rudimentary one that would maybe not be preferable for normal use but would be enough to quickly type a few letters for the purpose of performing a search. That way, it wouldn't have to switch back from another keyboard, or have the user do so manually, it could just switch back to its own main interface. I realize this wouldn't be truly simple, because it would require different languages/layouts, but again, the keyboards could be very basic.

@rugk
Copy link

rugk commented Sep 14, 2023

Btw I have manually granted WRITE_SECURE_SETTINGS to some apps like "logcat reader" or "Scoop" (okay a different seeing but anyway) so it is possible to explain and present it in a quite user-friendly way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

9 participants