Enable nonFinalResIds
This commit is contained in:
parent
15ccc6b930
commit
d28fa5db69
21 changed files with 146 additions and 188 deletions
|
|
@ -1,11 +1,11 @@
|
|||
package org.jellyfin.androidtv.auth.model
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class AuthenticationSortBy {
|
||||
@EnumDisplayOptions(name = R.string.last_use)
|
||||
LAST_USE,
|
||||
@EnumDisplayOptions(name = R.string.alphabetical)
|
||||
ALPHABETICAL
|
||||
enum class AuthenticationSortBy(
|
||||
override val nameRes: Int
|
||||
) : PreferenceEnum {
|
||||
LAST_USE(R.string.last_use),
|
||||
ALPHABETICAL(R.string.alphabetical);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
package org.jellyfin.androidtv.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class GridDirection {
|
||||
enum class GridDirection(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Horizontal.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.grid_direction_horizontal)
|
||||
HORIZONTAL,
|
||||
HORIZONTAL(R.string.grid_direction_horizontal),
|
||||
|
||||
/**
|
||||
* Vertical.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.grid_direction_vertical)
|
||||
VERTICAL,
|
||||
VERTICAL(R.string.grid_direction_vertical),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.jellyfin.androidtv.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
/**
|
||||
|
|
@ -10,35 +9,17 @@ import org.jellyfin.preference.PreferenceEnum
|
|||
* https://github.com/jellyfin/jellyfin-web/blob/master/src/components/homesections/homesections.js
|
||||
*/
|
||||
enum class HomeSectionType(
|
||||
override val serializedName: String
|
||||
override val serializedName: String,
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
@EnumDisplayOptions(R.string.home_section_latest_media)
|
||||
LATEST_MEDIA("latestmedia"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_library)
|
||||
LIBRARY_TILES_SMALL("smalllibrarytiles"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_library_small)
|
||||
LIBRARY_BUTTONS("librarybuttons"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_resume)
|
||||
RESUME("resume"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_resume_audio)
|
||||
RESUME_AUDIO("resumeaudio"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_resume_book)
|
||||
RESUME_BOOK("resumebook"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_active_recordings)
|
||||
ACTIVE_RECORDINGS("activerecordings"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_next_up)
|
||||
NEXT_UP("nextup"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_livetv)
|
||||
LIVE_TV("livetv"),
|
||||
|
||||
@EnumDisplayOptions(R.string.home_section_none)
|
||||
NONE("none"),
|
||||
LATEST_MEDIA("latestmedia", R.string.home_section_latest_media),
|
||||
LIBRARY_TILES_SMALL("smalllibrarytiles", R.string.home_section_library),
|
||||
LIBRARY_BUTTONS("librarybuttons", R.string.home_section_library_small),
|
||||
RESUME("resume", R.string.home_section_resume),
|
||||
RESUME_AUDIO("resumeaudio", R.string.home_section_resume_audio),
|
||||
RESUME_BOOK("resumebook", R.string.home_section_resume_book),
|
||||
ACTIVE_RECORDINGS("activerecordings", R.string.home_section_active_recordings),
|
||||
NEXT_UP("nextup", R.string.home_section_next_up),
|
||||
LIVE_TV("livetv", R.string.home_section_livetv),
|
||||
NONE("none", R.string.home_section_none),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
package org.jellyfin.androidtv.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class ImageType {
|
||||
enum class ImageType(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Poster.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.image_type_poster)
|
||||
POSTER,
|
||||
POSTER(R.string.image_type_poster),
|
||||
|
||||
/**
|
||||
* Thumbnail.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.image_type_thumbnail)
|
||||
THUMB,
|
||||
THUMB(R.string.image_type_thumbnail),
|
||||
|
||||
/**
|
||||
* Banner.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.image_type_banner)
|
||||
BANNER
|
||||
BANNER(R.string.image_type_banner),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,32 @@
|
|||
package org.jellyfin.androidtv.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class PosterSize {
|
||||
enum class PosterSize(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Smallest.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.image_size_smallest)
|
||||
SMALLEST,
|
||||
SMALLEST(R.string.image_size_smallest),
|
||||
/**
|
||||
* Small.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.image_size_small)
|
||||
SMALL,
|
||||
SMALL(R.string.image_size_small),
|
||||
|
||||
/**
|
||||
* Medium.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.image_size_medium)
|
||||
MED,
|
||||
MED(R.string.image_size_medium),
|
||||
|
||||
/**
|
||||
* Large.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.image_size_large)
|
||||
LARGE,
|
||||
LARGE(R.string.image_size_large),
|
||||
|
||||
/**
|
||||
* Extra Large.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.image_size_xlarge)
|
||||
X_LARGE
|
||||
X_LARGE(R.string.image_size_xlarge),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class AppTheme {
|
||||
enum class AppTheme(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* The default dark theme
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_theme_dark)
|
||||
DARK,
|
||||
DARK(R.string.pref_theme_dark),
|
||||
|
||||
/**
|
||||
* The "classic" emerald theme
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_theme_emerald)
|
||||
EMERALD,
|
||||
EMERALD(R.string.pref_theme_emerald),
|
||||
|
||||
/**
|
||||
* A theme with a more muted accent color, inspired by CTalvio's Monochromic CSS theme for Jellyfin Web
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_theme_muted_purple)
|
||||
MUTED_PURPLE,
|
||||
MUTED_PURPLE(R.string.pref_theme_muted_purple),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.androidtv.util.DeviceUtils
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class AudioBehavior {
|
||||
enum class AudioBehavior(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Directly stream audio without any changes
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_audio_direct)
|
||||
DIRECT_STREAM,
|
||||
DIRECT_STREAM(R.string.pref_audio_direct),
|
||||
|
||||
/**
|
||||
* Downnmix audio to stereo. Disables the AC3, EAC3 and AAC_LATM audio codecs.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_audio_compat)
|
||||
DOWNMIX_TO_STEREO
|
||||
DOWNMIX_TO_STEREO(R.string.pref_audio_compat),
|
||||
}
|
||||
|
||||
val defaultAudioBehavior = if (DeviceUtils.isChromecastWithGoogleTV) AudioBehavior.DOWNMIX_TO_STEREO
|
||||
else AudioBehavior.DIRECT_STREAM
|
||||
else AudioBehavior.DIRECT_STREAM
|
||||
|
|
|
|||
|
|
@ -1,30 +1,28 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class ClockBehavior {
|
||||
enum class ClockBehavior(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Always show clock.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_always)
|
||||
ALWAYS,
|
||||
ALWAYS(R.string.lbl_always),
|
||||
|
||||
/**
|
||||
* Show clock in menus only.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_clock_display_browsing)
|
||||
IN_MENUS,
|
||||
IN_MENUS(R.string.pref_clock_display_browsing),
|
||||
|
||||
/**
|
||||
* Show clock in video only.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_clock_display_playback)
|
||||
IN_VIDEO,
|
||||
IN_VIDEO(R.string.pref_clock_display_playback),
|
||||
|
||||
/**
|
||||
* Show clock never.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_never)
|
||||
NEVER
|
||||
NEVER(R.string.lbl_never),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
import org.jellyfin.sdk.model.constant.ItemSortBy
|
||||
|
||||
enum class LiveTvChannelOrder(
|
||||
val stringValue: String
|
||||
) {
|
||||
@EnumDisplayOptions(R.string.lbl_guide_option_played)
|
||||
LAST_PLAYED(ItemSortBy.DatePlayed),
|
||||
|
||||
@EnumDisplayOptions(R.string.lbl_guide_option_number)
|
||||
CHANNEL_NUMBER(ItemSortBy.SortName);
|
||||
override val nameRes: Int,
|
||||
val stringValue: String,
|
||||
) : PreferenceEnum {
|
||||
LAST_PLAYED(R.string.lbl_guide_option_played, ItemSortBy.DatePlayed),
|
||||
CHANNEL_NUMBER(R.string.lbl_guide_option_number, ItemSortBy.SortName);
|
||||
|
||||
companion object {
|
||||
fun fromString(value: String) = values()
|
||||
|
|
|
|||
|
|
@ -1,26 +1,25 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class NextUpBehavior {
|
||||
enum class NextUpBehavior(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Enable the Next Up screen - show the item's thumbnail
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_next_up_extended)
|
||||
EXTENDED,
|
||||
EXTENDED(R.string.lbl_next_up_extended),
|
||||
|
||||
/**
|
||||
* Enable the Next Up screen - hide the item's thumbnail
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_next_up_minimal)
|
||||
MINIMAL,
|
||||
MINIMAL(R.string.lbl_next_up_minimal),
|
||||
|
||||
/**
|
||||
* Disable the Next Up screen
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_never)
|
||||
DISABLED
|
||||
DISABLED(R.string.lbl_never),
|
||||
}
|
||||
|
||||
const val NEXTUP_TIMER_DISABLED: Int = 0
|
||||
|
|
|
|||
|
|
@ -1,36 +1,33 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class PreferredVideoPlayer {
|
||||
enum class PreferredVideoPlayer(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Automatically selects between exoplayer and vlc
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_video_player_auto)
|
||||
AUTO,
|
||||
AUTO(R.string.pref_video_player_auto),
|
||||
|
||||
/**
|
||||
* Force ExoPlayer
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_video_player_exoplayer)
|
||||
EXOPLAYER,
|
||||
EXOPLAYER(R.string.pref_video_player_exoplayer),
|
||||
|
||||
/**
|
||||
* Force libVLC
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_video_player_vlc)
|
||||
VLC,
|
||||
VLC(R.string.pref_video_player_vlc),
|
||||
|
||||
/**
|
||||
* Use external player
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_video_player_external)
|
||||
EXTERNAL,
|
||||
EXTERNAL(R.string.pref_video_player_external),
|
||||
|
||||
/**
|
||||
* Choose a player - play with button
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_video_player_choose)
|
||||
CHOOSE
|
||||
CHOOSE(R.string.pref_video_player_choose),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class RatingType {
|
||||
enum class RatingType(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Sets default rating type to tomatoes.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_tomatoes)
|
||||
RATING_TOMATOES,
|
||||
RATING_TOMATOES(R.string.lbl_tomatoes),
|
||||
|
||||
/**
|
||||
* Sets the default rating type to stars.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_stars)
|
||||
RATING_STARS,
|
||||
RATING_STARS(R.string.lbl_stars),
|
||||
|
||||
/**
|
||||
* Sets the default rating type to hidden.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_hidden)
|
||||
RATING_HIDDEN
|
||||
RATING_HIDDEN(R.string.lbl_hidden),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,21 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class RefreshRateSwitchingBehavior {
|
||||
@EnumDisplayOptions(R.string.state_disabled)
|
||||
DISABLED,
|
||||
enum class RefreshRateSwitchingBehavior(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
DISABLED(R.string.state_disabled),
|
||||
|
||||
/**
|
||||
* When comparing modes, use difference in resolution to rank modes.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_refresh_rate_scale_on_tv)
|
||||
SCALE_ON_TV,
|
||||
SCALE_ON_TV(R.string.pref_refresh_rate_scale_on_tv),
|
||||
|
||||
/**
|
||||
* When comparing modes, rank native resolution modes highest.
|
||||
* Otherwise use difference in resolution to rank modes.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.pref_refresh_rate_scale_on_device)
|
||||
SCALE_ON_DEVICE,
|
||||
SCALE_ON_DEVICE(R.string.pref_refresh_rate_scale_on_device),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,28 @@
|
|||
package org.jellyfin.androidtv.preference.constant
|
||||
|
||||
import org.jellyfin.androidtv.R
|
||||
import org.jellyfin.androidtv.ui.preference.dsl.EnumDisplayOptions
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
|
||||
enum class WatchedIndicatorBehavior {
|
||||
enum class WatchedIndicatorBehavior(
|
||||
override val nameRes: Int,
|
||||
) : PreferenceEnum {
|
||||
/**
|
||||
* Always show watched indicators.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_always)
|
||||
ALWAYS,
|
||||
ALWAYS(R.string.lbl_always),
|
||||
|
||||
/**
|
||||
* Hide unwatched count indicator, show watched check mark only.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_hide_unwatched_count)
|
||||
HIDE_UNWATCHED,
|
||||
HIDE_UNWATCHED(R.string.lbl_hide_unwatched_count),
|
||||
|
||||
/**
|
||||
* Hide unwatched count indicator, show watched check mark on individual episodes only.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_episode_marks)
|
||||
EPISODES_ONLY,
|
||||
EPISODES_ONLY(R.string.lbl_episode_marks),
|
||||
|
||||
/**
|
||||
* Never show watched indicators.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.lbl_never)
|
||||
NEVER
|
||||
NEVER(R.string.lbl_never),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ abstract class DisplayPreferencesStore(
|
|||
override fun <V : Enum<V>> setEnum(preference: Preference<*>, value: Enum<V>) =
|
||||
setString(
|
||||
preference.key, when (value) {
|
||||
is PreferenceEnum -> value.serializedName
|
||||
is PreferenceEnum -> value.serializedName ?: value.toString()
|
||||
else -> value.toString()
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1500,21 +1500,20 @@ public class FullDetailsFragment extends Fragment implements RecordingIndicatorV
|
|||
PopupMenu.OnMenuItemClickListener moreMenuListener = new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.addFav:
|
||||
case R.id.remFav:
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.addFav || itemId == R.id.remFav) {
|
||||
toggleFavorite();
|
||||
return true;
|
||||
case R.id.playTrailers:
|
||||
} else if (itemId == R.id.playTrailers) {
|
||||
playTrailers();
|
||||
return true;
|
||||
case R.id.gotoSeries:
|
||||
} else if (itemId == R.id.gotoSeries) {
|
||||
gotoSeries();
|
||||
return true;
|
||||
case R.id.shuffleAll:
|
||||
} else if (itemId == R.id.shuffleAll) {
|
||||
play(mBaseItem, 0, true);
|
||||
return true;
|
||||
case R.id.addQueue:
|
||||
} else if (itemId == R.id.addQueue) {
|
||||
addItemToQueue();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
package org.jellyfin.androidtv.ui.preference.dsl
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
|
||||
/**
|
||||
* Annotation used in the [OptionsItemEnum] to add display options to enum entries.
|
||||
* @param name The id of the name resource. -1 for "none" (default).
|
||||
* @param hidden True to hide this option or false (default) to display.
|
||||
*/
|
||||
annotation class EnumDisplayOptions(
|
||||
@StringRes val name: Int = -1,
|
||||
val hidden: Boolean = false
|
||||
)
|
||||
|
|
@ -5,6 +5,7 @@ import androidx.annotation.StringRes
|
|||
import androidx.preference.PreferenceCategory
|
||||
import org.jellyfin.androidtv.ui.preference.custom.RichListPreference
|
||||
import org.jellyfin.preference.Preference
|
||||
import org.jellyfin.preference.PreferenceEnum
|
||||
import org.jellyfin.preference.store.PreferenceStore
|
||||
import java.util.UUID
|
||||
|
||||
|
|
@ -26,17 +27,10 @@ class OptionsItemEnum<T : Enum<T>>(
|
|||
|
||||
private fun getEntries(): Map<T, String> {
|
||||
return clazz.enumConstants?.mapNotNull { entry ->
|
||||
val options = clazz
|
||||
.getDeclaredField(entry.name)
|
||||
.getAnnotation(EnumDisplayOptions::class.java)
|
||||
|
||||
when {
|
||||
// Options set but entry is hidden
|
||||
options?.hidden == true -> null
|
||||
// Options not set or name not set
|
||||
options == null || options.name == -1 -> Pair(entry, entry.name)
|
||||
// Options set and name set
|
||||
else -> Pair(entry, context.getString(options.name))
|
||||
entry is PreferenceEnum && entry.hidden -> null
|
||||
entry is PreferenceEnum && entry.nameRes != -1 -> Pair(entry, context.getString(entry.nameRes))
|
||||
else -> Pair(entry, entry.name)
|
||||
}
|
||||
}?.toMap().orEmpty()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ sdk.version=default
|
|||
|
||||
# Android
|
||||
android.useAndroidX=true
|
||||
# FIXME: Remove this once EnumDisplayOptions is updated
|
||||
android.nonFinalResIds=false
|
||||
# FIXME: Remove this once all uses of R have correct imports
|
||||
android.nonTransitiveRClass=false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
package org.jellyfin.preference
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
|
||||
interface PreferenceEnum {
|
||||
val serializedName: String
|
||||
/**
|
||||
* True to hide this option or false (default) to display.
|
||||
*/
|
||||
val hidden: Boolean get() = false
|
||||
|
||||
/**
|
||||
* The id of the name resource or -1 for "none".
|
||||
*/
|
||||
@get:StringRes
|
||||
val nameRes: Int
|
||||
|
||||
/**
|
||||
* The name used to store the preference or null to use the name property.
|
||||
*/
|
||||
val serializedName: String? get() = null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ abstract class SharedPreferenceStore(
|
|||
|
||||
override fun <V : Enum<V>> setEnum(preference: Preference<*>, value: Enum<V>) =
|
||||
setString(preference.key, when (value) {
|
||||
is PreferenceEnum -> value.serializedName
|
||||
is PreferenceEnum -> value.serializedName ?: value.toString()
|
||||
else -> value.toString()
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue