public final class SettingColorDialogPreference extends SettingDialogPreference<ColorPickerDialog.ColorOptions>
SettingDialogPreference implementation that may be used to allow to a user to pick
its preferred color for a specific setting preference.
This preference implementation by default displays the preferred color via SettingColorView
widget in the widget area (at the end of layout hierarchy). The preferred color may be specified
via setColor(int) and obtained via getColor().
When SettingDialogPreference.handleDialogButtonClick(Dialog, int) is called, this preference implementation
handles only ColorPickerDialog type of dialog. If its Dialog.BUTTON_POSITIVE button
has been clicked, the color provided via ColorPickerDialog.getColor() is set as color for
this preference via setColor(int).
Integer. See TypedArray.getColor(int, int).
SettingDialogPreference,
SettingColorDialogPreference Attributes
settingColorDialogPreferenceStyleSettingDialogPreference.OnClickListenerandroidx.preference.Preference.BaseSavedState, androidx.preference.Preference.OnPreferenceChangeListener, androidx.preference.Preference.OnPreferenceClickListener, androidx.preference.Preference.SummaryProvider<T extends androidx.preference.Preference>NO_DIALOG_ID| Constructor and Description |
|---|
SettingColorDialogPreference(android.content.Context context)
Same as
SettingColorDialogPreference(Context, AttributeSet) without attributes. |
SettingColorDialogPreference(android.content.Context context,
android.util.AttributeSet attrs)
Same as
SettingColorDialogPreference(Context, AttributeSet, int) with
R.attr.settingColorDialogPreferenceStyle as attribute for default style. |
SettingColorDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
Same as
SettingColorDialogPreference(Context, AttributeSet, int, int) with 0 as
default style. |
SettingColorDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Creates a new instance of SettingColorDialogPreference for the given context.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getColor()
Returns the preferred color value of this preference.
|
ColorPickerDialog.ColorOptions |
getDialogOptions()
Dialog options of this preference with the preferred color specified as
ColorPickerDialog.ColorOptions#color(int), if it is set. |
void |
onBindViewHolder(androidx.preference.PreferenceViewHolder holder) |
protected void |
onConfigureDialogOptions(ColorPickerDialog.ColorOptions options,
android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Called from one of constructors to configure dialog options specific for this dialog preference.
|
protected ColorPickerDialog.ColorOptions |
onCreateDialogOptions(android.content.res.Resources resources)
Called to create instance of dialog options specific for this dialog preference.
|
protected Object |
onGetDefaultValue(android.content.res.TypedArray attributes,
int index) |
protected boolean |
onHandleDialogButtonClick(Dialog dialog,
int button)
Called from
SettingDialogPreference.handleDialogButtonClick(Dialog, int) if the given dialog has
id associated with this dialog preference. |
protected void |
onSetInitialValue(Object defaultValue) |
void |
setColor(int color)
Sets a preferred color value for this preference.
|
getDialogId, handleDialogButtonClick, onGetSummaryText, setDialogId, setOnClickListener, synchronizeSummaryViewsetKeycallChangeListener, compareTo, findPreferenceInHierarchy, getContext, getDependency, getExtras, getFragment, getIcon, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getParent, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPersistedStringSet, getPreferenceDataStore, getPreferenceManager, getSharedPreferences, getShouldDisableView, getSummary, getSummaryProvider, getTitle, getWidgetLayoutResource, hasKey, isCopyingEnabled, isEnabled, isIconSpaceReserved, isPersistent, isSelectable, isShown, isSingleLineTitle, isVisible, notifyChanged, notifyDependencyChange, notifyHierarchyChanged, onAttached, onAttachedToHierarchy, onAttachedToHierarchy, onClick, onDependencyChanged, onDetached, onInitializeAccessibilityNodeInfo, onParentChanged, onPrepareForRemoval, onRestoreInstanceState, onSaveInstanceState, onSetInitialValue, peekExtras, performClick, performClick, persistBoolean, persistFloat, persistInt, persistLong, persistString, persistStringSet, restoreHierarchyState, saveHierarchyState, setCopyingEnabled, setDefaultValue, setDependency, setEnabled, setFragment, setIcon, setIcon, setIconSpaceReserved, setIntent, setLayoutResource, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setPreferenceDataStore, setSelectable, setShouldDisableView, setSingleLineTitle, setSummary, setSummary, setSummaryProvider, setTitle, setTitle, setViewId, setVisible, setWidgetLayoutResource, shouldDisableDependents, shouldPersist, toStringpublic SettingColorDialogPreference(@NonNull
android.content.Context context)
SettingColorDialogPreference(Context, AttributeSet) without attributes.public SettingColorDialogPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs)
SettingColorDialogPreference(Context, AttributeSet, int) with
R.attr.settingColorDialogPreferenceStyle as attribute for default style.public SettingColorDialogPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr)
SettingColorDialogPreference(Context, AttributeSet, int, int) with 0 as
default style.public SettingColorDialogPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr,
@StyleRes
int defStyleRes)
context - Context in which will be the new setting preference presented.attrs - Set of Xml attributes used to configure the new instance of this preference.defStyleAttr - An attribute which contains a reference to a default style resource for
this preference within a theme of the given context.defStyleRes - Resource id of the default style for the new preference.@NonNull protected ColorPickerDialog.ColorOptions onCreateDialogOptions(@NonNull android.content.res.Resources resources)
SettingDialogPreference
Default implementation creates instance of DialogOptions.
onCreateDialogOptions in class SettingDialogPreference<ColorPickerDialog.ColorOptions>resources - Application resources that may be used supply default values from resources
for the options.protected void onConfigureDialogOptions(@NonNull
ColorPickerDialog.ColorOptions options,
@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr,
@StyleRes
int defStyleRes)
SettingDialogPreferenceonConfigureDialogOptions in class SettingDialogPreference<ColorPickerDialog.ColorOptions>options - The options created via SettingDialogPreference.onCreateDialogOptions(Resources).protected Object onGetDefaultValue(@NonNull android.content.res.TypedArray attributes, int index)
onGetDefaultValue in class androidx.preference.Preferenceprotected void onSetInitialValue(@Nullable
Object defaultValue)
onSetInitialValue in class androidx.preference.Preferencepublic void setColor(int color)
If value of this preference changes, it is persisted and the change listener is notified about the change.
color - The preferred color to be persisted as Integer.getColor()public int getColor()
setColor(int),
getDialogOptions()public void onBindViewHolder(@NonNull
androidx.preference.PreferenceViewHolder holder)
onBindViewHolder in class SettingPreference@NonNull public ColorPickerDialog.ColorOptions getDialogOptions()
ColorPickerDialog.ColorOptions#color(int), if it is set.getDialogOptions in class SettingDialogPreference<ColorPickerDialog.ColorOptions>getColor()protected boolean onHandleDialogButtonClick(@NonNull
Dialog dialog,
int button)
SettingDialogPreferenceSettingDialogPreference.handleDialogButtonClick(Dialog, int) if the given dialog has
id associated with this dialog preference.onHandleDialogButtonClick in class SettingDialogPreference<ColorPickerDialog.ColorOptions>dialog - The dialog where the button has been clicked.button - The clicked dialog button.True if the button click event has been successfully handled, false
otherwise.