This library is meant to fix some of the problems found in the official AndroidX preference library. Also, there are new preference types available, such as RingtonePreference
, DatePickerPreference
, and TimePickerPreference
.
If you would like to support me, you may donate some small amount via PayPal.
Add this to your gradle file:
implementation "androidx.preference:preference:$androidxVersion"
implementation 'com.takisoft.preferencex:preferencex:1.0.0-alpha2'
import com.takisoft.preferencex.PreferenceFragmentCompat;
public class MyPreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferencesFix(@Nullable Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.settings, rootKey);
// additional setup
}
}
Warning! Watch out for the correct package name when importing
PreferenceFragmentCompat
, it should come fromcom.takisoft.preferencex
.
Now you can enjoy using preferenceX.
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.
Preference | Dependency | Preview |
---|---|---|
RingtonePreference |
implementation 'com.takisoft.preferencex:preferencex-ringtone:1.0.0-alpha2' |
|
DatePickerPreference |
implementation 'com.takisoft.preferencex:preferencex-datetimepicker:1.0.0-alpha2' |
|
TimePickerPreference |
implementation 'com.takisoft.preferencex:preferencex-datetimepicker:1.0.0-alpha2' |
|
ColorPickerPreference |
implementation 'com.takisoft.preferencex:preferencex-colorpicker:1.0.0-alpha2' |
|
SimpleMenuPreference |
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0-alpha2' (can be used independent of preferencex ) |
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.
The sample app shows an example of setting (via XML) and querying (programmatically) the input type of the EditTextPreference
:
<EditTextPreference
android:inputType="phone"
android:key="edit_text_test" />
EditTextPreference etPref = (EditTextPreference) findPreference("edit_text_test");
if (etPref != null) {
int inputType = etPref.getEditText().getInputType();
// do something with inputType
}
Note! Watch out for the correct package name when importing
EditTextPreference
, it should come fromcom.takisoft.preferencex
. If you import from the wrong package (i.e.androidx.preference
), thegetEditText()
method will not be available, however, the XML attributes will still be forwarded and processed by theEditText
.
- Convenience methods in
PreferenceFragmentCompat
; PreferenceCategory
with different colors;AutoSummaryEditTextPreference
;PreferenceActivityResultListener
;EditTextPreference
correctly callsnotifyChange
. (#66)
The current stable version is 1.0.0-alpha2.
This demo / bugfix is set to work on API level 14+.
Material design - everywhere.
API 15 | API 21 | API 26 |
---|---|---|
2018-05-11
New version: 1.0.0-alpha1 (based on v27.1.1)
- No support preferences related changes in the support library.
- Bug fixes (#153, #149, #155, #152).
2018-04-10
New version: 27.1.1.0 (based on v27.1.1)
- No support preferences related changes in the support library.
- Some bug fixes (see #147 for more info).
For older changelogs, check out the CHANGELOG file.
Feel free to ask / suggest anything on this page by creating a ticket (issues)!
Apache v2