Giter Club home page Giter Club logo

androidmaterialpreferences's Introduction

AndroidMaterialPreferences - README

API-Level License Donate

"AndroidMaterialPreferences" is an Android-library, which provides various preferences, which are designed according to Android 5's Material Design guidelines even on pre-Lollipop devices.

The library provides the following preferences:

  • A preference, which allows to show simple dialogs (DialogPreference).
  • A preference, which allows to enter a text via an EditText widget (EditTextPreference).
  • A preference, which allows to select a value from a list (ListPreference).
  • A preference, which allows to select multiple values from a list (MultiChoiceListPreference).
  • A preference, which allows to choose a floating point value or an integer value from a continuous range via a SeekBar widget (SeekBarPreference).
  • A preference, which allows to choose a decimal value using a NumberPicker widget (NumberPickerPreference).
  • A preference, which allows to choose a decimal value, consisting of individual digits of which each can be chosen using a NumberPicker widget (DigitPickerPreference).
  • A preference, which allows to choose an image or video resolution via two EditText widgets (ResolutionPreference).
  • A preference, which allows to choose a color from a predefined color palette (ColorPalettePreference).
  • A preference, which provides a toggleable option using a Switch widget (SwitchPreference).
  • A preference, which provides a toggleable option using a CheckBox widget (CheckBoxPreference.
  • A preference, which acts as a button and shows a centered title (ActionPreference).

Prior to version 4.0.0 this library relied on the Android SDK's preference classes such as android.preference.Preference. As these classes are deprecated starting with Android P, the library has been migrated to use the v14 Preference support library in version 4.0.0 and later.

License Agreement

This project is distributed under the Apache License version 2.0. For further information about this license agreement's content please refer to its full version, which is available at http://www.apache.org/licenses/LICENSE-2.0.txt.

Prior to version 2.0.4 this library was distributed under the GNU Lesser General Public License version 3.0 (GLPLv3).

Download

The latest release of this library can be downloaded as a zip archive from the download section of the project's Github page, which is available here. Furthermore, the library's source code is available as a Git repository, which can be cloned using the URL https://github.com/michael-rapp/AndroidMaterialPreferences.git.

Alternatively, the library can be added to your Android app as a Gradle dependency by adding the following to the respective module's build.gradle file:

dependencies {
    compile 'com.github.michael-rapp:android-material-preferences:5.3.2'
}

Before version 2.0.0 this project was hosted on Sourceforge. These older versions used the legacy Eclipse ADT folder structure and are not available as Gradle artifacts.

Examples

The following examples provide a quick overview on how to use the preferences, which are provided by the library, in your own Android app. This project also contains the source code of an example app, which implements use cases of the library for demonstration purposes, as well as a more detailed documentation in the Wiki and auto-generated javadoc files.

Since version 5.0.0 the library requires to use AndroidX instead of the older AppCompat support libraries. Make sure that you have migrated your app to AndroidX and that you are using one of the Material component themes instead of the AppCompat ones, e.g. Theme.MaterialComponents.Light.DarkActionBar instead of Theme.AppCompat.Light.DarkActionBar.

Specifying a theme

Most of the preferences, which are provided by the library show a dialog when the respective preference is clicked. The theme, which should be used for the dialogs, can be specified by using the theme attribute preferenceDialogTheme. The library comes with a predefined dark and light theme. When no theme is specified, the light theme is used by default. It can be referenced by using the resource id @style/MaterialDialog.Light, the dark theme corresponds to the id @style/MaterialDialog instead. In order specify the theme, which should be used, the attribute preferenceDialogTheme has to be overwritten in the theme of your app. By extending either one of default themes, which are provided by the library, custom theme attributes such like the attribute colorAccent, which is used to specify the default text color of a dialog's buttons, can be overwritten. The following example illustrates how this can be achieved by showing a sample res/values/styles.xml file:

<resources>

    <style name="AppTheme" parent="@style/Theme.MaterialComponents.Light.DarkActionBar">
        <item name="colorPrimary">@color/color_primary</item>
        <item name="colorPrimaryDark">@color/color_primary_dark</item>
        <item name="colorAccent">@color/color_accent</item>
        <item name="preferenceDialogTheme">@style/CustomLightTheme</item>
    </style>

    <style name="CustomLightTheme" parent="@style/MaterialDialog.Light">
        <item name="colorAccent">@color/color_accent</item>
    </style>

</resources>

If the theme of one of the preferences used in the app should differ from those used by the other ones, the attribute custom:dialogThemeResource can be used when specifying the preference as a XML resource. The examples shown below illustrate the use of this attribute.

Showing a header

All preferences, which show a dialog, when they are clicked, can show a header at the top of their dialog. The header may contain a background color or image as well as an icon. In order to show such a header, the following XML attributes have to be added to the XML resource, which is used to declare the preference:

custom:showDialogHeader="true"
custom:dialogHeaderBackground="@drawable/dialog_header_background"
custom:dialogHeaderIcon="@drawable/dialog_header_icon"

A preference's dialog, which contains such a header, may look like shown in the screenshot below:

SeekBarPreference

The XML code below shows how to declare a SeekBarPreference as part of a PreferenceScreen. The example contains all of the preference's custom attributes.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.SeekBarPreference 
        android:defaultValue="33.336" 
        android:dialogTitleColor="@android:color/black" 
        android:dialogMessageColor="@android:color/black" 
        android:dialogButtonTextColor="@android:color/black" 
        android:dialogBackground="@android:color/white" 
        android:dialogMessage="@string/seek_bar_preference_dialog_message" 
        android:dialogTitle="@string/seek_bar_preference_dialog_title" 
        android:key="@string/seek_bar_preference_key" 
        android:max="150" 
        android:summary="@array/seek_bar_preference_summaries" 
        android:title="@string/seek_bar_preference_title" 
        custom:decimals="2" 
        custom:floatingPointSeparator="." 
        custom:min="25" 
        custom:showProgress="true" 
        custom:showValueAsSummary="false" 
        custom:unit="Unit"
        custom:dialogThemeResource="@style/MaterialDialog" /> 

</PreferenceScreen>

The following screenshot shows how a SeekBarPreference may look like:

EditTextPreference

The example below shows how the attributes of an EditTextPreference can be specified within a XML resource.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.EditTextPreference 
        android:defaultValue="DefaultText" 
        android:dialogTitleColor="@android:color/black" 
        android:dialogMessageColor="@android:color/black" 
        android:dialogButtonTextColor="@android:color/black" 
        android:dialogBackground="@android:color/white" 
        android:dialogMessage="@string/edit_text_preference_dialog_message" 
        android:dialogTitle="@string/edit_text_preference_dialog_title" 
        android:key="@string/edit_text_preference_key" 
        android:summary="@string/edit_text_preference_summary" 
        android:title="@string/edit_text_preference_title" 
        custom:showValueAsSummary="false" 
        custom:dialogThemeResource="@style/MaterialDialog" /> 

</PreferenceScreen>

The picture shown below show the appearance of a EditTextPreference:

ListPreference

The example illustrates how the attributes of a ListPreference can be specified, if the preference should be declared within a XML resource.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.ListPreference 
        android:defaultValue=0 
        android:entries="R.array.list_preference_entries" 
        android:entryValues="R.array.list_preference_entry_values" 
        android:dialogTitleColor="@android:color/black" 
        android:dialogMessageColor="@android:color/black" 
        android:dialogButtonTextColor="@android:color/black" 
        android:dialogBackground="@android:color/white" 
        android:dialogItemColor="@android:color/black" 
        android:dialogItemControlColor="@android:color/black" 
        android:dialogMessage="@string/list_preference_dialog_message" 
        android:dialogTitle="@string/list_preference_dialog_title" 
        android:key="@string/list_preference_key" 
        android:summary="@array/list_preference_summary" 
        android:title="@string/list_preference_title" 
        custom:showValueAsSummary="false" 
        custom:dialogThemeResource="@style/MaterialDialog" /> 

</PreferenceScreen>

The screenshot below illustrates the appearance of a ListPreference:

MultiChoiceListPreference

The following XML code shows how the attributes of a MultiChoiceListPreference can be specified, if the preference should be declared within a XML resource.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.MultiChoiceListPreference 
        android:defaultValue="R.array.multi_choice_list_preference_entry_values" 
        android:entries="R.array.multi_choice_list_preference_entries" 
        android:entryValues="R.array.multi_choice_list_preference_entry_values" 
        android:dialogTitleColor="@android:color/black" 
        android:dialogMessageColor="@android:color/black" 
        android:dialogButtonTextColor="@android:color/black" 
        android:dialogBackground="@android:color/white" 
        android:dialogItemColor="@android:color/black" 
        android:dialogItemControlColor="@android:color/black" 
        android:dialogMessage="@string/multi_choice_list_preference_dialog_message" 
        android:dialogTitle="@string/multi_choice_list_preference_dialog_title" 
        android:key="@string/multi_choice_list_preference_key" 
        android:summary="@array/multi_choice_list_preference_summary" 
        android:title="@string/multi_choice_list_preference_title" 
        custom:showValueAsSummary="false" 
        custom:dialogThemeResource="@style/MaterialDialog" /> 

</PreferenceScreen>

The screenshot, which is shown in the following, illustrates how a MultiChoiceListPreference may look like:

NumberPickerPreference

The following example illustrates how of a NumberPickerPreference can be specified via XML for use within a PreferenceScreen.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.NumberPickerPreference 
        android:defaultValue="25" 
        custom:min="0" 
        android:max="100" 
        custom:useInputMethod="true" 
        custom:wrapSelectorWheel="false" 
        android:dialogTitleColor="@android:color/black" 
        android:dialogMessageColor="@android:color/black" 
        android:dialogButtonTextColor="@android:color/black" 
        android:dialogBackground="@android:color/white" 
        android:dialogMessage="@string/number_picker_preference_dialog_message" 
        android:dialogTitle="@string/number_picker_preference_dialog_title" 
        android:key="@string/number_picker_preference_key" 
        android:summary="@array/number_picker_preference_summary" 
        android:title="@string/number_picker_preference_title" 
        custom:unit="Unit" 
        custom:stepSize="5" 
        custom:showValueAsSummary="false" 
        custom:dialogThemeResource="@style/MaterialDialog" /> 

</PreferenceScreen>

The screenshot below illustes how a SeekBarPreference may look like:

DigitPickerPreference

The following example illustrates how of a DigitPickerPreference can be declared within a XML resource.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.DigitPickerPreference 
        android:defaultValue="25" 
        custom:numberOfDigits="2" 
        custom:useInputMethod="true" 
        custom:wrapSelectorWheel="false" 
        android:dialogTitleColor="@android:color/black" 
        android:dialogMessageColor="@android:color/black" 
        android:dialogButtonTextColor="@android:color/black" 
        android:dialogBackground="@android:color/white" 
        android:dialogMessage="@string/digit_picker_preference_dialog_message" 
        android:dialogTitle="@string/digit_picker_preference_dialog_title" 
        android:key="@string/digit_picker_preference_key" 
        android:summary="@array/digit_picker_preference_summary" 
        android:title="@string/digit_picker_preference_title" 
        custom:unit="Unit" 
        custom:showValueAsSummary="false" 
        custom:dialogThemeResource="@style/MaterialDialog" /> 

</PreferenceScreen>

The image shown below shows the appearance of a DigitPickerPreference:

ResolutionPreference

The following XML code shows how of a ResolutionPreference can be declared within a XML resource.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.ResolutionPreference 
        android:defaultValue="1024x768" 
        custom:unit=@string/resolution_preference_unit 
        android:dialogTitleColor="@android:color/black" 
        android:dialogMessageColor="@android:color/black" 
        android:dialogButtonTextColor="@android:color/black" 
        android:dialogBackground="@android:color/white" 
        android:dialogMessage="@string/resolution_preference_dialog_message" 
        android:dialogTitle="@string/resolution_preference_dialog_title" 
        android:key="@string/resolution_preference_key" 
        android:summary="@array/resolution_preference_summary" 
        android:title="@string/resolution_preference_title" 
        custom:showValueAsSummary="false" 
        custom:dialogThemeResource="@style/MaterialDialog" /> 

</PreferenceScreen>

The following screenshot illustrates the appearance of a ResolutionPreference:

ColorPalettePreference

The following XML structure illustrates how a ColorPalettePreference can be specified within a XML resource file.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.ColorPalettePreference 
        android:defaultValue="@color/red" 
        custom:showPreview="true" 
        custom:previewSize="@dimen/preview_size" 
        custom:previewShape="square" 
        custom:previewBorderWidth="@dimen/preview_border_width" 
        custom:previewBorderColor="@color/preview_border_color" 
        custom:previewBackground="@drawable/preview_background" 
        custom:colorFormat="rgb" 
        custom:dialogPreviewSize="@dimen/dialog_preview_size" 
        custom:dialogPreviewShape="square" 
        custom:dialogPreviewBorderWidth="@dimen/dialog_preview_border_width" 
        custom:dialogPreviewBorderColor="@color/dialog_preview_border_color" 
        custom:dialogPreviewBackground="@drawable/dialog_preview_background" 
        custom:numberOfColumns="2" 
        custom:colorPalette="@array/color_palette" 
        android:dialogTitleColor="@android:color/black" 
        android:dialogMessageColor="@android:color/black" 
        android:dialogButtonTextColor="@android:color/black" 
        android:dialogBackground="@android:color/white" 
        android:dialogMessage="@string/color_palette_preference_dialog_message" 
        android:dialogTitle="@string/color_palette_preference_dialog_title" 
        android:key="@string/color_palette_preference_key" 
        android:summary="@array/color_palette_preference_summary" 
        android:title="@string/color_palette_preference_title" 
        custom:showValueAsSummary="false" 
        custom:dialogThemeResource="@style/MaterialDialog" /> 

</PreferenceScreen>

A ColorPalettePreference may look like shown in the screenshot below:

SwitchPreference

The following XML code shows how a SwitchPreference can be declared within a XML resource.

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.SwitchPreference 
        android:defaultValue="true" 
        android:summaryOn=@string/summary_on 
        android:summaryOff=@string/summary_off 
        android:disableDependentsState=true 
        android:switchTextOn=@string/switch_text_on 
        android:switchTextOff=@string/switch_text_off 
        android:key="@string/switch_preference_key"
        android:summary="@array/switch_preference_summary" 
        android:title="@string/switch_preference_title" 
        custom:showValueAsSummary="false" /> 

</PreferenceScreen>

CheckBoxPreference

The following example shows how a CheckBoxPreference can be declared within a XML resource.

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto" >

    <de.mrapp.android.preference.CheckBoxPreference
        android:defaultValue="true"
        android:summaryOn=@string/summary_on
        android:summaryOff=@string/summary_off
        android:disableDependentsState=true
        android:key="@string/switch_preference_key"
        android:summary="@array/switch_preference_summary"
        android:title="@string/switch_preference_title"
        custom:showValueAsSummary="false" />

</PreferenceScreen>

Contact information

For personal feedback or questions feel free to contact me via the mail address, which is mentioned on my Github profile. If you have found any bugs or want to post a feature request please use the bugtracker to report them.

androidmaterialpreferences's People

Contributors

bagintz avatar michael-rapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidmaterialpreferences's Issues

ColorPalettePreference is not full height in version 4.0.0

Hi Michael, thanks for this awesome library. I noticed an issue after upgrading to v4.0.0, the ColorPalettePreference is not full height anymore. I didn't change anything with the theme or layout, only the changes required to migrate the library from the older version.

Below is a screenshot of what it looks like currently, whereas previously, the dialog was full height (similar to the ColorPalettePreference screenshot in your readme). There are about 50 colors in this dialog (notice the tiny scrollbar), so it's not an issue with it being only 3 colors.

Here is the relevant code. I tried setting a dialogHeight and dialogMaxHeight, but those didn't take any affect.

        <de.mrapp.android.preference.ColorPalettePreference
            android:defaultValue="@color/bottom_bar_background"
            android:key="pref_bottom_nav_color"
            android:title="@string/pref_bottom_nav_color"
            custom:colorFormat="hex4bytes"
            custom:colorPalette="@array/color_picker_options"
            custom:dialogHeight="400dp"
            custom:dialogMarginBottom="10dp"
            custom:dialogMarginLeft="10dp"
            custom:dialogMarginRight="10dp"
            custom:dialogMarginTop="10dp"
            custom:dialogMaxHeight="400dp"
            custom:showPreview="true"
            custom:showValueAsSummary="false" />

Is it an issue with the library or did I miss something? Thank you.

screenshot_automate_20180607-094517

Setting List looks different on Jelly Beans, Lollipop, and Nougat

Hi again,

Comments
I'm doing a quite extensive search for all variations in my app between versions and to smooth them out. That's why I find so many differences now :)

It feels like I've only found faults, but I really like your library and as I mentioned I went through many before I found this :) I think these are the last differences I've found from your libraries.

Issue Description
I found that the list style is different on different Android versions. The attached picture describes all of them, I also included an image from https://material.google.com/components/lists.html#lists-specs.

  • List item height on single line items
  • Font size and opacity on Jelly Beans
  • Left/right padding on Jelly Beans and Lollipop
  • Divider length on Jelly Beans and Lollipop (if there should be any divider).

different_styles

ConfirmDialogPreference feature

Hi Michael,

(Thanks for an awesome preference library! Found many along the way but this one was the best)

I have an feature request, my problem is that in some settings I have the ability to logout, or reset something. I.e. I only want a confirmation dialog preference. An example would be "Logout?" "Are you sure you want to logout?" With Logout / Cancel buttons.

I've extended your AbstractDialogPreference which makes this a lot easier, but it would be nice if more people can use it :) Of course you can change the code so that it matches your coding style :)

Code

import android.content.Context;
import android.support.annotation.NonNull;
import android.util.AttributeSet;

import de.mrapp.android.dialog.MaterialDialog;
import de.mrapp.android.preference.AbstractDialogPreference;

/**
 * A confirm dialog preference screen
 */
public class ConfirmDialogPreference extends AbstractDialogPreference {
private Listener mListener = null;

public ConfirmDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
}

public ConfirmDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}

public ConfirmDialogPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public ConfirmDialogPreference(Context context) {
    super(context);
}

/**
 * Set listener for when the dialog is closed
 * @param listener listen to dialog events
 */
public void setListener(Listener listener) {
    mListener = listener;
}

@Override
protected boolean needInputMethod() {
    return false;
}

@Override
protected void onPrepareDialog(@NonNull MaterialDialog.Builder dialogBuilder) {
    // Does nothing
}

@Override
protected void onDialogClosed(boolean positiveResult) {
    if (mListener != null) {
        mListener.onDialogClosed(positiveResult);
    }
}

public interface Listener {
    /**
     * Called when the dialog is closed
     * @param positiveResult true if the user clicked the positive button
     */
    void onDialogClosed(boolean positiveResult);
}
}

Example

ConfirmDialogPreference confirmDialogPreference = (ConfirmDialogPreference) findPreference(resources.getString(R.string.preference_logout_key));
confirmDialogPreference.setListener(new ConfirmDialogPreference.Listener() {
    @Override
    public void onDialogClosed(boolean positiveResult) {
        if (positiveResult) {
            user.logout();
        }
    }
});

BadParcelableException

I am getting a lot of these errors when using this library, any ideas?:

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{[APP]MainActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: de.mrapp.android.preference.AbstractDialogPreference$SavedState

Pressing OK on EditTextDialog with empty text leads to NPE

Hi there,

I'm not exactly sure when this started but fairly recent. When an EditTextDialog is opened, but there's no text entered, and OK is pressed, it leads to the following NPE.

    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence de.mrapp.android.dialog.EditTextDialog.getText()' on a null object reference
        at de.mrapp.android.preference.EditTextPreference.onDialogClosed(EditTextPreference.java:377)
        at de.mrapp.android.preference.DialogPreference.onDismiss(DialogPreference.java:2762)

Looks like there needs to be a null check here because I believe null (or empty) should be an acceptable value when accepting text input.

android.view.InflateException in EditTextPreference

Hi, thanks for the great library. I use it in several of my apps. I am running into a peculiar issue a few users have reported on Samsung Galaxy Tabs running Android 4.4 with the EditTextPreference. The app crashes as soon as the EditTextPreference is opened. I can't reproduce it myself, but is it possible to at least catch the error? Let me know if any more information is needed, thanks.

android.view.InflateException: at android.view.LayoutInflater.createView (LayoutInflater.java:626) at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:702) at android.view.LayoutInflater.inflate (LayoutInflater.java:470) at android.view.LayoutInflater.inflate (LayoutInflater.java:398) at android.view.LayoutInflater.inflate (LayoutInflater.java:354) at android.view.View.inflate (View.java:18457) at de.mrapp.android.preference.EditTextPreference.onPrepareDialog (EditTextPreference.java:346) at de.mrapp.android.preference.DialogPreference.showDialog (DialogPreference.java:1001) at de.mrapp.android.preference.DialogPreference.onClick (DialogPreference.java:2161) at android.preference.Preference.performClick (Preference.java:1052) at android.preference.PreferenceScreen.onItemClick (PreferenceScreen.java:229) at android.widget.AdapterView.performItemClick (AdapterView.java:308) at android.widget.AbsListView.performItemClick (AbsListView.java:1509) at android.widget.AbsListView$PerformClick.run (AbsListView.java:3471) at android.widget.AbsListView.onTouchUp (AbsListView.java:4849) at android.widget.AbsListView.onTouchEvent (AbsListView.java:4609) at android.view.View.dispatchTouchEvent (View.java:8135) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2425) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2149) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2431) at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2164) at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent (PhoneWindow.java:2295) at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1622) at android.app.Activity.dispatchTouchEvent (Activity.java:2565) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent (PhoneWindow.java:2243) at android.view.View.dispatchPointerEvent (View.java:8343) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4768) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4634) at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4192) at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4246) at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4215) at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:4326) at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4223) at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:4383) at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4192) at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4246) at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4215) at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4223) at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4192) at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:6557) at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:6474) at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:6445) at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:6410) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:6637) at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:185) at android.os.MessageQueue.nativePollOnce (Native Method) at android.os.MessageQueue.next (MessageQueue.java:138) at android.os.Looper.loop (Looper.java:131) at android.app.ActivityThread.main (ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative (Native Method) at java.lang.reflect.Method.invoke (Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1099) at dalvik.system.NativeStart.main (Native Method) Caused by: java.lang.reflect.InvocationTargetException: at java.lang.reflect.Constructor.constructNative (Native Method) at java.lang.reflect.Constructor.newInstance (Constructor.java:423) at android.view.LayoutInflater.createView (LayoutInflater.java:600)

Crash when restoring SeekBarPreference's saved state

When using a SeekBarPreference within a Fragment, the app may crash when restoring the preference's state. The issue seems to occur after the device's display remained turned of for quite some time with the preference dialog opened. When turning the device on again, the Fragment's state, including the state of the SeekBarPreference, gets restored, resulting in a crash. This bug seems not to happen after orientation changes. See attached stacktrace for further information.

image-preference

In the settings the user should be able to set a profile image. This image should be visible in the settings-view.

Changing the default number of a NumberPickerPreference may cause a crash

When the default number of a NumberPickerPreference is changed by using the setter method or a XML attribute, this may cause the app to crash. The reason is, that the minimum and maximum number are not initialized yet and therefore are 0. Therefore the precondition, that the preference's number must be between both values, may fail.

How can i open sub screen


<de.mrapp.android.preference.SwitchPreference
android:defaultValue="@bool/preference_default_home"
android:key="@string/preference_key_default_home"
android:summary="@string/set_as_default_summary"
android:title="@string/set_as_default"
/>

<PreferenceCategory android:title="@string/general_text">
    <de.mrapp.android.preference.SwitchPreference
        android:defaultValue="@bool/preference_default_leftscreen"
        android:key="@string/preference_key_launcher_leftscreen"
        android:summary="@string/preferences_title_leftscreen_summary"
        android:title="@string/preferences_title_leftscreen"
        android:icon="@drawable/setting_appearance_ic"/>

    <de.mrapp.android.preference.ListPreference
        android:defaultValue="@string/preference_default_effect"
        android:entries="@array/transition_effect_entries"
        android:entryValues="@array/transition_effect_entries_values"
        android:key="@string/preference_key_launcher_effect"
        android:summary="@string/preferences_title_effect_summary"
        android:title="@string/appearance_text"
        android:icon="@drawable/setting_appearance_ic"/>


    <PreferenceScreen android:title="@string/gesture_text"
        android:dependency="">
        <de.mrapp.android.preference.ListPreference
            android:defaultValue="@string/preference_default_effect"
            android:entries="@array/transition_effect_entries"
            android:entryValues="@array/transition_effect_entries_values"
            android:key="@string/preference_key_launcher_effect"
            android:summary="@string/preferences_title_effect_summary"
            android:title="@string/appearance_text"
            android:icon="@drawable/setting_appearance_ic"/>
    </PreferenceScreen>

</PreferenceCategory>

NullPointerException in ListPreference

Hi, great library!

I ran into a NPE when updating the values array in a list preference. This happened during development, but could potentially happen in production as well if an update modified the values array. I think it would be better if the library silently falled back to a default value or no value at all in this case.

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference at de.mrapp.android.preference.AbstractListPreference.indexOf(AbstractListPreference.java:202)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.