Common practice for handling time field EditTexts? - android

So if I have three EditTexts: one for hours, minutes, seconds, with a max length of two numbers per field, it is conceivable that someone inputs "99" seconds or "99" hours for example -- numbers that are >=60.
If someone entered 60 seconds you'd want this to be the same as "1 minute 00 seconds" for example.
Is there a common practice for this, or a common input field in Android that allows for the input of time in a standardized way?
Because otherwise I end up delving into this awkward dance of trying to "translate" the EditTexts when someone is done editing them (apparently there's no clean, consistent way to do this), but then there is the issue of what happens when someone enters all 9's and there is no room to "carry over" anything.
Is there a standardized input for this?

Yes, there is a standard widget to enter a time in Android. You can see it in different forms here and there. It's TimePicker widget. You can find a quick tutorial here.

Related

Forcing talkback to read some specific characters - Flutter

I would like to make the talkback say a simple mathematical expression like: "2 - (3/5)"
However, when it reads, talkback skips the parentheses, thus affecting the expression to take on a different meaning.
Thanks to #QuentinC I was able to read more questions on the subject. Would this fall under "it's best to leave it at that and not edit" cases, or should I instead be looking for ways to force talkback to speak every character?

how to convert hours:min:sec to dec number in android studio

I am building an Android Studio code that is supposed to calculate the user's hours of work by the hourly pay he receives.
I need to convert the number of hours to numeric value - DEC, and also reverse.
Is there any library that can help with that?
I'm pretty new so I'll glad if it was simple and understandable.
thanx.
This question is a little vague, so I am going to make a lot of assumptions.
I am assuming you mean: If a guy make a 100 dollars at 10 dollars an hour, how many hours did he work?
I am assuming you would like to go the opposite way, stating if a guy works 10 hours at 10 dollars an hour, how much did he make?
To accomplish this goal, you really do not need to convert hours to a decimal scale. For the first assumption, you would use a formula like so:
Total/per hour.
This would look something like
float total = 100.00;
float pHour = 10.00;
float hours = total/pHour;
On the second assumption, you could just rearrange the terms to where you would have;
float total = hours*pHour
If this does not match what you are asking, there are plenty of websites that will show you conversion formulas. Implementing these into a java program are usually as straight forward as my example. Now if you want to make the values user inputted or update on a database or anything else, there are also plenty of options and tutorials on how to do so.
In addition, please give more detail and be extremely clear when writing your question. There are answers for everything.

How to recieve length of time based input from user?

I am currently using a TimePickerDialog in order to receive a length of time to count down from. The problem is that I need it to be possible to select 0 hours and some number of minutes from the TimePicker. I have been unable to locate any information on how to modify the TimePickerDialog class in order to make this happen. Any help would be greatly appreciated. If easier methods (that still look good) of receiving length based input exist, any links or information would also be awesome.
You might be looking for NumberPicker widget, It enables you to select a range of numbers including 0. Take a look at this question question

Performance impact of generating Content Descriptions for TextViews

I have a lot of dynamically generated TextViews (being fed to a list array adapter), and each of their text contains a summary of a lot of small information. In an effort to improve UI, I used some styling when displaying information, like so:
(4 Votes) ☬ [tag1] [java] [regex] ☬ 2 min ago ☬ author ☬ 245 points
This line is constructed using a StringBuilder. This line (let's say) looks nice, but not friendly to accessibility tools such as "Google Talk Back". It reads like so: "four votes unknown character bracket tag one close bracket..."
So to fix that, I'm generating another string and set it for content description, like so:
Asked by "author", who has "245" reputation points, received "4 votes" since "two minutes ago", these are the tags: "tag1", "java", "regex".
This line would also be generated using StringBuilder, essentially doubles my run-time.
I'm asking:
Is this really doubling my run-time? Is it worth it? Obviously only a very small percentage of people would need accessibility tools, but looks like I'm sacrificing everyone else's CPU cycles.
If it indeed has a negative impact on performance, how can I improve it? Is there a way to detect whether "Talk Back" is used? Is android smart enough to detect this itself, and ignore setContentDescription() line?
I don't think its worth worrying about unless your app has performance issues. But it you do, you can always turn it on or off based on if any accessibility settings are turned on. You can check for enables accessibility apps in Secure Settings.

Best practice for selecting birth year

Background: I've want my users to select their birth year from a list of birth years.
I'm currently using a spinner with an item resource in XML that creates a long-scrolling drop-down list. I've read posts on using DatePicker but it would require some major modifications that make is somewhat unstable from platform to platform. So my question is:
How best to represent a selectable list of years in a form?
I do not think there is much of best practice available here. What you choose will depend on the feel of your application and how well the method integrates with it.
That said, a simple EditText is likely best - nothing clever required. Consider also setting android:digits="1234567890" on it. Doing so will also display the comfortable numeric keyboard.
I can't say I'm familiar with the andriod user interface but why does it have to be mutually exclusive to either selecting or typing in a year? Cannot you have a textbox with a drop down button next to it to select a year?
For me personally, I'd consider a date picker to be a little extreme unless you are wanting their full DOB in which case you need to be really careful how you do it due to the large variations on date representations throughout the world; in that situation then a date picker would possibly be the most suitable option.
Edit: Just something to note, if you do choose a drop down list, make sure by default you select a suitable year rather than the most recent. You know your users best but it is unlikely that you'll get a 10 year old using your app, and showing 10 items (which would automatically be skipped for 99.99% of the users) on a drop down listbox can be quite a bit of screen real estate on a small device.

Categories

Resources