How to detect user is touching the soft keyboard? - android

I want to determine the duration of user taps or swipes on the keyboard so that I can determine how long words/letters take a person to input using the soft keyboard.
Is there a way to detect only that the user has touched the keyboard (I don't care about what they are entering at this point)? I am using a TextWatcher to get the end of the tap/swipe, but I have not had any success getting the beginning of the tap/switch when the user first touches the keyboard.

Is there a way to detect only that the user has touched the keyboard
Write your own input method editor (a.k.a., soft keyboard) that contains your desired time recording. Then, convince users to switch to use your input method editor.
I am using a TextWatcher to get the end of the tap/swipe
No, you are using a TextWatcher to detect changes to text in an EditText. Such changes may be from a user interacting with an input method editor. Or, they may be from the user using a physical keyboard. Or, they may be from action mode operations like cut and paste.

Related

Shift Keyboard from Alpha to Numeric

I have a Zebra TC8300 scanner that has an enterprise keyboard. On initial show of the keyboard it shows Alpha keys. User has to slide the keyboard to get to the numeric keypad. I have an Autocomplete text box on a dialog. It has a threshold of 2. The cycle is, Once the threshold is reached, I dismiss the keyboard, call a backend API, display the results in the dropdown, set the threshold to the current length of the text box and then display the keyboard. Dismissing the keyboard is done so the user does not continue entering until the results of the API are returned. The 'issue' is the user is complaining that, if he is entering numbers, once the cycle completes, they see Alpha keys. They want the keypad to stay on the numeric so they can continue entering digits until they desire to enter alpha. Crazy, but that's what they want. I can't set the inputtype because that removes the option of going back to alpha keys once you set numeric. Any Ideas?

Ionic2 focus input without keyboard opening

We are doing ionic2 application to scan the barcode and take the user to detail of that product. The screen has input field with Opacity 0 since the input should not be visible to user to prevent user interaction. Right now the functionality works fine but the keyboard opens by default when ever user visits this screen.
I tried to user below code to hide the keyboard but this looks odd as the keyboard visible for fraction of time and then hidden;
cordova.plugins.Keyboard.close();
I want to focus the input without keyboard open, is it possible ? could you please guide me
After al long research found that there is no solution to focus the input without keyboard. Hence i changed the approach and create the broadcast receiver to handle the barcode scan.

InputMethodManager showSoftInput method

What is the purpose of the method showSoftInput in class InputMethodManager? I am new to android, and well for me the documentation is not very clear :
Explicitly request that the current input method's soft input area be shown to the user, if needed. Call this if the user interacts with your view in such a way that they have expressed they would like to start performing input into it.
From what I have understood it opens the keyboard, am I am right? Why should we use this method, doesn't touching an EditText open automatically the keyboard??
No, touching an edit text doesn't automatically open a soft keyboard. That's just the default behavior. Under the hood, when you touch the edit text a series of events occurs. Eventually the Android framework will call showSoftInput on the IMS of the keyboard. This is the keyboard's chance to decide it doesn't want to show for some reason and return false if it is not shown. For example, I believe at Swype we overrode this not to show the keyboard if there was a hardware keyboard on the device already slid out, on the theory they then wanted to use the hardware keyboard.
Most of the time you're just going to either use the default implementation here, or do a few minor checks then fall back to the default implementation.

Android: Detect When Soft Keyboard Is About to Show?

Is there a way to detect when the keyboard is about to be presented in Android?
My problem is that I have a ListView with EditTexts in it. When the keyboard is about to be presented, these are quite often redrawn, causing an EditText that was JUST tapped to lose focus and require an extra tap.
My proposed solution is to monitor when the keyboard is about to be shown, check to see which view currently has focus, then after the keyboard is done being shown, restore focus to that view.
However, I have no idea how to detect when the keyboard is "about to be shown" in Android. How would I do this?
(I would also accept an alternative answer that addresses my actual problem: EditText losing focus when keyboard is displayed)
You could do it the other way, create an unique OnFocusChangedListener myListener and set it to all your EditTexts and put a switch inside and store which is the last view getting/losing focus

Highlight text in EditText when keyboard opens

I'd like to highlight the text in an EditText when a keyboard opens for user input (this could be a hardware keyboard or the virtual keyboard).
Highlighting isn't my problem, my problem is a trigger to highlight. Is there a handler that gets executed when the keyboard appears on a specific View (in this case, my EditText)? Are there different handlers for hardware keyboard vs virtual keyboard?
As far as I know, you can't get notified of those things at that level. Why not just highlight it when the EditText gets focus? In practice this will generally mean that an IME is displayed.
In fact, there is already a method to do exactly this: setSelectAllOnFocus.

Categories

Resources