Preference

open class Preference : Comparable<T> (source)

(SESL variant) The basic building block that represents an individual setting displayed to a user in the preference hierarchy. This class provides the data that will be displayed to the user and has a reference to the SharedPreferences or PreferenceDataStore instance that persists the preference's values.

When specifying a preference hierarchy in XML, each element can point to a subclass of Preference, similar to the view hierarchy and layouts.

This class contains a key that that represents the key that is used to persist the value to the device. It is up to the subclass to decide how to store the value.

Inheritors

Constructors

Link copied to clipboard
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int)
Perform inflation from XML and apply a class-specific base style.
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet, defStyleAttr: Int)
Perform inflation from XML and apply a class-specific base style.
constructor(@NonNull context: Context, @Nullable attrs: AttributeSet)
Constructor that is called when inflating a preference from XML.
constructor(@NonNull context: Context)
Constructor to create a preference.

Types

Link copied to clipboard
A base class for managing the instance state of a Preference.
Link copied to clipboard
Interface definition for a callback to be invoked when the value of this Preference has been changed by the user and is about to be set and/or persisted.
Link copied to clipboard
Interface definition for a callback to be invoked when a Preference is clicked.
Link copied to clipboard
Interface definition for a callback to be invoked when the summary of this Preference is requested (typically when this preference is added to the hierarchy or its value is updated).

Properties

Link copied to clipboard
val DEFAULT_ORDER: Int = 2147483647
Specify for setOrder if a specific order is not required.

Functions

Link copied to clipboard
open fun callChangeListener(newValue: Any): Boolean
Call this method after the user changes the preference, but before the internal state is set.
Link copied to clipboard
open fun compareTo(@NonNull another: Preference): Int
Compares preference objects based on order (if set), otherwise alphabetically on the titles.
Link copied to clipboard
Returns the Context of this preference.
Link copied to clipboard
Returns the key of the dependency on this preference.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one.
Link copied to clipboard
Return the fragment class name associated with this preference.
Link copied to clipboard
Returns the icon of this preference.
Link copied to clipboard
Return the Intent associated with this preference.
Link copied to clipboard
open fun getKey(): String
Gets the key for this preference, which is also the key used for storing values into SharedPreferences or PreferenceDataStore.
Link copied to clipboard
Gets the layout resource that will be shown as the View for this preference.
Link copied to clipboard
Returns the callback to be invoked when this preference is changed by the user (but before the internal state has been updated).
Link copied to clipboard
Returns the callback to be invoked when this preference is clicked.
Link copied to clipboard
open fun getOrder(): Int
Gets the order of this preference with respect to other preference objects on the same level.
Link copied to clipboard
Returns the PreferenceGroup which is this preference assigned to or null if this preference is not assigned to any group or is a root preference.
Link copied to clipboard
open fun getPersistedStringSet(defaultReturnValue: Set<String>): Set<String>
Attempts to get a persisted set of Strings if this preference is persistent.
Link copied to clipboard
Returns PreferenceDataStore used by this preference.
Link copied to clipboard
Gets the PreferenceManager that manages this preference object's tree.
Link copied to clipboard
Returns the SharedPreferences where this preference can read its value(s).
Link copied to clipboard
Checks whether this preference should disable its view when it's action is disabled.
Link copied to clipboard
Returns the summary of this preference.
Link copied to clipboard
Returns the SummaryProvider used to configure the summary of this preference.
Link copied to clipboard
Returns the title of this preference.
Link copied to clipboard
Gets the layout resource for the controllable widget portion of this preference.
Link copied to clipboard
open fun hasKey(): Boolean
Checks whether this preference has a valid key.
Link copied to clipboard
Returns whether the summary of this preference can be copied to the clipboard by long pressing on the preference.
Link copied to clipboard
open fun isEnabled(): Boolean
Checks whether this preference should be enabled in the list.
Link copied to clipboard
Returns whether the space of this preference icon view is reserved.
Link copied to clipboard
open fun isPersistent(): Boolean
Checks whether this preference is persistent.
Link copied to clipboard
open fun isSelectable(): Boolean
Checks whether this preference should be selectable in the list.
Link copied to clipboard
Checks whether this preference is shown to the user in the hierarchy.
Link copied to clipboard
Gets whether the title of this preference is constrained to a single line.
Link copied to clipboard
Checks whether this preference should be visible to the user.
Link copied to clipboard
open fun notifyDependencyChange(disableDependents: Boolean)
Notifies any listening dependents of a change that affects the dependency.
Link copied to clipboard
open fun onAttached()
Called when the preference hierarchy has been attached to the list of preferences.
Link copied to clipboard
Binds the created View to the data for this preference.
Link copied to clipboard
open fun onDependencyChanged(@NonNull dependency: Preference, disableDependent: Boolean)
Called when the dependency changes.
Link copied to clipboard
open fun onDetached()
Called when the preference hierarchy has been detached from the list of preferences.
Link copied to clipboard
Initializes an android.view.accessibility.AccessibilityNodeInfo with information about the View for this preference.
Link copied to clipboard
open fun onParentChanged(@NonNull parent: Preference, disableChild: Boolean)
Called when the implicit parent dependency changes.
Link copied to clipboard
Return the extras Bundle object associated with this preference, returning null if there is not currently one.
Link copied to clipboard
Called when a click should be performed.
Link copied to clipboard
open fun persistStringSet(values: Set<String>): Boolean
Attempts to persist a set of Strings if this preference is persistent.
Link copied to clipboard
open fun restoreHierarchyState(@NonNull container: Bundle)
Restore this preference hierarchy's previously saved state from the given container.
Link copied to clipboard
open fun saveHierarchyState(@NonNull container: Bundle)
Store this preference hierarchy's frozen state into the given container.
Link copied to clipboard
open fun seslGetPreferenceBounds(bounds: Rect)
Link copied to clipboard
open fun seslSetRoundedBg(where: Int)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun setCopyingEnabled(enabled: Boolean)
Sets whether the summary of this preference can be copied to the clipboard by long pressing on the preference.
Link copied to clipboard
open fun setDefaultValue(defaultValue: Any)
Sets the default value for this preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.
Link copied to clipboard
open fun setDependency(@Nullable dependencyKey: String)
Sets the key of a preference that this preference will depend on.
Link copied to clipboard
Link copied to clipboard
open fun setDotVisibility(isVisible: Boolean)
Link copied to clipboard
open fun setEnabled(enabled: Boolean)
Sets whether this preference is enabled.
Link copied to clipboard
open fun setFragment(@Nullable fragment: String)
Sets the class name of a fragment to be shown when this preference is clicked.
Link copied to clipboard
open fun setIcon(@Nullable icon: Drawable)
Sets the icon for this preference with a Drawable.
open fun setIcon(iconResId: Int)
Sets the icon for this preference with a resource ID.
Link copied to clipboard
open fun setIconSpaceReserved(iconSpaceReserved: Boolean)
Sets whether to reserve the space of this preference icon view when no icon is provided.
Link copied to clipboard
open fun setIntent(@Nullable intent: Intent)
Sets an Intent to be used for startActivity when this preference is clicked.
Link copied to clipboard
open fun setKey(key: String)
Sets the key for this preference, which is used as a key to the SharedPreferences or PreferenceDataStore.
Link copied to clipboard
open fun setLayoutResource(layoutResId: Int)
Sets the layout resource that is inflated as the View to be shown for this preference.
Link copied to clipboard
Sets the callback to be invoked when this preference is changed by the user (but before the internal state has been updated).
Link copied to clipboard
Sets the callback to be invoked when this preference is clicked.
Link copied to clipboard
open fun setOrder(order: Int)
Sets the order of this preference with respect to other preference objects on the same level.
Link copied to clipboard
open fun setPersistent(persistent: Boolean)
Sets whether this preference is persistent.
Link copied to clipboard
Sets a PreferenceDataStore to be used by this preference instead of using SharedPreferences.
Link copied to clipboard
open fun setSelectable(selectable: Boolean)
Sets whether this preference is selectable.
Link copied to clipboard
open fun setShouldDisableView(shouldDisableView: Boolean)
Sets whether this preference should disable its view when it gets disabled.
Link copied to clipboard
open fun setSingleLineTitle(singleLineTitle: Boolean)
Sets whether to constrain the title of this preference to a single line instead of letting it wrap onto multiple lines.
Link copied to clipboard
open fun setSummary(summaryResId: Int)
Sets the summary for this preference with a resource ID.
open fun setSummary(@Nullable summary: CharSequence)
Sets the summary for this preference with a CharSequence.
Link copied to clipboard
Set a SummaryProvider that will be invoked whenever the summary of this preference is requested.
Link copied to clipboard
open fun setTitle(titleResId: Int)
Sets the title for this preference with a resource ID.
open fun setTitle(@Nullable title: CharSequence)
Sets the title for this preference with a CharSequence.
Link copied to clipboard
open fun setViewId(viewId: Int)
Set the ID that will be assigned to the overall View representing this preference, once bound.
Link copied to clipboard
fun setVisible(visible: Boolean)
Sets whether this preference should be visible to the user.
Link copied to clipboard
open fun setWidgetLayoutResource(widgetLayoutResId: Int)
Sets the layout for the controllable widget portion of this preference.
Link copied to clipboard
Checks whether this preference's dependents should currently be disabled.
Link copied to clipboard
open fun toString(): String