B4A Library [Class] Input Type Constants

This class contains constants for all of the available inputtypes as defined on Android Developers except TYPE_TEXT_FLAG_AUTO_COMPLETE, which would require a Java library to be of any use, but we have other options to do this anyway.

It also provides a method to update the values associated with an EditText as many of the Constants need to be OR'd to work.

There are some examples in the file, the basic principle is that you need to specify a class and either the Flag and/or variation required. Some are already available in the designer and the InputType Constants provided with the EditText methods.

I wanted to use FLAG_NO_SUGGESTIONS and it seemed almost as easy to create a class with all of the constants.

I've tested quite a few of the combinations and some do not seem to do anything on some devices. For instance, the HTC already has sense which is automatically on and provides some functionality without having to turn it on.

There are also methods to get the current InputType, InputTypeClass, InputTypeFlags and InputTypeVariation.

You can compile it directly to a library if you want to. Let me now if you find any issues.


Requires the Reflection Library.

Version 1 attached
Version 1.1 - Added initialize object
Version 1-2 - Added missing flag for completeness, would require an additional library to implement.
 

Attachments

  • ipc1-2.zip
    10.7 KB · Views: 788
Last edited:

Caravelle

Active Member
Licensed User
Longtime User
I was looking for a code snippet which would enable me to set the keyboard to capital letters and turn off suggestions, and hoped that this would give me a clue. I know you have to OR the constants, but I'm not sure how I do that, so I need a simple example.

Anyway, I tried this demo on my Galaxy Tab 7 with Swiftkey soft keyboard (which I much prefer to the original), and each of your settings seems to work except "no suggestions". I still get suggestions. In the app I am writing, suggestions are a pain in the neck and I need them gone ! Most of what I need to key in are alphanumeric codes, not words in any language, with the possible exception of Klingon. You would think there would be a setting in the Swiftkey app itself to turn suggestions off, but if there is I can't find it.

So I switched back to the Samsung keyboard, and the result is just the same :BangHead:. The suggestions are not going away. At least the Samsung keyboard gives me the option to turn suggestions ("predictive text") off via its internal settings menu, but it's not convenient to keep changing, especially as my app is likely to be used at the same time as I'm writing emails, swapping back and forth.

Can you tell me please if I have to conclude that neither of my keyboards will respond to programmatic instructions to switch suggestions off ? I'd be delighted to hear that there's simply a mistake in your code, but I fully expect to hear that it's perfect.

Thanks

Caravelle
 

stevel05

Expert
Licensed User
Longtime User
Hi Caravelle,

Not good news I'm afraid, searching on Google shows that these keyboard modifiers are dependent on the manufacturers/developers implementation and there appear to be a few instances where some just don't work.

I can confirm that these work on my test devices, (it was FLAG_NO_SUGGESTIONS that I wanted in the first place) so the code is correct.

There are suggestions on the net that some devices work only with specific combinations, so you could try mixing them up to see if you can find a sequence that will work for you.

I can't give you any more info I'm afraid as I don't have a Galaxy Tab to try it on.
 
Last edited:

Caravelle

Active Member
Licensed User
Longtime User
Oh dear, I thought that would be the case. It is typical that all the modifiers <do> in fact work with my keyboards, except the one I really need to use. S*d's Law strikes again.

The trouble is I don't really know how to "mix them up", that's what I was looking for in the first place !

I have asked SwiftKey to include an option to turn suggestions off like Samsung do, but I don't expect a Swift reaction.

Just to amuse everyone... I typed "what happens if I OR two numbers?" into Google. One of the top results was "Curious About Astronomy: What would happen if two stars collided?" :SHOCKED: I think I'd better not experiment then. Just in case.

Caravelle
 

stevel05

Expert
Licensed User
Longtime User
Have a look at the SetInputType method in the SLInpTypeConst module. You need to use Bit.Or, or you can just pass them to the method.
 

Caravelle

Active Member
Licensed User
Longtime User
Thanks.

In my app this works nicely to set the Caps Lock (excuse the layman's terms, but in plain language that's what it does):

B4X:
TxtSearch.InputType = Bit.OR(TxtFind.INPUT_TYPE_TEXT, 4096)

I've tried to get rid of the suggestions like this:

B4X:
TxtSearch.InputType = Bit.OR(TxtFind.INPUT_TYPE_TEXT, Bit.OR(4096, 80000))
. I don't know if that's the right way of coding it. This keeps the CAPS LOCK but doesn't get rid of suggestions. Fortunately no stars have collided yet, not locally anyway. I guess I'll just have to try feeding other numbers in where it says "80000" and see what happens.

Incidentally, many users have asked Swiftkey to have an option to disable predictive text, and the person who manages their suggestion Forum has given it the thumbs-down, his reasoning betraying a lack of understanding of how the product works. Time to look for another keyboard I think, as other disgruntled users are doing.

I'm now going to search for a way of programatically selecting one of a set of installed keyboards - that may provide an answer if I can find one that follows the "standard".

Thanks

Caravelle
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
how do I see the numeric keypad on most single colon ":"
thank you
 

stevel05

Expert
Licensed User
Longtime User
Sorry Roberto, I don't understand your question. Can you explain a little more?
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hi Stevel
in other words, I would like to display the numeric keypad on most single key character ":" colon. I hope I was clear.
thank you
 
Top