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.handleOnDialogButtonClick(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
uiSettingColorDialogPreferenceStyleSettingDialogPreference.OnClickListenerNO_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#uiSettingColorDialogPreferenceStyle 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 |
onBindView(android.view.View view) |
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.handleOnDialogButtonClick(Dialog, int) if the given dialog has
id associated with this dialog preference. |
protected void |
onSetInitialValue(boolean restorePersistedValue,
Object defaultValue) |
void |
setColor(int color)
Sets a preferred color value for this preference.
|
getDialogId, handleOnDialogButtonClick, onGetSummaryText, setOnClickListener, synchronizeSummaryViewsetKeycallChangeListener, compareTo, findPreferenceInHierarchy, getContext, getDependency, getEditor, getExtras, getFragment, getIcon, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPersistedStringSet, getPreferenceManager, getSharedPreferences, getShouldDisableView, getSummary, getTitle, getTitleRes, getView, getWidgetLayoutResource, hasKey, isEnabled, isPersistent, isSelectable, notifyChanged, notifyDependencyChange, notifyHierarchyChanged, onAttachedToActivity, onAttachedToHierarchy, onClick, onCreateView, onDependencyChanged, onParentChanged, onPrepareForRemoval, onRestoreInstanceState, onSaveInstanceState, peekExtras, persistBoolean, persistFloat, persistInt, persistLong, persistString, persistStringSet, restoreHierarchyState, saveHierarchyState, setDefaultValue, setDependency, setEnabled, setFragment, setIcon, setIcon, setIntent, setLayoutResource, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setSelectable, setShouldDisableView, setSummary, setSummary, setTitle, setTitle, setWidgetLayoutResource, shouldCommit, shouldDisableDependents, shouldPersist, toStringpublic SettingColorDialogPreference(android.content.Context context)
SettingColorDialogPreference(Context, AttributeSet) without attributes.public SettingColorDialogPreference(android.content.Context context,
android.util.AttributeSet attrs)
SettingColorDialogPreference(Context, AttributeSet, int) with
R.attr#uiSettingColorDialogPreferenceStyle as attribute for default style.public SettingColorDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
SettingColorDialogPreference(Context, AttributeSet, int, int) with 0 as
default style.public SettingColorDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
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.protected ColorPickerDialog.ColorOptions onCreateDialogOptions(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(ColorPickerDialog.ColorOptions options,
android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
SettingDialogPreferenceonConfigureDialogOptions in class SettingDialogPreference<ColorPickerDialog.ColorOptions>options - The options created via SettingDialogPreference.onCreateDialogOptions(Resources).protected Object onGetDefaultValue(android.content.res.TypedArray attributes, int index)
onGetDefaultValue in class android.preference.Preferenceprotected void onSetInitialValue(boolean restorePersistedValue,
Object defaultValue)
onSetInitialValue in class android.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 onBindView(android.view.View view)
onBindView in class SettingPreferencepublic ColorPickerDialog.ColorOptions getDialogOptions()
ColorPickerDialog.ColorOptions#color(int), if it is set.getDialogOptions in class SettingDialogPreference<ColorPickerDialog.ColorOptions>getColor()protected boolean onHandleDialogButtonClick(Dialog dialog,
int button)
SettingDialogPreferenceSettingDialogPreference.handleOnDialogButtonClick(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.