Why simple Text() recomposed? - android

I have a dialog with header, message, input string and 2 buttons based on AlertDialog.
Full code is here
Before refactoring my buttons recomposed when user enters text, I change it, but did not touch the message. And after that suddenly message starts to recompose when user enters text.
The picture is like this now.
I did investigate this, but with no luck. If I change the message with simple constant like "message" the recompositing is not happen. If I change the message with constant stringResourse(...) inside dialog (not in screen function) the recompositing is not happen. May be this is a bug in compose?

Related

how to implement sms verification design

I would love to add this elegant verification code screen to my app but I'm completely lost in how to do it
should I implement each box as a TextInputEditText ?
how can I make the cursor move from one box to the next one while typing ?
ps : I'm using kotlin
I would make those boxes as a TextViews (not EditText) - you don't want to have a soft keyboard opened and the user will be only using buttons below in order to enter verification code.
When the user presses number below - show it in the next available TextView, when every TextView is filled with number - verify whole code. The same should work backspace button - clearing previous filled TextView.
You might want to make TextView to be highlight when it is going to be filled with the next number press, you can do this with a state-list background.

Best GUI to let the user edit a list of strings in Android?

Suppose, I need the user to be able to input a list of strings somewhere in the settings of the app. Say, it's a list of URLs. The strings are not supposed to have any spaces, commas or semicolons inside.
The easiest thing I thought of so far is to make a big multi-line EditText with a hint to the user "Separate strings by spaces" and each time the user presses OK, use split(" ") to extract the array of strings.
The problem with that simple solution is that sometimes strings are not long enough to fill the whole EditText width, and >1 strings appear visually in 1 line. Sometimes the URLs are too long, so "www." remains on one line, and the rest of the address appears on the next line. It all looks messy and the user looses track where separate URLs start and end in the line.
Another easy solution: a long single-liner where all strings are separated by ; with optional spaces after. VisualStudio uses that in settings, I find it bad as well since you don't see all the strings at once and have to move in this long line a lot (even harder with the clumsy touch screen).
A more expensive solution: a vertically scrollable list of single-line EditTexts, which are generated programmatically each time the settings screen is opened. Would also need a "+" button which creates a new EditText and a "-" button next to each of the existing EditText's.
EDIT: Another idea: show all the strings in a plain ListView with a "+" button in the last row. When you tap "+", it turns into an EditText with 2 buttons to the right: "OK", "Cancel". "OK" would save the newly added string.
If the user taps any of the items in the list, the line turns into an EditText with "OK" and "Delete" button. "OK" saves edits, "Delete" deletes the item. "OK" and "Delete" buttons better should have images instead of words.
Or, well, all strings can be shown in a ListView, and each time the user taps on an item, an additional popup is shown with EditText for editing the string and 3 buttons below: "OK", "Cancel" and "Delete".
Am I thinking along the right lines? Do you know any existing patterns/libraries/solutions which solve this problem efficiently on touch screens?
It would be better, to have only a single editText, where user can set values in list one by one, and can see added values in listView, There may be some provision for a button to save all entered data, onve. See following link once,
http://www.mubasheralam.com/tutorials/android/listview-transcript-mode
IMHO touch screens are not made for extensive writing since the touch keyboards are awful for writing stuff too long or with too much symbols (e.g. programming language or URL). Do not think about touch apps like old desktop apps/systems. Maybe you should rethink your design and try to avoid this data input.
If it's something your app cannot live without, or you simply do want to do it that way anyway:
I think a newline separator is way more clear than a space or a ";" (assuming the URLs cannot contain ";" btw...).
What about one EditText for each URL, generating EditTexts programatically as the previous one is filled.

Android: EditText setError covers up standard AlertDialog buttons

I have a standard (not custom, no layout) AlertDialog with literally just an EditText as its view and two buttons (OK and cancel.)
When there's a problem with the input, I show an error message that ends up being three lines of text, which occludes the OK and cancel buttons. The error text does disappear once the user types something, but I'd sure like the cancel button to be visible.
Is there any (easy) way of changing the placement of the error text?
Unfortunately, not without some customization. The internal PopupWindow managed for the error display is called with showAsDropDown(), which let's Android decide where to display the view in relation to it's anchor (the error icon, in this case) and it will always be below the view unless there is not enough window space. You would have to create (albeit fairly simple) subclass of EditText that displays the internal PopupWindow using showAtLocation() instead.
Here's the link to the TextView source to hopefully help out if you want to try that. The setError() and showError() methods are what you would be after overriding.
HTH

popup windows in android?

Pretty new to android so excuse me if this is a really obvious question.
Say my application has a bunch of TextViews, each one showing the attributes of a certain product (name, price, etc). I have a button next to each of these TextViews labeled "modify".
How do I make it so that when I press the modify button next to a certain attribute, a popup window with a space to enter text into comes up so that the user can enter text into this box and then have the actual attribute listing on the original page change? Actually I just need a push in the right direction with creating this popup text field... not sure if there is already some built in functionality for this or if not, what would be the best way to create this kind of thing.
Thanks.
Why not have the modify button set TextEdit.setEnabled(true); and then change focus with TextEdit.setFocus? Note that both of these are inherited from view
If you really want a dialog you might want to looking into the AlertDialog.Builder. I know you can use it with buttons and radio buttons, but I'm not sure you can get it to work with a TextView.
Use a code like this for the input popup: Android dialog input text
In the positive button handler, set your edittext content programmatically like this:
myEditText.setText(value).
As simple as that. The only difference with a standard GUI framework is that you don't retrieve the value as a result of the popup function. Instead, you must provide an action handler.

patterns on showing an empty textfield in Android

Well I am developing a simple Tip Calculator app as a part of a course and I was faced with the problem that if the user enters an empty text field, how should the error be shown to the user.
I thought of 3 ways:
Show a Dialog stating Bill Amount not specified [Though this is really very lame.]
To show a message in red stating "Bill Amount not specified" and highlighting the text field [Something similar to what it is done on the Web when you do not say enter a username on Gmail].
Use the Animation class to kinda vibrate the text-field in order to show that its not populated.
I was wondering if there are some patterns or good practices which are followed in order to display an error message related to a required field being empty.
Thanks in advance
I've found using Toasts and optionally slight style changes notifies users without being too intrusive. I cannot stand JavaScript popup boxes on websites.
Toast toast = Toast.makeText(this, "Bill amount not specified", Toast.LENGTH_SHORT);
toast.show();
Then animate your box or maybe add/change some red text to guide the user to the correct input box. This way notifies the user without requiring any additional input beyond fixing their mistake (like hitting "OK" on a dialog, etc)
I'd put up an AlertDialog with a "required field blank" message and then, on dismissal of that, set the user input focus to the field in question. (In HTML forms, it's pretty standard to turn the label red, so you could do that too; maybe use a key listener to turn the label back to its original colour when text is entered?)
ETA: or, have a textview with the "required field!" message in above the field but with visibility set to gone by default; then you can just change it to visible/not as needed, which will be a clear visual clue to the user without the annoyance of having to dismiss a dialog.
I'd find the animation thing really annoying. Basically, go with option 2.

Categories

Resources