|
1 | | -ActionBarPreferenceActivityLibrary |
| 1 | +MaterialPreferenceLibrary |
2 | 2 | ================================== |
3 | 3 |
|
4 | | -Allows to have an ActionBar even on PreferenceActivity, even for pre-Honeycomb versions of Android. |
| 4 | +Allows to have a nice Material-Design look&feel for API 7 and above for the PreferenceActivity, including most commonly used preferences and also showing the actionBar. |
| 5 | +All the dialogs are using the support library's dialogs, including accent-color. |
| 6 | +You can even choose which theme to use. |
5 | 7 |
|
6 | | -All this library does is to simply put a Toolbar at the top of the PreferenceActivity, and you need to use the Toolbar instead of the ActionBar. |
| 8 | +Supported preferences are: |
| 9 | +- **DialogPreference** |
| 10 | +- **EditTextPreference** |
| 11 | +- **ListPreference** |
| 12 | +- **NumberEditTextPreference** - a customized preference I've made, that's like EditTextPreference, but allows to enters digits only. |
| 13 | +- **Preference** |
| 14 | +- **SwitchPreference** |
| 15 | +- **TwoStatePreference** |
7 | 16 |
|
8 | | -Screenshots |
9 | | -== |
10 | | -Gingerbread : |
| 17 | +Sample and screenshots |
| 18 | +================================== |
| 19 | +Just check the code, or see how it works on my app, here: |
| 20 | +https://play.google.com/store/apps/details?id=com.lb.app_manager |
| 21 | + |
| 22 | +**Screensots:** |
| 23 | + |
| 24 | +**Gingerbread :** |
11 | 25 |
|
12 | | - |
13 | 26 |
|
14 | | -Lollipop : |
| 27 | +**Lollipop :** |
15 | 28 |
|
16 | | - |
| 29 | +Notes |
| 30 | +================================== |
| 31 | + |
| 32 | +1. About the **actionBar**, all this library does is to simply put a Toolbar at the top of the PreferenceActivity, and you need to use the Toolbar instead of the ActionBar. |
| 33 | +2. Not all preferences were imported. |
| 34 | +3. Sadly, **reflection** was used for 2 functions of "PreferenceManager" which aren't public (yet the framework's classes have full access to it) : "unregisterOnActivityDestroyListener", "registerOnActivityDestroyListener". Those functions seem to be used only for dismissing the dialogs when the activity is being destroyed. Just in case something goes wrong, I've made the code ignore (and write in the logs) in case they are unreachable. |
| 35 | +4. **Preference icon** is missing, but I think it should be easy to add it. The reason it was missing is because I need to use the internal class that extends ImageView for it, which has "minWidth" and "minHeight", yet those are missing from old APIs, so I would need to import the entire code of ImageView... However, I'm sure there is a better way. |
| 36 | +5. Not tested on **PreferenceFragment** (yet), but you can try it using these libraries and see if you can support even older APIs : |
| 37 | +https://github.com/Machinarius/PreferenceFragment-Compat |
| 38 | +https://github.com/kolavar/android-support-v4-preferencefragment |
| 39 | +6. In order to add **action items**, you need to do it completely via code, without using XML. Otherwise, on some Android versions (or all?), the action items will all gather inside the overflow menu item. |
| 40 | +7. Some **attributes** should be used using Android's framework, and some using mine. Sorry for the confusion. |
| 41 | + |
| 42 | +Contribution is appreciated. Please try to be "loyal" to the original code of Android, as I've tried. |
17 | 43 |
|
18 | 44 | Requirements |
19 | 45 | == |
20 | 46 | This library needs: |
21 | | - - API 8 and above. |
| 47 | + - API 7 and above. |
22 | 48 | - AppCompat v7. |
23 | 49 |
|
24 | 50 | That's it. |
25 | 51 |
|
26 | 52 | What this library doesn't do |
27 | 53 | == |
28 | | -Sadly, it doesn't style the preferences, but you can use the one of the support library if you wish. |
29 | | - |
30 | | -It has handled dialogs in the past, but no longer. If you wish to have material-style dialogs, you can use this great library: |
31 | | - https://github.com/fengdai/AlertDialogPro |
| 54 | +Sadly, it doesn't support all kinds of preferences. Currently, those are missing: |
| 55 | + - RingtonePreference |
| 56 | + - MultiSelectListPreference |
| 57 | + - CheckBoxPreference |
| 58 | +and others... |
32 | 59 |
|
33 | | -Also, note that in order to add action items, you need to do it completely via code, without using XML. Otherwise, on some Android versions (or all?), the action items will all gather inside the overflow menu item. |
| 60 | +Also, note that |
34 | 61 |
|
35 | 62 | Thanks |
36 | 63 | == |
37 | | -Didn't get a lot of code from others: |
38 | | - |
39 | | - - Some code I got from my own app: |
40 | | - https://play.google.com/store/apps/details?id=com.lb.app_manager |
41 | | - - The support library of Google, of course: |
42 | | - http://android-developers.blogspot.co.il/2014/10/appcompat-v21-material-design-for-pre.html |
43 | | - - This website: |
44 | | - https://chris.banes.me/2014/10/17/appcompat-v21/ |
| 64 | +Android's code ? |
0 commit comments