• This repository has been archived on 01/May/2021
  • Stars
    star
    408
  • Rank 105,946 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 10 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Allows to have an ActionBar on PreferenceActivity

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 :)

More Repositories

1

AutoFitTextView

A TextView that automatically fit its font and line count based on its available size and content
Kotlin
912
star
2

LollipopContactsRecyclerViewFastScroller

A sample of how to mimic the way that the contacts app handles a Fast-Scroller for a RecyclerView
Java
542
star
3

AndroidJniBitmapOperations

Allows to perform various simple operations on bitmaps via JNI , while also providing some protection against OOM using the native Java environment on Android
C++
540
star
4

ListViewVariants

Provides special ways to handle ListViews, including PinnedHeaderListView in Lollipop's Contacts' app style
Java
336
star
5

ChipsLibrary

A fork to Google's Gmail/Hangouts chips library, with some extra features
Java
301
star
6

VideoTrimmer

Allows to trim videos on Android, including UI
Kotlin
144
star
7

RootHelper

An extension to use libsuperuser library more easily
Kotlin
123
star
8

ThreePhasesBottomSheet

A bottom sheet sample that's similar to how Google Maps treat it
Java
110
star
9

WebpifyYourAndroidApp

A small tool to convert your app's png&jpg image files into WebP when possible
Java
105
star
10

LB-Launcher

A truly open sourced launcher app, based on the same launcher app that comes with Android
Java
49
star
11

PhoneCallRecorder

A POC of recording calls
Kotlin
41
star
12

ParallaxViewPagers

A POC to show how to have multiple ViewPagers work in Parallax effect with each other
Java
26
star
13

apk-parser

Java
20
star
14

MultiTouchPlaceholderView

Gesture-based image layer, to move it into placeholders (empty content within a bitmap)
Java
19
star
15

CommonUtils

Just a set of Android classes and functions that I commonly use in various projects
Kotlin
16
star
16

ExoPlayerCacheSample

A sample to demonstrate how to use cache on ExoPlayer, and to investigate the best way to use the cached file later
Kotlin
13
star
17

FastScrollerAndRecyclerViewFixes

A collection of fixes for FastScroller
Java
12
star
18

DayAndNightDetector

Detects if it's now day or night using the TwilightCalculator class by Google
Kotlin
9
star
19

AsyncTaskEx

A modified version of AsyncTask, in Kotlin, with some things removed and some added
Kotlin
7
star
20

AndroidVersionsStats

Gets updated information about the version statistics of Android distribution, as found from Android Studio code
Kotlin
7
star
21

DialogShard

An alternative to DialogFragment, that's intended to overcome fragments exceptions
Java
7
star
22

ScreenshotSample

shows a sample of how to take a screenshot on Android
Java
7
star
23

WallpaperPicker

A port of Android's Wallpaper-picker, as used in the launcher itself
Java
6
star
24

UserActivityRecognitionSample

A sample to show how to handle User-Activity-Recognition, based on https://github.com/jarroyoesp/TransitionRecognitionApp
Kotlin
4
star
25

FloatingActionButtonEx

A modified version of FloatingActionButton library, that better handles various issues
Java
4
star
26

GifLiveWallpaper

An example of showing GIF animation using Movie class of Android, based on : https://stackoverflow.com/a/51127570/878126
Kotlin
4
star
27

FullSizePopupSpinner

A spinner-like view, which shows all items below, including indication of which item is selected
Java
4
star
28

SdkTest

Just some test for Jitpack, to see if it can handle aar files in Github
3
star
29

VideoAndAudioMux

A POC about how to mux (join) video and audio files together into a single video file that has the audio in it
Kotlin
3
star
30

RecyclerViewDragAndDropTest

A sample to show how to have drag&drop functionality on RecyclerView (and optionally also swipe-to-dismiss)
Kotlin
3
star
31

customized-popup-window-sample

A sample of having a customized popup window, that should work like context menu
Kotlin
2
star
32

ExoPlayerScaleCrop

POC to show how to scale-crop at any point of the video, and not just like center-crop of ImageView
Kotlin
2
star
33

DocumentsProviderSample

A very small sample of how to implement DocumentsProvider, to have new items of Android's file-picker
Kotlin
2
star
34

AutomatedTextSwitcher

A TextSwitcher that allows automatic switching of texts within itself
Kotlin
1
star
35

AlarmClockSample

Just a test to show how to set an alarm on Android
Kotlin
1
star
36

GetPlayStoreInstalledAppsHistory

A POC to get history of installed apps from the Play Store ("library"), based on Aurora Store source code
Kotlin
1
star
37

OpenGlVideoLiveWallpaper

A minimized sample of showing a video inside a live wallpaper using OpenGl, based on alynx-live-wallpaper repository
Kotlin
1
star
38

ZipFileProviderSample

Demonstrates how to share a zip file that contains multiple files, without actually creating the zipped file
Kotlin
1
star
39

VectorChildFinder

A repository to allows finding inner parts of VectorDrawable, and perform operations on them, based on VectorChildFinder repository
Java
1
star
40

ApkManifestFetcher

A sample of how to try to parse all kinds of APK manifest content , including ability to parse via InputStream
Kotlin
1
star
41

MovieLiveWallpaper

Sample app to show how to view a video in a live wallpaper app on Android
Kotlin
1
star