public class SettingEditDialogPreference extends SettingDialogPreference<EditDialog.EditOptions>
SettingDialogPreference implementation that may be used to allow to a user to specify
its preferred input text for a specific setting preference.
This preference implementation by default displays the preferred input text as its summary text
if it is specified, or the standard summary text if there is no input text persisted. The preferred
input text may be specified via setInput(String) and obtained via getInput().
When SettingDialogPreference.handleDialogButtonClick(Dialog, int) is called, this preference implementation
handles only EditDialog type of dialog. If its Dialog.BUTTON_POSITIVE button has
been clicked, the input provided via EditDialog.getInput() is set as input for this
preference via setInput(String).
String. See TypedArray.getString(int).
SettingDialogPreference,
SettingEditDialogPreference Attributes
settingEditDialogPreferenceStyleSettingDialogPreference.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 |
|---|
SettingEditDialogPreference(android.content.Context context)
Same as
SettingEditDialogPreference(Context, AttributeSet) without attributes. |
SettingEditDialogPreference(android.content.Context context,
android.util.AttributeSet attrs)
Same as
SettingEditDialogPreference(Context, AttributeSet, int) with
R.attr.settingEditDialogPreferenceStyle as attribute for default style. |
SettingEditDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
Same as
SettingEditDialogPreference(Context, AttributeSet, int, int) with 0 as
default style. |
SettingEditDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Creates a new instance of SettingEditDialogPreference for the given context.
|
| Modifier and Type | Method and Description |
|---|---|
EditDialog.EditOptions |
getDialogOptions()
Dialog options of this preference with the preferred input specified as
EditDialog.EditOptions#content(CharSequence), if it is set. |
String |
getInput()
Returns the preferred input value of this preference.
|
void |
onBindViewHolder(androidx.preference.PreferenceViewHolder holder) |
protected void |
onConfigureDialogOptions(EditDialog.EditOptions 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 EditDialog.EditOptions |
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 typedArray,
int index) |
protected CharSequence |
onGetSummaryText()
Called from
SettingDialogPreference.synchronizeSummaryView(PreferenceViewHolder) to retrieve the current
summary text for this dialog preference. |
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 |
setInput(String input)
Sets a preferred input value for this preference.
|
getDialogId, handleDialogButtonClick, 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 SettingEditDialogPreference(@NonNull
android.content.Context context)
SettingEditDialogPreference(Context, AttributeSet) without attributes.public SettingEditDialogPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs)
SettingEditDialogPreference(Context, AttributeSet, int) with
R.attr.settingEditDialogPreferenceStyle as attribute for default style.public SettingEditDialogPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr)
SettingEditDialogPreference(Context, AttributeSet, int, int) with 0 as
default style.public SettingEditDialogPreference(@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.protected void onConfigureDialogOptions(@NonNull
EditDialog.EditOptions options,
@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr,
@StyleRes
int defStyleRes)
SettingDialogPreferenceonConfigureDialogOptions in class SettingDialogPreference<EditDialog.EditOptions>options - The options created via SettingDialogPreference.onCreateDialogOptions(Resources).@NonNull protected EditDialog.EditOptions onCreateDialogOptions(@NonNull android.content.res.Resources resources)
SettingDialogPreference
Default implementation creates instance of DialogOptions.
onCreateDialogOptions in class SettingDialogPreference<EditDialog.EditOptions>resources - Application resources that may be used supply default values from resources
for the options.protected Object onGetDefaultValue(@NonNull android.content.res.TypedArray typedArray, int index)
onGetDefaultValue in class androidx.preference.Preferenceprotected void onSetInitialValue(@Nullable
Object defaultValue)
onSetInitialValue in class androidx.preference.Preferencepublic void setInput(@Nullable
String input)
If value of this preference changes, it is persisted and the change listener is notified about the change.
input - The preferred input to be persisted.getInput()@Nullable public String getInput()
setInput(String),
getDialogOptions()public void onBindViewHolder(@NonNull
androidx.preference.PreferenceViewHolder holder)
onBindViewHolder in class SettingPreference@Nullable protected CharSequence onGetSummaryText()
SettingDialogPreferenceSettingDialogPreference.synchronizeSummaryView(PreferenceViewHolder) to retrieve the current
summary text for this dialog preference.
Default implementation returns the text provided by Preference.getSummary() method.
onGetSummaryText in class SettingDialogPreference<EditDialog.EditOptions>@NonNull public EditDialog.EditOptions getDialogOptions()
EditDialog.EditOptions#content(CharSequence), if it is set.getDialogOptions in class SettingDialogPreference<EditDialog.EditOptions>getInput()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<EditDialog.EditOptions>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.