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