IME and catching (touch) events - android

Im currently trying to get my diploma in psychology and i want to write about different types of keyboards for smartphones. To research this area i need a tool that measures times. As Im new to Android programming, my friend is helping me, but we got stuck.
Here is what we need, and what we tried. Id really appreciate any help =)
We need a way to call a function before user input in IME begins and after user input in IME ends. (We need this only for timelogging, we dont need the actual input.)
We also need to call a function before user input for chosing autocorrection starts/ends.
We need to do this for all kinds of IMEs especially keyboards
like Swype, Swiftkey etc (though one of them working is enough)
We tried:
TextWatcher via addTextChangedListener
- seems to be unreliable to get the times beforeTextChanged/afterTextChanged is randomly called, even within a gesture
or multiple times within a gesture
subclassing EditText implementing OnTouchListener,
using onTouch()
- didnt seem to get called at all when using swype, so either we did it wrong or ime/swpye consumes those events,
also tried it with onKeyPreIme, wasnt called either
Ideal would be:
a way of catching the "touch" events before they are passed to the IME to log the current time via System.currentTimeMillis()
the same "after" the gesture ends i.e. when the finger is released from display
we dont need actual code, a link to the right command/documentation/widget would be sweet.
You get bonus cookies if you are ever in berlin and need a place to ... get cookies :)

Not sure if this is much of an answer, but...
Is your plan to write this in an Android application that you can distribute and run on anybody's device?
Sounds like whatever you do on the EditText or your application may not be enough because the IME is a separate module in Android, so you would not be able to get any information about auto correct or prediction or things like that (different IME have different of such features). You would only be able to get the text entered (or removed) from the text entry.
The best I can think of is for you to develop your own IME, then you can log anything you like in there.
To go about that, I would suggest, you first checkout this article from Android Developer:
http://developer.android.com/guide/topics/text/creating-input-method.html
And then you can check out the source code for the default Latin IME there:
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/inputmethod/latin/LatinIME.java
Although this one has probably much more than you need and has (I think) some links into the Android framework itself, so you cannot really build it as a separate module the way it is now.
Hope that helps

Related

Android Accessibility : characters announced twice

Precondition : Accessibility Talkback on.
Problem : While typing in characters from soft keyboard into the edit text, the characters are announced twice.
(I think once by the keyboard and once by the edit text).
Problem: Sighted users don't understand/empathize well with the types of information that blind users need. They just use a keyboard with TalkBack on, without actually closing their eyes and experiencing it the way a blind or partially sighted user would.
Solution: Close your eyes and actually use the keyboard the same way a TalkBack user would. You will discover that there are actually two relevant pieces of information here. The key that you're going to select and the key that you've actually selected.
Real Solution: Let Android do its thing unless you REALLY know what you're doing. More often than not, well intentioned, developers just muck things up when they start trying too hard. Provide content descriptions for your non-text controls, hook up some nice data associations when necessary and otherwise leave things alone.

How to make text input with dropdown suggestions using Flutter

I have just begun using Flutter to create a mobile app.
The first thing I need the app to do is to take an Address/location as input from the user.
I would like to use a text input field that once you start typing it suggests locations based on the google place API.
Sadly there is no widget to enable this out of the box, but it shouldn't be so hard to do. Google's places API returns results based on any text input, so you can just keep sending keystrokes until the user sees (and selects) their desired location. I've got the API working already.
Now I'm struggling with how to build the front end experience.
I was hoping to have a drop-down text field, but I'm not finding anything similar in the widget library.
My next best idea was an input field with a DropdownButton class next to it. I want to make the DropdownButton invisible (0 width) but programmatically make it drop down once the user begins typing.
Sadly I don't see any way to control the visibility of the Dropdown List, so I'm not sure this will work.
Does anyone have any better ideas?
Image of what I have so far but obviously this is not optimal:
It's probably late for an answer but I'll still post this in case anyone else is still curious about this.
If you have the API wired up then what might prove useful is this third-party package.
It's called Flutter Typeahead.
It's a generic input with dropdowns and the data can come from any API and not just the Google Places API.

Detect when the user enters/leaves "Swipe to type" mode in TextInput/EditText (Android)

This is an Android question.
Inside my <TextInput> (ReactNative (which renders an EditText in Android)) when the user types "#" and then they use Androids swipe mode to auto-complete a word, it adds a space between the "#" and the autocompleted word. So what I was doing was, onChange of the text, I replace the space between "#" and the word, however while the user is in swift mode, it is really messing things up. The space comes back and the swift autocomplete messes up to another word.
Is there a way in react-native to listen when the user accepts an autocompletion? I want to then check if the previous two chars are a # (hashtag and space) and if so, then replace it with just # (hashtag without space).
I was thinking the onCommitCompletion- https://developer.android.com/reference/android/widget/TextView.html#onCommitCompletion(android.view.inputmethod.CompletionInfo) - fires after a suggested word is accepted - is this true? If it is this would be perfect and I can submit a PR to react-native to accept this for Android.
Here is a video of what's happening: https://gfycat.com/AdmirableGrizzledIrishsetter
Low quality:
This is happening because you are typing a text via Swipe feature of your keyboard. The Swipe feature automatically adds an extra space before and after the String. There is no way to get rid of it, it's an integrated feature of(some) the keyboard. We have no control over it.
Don't worry, the end user is aware of it and all he has to do is type the whole text rather than using Swipe feature to input his text.
Try disabling AutoComplete inside your TextInput , perhaps like <TextInput autoCorrect={false}/>, I'm not sure.
Also, this isn't the problem with Android phones only, try installing GBoard in an Apple Device and you'll face the same problem.
I worked on a major keyboard for 2 years and I have no idea what you mean by "swift mode". But there is no such feature in the generic keyboard API. It may be a feature of some particular keyboard, but there'd be no way to programmatically turn it off.
What you're describing comes closest to sounding like autospacing. This is not a concept that Android has, it would be a concept of each individual keyboard. And since Android knows nothing about it, it can't turn it off (on many keyboards the user could, but that's it).
You might be able to override it (not turn it off, but force the spaces to disappear) if you were to do some work with either overridding the InputConnection or setting a text watcher in Java and altering the text to be inserted, but neither can be done at the react native level- you'd need to write a custom edit text and link that down to react native via a native component.
I think this would be onCommitCompletion - I'm not sure though I am not able to test yet. I think in this callback I would get the position, and see if there is a leading space, and if so then remove that leading space.

is it possible to detect/modify input from softkeyboard

I'm currently working on android service. One of its task is to read the input data entered by user (and also modify it) .
The only possible way that till now, I've figured out is to make a custom keyboard and write methods in that custom keyboard. I don't want this .
Is their any other method for it?
Thanks
Edit: I need this to work across multiple applications. So I don't think TextWatcher can help here.
It can surely be observed by using an Accessibilityservice.
Check
http://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html
specially typeViewTextChanged and typeWindowContentChanged
This will not completly check all key hooks but you can check for changedtext in the focused window. With a little workaround you will be able to do what you want to do.

Adding a "View" to the recieving/placing call window on android

I am looking for some help, not being spoon feed source code (which from some of the threads I have read on this forum wouldn't happen anyway). I am really just wanting to know if what I have conjured up in my head is even possible or not, and if it is if I could get pointed in the right direction. So, I am looking to add a "view", doesn't really matter what type the concept would be the same for all of them, to appear when receiving or placing a phone call. You know the one that has the little droid waving at you or a photo, etc. The only thing is that I would only want like the top 30px to be this "view".
For instance, you receive a phone call and at the top of your screen on top of the receiving call window is a TextView with a note about this person (i.e. - he stinks).
The only thing I have been able to come up with so far is that I would have to bring up a layout that was either invisible or gone, but have yet to figure it out as of yet.
Am I barking up the right tree or do I need to find a different tree to sniff. Any and all help would be appreciated.
I honestly don't know the answer to this, but if it were possible then presumably you would have to have your own custom Activity launch in response to an incoming phone call event. This Activity of your own would replace the standard system phone application. So I did a search on here and the most vaguely related previous questions I could find within a short time are these:
Is it possible to write a new "phone" activity, and if yes then how?
Launch an activity at end of a phone call on Android
Answers on those seem to suggest the phone would need to be rooted before you could replace the standard phone app for receiving calls.

Categories

Resources