MaterialPreferenceLibrary


Source link: https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary

MaterialPreferenceLibrary

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. All the dialogs are using the support library's dialogs, including accent-color. You can even choose which theme to use.

Supported preferences are:

  • DialogPreference
  • EditTextPreference
  • ListPreference
  • Preference
  • SwitchPreference
  • TwoStatePreference
  • CheckBoxPreference
  • Partial support for (inner) PreferenceScreen. It's partial since I can't extend from it (and can't give it to you to be used), so what I did is to at least set the same layout for all PreferenceScreen classes.

In addition to all of those, I've disabled the truncating of the text of all the supported preferences, so that translated text will still be fully shown. Do try ot make them short though.

Import

Via gradle :

allprojects {

repositories {

 jcenter()

 maven {

  url "https://jitpack.io"

  
}

 
}
  
}

dependencies {

compile 'com.github.AndroidDeveloperLB:MaterialPreferenceLibrary:###' 
}
 

where "###" is the number as shown here: https://jitpack.io/#AndroidDeveloperLB/MaterialPreferenceLibrary/ .

Sample

Just check the code (it has a sample inside), or see how it works on my app, here:

Screenshots

Here's a demo of how the library performs on both Gingerbread and Lollipop, including how the native preferences look and behave:

Notes

  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.
  2. Not all preferences were imported.
  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.
  4. Not tested on PreferenceFragment (yet), but you can try it using these libraries and see if you can support even older APIs : https://github.com/Machinarius/PreferenceFragment-Compat https://github.com/kolavar/android-support-v4-preferencefragment
  5. 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.
  6. Some attributes should be used using Android's framework, and some using mine. Sorry for the confusion.
  7. Preference selection obviously can't have ripples, but it should at least be possible to have Kitkat style selection for pre-Kitkat versions.
  8. Sadly, it doesn't support all kinds of preferences. Currently, those are missing:
  • RingtonePreference
  • MultiSelectListPreference
  • others ?

Contribution is appreciated. Please try to be "loyal" to the original code of Android, as I've tried.

Requirements

This library needs:

  • API 7 and above.
  • AppCompat v7.

That's it.

Thanks

Android's code ?

License

It's Apache2 . Do with it what you wish. Credits are appreciated :)

Resources

Base is a lightweight library that gives you a clean architecture foundation for your Android MVP's.

Handy Android widgets.

An android library that brings the expandable layout with various animation. You can include optional contents and use everywhere.

Android library to display a list of items for pick one with blur effect (if you wish). Support for Android 3.0 and up. It supports portrait and landscape mode, saving the state.

Reactive BroadcastReceiver implementations for Android.

A layout to transition between two views using a Floating Action Button as shown in many Material Design concepts.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes