|
| 1 | +package org.schabi.newpipe.settings.preferencesearch |
| 2 | + |
| 3 | +import android.util.Log |
| 4 | +import androidx.annotation.XmlRes |
| 5 | + |
| 6 | +/** |
| 7 | + * Represents a preference-item inside the search. |
| 8 | + * |
| 9 | + * @param key Key of the setting/preference. E.g. used inside [android.content.SharedPreferences]. |
| 10 | + * @param title Title of the setting, e.g. 'Default resolution' or 'Show higher resolutions'. |
| 11 | + * @param summary Summary of the setting, e.g. '480p' or 'Only some devices can play 2k/4k'. |
| 12 | + * @param entries Possible entries of the setting, e.g. 480p,720p,... |
| 13 | + * @param breadcrumbs Breadcrumbs - a hint where the setting is located e.g. 'Video and Audio > Player' |
| 14 | + * @param searchIndexItemResId The xml-resource where this item was found/built from. |
| 15 | + */ |
| 16 | + |
| 17 | +data class PreferenceSearchItem( |
| 18 | + val key: String, val title: String, |
| 19 | + val summary: String, val entries: String, |
| 20 | + val breadcrumbs: String, @XmlRes val searchIndexItemResId: Int |
| 21 | +) { |
| 22 | + fun hasData(): Boolean { |
| 23 | + return !key.isEmpty() && !title.isEmpty() |
| 24 | + } |
| 25 | + |
| 26 | + fun getAllRelevantSearchFields(): MutableList<String?> { |
| 27 | + return mutableListOf(title, summary, entries, breadcrumbs) |
| 28 | + } |
| 29 | + |
| 30 | + override fun toString(): String { |
| 31 | + return "PreferenceItem: $title $summary $key" |
| 32 | + } |
| 33 | +} |
0 commit comments