android preference settings range value - android

I am implementing a preference activity so I can let choices to the user about what my app can and can't do and to define a user profile so I can change the way I request data.
I have one part where I need to show places to the user (restaurant, stores, etc) so I would like to be able to have a "range widget".
Let's say :
1 = poor
2 = cheap
3 = average
4 = rich
I want the user being able to say I want only store between 1 and 3 so it would need to be a widget with a double "circle" allowing the user to create a range.
Any idea of something like this existing ? (I am pretty sure I already seen something like this in the past but I can't remember where)

Take a look at RangeBar. It sounds exactly like what you need

Related

Best Practice of multi language Android App

I'm making an android app with multi-language support.
I have around 30 language to support my app.
I'm playing within 2 Case.
case 1 . First case is creating values folder of every language in res folder.
case 2. Second case Get every language content with a key from server
e.g. TXT_HELLO = HELLO if user choose English
TXT_HELLO. = HOLA. if user choose Spanish
Suppose from language list I select Spanish during language change
then server give me list of every Spanish content with a same key
[Key] = [Value]
e.g. TXT_HELLO = Hola
TXT_GOOD = Bueno
& then I save this value with key is session & all key also in my Constant class
Similarly In Case if I select English:
[Key] = [Value]
e.g. TXT_HELLO = Hello
TXT_GOOD = good. as Soon
This is how my kotlin code work.
fun getLanguageValue(key : String)->{
return sharedPre.getString(key)
}
txtViewHello.text = getLanguageValue(MyConstant.TXT_HELLO)
cons and pros of case 1 .
pros : It handle by system and good memory management
cons : Language only can add on new release apk. if some word is wrong then can't be correct without release.
cons and pros of case 2 .
pros : if some word is wrong then can correct online. No need to release new APK or can add more language at any time.
cons : It handle by me and initialization of objects is more complex.
So please suggest me what is best approach & what is best practice to change language.
You could attempt to write your own language switcher that does this, but I'd advise against it. This is basically fighting the system, and is very hard to handle properly.
The best way to handle multiple languages is to use resource qualifiers, and make the system do the hard work for you. It will also match the user's expectation that your app will be in the same language as the entire rest of their phone.

How do I set multiple notifications using one date selection?

I need to set multiple notifications at the same time based on a list of mutiple choice questions. I will figure the radio buttons and if statements out later, for now I'm just setting the dates randomly for testing purposes.
If the user selects jan 1st and clicks a button. It will set a notification in the future with a reminder to do an activity. It also saves this information so the user can edit the details if he desires or change a few options.
This part I already have coded and it works just fine. however, It only sets a single notification currently. It is a pretty involved code consisting database, receivers, fragments, etc. that all talk to each other.
As I said, this part I have working just fine but I am not including all the code because it is seriously involved and no one would try to break it down if i drown you in a sea of code. I can certainly post specific code if someone request it.
My issue is that I need it to set a good amount of notifications at various future dates upon the button click, not just one. I need to change the notification message to a preset variable string for each additional notification event but some things like title will remain the same.
my current working code executes like this....
User Selects Jan 1 > User Clicks Button > Notification set for Feb 14 with a unique title and message set by the user and saved for future editing...
At the same time the notifications are set they are saved so the user can change the date and a few options if needed. I want only one title and a single date saved. I have the save feature already working but I need to know how to link the additional reminders to the existing saved item. Im trying to make all the data linked so that if the user deletes the saved item, all the set notifications for that file are deleted and not just the one that falls on the user selected date.
===== This is what I am trying to pull off
User Picks Some Options and Clicks A Button [I have this working already]
Upon Click of said button, the following notifications are all set in the future :
[currently it sets this notification only]
Jan 1 notification :
(title)Day Master App
(message)Happy New Year
[Im trying to figure out how to add the following notifications upon the above button click and also save this information to the existing db under the same item]
Feb 14 notification : (title)Day Master App - (message)Its V Day
March 1 notification : (title)Day Master App - (message)Spring Is Near
March 14 notification : (title)Day Master App - (message)Its probably raining
(((and we'll just pretend i finished the list...)))
I cant make the future notifications a static number because when the future notifications are set is determined by a bunch of radio button choices before the user clicks the execute button. This is going to be a pretty complex and hacky if/else novel the way I think I have to do it. Am I correct?
I have a display/edit listview that shows your saved notifications and the unique name and date the user set. This works fine currently but only sets a single notification based on user input.
I need to add some more notifications but i dont need to save them under a different item or name. I want them all under the same save item so all the notifications that were set when the button was clicked can be added and deleted as a group. There will be no option to delete certain notifications that were set. It will be all or none.
I would imagine I could just add some more variables into the existing "save notification" code? As in piggyback some more items (like all the dates and messages) for the additional notifications? do i need to write a new function for each future notification I set in order to be able to delete it?
do I need to create a new db for each additional notification that is set? A separate Adapter? Im so confused...
===
Im not looking for a code example exactly, I want to know how this would be implemented into an existing code. I realize there is probably 100 ways to code what I have described. I just need the process explained.
Please explain this to me slowly. I know im way overthinking this.
I tried to explain this as best I could, if you need clarification on something please ask. Thank You.
I have solved my problem although I could not accomplish exactly what I was trying to originally.
I managed to set the multiple notifications on a single click with different dates by simply copying the same code I used to display the single notification and simply giving each additional notification a unique ID and creating a new variables to give them individual text, future dates, separate times, etc. These variables can be easily set programmaticly or by the user when you set them up.
// On clicking the set notifications button
public void SetNotificationsButton(View v){
ReminderDatabase rb = new ReminderDatabase(this);
// Creating Original Reminder
int ID = rb.addReminder(new Reminder(mTitle,
mDate, mTime, mRepeat, mRepeatNo, mRepeatType, mActive));
// Create Feeding Notification
int FeedingID = rb.addReminder(new Reminder("Have you fed the cat today?",
mFeedingDate, mFeedingTime, mRepeat, mRepeatNo, mRepeatType, mActive));
}
//
// and just continued copy and pasting the rest of the notification events
// changing the ID for each individual notification. Without a unique ID
// the current notification will override the previous notification and
// appear to only set the last reminder.
I was not able to remove all notifications by selecting a single list item, I probably could have figured this out by grouping the notifications into a separate variable but once I realized that you can only have a maximum of 50 notifications set at any given time it seemed like overkill.
Since I have a repeat option for certain notifications I can keep my notifications set; numbers low and stay away from the 50 at a time limit while still firing a reminder to the user every day.
I found a great example for setting single notifications I used as reference.
https://github.com/blanyal/Remindly
Thank those of you who took the time to read my question.

Dynamic properties specified by user

i was wondering if there is a chance to create comparable properties for objects defined by the user itself.
Following case: In my android app, the user creates a object "car", this object has predefined properties like color, size, doors, engine and so on ... but now, the user wants to add an individual property like "length" ... for that the user gets a plus button under the view to add this property ... now he can type in the wanted property, but what he dont want is to define the type of the input!
The users thinks "hey, its pretty obvious that length is expressed with a number so why i have to choose the type for this?"
I dont want to limit the user if i give them only predefined propertys.
I thought about saving every new parameter as a string, but then the values arent comparable anymore ... "900" is bigger than "1000" in a string comparison and so on. And i want to filter data and do queries later.
I dont disagree at all with the idea to let the user choose which type the field is, but i dont want to ask them too much in an android application.
If this all is not possible, how can i smartly get the information for the type from the user?
How can i handle this problem? Can someone give me a hint or keyword to search for?
Natural sorting might be the thing you are looking for. It will solve the problem with numbers.

Android application structure issue

I'm working on application and I need some suggestions which is the best way to code it for Android. Basically it's something like event guide for a few cities. Imagine this :
I have an activity with 7 different buttons (7 different cities) and clicking on one of these buttons I'm opening a new activity where I have all months (January-December) as buttons again. If there is some event in February for example in the chosen city the button will be active and I will go to another activity where I have a list with the events. So my idea is to do it in this way :
Create one Activity with all Cities
Create one Calendar activity with all months.
When user select for example Paris, I'll send an extra via intent with an ID of the chosen city :
intent.putExtra("chosenCity", 2); //something like this
In the Calendar activity I will make active/inactive months buttons depending on that extra sent from Cities activity.
And when user chose a month I will send that chosenCity extra again to the ListViewEvents activity and populate the list view from Database (for example) depending on that extra.
So my question is : is it a good way to build an application like that? Or if it's not, which is the best way to achieve this?
Thanks in advance!
Sounds like you already know pretty much what you need to do. The only thing left is to implement it. The only thing I'll add is that your should probably store all your database and use a CursorAdapter to display them in the ListView. You can store all the events in the database and just create your select statement in such a way that it only selects the events you want to display at any given time. When using this CursorAdapter, I highly recommend you use the CursorLoader.

Android TextViews. Is parametrization possible? Is binding to model possible?

I am new to both Android and Stack Overflow. I have started developing and Android App and I am wondering two things:
1) Is it possible to parametrize a TextView? Lets say I want to render a text message which states something like: "The user age is 38". Lets suppose that the user age is the result of an algorithm. Using some typical i18n framework I would write in my i18n file something like "The user age is {0}". Then at run time I would populate parameters accordingly. I haven't been able to figure out how to do this or similar approach in Android.
2) Let's suppose I have a complex object with many fields. Eg: PersonModel which has id, name, age, country, favorite video game, whatever. If I want to render all this information into a single layout in one of my activities the only way I have found is getting all needed TextViews by id and then populate them one by one through code.
I was wondering if there is some mapping / binding mechanism in which I can execute something like: render(myPerson, myView) and that automatically through reflection each of the model properties get mapped into each of the TextViews.
If someone has ever worked with SpringMVC, Im looking for something similar to their mechanism to map domain objects / models to views (e.g. spring:forms).
Thanks a lot in advanced for your help. Hope this is useful for somebody else =)
bye!
In answer to #1: You want String.format(). It'll let you do something like:
int age = 38;
String ageMessage = "The user age is %d";
myTextView.setText(String.format(ageMessage, age));
The two you'll use the most are %d for numbers and %s for strings. It uses printf format if you know it, if you don't there's a quicky tutorial in the Formatter docs.
For #2 I think you're doing it the best way there is (grab view hooks and fill them in manually). If you come across anything else I'd love to see it.

Categories

Resources