All Projects → yarolegovich → Materialpreferences

yarolegovich / Materialpreferences

Licence: apache-2.0
A highly flexible set of lovely looking views that provides functionality of preferences.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Materialpreferences

Materialdialog Android
📱Android Library to implement animated, 😍beautiful, 🎨stylish Material Dialog in android apps easily.
Stars: ✭ 602 (+21.62%)
Mutual labels:  material-design, material-ui, android-ui
Aestheticdialogs
📱 An Android Library for 💫fluid, 😍beautiful, 🎨custom Dialogs.
Stars: ✭ 352 (-28.89%)
Mutual labels:  material-design, material-ui, android-ui
Slidetoact
A simple 'Slide to Unlock' Material widget for Android, written in Kotlin 📱🎨🦄
Stars: ✭ 783 (+58.18%)
Mutual labels:  material-design, material-ui, android-ui
Alerter
An Android Alerting Library
Stars: ✭ 5,213 (+953.13%)
Mutual labels:  material-design, material-ui, android-ui
Bottomsheet
BottomSheet dialog library for Android
Stars: ✭ 219 (-55.76%)
Mutual labels:  material-design, material-ui, android-ui
Materialfavoritebutton
Animated favorite/star/like button
Stars: ✭ 586 (+18.38%)
Mutual labels:  material-design, material-ui, android-ui
Mediapicker
Easy customizable picker for all your needs in Android application
Stars: ✭ 105 (-78.79%)
Mutual labels:  material-design, material-ui, android-ui
Android Material Design For Pre Lollipop
Various UI implementations, animations & effects based on Material Design compatible with pre Lollipop devices as well. (Work in progess)
Stars: ✭ 585 (+18.18%)
Mutual labels:  material-design, material-ui, android-ui
Materialdrawer
The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.
Stars: ✭ 11,498 (+2222.83%)
Mutual labels:  material-design, material-ui, android-ui
Ibackdrop
A library to simply use Backdrop in your project (make it easy). Read more ->
Stars: ✭ 137 (-72.32%)
Mutual labels:  material-design, material-ui, android-ui
Datingapp
Dating UI kit is used for online meet up with girls and boys . The screen contains more than 30 icons and most of all required elements required to design an application like this. The XML and JAVA files contains comments at each and every point for easy understanding. Everything was made with a detail oriented style and followed by today's web trends. Clean coded & Layers are well-organized, carefully named, and grouped.
Stars: ✭ 97 (-80.4%)
Mutual labels:  material-design, material-ui, android-ui
Sequent
A simple continuous animation library for Android UI.
Stars: ✭ 263 (-46.87%)
Mutual labels:  material-design, material-ui, android-ui
Fancyshowcaseview
An easy-to-use customisable show case view with circular reveal animation.
Stars: ✭ 1,662 (+235.76%)
Mutual labels:  material-design, material-ui, android-ui
Materiallettericon
Material first letter icon like lollipop contacts icon. Letter(s) on a shape drawn on canvas.
Stars: ✭ 255 (-48.48%)
Mutual labels:  material-design, material-ui, android-ui
Carbon
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.
Stars: ✭ 2,942 (+494.34%)
Mutual labels:  material-design, material-ui, android-ui
Android Login
Stars: ✭ 317 (-35.96%)
Mutual labels:  material-design, android-ui
Colorpreference
A custom preference item for easy implementation of a color picker in Android's preference screen.
Stars: ✭ 299 (-39.6%)
Mutual labels:  preferences, sharedpreferences
Binaryprefs
Rapidly fast and lightweight re-implementation of SharedPreferences which stores each preference in files separately, performs disk operations via NIO with memory mapped byte buffers and works IPC (between processes). Written from scratch.
Stars: ✭ 484 (-2.22%)
Mutual labels:  preferences, sharedpreferences
Preferenceroom
🚚 Android processing library for managing SharedPreferences persistence efficiently and structurally.
Stars: ✭ 341 (-31.11%)
Mutual labels:  preferences, sharedpreferences
Googlekeepclone
A clone of Google Keep with its original Material Design aesthetics
Stars: ✭ 281 (-43.23%)
Mutual labels:  material-design, material-ui

MaterialPreferences

This library is a set of VIEWS (not Preferences) and is aimed to solve this problems:

  • Preferences look ugly on pre-lollipop.
  • Preferences are not flexible. For example, it can be problematic to embed them to another screen (especially for fragment-haters).
  • Preferences don't allow you to show custom selection dialogs.

Screenshots

Gradle

Add this into your dependencies block:

compile 'com.yarolegovich:mp:1.1.6'

For LovelyInput you will also need this:

compile 'com.yarolegovich:lovelyinput:1.1.6'

And jitpack to the list of repositories:

maven { url "https://jitpack.io" }

Wiki

Sample project that shows how to work with different library features is available as sample module. You can also download APK and play with it.

Contents

  1. Types of preferences
  2. UserInputModule
    Allows you to show any dialogs (or event not dialogs) you want, when some preferencesare clicked.
  3. StorageModule
    Allows you to save/retrieve values to/from any data source.
  4. LovelyInput
    Implementation of UserInputModule based on LovelyDialog library.

Types of preferences

There are 2 ViewGroup classes:

And a lot of AbsMaterialPreference subclasses:

Each preference contains optional title, summary and icon (icon can be tinted). Also for some preferences it is mandatory to set default value and key (at least when dealing with SharedPreference as StorageModule).

<com.yarolegovich.mp.AnyAbsMaterialPreferenceSubclass
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:mp_icon="@drawable/your_icon"
    app:mp_icon_tint="@color/textSecondary"
    app:mp_title="@string/your_title"
    app:mp_summary="@string/your_summary"
    app:mp_key="@string/pkey_your_key"
    app:mp_default_value="42|true|any string"/>

MaterialPreferenceScreen

ViewGroup.In essence - scrollable LinearLayout. Use it or not is a matter of preference, but it has some useful features.

public void setVisibilityController(int controllerId, List<Integer> controlledIds, boolean showWhenChecked);
public void setVisibilityController(final AbsMaterialCheckablePreference controller, final List<Integer> controlledIds, final boolean showWhenChecked);

Sets some checkable preference to control visibility of views with specified ids. Last parameter is used to define when views should be visible (if preference is checked or not).

MaterialPreferenceScreen screen = (MaterialPreferenceScreen) findViewById(R.id.preference_screen);
screen.setVisibilityController(R.id.pref_auto_loc, Arrays.asList(R.id.pref_location), false);

Now when our R.id.pref_auto_loc preference is checked/unchecked - R.id.pref_location will be hidden/shown.

MaterialPreferenceCategory

ViewGroup. Has optional attributes

app:mpc_title="@string/your_title"
app:mpc_title_color="@color/your_color"

to specify a title and title color for category. In essence - CardView with vertical LinearLayout inside it.

MaterialStandardPreference

The simplest preference. Doesn't perform anything (until you set OnClickListener on it). Saves nothing.

MaterialRightIconPreference

The same as MaterialStandardPreference, but icon is on the right. Saves nothing.

AbsMaterialTextValuePreference

Sometimes I want to show current value of preference in summary or maybe on the right of the row. With sublcasses of MaterialTextInputPreference you have an option to do this by using:

<!-- default is notShow --> 
app:mp_show_value="notShow|onBottom|onRight" 

attribute. It can take one of the listed values, that I think are pretty self-explanatory. Any subclass has access to this functionality.

AbsMaterialListPreference

Subclass of AbsMaterialTextValuePreference. Defines two attributes:

app:mp_entry_descriptions="@array/some_string_array"
app:mp_entry_values="@array/some_string_array"

The first one contains values that will be shown in the dialog when preference is clicked. Second contains values that will be saved after some item is selected. If one attribute is omitted - another one will be used for both purposes.

MaterialChoicePreference

Subclass of AbsMaterialListPreference. On click shows dialog with items from mp_entry_descriptions, when any item is selected - item with corresponding index from mp_entry_values will be saved. Saves String value.

MaterialMultiChoicePreference

Subclass of AbsMaterialListPreference. On click shows dialog with items from mp_entry_descriptions, any number of items can be checked and after the dialog is dismissed - items from mp_entry_values with indices that correspond to indices of checked items will be saved. Saves Set value. Class also defines attribute:

app:mp_default_selected="@array/checked_items"

To specify items selected by default.

MaterialEditTextPreference

Subclass of AbsMaterialTextValuePreference. On click shows dialog with EditText and confirm button. After confirm button is clicked - text will be saved. Saves String value.

AbsMaterialCheckablePreference

Contains some checkable view and changes its state on click. All subclasses save boolean.

MaterialSwitchPreference

Subclass of AbsMaterialCheckablePreference. Contains SwitchCompat view on the right.

MaterialCheckboxPreference

Subclass of AbsMaterialCheckablePreference. Contains CheckBox view on the right.

MaterialColorPreference

Contains custom ColorView on the right that reflects currently selected color. Defines attributes:

app:mp_initial_color="@color/your_color"
app:mp_border_color="@color/your_color"
app:mp_border_width="@dimen/your_width"
app:mp_indicator_shape="circle|square"

On click shows color picker dialog. By default it uses VintageChroma. Saves color int.

MaterialSeekBarPreference

Contains AppCompatSeekBar view under the summary and optional TextView that reflects current value. Defines attributes:

app:mp_max_val="12"
app:mp_min_val="1"
app:mp_show_val="true"

TextView with current value will be shown if mp_show_val is set to true (which is not by default). Saves int.

UserInputModule

Interface that defines methods called when some preferences are clicked:

  • MaterialEditTextPreference -> showEditTextInput(...)
  • MaterialChoicePreference -> showSingleChoiceInput(...)
  • MaterialMutltiChoicePreference -> showMultiChoiceInput(...)
  • MaterialColorPreference -> showColorSelectionInput(...)

If you want some special look of your dialogs you need to implement this interface together with UserInputModule.Factory. Then you need to set it as default UserInputModule or as UserInputModule for specific screen.

To see real example refer to this project.

Suppose you have classes:

public class MyFancyInputModule implements UserInputModule { ... }

public class MyFancyInputModuleFactory implements UserInputModule.Factory { ... }

Then you need to do the following to set it as a default module:

MaterialPreferences.instance().setUserInputModule(new MyFancyInputModuleFactory());

Or set is as module for some specific screen:

MaterialPreferencScreen screen = (MaterialPreferenceScreen) findViewById(R.id.preference_screen);
screen.setUserInputModule(new MyFancyInputModuleFactory());

StorageModule

Interface that defines methods called by preferences to save/retrieve value. This gives you additional flexibility, because preferences now can be used for different purposes - you can even initialize POJOs with the help of this feature.

To set your storage module follow the same procedure as with UserInputModule.

Suppose you have classes:

public class MyCoolStorageModule implements StorageModule { ... }

public class MyCoolStorageModuleFactory implements StorageModule.Factory { ... }

Then you need to do the following to set it as a default module:

MaterialPreferences.instance().setStorageModule(new MyCoolStorageModuleFactory());

Or set is as module for some specific screen:

MaterialPreferencScreen screen = (MaterialPreferenceScreen) findViewById(R.id.preference_screen);
screen.setStorageModule(new MyCoolStorageModuleFactory());

If you want to store data inside preferences, but not default - you can use:

new SharedPrefsStorageFactory("filename")

LovelyInput

Implementation of UserInputModule combined with my another library - LovelyDialog. For information on how to use it - check sample. You can use not only

setKeyIconMappings(Set<String, Integer> mappings);

but also

setKeyTitleMappings(Set<String, String> mappings);
setKeyMessageMappings(Set<String, String> mappings);

Source code of module can serve you as an example of custom UserInputModule.

License

Copyright 2016 Yaroslav Shevchuk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].