I recently decided to add a few preferences to my app. In researching how to create the Settings, I read about the SettingsActivity template that comes with Android Studio and decided to give it a try. I was pleasantly surprised to see how much of the work it does for me. My preferences are, for the most part, working very well and doing what I want them to do and it took very little time to make that happen.
However, the downside seems to be that it is not clear to me how I can customize the Settings pages generated by the template. I don't mean changing the preferences themselves: that turns out to be pretty straight-forward. I have Text, Switch, and ListPreferences and they were easy enough to write. But I see no obvious ways to do some other things:
Also, two other settings-related issues:
However, the downside seems to be that it is not clear to me how I can customize the Settings pages generated by the template. I don't mean changing the preferences themselves: that turns out to be pretty straight-forward. I have Text, Switch, and ListPreferences and they were easy enough to write. But I see no obvious ways to do some other things:
- make the fonts different or bigger
- change the colours of headings or items or the background colour of the settings pages
- add "up" navigation so that I don't have to use the back button on the bezel of the phone (I had hoped to add a toolbar with up navigation enabled but I can't figure out how to add a Toolbar to a <PreferenceScreen>; it *looks* like an XML file but it won't tolerate a Toolbar being added to it
Also, two other settings-related issues:
- One of my settings lets the user choose a date format - 2018-08-08 or 08/08/2018 for example - and I want that setting to take effect immediately. How do I make RecyclerView redraw itself upon returning from the Settings pages? Right now, the only way I can find to force a redraw is to click on the Add, Edit or Remove icons, then click Cancel when those activities start; when I come back from that, the RecyclerView is redrawn.
- Is there any way to make it impossible for a user to change a setting once set, unless given an override code by Tech Support (me)? One of the settings that they must set immediately upon using the app for the first time, is their first name/nickname. Once they've chosen that, I use that value on every sale to indicate that Beth or Tom made that sale. If they could change their user name in the Settings, they'd also change the records they're putting on the database. Now, I can simply ask them not to change the name once they choose it but users are not necessarily going to comply with that so I'm wondering if I can lock the setting value somehow - perhaps to be overridden if I give them a secret code of some kind - so that I know they've changed the user name and can deal with the consequences on the rest of the system.