Skip to content

Commit

Permalink
Follow the establish preference format
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart committed Oct 11, 2024
1 parent d180026 commit f8c4ebd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
/**
* Configure segment handling behavior (Auto skip, Show skip button, Hide skip button).
*/
var skipMode = enumPreference<SegmentMode>("skip_mode", SegmentMode.SHOW_SKIP_BUTTON)
var skipMode = enumPreference("skip_mode", SegmentMode.SHOW_SKIP_BUTTON)

/**
* Whether to use an external playback application or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ private void initActions(Context context) {
zoomAction.setLabels(new String[]{context.getString(R.string.lbl_zoom)});
selectSkipAction = new SelectSkipAction(context, this, KoinJavaComponent.get(UserPreferences.class));
selectSkipAction.setLabels(new String[]{
context.getString(SegmentMode.AUTO_SKIP.label()),
context.getString(SegmentMode.SHOW_SKIP_BUTTON.label()),
context.getString(SegmentMode.HIDE_SKIP_BUTTON.label())
context.getString(SegmentMode.AUTO_SKIP.getNameRes()),
context.getString(SegmentMode.SHOW_SKIP_BUTTON.getNameRes()),
context.getString(SegmentMode.HIDE_SKIP_BUTTON.getNameRes())
});
chapterAction = new ChapterAction(context, this);
chapterAction.setLabels(new String[]{context.getString(R.string.lbl_chapters)});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SelectSkipAction(
videoPlayerAdapter.leanbackOverlayFragment.setFading(false)
PopupMenu(context, view, Gravity.END).apply {
SegmentMode.entries.forEach {
menu.add(0, it.ordinal, it.ordinal, context.getString(it.label())).apply {
menu.add(0, it.ordinal, it.ordinal, context.getString(it.nameRes)).apply {
isChecked = preferences[UserPreferences.skipMode] == it
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package org.jellyfin.androidtv.ui.playback.segments

import org.jellyfin.androidtv.R
import org.jellyfin.preference.PreferenceEnum

enum class SegmentMode {
SHOW_SKIP_BUTTON {
enum class SegmentMode(
override val nameRes: Int,
) : PreferenceEnum {

SHOW_SKIP_BUTTON(R.string.lbl_show_skip_button) {
override fun icon(): Int = R.drawable.ic_select_skip_show_button
override fun label(): Int = R.string.lbl_show_skip_button
},
AUTO_SKIP {
AUTO_SKIP(R.string.lbl_auto_skip) {
override fun icon(): Int = R.drawable.ic_select_skip_auto_skip
override fun label(): Int = R.string.lbl_auto_skip
},
HIDE_SKIP_BUTTON {
HIDE_SKIP_BUTTON(R.string.lbl_hide_skip_button) {
override fun icon(): Int = R.drawable.ic_select_skip_hide_button
override fun label(): Int = R.string.lbl_hide_skip_button
};

abstract fun icon(): Int
abstract fun label(): Int
}

0 comments on commit f8c4ebd

Please sign in to comment.