Preferences - OneUIProject/OneUI-Design-Library GitHub Wiki

de.dlyt.yanndroid.oneui.layout.PreferenceFragment

Samsung's Preferences.

Attributes and usage are the same as Google's PreferenceFragmentCompat but you have to use de.dlyt.yanndroid.oneui.layout.PreferenceFragment instead. All the default preferences from androidx.preference are already included, plus additional custom ones (see below).

Methods

PreferenceFragment:

Return RecyclerView, to access all of it's methods.

public final RecyclerView getListView()

Enable/disable rounded corners.

public void seslSetRoundedCorner(boolean enabled)

Create and add a RelatedCard to the bottom of the Preferences.

PreferencesRelatedCard relatedCard = createRelatedCard(context);
relatedCard.addButton("This", this)
            .addButton("That", this)
            .addButton("There", this)
            .show(this);

Preference:

Set custom rounded corners position for a preference (SeslRoundedCorner.ROUNDED_CORNER_*).

public void seslSetRoundedBg(int where)

Set custom rounded corners position for a preference category (SeslRoundedCorner.ROUNDED_CORNER_*).

public void seslSetSubheaderRoundedBackground(int where) 

Set custom preference summary text color.

public void seslSetSummaryColor(int color)
public void seslSetSummaryColor(ColorStateList color)

Custom Preferences:

SwitchPreferenceScreen

Clickable SwitchPreference used to contain inner preferences, can be used in combination with SwitchBarLayout.

<SwitchPreferenceScreen
    android:key="..."
    android:summary="..."
    android:title="..."/>

Both OnPreferenceClickListener and intent tag can be used to manage the behavior of the Preference when clicked.

TipsCard

<TipsCardViewPreference
    android:key="..."
    android:summary="..."
    android:title="..." />

ColorPickerPreference

<ColorPickerPreference
    android:defaultValue="..."
    android:key="..."
    android:title="..."
    app:pickerType="..."
    app:showAlphaSlider="..." />

android:defaultValue: default color string (ex. #FF2525)
app:pickerType: classic or detailed
app:showAlphaSlider: show transparency seekbar in classic picker type

HorizontalRadioPreference

Samsung's Radio Preferences used in Light/Dark mode Settings and Resolution Settings.

<HorizontalRadioPreference
    android:key="..."
    android:title="..."
    app:entriesImage="..."
    app:entries="..."
    app:entriesSubtitle="..."
    app:entryValues="..."
    app:viewType="..." />

app:entriesImage: array with drawables (to be used only with image viewType)
app:entries: string array for the names
app:entriesSubtitle: string array for the subtitle (to be used only with noImage viewType) app:entriesValues: string array for the values
app:viewType: image or noImage

SeekBarPreference

<SeekBarPreference
    android:key="..."
    android:title="..."
    app:min="..."
    app:max="..."
    app:overlap="..."
    app:seekBarIncrement="..."
    app:adjustable="..."
    app:showSeekBarValue="..."
    app:seekBarMode="..."
    app:seekBarSeamless="..."
    app:units="..."
    app:updatesContinuously="..."
    app:viewType="..." />

app:min: min seekbar value
app:max: max seekbar value
app:overlap: overlap point (orange limit)
app:seekBarIncrement: from google: (Sets the increment amount on the SeekBar for each arrow key press.)
app:adjustable: from google: (Sets whether the SeekBar should respond to the left/right keys.)
app:showSeekBarValue: show a text with the current seekbar value in the preference
app:seekBarMode: set OUI seekbar style (standard|expand)
app:seekBarSeamless: enable seekbar seamless effect
app:units: value unit that gets appended to seekbar value if shown (ex: units="%" -> seekbar shows "100 %")
app:updatesContinuously: set key in sharedpreferences when dragging the seekbar instead of when releasing A.K.A (Sets whether the SeekBarPreference should continuously save the SeekBar value while it is being dragged.)

LayoutPreference

Preference that can inflate custom layouts.

<LayoutPreference
    android:key="..."
    android:layout="..."
    android:selectable="..." />

android:selectable="false" to remove the default ripple effect.

public <T extends View> T findViewById(int id)
public void setDescendantFocusability(int descendantFocusability)

InsetPreferenceCategory

Preference category with customizable height/round corners.

<InsetPreferenceCategory
    android:key="..."
    android:title="..."
    app:height="..."
    app:roundStroke="..." />