This is separate from whether the app has requested an editor action: usually the editor action is displayed as a replacement for the enter key, but it's possible for an input method to offer both as alternatives.
The simple answer is, of course, "when it's possible to enter a newline". When a TextView is in single-line mode, it's not possible to enter a newline even if the keyboard shows a key: as I found in this answer, Android itself treats the key as an editor action and substitutes a zero-width space for any newlines added to the TextView.
How can the input method tell whether newlines will be respected, or otherwise whether it's appropriate to show an enter key (as an alternative to any specified editor action)?
Your best bet would be to check the EditorInfo object returned using the getCurrentInputEditorInfo() and take a best guess if showing the Enter key is apt or not.
Related
I have an Android EditText with suggestions enabled. My goal is not to disable suggestion (since i'm able to do that), but to skip some string values from them.
For example, suppose that i'd like to skip 'hello' word.
If i write 'he' in the EditText, my suggestions list shouldn't contain 'hello' since it's a string that has to be skipped. Is it possible?
Hope i explained myself, thanks
Short and sweet: I have no idea what the difference between textVisiblePassword and text is, in regards to inputType on an EditText. According to the docs, textVisiblePassword is "text that is a password that should be visible", where password is unhelpfully "text that is a password".
What's the diff? Why use textVisiblePassword?
Using textVisiblePassword type explicilty tells software keyboard, that content of this field should not be added to any vocabulary, synchronized through network, added to usage statistics or anything like this. It still makes sense to use it for sensitive data, like logins - not exactly secret, but nothing you would share.
when we setup textPassword input type on edit text. textVisiblePassword inputtype is used when we want to have show password option. This option will make the password readable whereas text inputtype won't do this
Does anybody know of a way, or something that could ease the process of manually removing the extra strings, to get only the content of the "Text" column in the logcat view when copying the logcat content?
Seems not possible, but I've drawn an attention to it through android issues portal:
https://code.google.com/p/android/issues/detail?id=77883&thanks=77883&ts=1413891569
Hopefully it will be implemented soon enough, as it woudl be really helpful.
There are two ways to achieve that:
The First Way, if you have multiple lines:
copy your text to Notepad++ or any editor that uses Regex.
press ctrl+f and choose Replace tab.
use a Regex format in order to remove all the unnecessary tags info, for example in the case of System.out messages, the Regex formula will be:
\d*-\d* \d*:\d*:\d*\.\d*: I\/System\.out\(\d*\):
if the messages are like:
03-14 14:44:17.557: I/System.out(18293):
finaly, use this formula in [find what] field and use a white space in the [Replace with] field, and don't forget to choose Regular Expression choice in the (search mode) field.
The second way, if you have a single line of log: as described here:
Right click on the line in Logcat which you wish to copy text from
Click “find similar messages”
In the window that pops up the text is contained in the field “by Log Message:”
This text can now be copied via Ctrl+C
Our company's name always comes up as misspelled (the red underline) when typed into EditText fields in our app. Is there a way I can disable the misspelling flag for a specific word to avoid this nagging feature?
And before someone suggests android:inputType="textNoSuggestions", I would still like spellcheck to be available to that specific field, and only exclude our company name.
I have no idea if it'll work, but you can try putting android.text.style.LocaleSpan over each occurrence of the company name, using Locale.ROOT (which has no language) as the target locale.
(Most of the time you encounter a CharSequence in a text view it can be cast to Spannable. If it can't, just copy its contents into a SpannableStringBuilder.)
I am trying to modify the SoftKeyboard example (Andriod 3.1 on Moto Xoom) so that I can use an icon on the key and have it output a unicode character when that key is pressed. Specifically I am trying to have it output a beamed eighth note (musical symbol) which is unicode \u266B. Unfortunately I cannot use keyOutputText and keyIcon on the same key in the symbols.xml file which lays out the keys. I need keyIcon because I could not find a way to change the Typeface on the Keyboard Keys to one with that character. I found where I would do it, but its a call to a private method (.setTypeFace) buried in android.jar (KeyboardView if I recall) so I can't.
So I just use an icon to put on the key. This works fine in combination with android:codes, however android:codes will not output my unicode character when I feed it android:codes="\\u266B" which documentation says it should accept. I need android:keyOutputText="\u266B" to get the character to actually output into my EditText. So I can make the key display an icon of my character and the EditText display the character itself, but not the two together. When I try to use the 2 together it compiles and runs just fine, then I hit the shift button on the keyboard to display the symbols and only the numbers 0-9 show up, the rest of the keyboard is just gone. Now error messages or anything, just gone. Nowhere does it say these two things are exclusive that I could find, nor does it make any logical sense for them to be. If this is a bug, I just want to know so I can accept it and stop banging my head against it (a planned fix date would be nice too). If not, how can I get both the key on the keyboard and the EditText box to show my beamed eighth note. I am open to any suggestion or work arounds. Thanks.
Use a HashMap to map the android:codes to your unicode character.
In XML :
<Key android:codes="719" android:keyIcon="#drawable/zo"/> //use your icon and required code here
In java code:
HashMap<String, String> keyCodeMap = new HashMap<String, String>();
keyCodeMap.put("719", ""+'\u0986');
Then, in the onKey(int primaryCode, int[] keyCodes) method get the corresponding character using using following code:
String c = keyCodeMap.get(String.valueOf(primaryCode));
Use the value of c where you need.
Not sure if this is really going to help, since it's for AnySoftKeyboard, but the problem is the same, so maybe the solution is too?
What solved the problem (for me, creating a layout for ASK) was this:
supply both keyIcon and keyOutputText AS WELL as android:codes, but NO keyLabel!
keyLabel gets filled (by ASK?) with the first letter of android:codes, but you still see the image and it outputs multi-letter text.
Hope it helps, might be worth a try in any case, I guess.
(Please note: I just found this out and although I could reproduce it, I can't guarantee if it really was this that solved the problem. I honestly think so, though.)
Instead of using \u266B in android:codes try the int value of the unicode: 0x266B.
Then from onKey you can convert it back to String using:
Character.toString((char)primaryCode)