From 27de55880c0a5cacae8b015b6bafc8e8dcabb156 Mon Sep 17 00:00:00 2001 From: Yuriy Liskov Date: Sun, 15 Nov 2020 03:15:34 +0200 Subject: [PATCH] option: player full date --- MediaServiceCore | 2 +- .../common/app/models/data/Video.java | 4 ++-- .../models/playback/managers/SuggestionsLoader.java | 3 ++- .../settings/PlayerSettingsPresenter.java | 11 +++++++++++ .../smartyoutubetv2/common/prefs/PlayerData.java | 13 ++++++++++++- common/src/main/res/values-ru/strings.xml | 2 ++ common/src/main/res/values-uk/strings.xml | 2 ++ common/src/main/res/values/strings.xml | 2 ++ 8 files changed, 34 insertions(+), 5 deletions(-) diff --git a/MediaServiceCore b/MediaServiceCore index 7a03f1c1c..11083b387 160000 --- a/MediaServiceCore +++ b/MediaServiceCore @@ -1 +1 @@ -Subproject commit 7a03f1c1ca47e1f1838e806ed5e7a4c57f13b436 +Subproject commit 11083b3879fb69bd679f114a2050e55e0213addf diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/data/Video.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/data/Video.java index 213adcd3a..04c2e08f9 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/data/Video.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/data/Video.java @@ -167,13 +167,13 @@ public final class Video implements Parcelable { return playlistIndex > 0; } - public void sync(MediaItemMetadata metadata) { + public void sync(MediaItemMetadata metadata, boolean useAlt) { if (metadata == null) { return; } title = metadata.getTitle(); - description = metadata.getDescription(); + description = useAlt ? metadata.getDescriptionAlt() : metadata.getDescription(); channelId = metadata.getChannelId(); nextMediaItem = metadata.getNextVideo(); } diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/playback/managers/SuggestionsLoader.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/playback/managers/SuggestionsLoader.java index 77b02fa4f..23c92cd37 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/playback/managers/SuggestionsLoader.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/models/playback/managers/SuggestionsLoader.java @@ -8,6 +8,7 @@ import com.liskovsoft.sharedutils.mylogger.Log; import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video; import com.liskovsoft.smartyoutubetv2.common.app.models.data.VideoGroup; import com.liskovsoft.smartyoutubetv2.common.app.models.playback.PlayerEventListenerHelper; +import com.liskovsoft.smartyoutubetv2.common.prefs.PlayerData; import com.liskovsoft.smartyoutubetv2.common.utils.RxUtils; import com.liskovsoft.youtubeapi.service.YouTubeMediaService; import io.reactivex.Observable; @@ -84,7 +85,7 @@ public class SuggestionsLoader extends PlayerEventListenerHelper { private void syncCurrentVideo(MediaItemMetadata mediaItemMetadata) { Video video = mController.getVideo(); - video.sync(mediaItemMetadata); + video.sync(mediaItemMetadata, PlayerData.instance(mActivity).isShowFullDateEnabled()); mController.setVideo(video); } diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/PlayerSettingsPresenter.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/PlayerSettingsPresenter.java index 25bc7ae5f..6d53680ed 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/PlayerSettingsPresenter.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/PlayerSettingsPresenter.java @@ -29,6 +29,7 @@ public class PlayerSettingsPresenter { appendOKButtonCategory(settingsPresenter); appendUIAutoHideCategory(settingsPresenter); + appendOtherCategory(settingsPresenter); settingsPresenter.showDialog(mContext.getString(R.string.dialog_player_ui)); } @@ -72,4 +73,14 @@ public class PlayerSettingsPresenter { settingsPresenter.appendRadioCategory(mContext.getString(R.string.player_ui_hide_behavior), options); } + + private void appendOtherCategory(AppSettingsPresenter settingsPresenter) { + List options = new ArrayList<>(); + + options.add(UiOptionItem.from(mContext.getString(R.string.player_full_date), + option -> mPlayerUIData.showFullDate(option.isSelected()), + mPlayerUIData.isShowFullDateEnabled())); + + settingsPresenter.appendCheckedCategory(mContext.getString(R.string.player_other), options); + } } diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/PlayerData.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/PlayerData.java index 4a3eea98b..2ac669bc9 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/PlayerData.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/PlayerData.java @@ -15,6 +15,7 @@ public class PlayerData { private final AppPrefs mPrefs; private int mOKButtonBehavior; private int mUIHideTimeoutSec; + private boolean mIsShowFullDateEnabled; public PlayerData(Context context) { mContext = context; @@ -48,6 +49,15 @@ public class PlayerData { return mUIHideTimeoutSec; } + public void showFullDate(boolean show) { + mIsShowFullDateEnabled = show; + persistData(); + } + + public boolean isShowFullDateEnabled() { + return mIsShowFullDateEnabled; + } + private void restoreData() { String data = mPrefs.getPlayerData(); @@ -55,9 +65,10 @@ public class PlayerData { mOKButtonBehavior = Helpers.parseInt(split, 0, ONLY_UI); mUIHideTimeoutSec = Helpers.parseInt(split, 1, 3); + mIsShowFullDateEnabled = Helpers.parseBoolean(split, 2, false); } private void persistData() { - mPrefs.setPlayerData(Helpers.mergeObject(mOKButtonBehavior, mUIHideTimeoutSec)); + mPrefs.setPlayerData(Helpers.mergeObject(mOKButtonBehavior, mUIHideTimeoutSec, mIsShowFullDateEnabled)); } } diff --git a/common/src/main/res/values-ru/strings.xml b/common/src/main/res/values-ru/strings.xml index 76e6f01e8..b1be84f36 100644 --- a/common/src/main/res/values-ru/strings.xml +++ b/common/src/main/res/values-ru/strings.xml @@ -94,4 +94,6 @@ Больше не показывать Проверять автоматически Выбирать на старте + Other + Точная дата в описании \ No newline at end of file diff --git a/common/src/main/res/values-uk/strings.xml b/common/src/main/res/values-uk/strings.xml index 4b43fab5a..46a36df2a 100644 --- a/common/src/main/res/values-uk/strings.xml +++ b/common/src/main/res/values-uk/strings.xml @@ -94,4 +94,6 @@ Більше не показувати Перевіряти автоматично Обирати на старті + Other + Точна дата в описі \ No newline at end of file diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 6037accc9..5259f3812 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -94,4 +94,6 @@ Show again Check automatically Select on boot + Other + Precise date in description \ No newline at end of file