MaterialPreferences

An Android library that lets you implement customizing MaterialPreferences on Setting UI by Battle Entertainment.

Including in your project

build.gradle

dependencies {
  implementation "com.github.battleent:MaterialPreferences:0.3.0"
}

Usage

Can be used just like using Preferences.

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <com.battleent.materialpreferences.MaterialPreferenceCategory
        android:title="Notification"
        app:pref_category_background="@color/white_three"
        app:pref_category_title_color="@color/colorPrimary"/>

    <com.battleent.materialpreferences.MaterialSwitchPreference
        android:defaultValue="true"
        android:key="Notification0"
        android:title="Marketing"
        android:summary="receive events, promotions like marketing messages."
        app:pref_switch_title_color="@android:color/holo_blue_dark"
        app:pref_switch_summary_color="@android:color/holo_blue_light"/>

    <com.battleent.materialpreferences.MaterialSwitchPreference
        android:defaultValue="true"
        android:key="Notification1"
        android:title="Snooze"
        android:summary="do not receiving notifications at night."
        app:pref_switch_title_color="@android:color/holo_green_dark"
        app:pref_switch_summary_color="@android:color/holo_green_light"
        app:pref_switch_checked_thumb_color="@android:color/holo_blue_dark"
        app:pref_switch_checked_track_color="@android:color/holo_blue_light"
        app:pref_switch_unchecked_thumb_color="@android:color/holo_green_dark"
        app:pref_switch_unchecked_track_color="@android:color/holo_green_light"/>

    <com.battleent.materialpreferences.MaterialPreference
        android:defaultValue="true"
        android:title="More"
        android:summary="show more details"/>
</PreferenceScreen>

MaterialPreferenceCategory

Material PreferenceCategory is composed of just title. It is used to split sections.

<com.battleent.materialpreferences.MaterialPreferenceCategory
        android:title="Category"
        app:pref_category_background="@color/white_three"
        app:pref_category_title_color="@color/md_deep_orange_700"
        app:pref_category_title_size="18sp"
        app:pref_category_padding_bottom="6dp"
        app:pref_category_padding_left="6dp"
        app:pref_category_padding_top="6dp"/>

MaterialPreference

Material Preference is composed of title and summary.

<com.battleent.materialpreferences.MaterialPreference
        android:defaultValue="true"
        android:title="More"
        android:summary="show more details"
        app:pref_title_color="@android:color/holo_green_dark"
        app:pref_summary_color="@android:color/holo_green_light"
        app:pref_title_size="18sp"
        app:pref_summary_size="13sp"
        app:pref_title_background="@color/greyish_brown"
        app:pref_summary_background="@android:color/white"/>

MaterialSwitchPreference

Material Preference is composed of title, summary and switch. It saves switch's on-off status.

<com.battleent.materialpreferences.MaterialSwitchPreference
        android:defaultValue="true"
        android:key="Notification1"
        android:title="Snooze"
        android:summary="do not receiving notifications at night."
        app:pref_switch_background="@color/white_three"
        app:pref_switch_title_color="@android:color/holo_green_dark"
        app:pref_switch_summary_color="@android:color/holo_green_light"
        app:pref_switch_checked_thumb_color="@android:color/holo_blue_dark"
        app:pref_switch_checked_track_color="@android:color/holo_blue_light"
        app:pref_switch_unchecked_thumb_color="@android:color/holo_green_dark"
        app:pref_switch_unchecked_track_color="@android:color/holo_green_light"/>

MaterialCheckBoxPreference

Material Preference is composed of title, summary and checkbox. It saves checkbox's isChecked status.

    <com.battleent.materialpreferences.MaterialCheckBoxPreference
        android:defaultValue="true"
        android:key="Notification4"
        android:title="Marketing"
        android:summary="receive events, promotions like marketing messages."
        app:pref_checkbox_background="@color/background800"
        app:pref_checkbox_title_color="@android:color/holo_blue_light"
        app:pref_checkbox_title_background="@color/background"
        app:pref_checkbox_summary_color="@android:color/white"/>

MaterialProgressPreference

Material Preference is componsed of title, summary and progress.

It can be used to showing progress during synchronize or fetching data.

<com.battleent.materialpreferences.MaterialProgressPreference
        android:title="Marketing"
        android:summary="receive events, promotions like marketing messages."
        app:pref_progress_visibility="true"/>

you can set visibility using below method.

.visible(Boolean visibility)

GitHub