You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-84Lines changed: 23 additions & 84 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,6 @@
1
-
# Android Support library - preference v7 bugfix
1
+
# AndroidX Preference eXtended
2
2
3
-
> **BREAKING CHANGE** in 26.1.0.3: The custom attribute names for extra preference types use `pref_` prefix in order to avoid name collision with other libraries. See the changelog for more details.
4
-
5
-
This library is meant to fix some of the problems found in the official support preference-v7 library. Also, there are [new preference types](#extra-types) available, such as `RingtonePreference`, `DatePickerPreference`, and `TimePickerPreference`.
3
+
This library is meant to fix some of the problems found in the official AndroidX preference library. Also, there are [new preference types](#extra-types) available, such as `RingtonePreference`, `DatePickerPreference`, and `TimePickerPreference`.
> Notice the versioning: the first three numbers are *always* the same as the latest official library while the last number is for own updates. I try to keep it up-to-date but if, for whatever reasons, I wouldn't notice the new support library versions, just issue a ticket.
29
22
30
23
### 2. Use the appropriate class as your fragment's base
31
-
You can use either `PreferenceFragmentCompat` or `PreferenceFragmentCompatDividers`. The former is the fixed version of the original fragment while the latter is an extended one where you can set the dividers using the divider flags. The `PreferenceFragmentCompatDividers` is the recommended approach as it uses the updated Material Design guidelines to create the appropriate divider config.
@@ -44,75 +35,27 @@ public class MyPreferenceFragment extends PreferenceFragmentCompat {
44
35
}
45
36
}
46
37
```
47
-
> **Warning!** Watch out for the correct package name when importing `PreferenceFragmentCompat`, it should come from `com.takisoft.fix.support.v7.preference`.
You should set your containing `Activity`'s theme to either a variant of `@style/PreferenceFixTheme` or create your own and use it as the parent theme. `PreferenceFixTheme` is based on `Theme.AppCompat` and contains the required attribute `preferenceTheme`. The fix theme is available for all `Theme.AppCompat` variants, such as `NoActionBar`, `Light`, etc.
75
-
For example, the sample app uses `PreferenceFixTheme.Light.NoActionBar` as the parent theme:
Now you can enjoy using the support preferences API without losing all your hair.
40
+
Now you can enjoy using preferenceX.
87
41
88
42
---
89
43
90
44
## Extra types
91
45
92
-
There are additional preferences not part of the official support library, but decided to add them to some extra libraries. You can add all of them to your project using
There are additional preferences not part of the official support library, but decided to add them to some extra libraries. You can add them to your project using Gradle.
[`SimpleMenuPreference`](https://github.com/Gericop/Android-Support-Preference-V7-Fix/wiki/Preference-types#simplemenupreference) | `implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0-alpha1'` (can be used independent of `preferencex`) | 
107
55
108
56
---
109
57
110
58
## Custom solutions
111
-
### Dividers
112
-
If you use `PreferenceFragmentCompatDividers` as your base class for the preference fragment, you can use 3 new methods to customize the dividers:
113
-
-`setDivider(Drawable drawable)`: Sets a custom `Drawable` as the divider.
114
-
-`setDividerHeight(int height)`: Sets the height of the drawable; useful for XML resources.
115
-
-`setDividerPreferences(int flags)`: Sets where the dividers should appear. Check the documentation of the method for more details about the available flags.
116
59
117
60
### Hijacked `EditTextPreference`
118
61
The support implementation of `EditTextPreference` ignores many of the basic yet very important attributes as it doesn't forward them to the underlying `EditText` widget. In my opinion this is a result of some twisted thinking which would require someone to create custom dialog layouts for some simple tasks, like showing a numbers-only dialog. This is the main reason why the `EditTextPreference` gets hijacked by this lib: it replaces certain aspects of the original class in order to forward all the XML attributes set (such as `inputType`) on the `EditTextPreference` to the `EditText`, and also provides a `getEditText()` method so it can be manipulated directly.
@@ -131,25 +74,21 @@ if (etPref != null) {
131
74
// do something with inputType
132
75
}
133
76
```
134
-
> **Note!** Watch out for the correct package name when importing `EditTextPreference`, it should come from `com.takisoft.fix.support.v7.preference`. If you import from the wrong package (i.e. `android.support.v7.preference`), the `getEditText()` method will not be available, however, the XML attributes will still be forwarded and processed by the `EditText`.
77
+
> **Note!** Watch out for the correct package name when importing `EditTextPreference`, it should come from `com.takisoft.preferencex`. If you import from the wrong package (i.e. `androidx.preference`), the `getEditText()` method will not be available, however, the XML attributes will still be forwarded and processed by the `EditText`.
135
78
79
+
### Others
136
80
137
-
### PreferenceCategory's bottom margin reduce
138
-
Some people found the preference category's bottom margin too big, so now you can change it from the styles by setting the `preferenceCategory_marginBottom` value in your theme, for example:
The original implementation uses `?attr/textAppearanceSmall` as the message style in the popup dialog (the one you find when clicking on an `EditTextPreference` with a set `android:dialogMessage` attribute), but it seems really small and might be hard to read. In order to fix that, a new attribute has been introduced to the `PreferenceFixTheme`: `preferenceDialog_messageAppearance`. This attribute controls the appearance of the message in the dialog and is set to `@style/TextAppearance.AppCompat.Subhead` by default. If you wish to change this, you'll just have to add the following line to your theme:
0 commit comments