Material Preference


Source link: https://github.com/codevscolor/MaterialPreference

Material Preference

Report an issue

This library can be used to implement Material Designed Settings/Preference Screen on Pre-Lollipop devices. (Currently supporting devices upto api 9 )

  • Material Preference Library uses com.android.support:preference-v7:x.x.x support library widgets.
  • Also it includes a color chooser dialog widget, that can be used to select accent color .
  • Header is tinted with selected secondary color.

Demo

On Lollipop :

On KitKat :

Light Theme :

Download

dependencies {
 compile 'com.codevscolor.materialpreference:mp:0.2.1' 
}
 

How do I use this library ?

  1. Create one preference xml file inside res/xml folder
  2. Add android.support.v7.preference widgets.
  3. For Preference category, use com.codevscolor.materialpreference.widget.MaterialPreferenceCategory with a title , like :
<com.codevscolor.materialpreference.widget.MaterialPreferenceCategory android:title="Category one"> ......... ......... </com.codevscolor.materialpreference.widget.MaterialPreferenceCategory>
  1. If you want to use color chooser widget,use it with a key, summary and title like
<com.codevscolor.materialpreference.widget.ColorChooserPreference

 android:key="secondary_color_position"

 android:summary="select accent color"

 android:title="secondary color" />
  1. Now create your Preference Activity like
import com.codevscolor.materialpreference.util.MaterialPrefUtil; import com.codevscolor.materialpreference.activity.MaterialPreferenceActivity; import com.codevscolor.materialpreference.callback.MaterialPreferenceCallback;  public class SettingsActivity extends MaterialPreferenceActivity implements MaterialPreferenceCallback {

//initialization of the sdk should be done here
  @Override
  public void init(@Nullable Bundle savedInstanceState) {

//register this class as listener for preference change

setPreferenceChangedListener(this);

 //use dark theme or not . Default is light theme

useDarkTheme(true);

 //set toolbar title

setToolbarTitle("My Toolbar");

 //set primary color

setPrimaryColor(MaterialPrefUtil.COLOR_BLUE_GREY);

 //default secondary color for tinting widgets, if no secondary color is used yet

setDefaultSecondaryColor(this, MaterialPrefUtil.COLOR_BLUE);

 //set application package name and xml resource name of preference

setAppPackageName("com.exampletest.sampleapplicationsettings");

//set xml resource name

setXmlResourceName("settingspreference");

 //optional

//if you are using color picker, set the key used for color picker in the xml preference

setColorPickerKey("secondary_color_position");

}

 /** 
  * callback for preference changes 
  * 
  * @param sharedPreferences 
  * @param name 
  */
  @Override
  public void onPreferenceSettingsChanged(SharedPreferences sharedPreferences, String name) {

Toast.makeText(this, "preference with key " + name + " changed", Toast.LENGTH_LONG).show();

  
}
 
}
 

Compatibility

API level 8 and above

Author

codevscolor - @codevscolor on GitHub, personal blog : codevscolor

License

Apache 2.0

Resources

A file picker fragment for Android that can be embedded in your app.

Android library project that intends to simplify the usage of location providers with a twist: you can modify the location strategy based in your activity.

The principle behind it is detecting the activity the user is doing (moving in a vehicle, riding a bicycle, walking, running, being still) and based on those results, changing the accuracy for the detection and the sensors used.

All this is aimed to be more battery efficient than the usual location strategies.

Clustering library for points of interest in Android v2 Maps.

Android Annotations @ViewById annotation generator for Android Studio / IntelliJ IDEA, heavily based on the ButterKnifeZelezny plugin.

Library for handling Youtube Player in scrollable Views (ListView, GridView, ScrollView...)

Features:

  • Allows seamless transition between portrait and landscape (without rebufering)
  • Allows playback of one video at time
  • Attaches it self to view in scrollable container and scrolls with it
  • Supports AbsListView and ScrollView
  • Works from API level 17 (like YT API)

A command-line tool to copy Android Material Design icons to your project folders: drawable-ldpi, drawable-mdpi, and etc.

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