Android password fields - input hidden at all times - java

As most of you know, at the moment, the password field works in a way that it hides the input, but not right away. As you input a character, it shows that character, then a moment later turns it into a *, I'm wondering if there's a way to incorporate a functionality that makes the characters stars at all times.
Any ways of doing this?

Don't set the default edit text property as password. Instead, you can use addTextChangedListener() which will get called as soon as the user enters a character. Maintain an activity level string say "mPass". In the TextWatcher(), onTextChanged method, append character to your mPass and replace the input character by *.
But you will have to be careful regarding this because application will pass control to the TextWatcher() even after you have replaced the character by *. If not handled properly it will get called recursively causing the application to crash.
Credit to Pallavi

Related

Counter of entered characters for Vaadin Text Field (Without JS)

I need to add counter inside Vaadin Text Field's helper text:
Entered characters / Maximum possible number of characters
Question:
How can I get the current number of characters entered by the user, without using JS?
If you change the value change mode of the text field to ValueChangeMode.EAGER, then there will be a server-side value change event every time the value is changed which means that you can do getValue().length() to find the length. This approach is really straightforward but it has the drawback that it causes some redundant network traffic since each change needs to be processed on the server.
If you want something that avoids sending all changes to the server, then a little bit of JavaScript would be needed, unless you can find an existing add-on that already integrates that JavaScript for you.

Issue with sendkeys in selenium is not entering the full value in TextFiled

We are facing an issue to enter the value in text area,the text is entered but its not full (i mean if they are 10lines its entering only four lines).
This particularly happens in IE browser.
I have a text which contains *,am replacing that * with some text according to my requirement.
Its a huge text may be of 10 lines.Am replacing the star(*) at every line and then storing it in a variable.Finally am using send keys to send this replaced value,Where am facing this problem only some value is entered.
When i used java script it work magically, full value got entered into textField.
But is there a better solution for this other than using java script.
Thanks in advance
You could try splitting your text string into chunks of let's say 1024 characters and call sendKeys() several times. To your test case behavior, it shouldn't make a difference whether you type one very long text or several short ones into the same text field.

How can I sanitize text from a codename one textarea?

I have a text area in a form that is filled by the user. There are no constraints on the text area.
Because of the prepondernce of differnt types of mobile keyboards, I want to make sure that the text I get from the text area is sanitized. i.e. It should be stripped clean of any emoticons or hidden characters. It should only contain alphaumeric and punctuation characters.
What is the best way to do this in codename one? Thank you for your help.
This can be done using a regexp and there is no cleaner way. However, I believe you are approaching the problem sub-optimally.
You can detect the browser used by the user from the user agent string and based on that you can determine whether emoticons should be shown or not. Before you render the content, check whether emoticons should be shown. If not, then filter out unneeded characters. If yes, then show those emoticons.
Finally, I must mention that you must protect your database against SQL injection attempts or accidental bugs and you should make sure that XSS is not possible either.

accessing androids auto correct facilities?

Is there a way of using Android's auto correct / predictive text capabilities with a bespoke input method? I'd like to be able to access a list of the nearest words to the word entered, similar to what happens when we send a text. For example if I entered the string "hapy" I would get a list containing "happy", harpy", "hazy" ...
Looks like a yes.
And the place to start: http://developer.android.com/guide/topics/text/spell-checker-framework.html
You wouldn't want to. First off, predictive text was only turned into a service with 4.0. Before then it was just part of the keyboard, and most keyboards still implement their own I suspect. Secondly, it would be optimized for typing mistakes, not voice mistakes. Typing g instead of f is common (they're next to each other), doing it by voice is not. It wouldn't work well.
But the built in voice to text behavior does return alternatives- it returns an array list of possible texts. That is your auto-correct.

How to replace console input value with * in java?

How can I print * in the place of input character which is entered from keyboard?
Example:
If I type in the console: mouli, then it should replace m with * and then o with * and so on.
There's no way of solving this using the standard API. If this is indeed an explicit requirement, you'll have to use some system specific library that interacts with the underlying terminal.
If the intention is to let the user enter a password however, I suggest you use Console.readPassword.
The console is not a "part" of Java. It's just one of many means of inputting information to your program. I think your question is more like:
"I'm reading a string in from the Keyboard, and I want to replace every character with an asterisk".
But I'm not sure if that's actually what you want.
Alternatively, if you're trying to make a "password" entry field in the console, where typed characters appear as asterisks, you may want to look into the Console class, seen here. However, I would lean towards the assumption that your purpose would be better suited by an actual GUI. The readPassword method only stops the letters from appearing on the screen, but doesn't replace them.

Categories