Skip to content
This repository was archived by the owner on Jan 16, 2019. It is now read-only.

Commit 678b2fc

Browse files
author
Jens Driller
committed
Initial import
0 parents  commit 678b2fc

33 files changed

Lines changed: 953 additions & 0 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.gradle
2+
.idea
3+
.DS_Store
4+
*.iml
5+
build
6+
local.properties

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Jens Driller
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Android - MaterialPreference
2+
============================
3+
* A simple backward-compatible implementation of a Material Design Preference aka settings item
4+
* XML layouts are taken from [Android Platform Framework Base](https://github.com/android/platform_frameworks_base)
5+
6+
Screenshots
7+
-----------
8+
* Here's a side-by-side comparison with a native Lollipop preference:
9+
10+
![alt text](https://raw.github.com/jenzz/Android-MaterialPreference/master/assets/Screenshot1.png "Material Preference Screenshot")
11+
12+
Usage
13+
-----
14+
In your settings XML file that describes your preferences (must be located in `res/xml/` folder)
15+
just use the custom [`Preference`](http://developer.android.com/reference/android/preference/Preference.html)
16+
and [`PreferenceCategory`](http://developer.android.com/reference/android/preference/PreferenceCategory.html) like this:
17+
18+
```xml
19+
<com.jenzz.materialpreference.PreferenceCategory
20+
android:title="Material Category">
21+
22+
<com.jenzz.materialpreference.Preference
23+
android:title="Material Preference"
24+
android:summary="Material Summary" />
25+
26+
</com.jenzz.materialpreference.PreferenceCategory>
27+
```
28+
29+
That's it. You can use all the attributes you know from the original preferences.
30+
31+
You're probably wondering why there's only a Material Design version
32+
of [`Preference`](http://developer.android.com/reference/android/preference/Preference.html)
33+
and one for [`PreferenceCategory`](http://developer.android.com/reference/android/preference/PreferenceCategory.html).
34+
Where are [`ListPreference`](http://developer.android.com/reference/android/preference/ListPreference.html),
35+
[`EditTextPreference`](http://developer.android.com/reference/android/preference/EditTextPreference.html), etc?
36+
I don't use them. Instead I just show a simple [`Preference`](http://developer.android.com/reference/android/preference/Preference.html)
37+
and display a Material Design dialog when the user selects it.
38+
I highly recommend using the [material-dialogs](https://github.com/afollestad/material-dialogs) library for that.
39+
40+
Theming
41+
-------
42+
* On Lollipop, the preference color is derived from the `android:colorAccent` attribute of your app theme.
43+
* If you're using AppCompat, it is inherited from the `colorAccent` attribute.
44+
* If you want a totally different color for your preferences (why would you?), you can still override it in your app theme like this:
45+
46+
```xml
47+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
48+
<item name="mp_colorAccent">#bada55</item>
49+
</style>
50+
```
51+
52+
Example
53+
-------
54+
Check out the [sample project](https://github.com/jenzz/Android-MaterialPreference/tree/master/sample) for an example implementation.
55+
56+
Download
57+
--------
58+
59+
Grab it via Gradle:
60+
61+
```groovy
62+
compile 'com.jenzz:materialpreference:1.0'
63+
```
64+
65+
License
66+
-------
67+
This project is licensed under the [MIT License](https://raw.githubusercontent.com/jenzz/Android-MaterialPreference/master/LICENSE).

assets/Screenshot1.png

46.9 KB
Loading

build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
dependencies {
6+
classpath 'com.android.tools.build:gradle:1.0.1'
7+
classpath 'com.novoda:bintray-release:0.2.5'
8+
}
9+
}
10+
11+
allprojects {
12+
repositories {
13+
jcenter()
14+
}
15+
}

gradle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# suppress inspection "UnusedProperty" for whole file
2+
VERSION_NAME=1.0
3+
VERSION_CODE=1
4+
5+
ANDROID_BUILD_COMPILE_SDK_VERSION=21
6+
ANDROID_BUILD_TARGET_SDK_VERSION=21
7+
ANDROID_BUILD_TOOLS_VERSION=21.1.2

gradle/wrapper/gradle-wrapper.jar

48.7 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Apr 10 15:27:10 PDT 2013
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip

gradlew

Lines changed: 164 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)