• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

AndroidDeveloperLB/MaterialPreferenceLibrary: Allows to have an ActionBar on Pre ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

AndroidDeveloperLB/MaterialPreferenceLibrary

开源软件地址(OpenSource Url):

https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

Release

Note : This library is not developed anymore, as there is an official way to support old Android versions with preferences that have same material design style, by using PreferenceFragmentCompat : https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat

MaterialPreferenceLibrary

Allows to have a nice Material-Design look&feel for API 14 (even below if you use release 10 of the library) 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:

sample app

Screenshots

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

demo

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:

  • Android API 14 and above (release 10 supports even below).
  • AppCompat v7.

That's it.

Thanks

Android's code ?

License

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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap