Android display # sign with phone soft keyboard - android

I'm trying to make an a soft keyboard which an EditText presents have a layout of a phone keyboard but also with a "." and "#" signs.
What I tried was this on the edit text:
android:inputType="textEmailAddress|phone"
android:digits="0123456789.#"
I'm seeing the keyboard like I want as a phone layout in general and with the "." symbol but without the "#" symbol.. how can I add it to the keyboard?

I'm trying to make an a soft keyboard which an EditText presents have a layout of a phone keyboard but also with a "." and "#" signs.
There is nothing in the specifications that supports this.
android:inputType="textEmailAddress|phone"
Quoting the documentation for android:inputType: "Generally you can select a single value, though some can be combined together as indicated." The docs do not suggest that textEmailAddress can be combined with phone.
android:digits="0123456789.#"
This stipulates what characters are allowed. I am not aware that an InputMethod even finds out about this attribute; one certainly does not have to somehow magically adjust its keyboard layout to accommodate it.
how can I add it to the keyboard?
You don't, except perhaps by writing your own InputMethod, then forcing people at gunpoint to use it.
Please understand that there are over 8,000 Android device models. Dozens, if not hundreds, of input methods will be shipped on these devices, and others can be installed by users separately. These are written by independent developers. There is no requirement for any of them to even have keys, as evidenced by Graffiti Pro. And they certainly do not have to handle some arbitrary set of keys that an app developer wants.
android:inputType gives you a chance to supply a hint to the input method for how it should optimize the layout for the user. android:inputType specifically limits things to a few classes to keep things sane for the developers of the input methods. Furthermore, android:inputType is a hint, not a demand; as Graffiti Pro illustrates, not all input methods will necessarily change based upon android:inputType, at least for all possible types.

Related

Is there a way to restrict the Android soft keyboard to allow ONLY emoji characters?

I have an EditText that can ONLY be a SINGLE Emoji character. I've added code and a filter to ensure this, but I still have a usability problem because the keyboard pops up in NORMAL text mode. It's not obvious to the user that only an Emoji character is allowed.
<EditText
android:id="#+id/activity_emoji"
style="#style/Material.Widget.EditText.Light"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:text="😎"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true" />
Ideally I could disable all input except Emoji, but that appears to be impossible. Another option would be to have the keyboard pop up already on the Emoji page instead of on the normal alphabet. Is it possible to do that, and if so how?
Seems to me the simple solution would be supporting:
android:inputType="Emoji"
I've added code and a filter to ensure this
Since there is no requirement for an input method editor to offer emoji, you have a slight problem.
I still have a usability problem because the keyboard pops up in NORMAL text mode
Many input method editors only have what you consider to be normal text mode.
Please understand that there are over 26,000 Android device models. These ship with dozens, if not hundreds, of pre-installed keyboards. Users can also install others from the Play Store, F-Droid, and elsewhere. None have to offer emoji. I would expect that relatively few do, though the ones that do (like GBoard) will be the most widely-used ones.
Also, please bear in mind that not all Android devices use soft keyboards. Sometimes, that's a fairly permanent state (e.g., Chromebooks). Sometimes, it is a temporary state (Bluetooth keyboard enabled, USB keyboard plugged in, other assistive device attached).
Is it possible to do that, and if so how?
No, sorry.

Disable speech to text button (Micro phone) on soft input keyboard in android programmatically

Thanks in advance for the help.
I am developing an android application for research purposes and need to disable the speech to text button on the soft input keyboard. The reason for this is due to concurrency issues that arise since the application I am developing uses the microphone. I understand that for a general application disabling keys is generally seen as impossible (since users may change default keyboards). I know for a fact that the default keyboard will be used.
With this in mind is it possible to disable certain keys? I believe that at the least I should be able to specify the input type such that the microphone button is hidden. I say this because if I disable speech to text in the settings (not programmatically, but manually as a user) the microphone icon is removed from the keyboard. I'm open to any possible solution (with the exception of not using the default keyboard) as this application will not appear on the play store.
You can't force the user input through anything other than pre-defined keyboards that already exist in the user's device.
The only way you could get around this is by programming your own custom, on-the-fly keyboard, and that is a very bad idea.
Just disable voice input programmatically by using XML declarations in the EditText you're looking at. You can do this with the attribute:
android:privateImeOptions="nm" // nm stands for No Microphone.
If you want to set it programmatically you can try this::
// deprecated i guess
edt_txt.setPrivateImeOptions("nm");
// this one is new but it works only with Google Keyboard.
edt_txt.setPrivateImeOptions("com.google.android.inputmethod.latin.noMicrophoneKey");
You can combine values in PrivateImeOptions parameter in CVS form so best option is to use:
edt_txt.setPrivateImeOptions("nm,com.google.android.inputmethod.latin.noMicrophoneKey");
Take a look through here and see if you can find what you're looking for.
More info about Google Keyboard here -> look for method setOptions
To disable microphone button on multiple keyboard. Use property
android:privateImeOptions="nm"
But it will not work for Gboard(google native keyboard)
To disable on microphone on Gboard use
android:privateImeOptions="nm"
editText.setImeOptions(IME_FLAG_NO_PERSONALIZED_LEARNING)
Just use this in your editText on the layout file:
android:imeOptions="flagNoPersonalizedLearning"

Keyboard characters in different locales

I'm developing a keyboard (IME) for Android. I want it to be useful for people from every country. So, I need to know which symbols should be placed on keyboard based on current locale.
My first idea is to copy computer keyboard layouts. Where can I get the contents of preferred computer keyboard layout for each locale?
Also, I've noticed that phone keyboards usually contains some special symbols which aren't present on computer keyboard. Which symbols are important for phones and why? For example, all keyboards I've met provide a way to type '¿' symbol. But this symbol doesn't make any sense in my locale (russian) and isn't used in english. Is there a reason for placing this symbol on every keyboard?

Android soft keyboard show numbers view first

I have a login screen on my app which accepts a CPF as login (CPF is an unique number identification that every Brazilian citizen have, e.g: 10546819546), but it can also accept passport numbers as the login, and these may have letters on it.
My problem is that I want the keyboard, when it pops up, to show to number/symbols "view" before the default alphabet one. Changing the inputMethod to phone or number does not solve my problem, because as I said, the login may contain letters.
I've seen some explanations to questions somewhat similar to mine but all of them either didn't solve my problem or it was too overcomplicated.
This is merely a small adjust to slightly improve user experience and entertain me developing the app, so if the solution is something like "override the default keyboard, make a custom component" etc, I'll just leave it alone.
TL;DR: I want to show the number/symbol soft keyboard before the letters one.
Unfortunately when it comes to the soft keyboard you are somewhat at the mercy of whoever made the one the user has their device set to. Lots of devices come pre-loaded and defaulted to the swype keyboard. But many others have soft keyboards that were made by the manufacturer of that device. It it up to whoever created it to decide how the keyboard reacts to the android:inputType that you pass to it. It is possible that some of the ones out there right now actual have the behavior you are looking for when you set them to number or phone. I just checked it out on my sidekick and found that it was the same as yours both number and phone provided no way to input letters.

Detecting if keys are available in onscreen keyboard of mobile device

I'm adding some mobile usability optimisations to our site. As part of this I am tweaking the type attribute of textfields, to give the user the best input tools for the expected data type.
One issue I have come up against in touchscreen mobile devices is that browsers on different OSes, and even different browsers on the same OS, show different onscreen keyboards when input type="number" is used.
Safari on iOS 4.3.3 (iPhone 4) and Chrome on Android 2.3.4 include a decimal point, but Firefox on Android 2.3.4 does not.
I have tried adding the step attribute (step="0.1") with no improvement in Firefox.
If I cannot show the decimal point I will need to show Firefox the full QWERTY keyboard, which is obviously not going to make for the best user experience. It also raises the issue of browser/device sniffing. Either I'll need to make QWERTY the default, and show the numberpad to the handful of devices I can actually test on, or make numberpad the default, and switch back to QWERTY on devices which I know this will break on, the latter option being far less robust as I cannot test on every device ever made.
Testing for support for input type="number" is not a fix, as obviously the browser does support the element, it just doesn't offer enough keyboard options to enter all number types.
So.. I was wondering if anyone knew of a way to test for the presence of a certain key (such as the decimal point) in the keyboard the browser/OS assigns to the input type, and/or if anyone else has some better suggestions, as I'm quite new to mobile devices.
I should also mention that I am using JavaScript here, as this is a website, not a native App.
Thanks :)
Unfortunately, firefox does not support numeric input type. However, you can still try using these additional HTML attributes for making an input field prompt the user for numeric input
inputmode='numeric'
pattern='[0-9]*' //this makes it show only the numbers 0-9 without all the slashes and dashes and everything. Ignore this if that's not what you want

Categories

Resources