mirror of
https://github.com/yuliskov/SmartTube.git
synced 2025-05-17 11:25:54 +08:00
video card: playback preview: upd 4
This commit is contained in:
@ -386,7 +386,7 @@ public class VideoStateController extends BasePlayerController {
|
||||
|
||||
public void saveState() {
|
||||
// Skip mini player, but don't save for the previews (mute enabled)
|
||||
if (isEmbedMuted()) {
|
||||
if (isMutedEmbed() || isBeginEmbed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -407,7 +407,7 @@ public class VideoStateController extends BasePlayerController {
|
||||
|
||||
private void persistState() {
|
||||
// Skip mini player, but don't save for the previews (mute enabled)
|
||||
if (isEmbedMuted()) {
|
||||
if (isMutedEmbed() || isBeginEmbed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -655,7 +655,15 @@ public class VideoStateController extends BasePlayerController {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmbedMuted() {
|
||||
return getVideo() != null && getPlayer() != null && getVideo().embedPlayer && Helpers.floatEquals(getPlayer().getVolume(), 0);
|
||||
private boolean isMutedEmbed() {
|
||||
return isEmbed() && getPlayer() != null && Helpers.floatEquals(getPlayer().getVolume(), 0);
|
||||
}
|
||||
|
||||
private boolean isBeginEmbed() {
|
||||
return isEmbed() && getPlayer() != null && getPlayer().getPositionMs() <= BEGIN_THRESHOLD_MS;
|
||||
}
|
||||
|
||||
private boolean isEmbed() {
|
||||
return getVideo() != null && getVideo().embedPlayer;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ public class MainUISettingsPresenter extends BasePresenter<Void> {
|
||||
|
||||
appendTopButtonsCategory(settingsPresenter);
|
||||
appendColorScheme(settingsPresenter);
|
||||
appendCardPreviews(settingsPresenter);
|
||||
appendCardStyle(settingsPresenter);
|
||||
appendThumbSource(settingsPresenter);
|
||||
//appendCardTitleLines(settingsPresenter);
|
||||
@ -105,11 +106,23 @@ public class MainUISettingsPresenter extends BasePresenter<Void> {
|
||||
return styleOptions;
|
||||
}
|
||||
|
||||
private void appendCardStyle(AppDialogPresenter settingsPresenter) {
|
||||
private void appendCardPreviews(AppDialogPresenter settingsPresenter) {
|
||||
List<OptionItem> options = new ArrayList<>();
|
||||
|
||||
OptionItem animatedPreviewsOption = UiOptionItem.from(getContext().getString(R.string.card_animated_previews),
|
||||
option -> mMainUIData.enableCardAnimatedPreviews(option.isSelected()), mMainUIData.isCardAnimatedPreviewsEnabled());
|
||||
for (int[] pair : new int[][] {
|
||||
{R.string.option_disabled, MainUIData.ANIMATED_PREVIEW_DISABLED},
|
||||
{R.string.card_preview_muted, MainUIData.ANIMATED_PREVIEW_MUTED},
|
||||
{R.string.card_preview_full, MainUIData.ANIMATED_PREVIEW_FULL}}) {
|
||||
options.add(UiOptionItem.from(getContext().getString(pair[0]), optionItem -> {
|
||||
mMainUIData.setAnimatedPreviewType(pair[1]);
|
||||
}, mMainUIData.getAnimatedPreviewType() == pair[1]));
|
||||
}
|
||||
|
||||
settingsPresenter.appendRadioCategory(getContext().getString(R.string.card_preview), options);
|
||||
}
|
||||
|
||||
private void appendCardStyle(AppDialogPresenter settingsPresenter) {
|
||||
List<OptionItem> options = new ArrayList<>();
|
||||
|
||||
OptionItem multilineTitle = UiOptionItem.from(getContext().getString(R.string.card_multiline_title),
|
||||
option -> mMainUIData.enableCardMultilineTitle(option.isSelected()), mMainUIData.isCardMultilineTitleEnabled());
|
||||
@ -120,7 +133,6 @@ public class MainUISettingsPresenter extends BasePresenter<Void> {
|
||||
OptionItem autoScrolledTitle = UiOptionItem.from(getContext().getString(R.string.card_auto_scrolled_title),
|
||||
option -> mMainUIData.enableCardTextAutoScroll(option.isSelected()), mMainUIData.isCardTextAutoScrollEnabled());
|
||||
|
||||
options.add(animatedPreviewsOption);
|
||||
options.add(multilineTitle);
|
||||
options.add(multilineSubtitle);
|
||||
if (Build.VERSION.SDK_INT > 19) {
|
||||
|
@ -17,6 +17,9 @@ import java.util.List;
|
||||
|
||||
public class MainUIData extends DataChangeBase implements ProfileChangeListener {
|
||||
private static final String MAIN_UI_DATA = "main_ui_data2";
|
||||
public static final int ANIMATED_PREVIEW_DISABLED = 0;
|
||||
public static final int ANIMATED_PREVIEW_MUTED = 1;
|
||||
public static final int ANIMATED_PREVIEW_FULL = 2;
|
||||
public static final int CHANNEL_SORTING_NEW_CONTENT = 0;
|
||||
public static final int CHANNEL_SORTING_NAME = 1;
|
||||
public static final int CHANNEL_SORTING_DEFAULT = 2;
|
||||
@ -102,6 +105,7 @@ public class MainUIData extends DataChangeBase implements ProfileChangeListener
|
||||
private boolean mIsChannelsFilterEnabled;
|
||||
private boolean mIsChannelSearchBarEnabled;
|
||||
private boolean mIsPinnedChannelRowsEnabled;
|
||||
private int mAnimatedPreviewType;
|
||||
|
||||
private MainUIData(Context context) {
|
||||
mContext = context;
|
||||
@ -333,6 +337,15 @@ public class MainUIData extends DataChangeBase implements ProfileChangeListener
|
||||
return (mTopButtons & button) == button;
|
||||
}
|
||||
|
||||
public int getAnimatedPreviewType() {
|
||||
return mAnimatedPreviewType;
|
||||
}
|
||||
|
||||
public void setAnimatedPreviewType(int type) {
|
||||
mAnimatedPreviewType = type;
|
||||
persistState();
|
||||
}
|
||||
|
||||
private void initColorSchemes() {
|
||||
mColorSchemes.add(new ColorScheme(
|
||||
R.string.color_scheme_teal,
|
||||
@ -404,6 +417,7 @@ public class MainUIData extends DataChangeBase implements ProfileChangeListener
|
||||
mIsChannelsFilterEnabled = Helpers.parseBoolean(split, 18, true);
|
||||
mIsChannelSearchBarEnabled = Helpers.parseBoolean(split, 19, true);
|
||||
mIsPinnedChannelRowsEnabled = Helpers.parseBoolean(split, 20, true);
|
||||
mAnimatedPreviewType = Helpers.parseInt(split, 21, ANIMATED_PREVIEW_FULL);
|
||||
|
||||
for (Long menuItem : MENU_ITEM_DEFAULT_ORDER) {
|
||||
if (!mMenuItemsOrdered.contains(menuItem)) {
|
||||
@ -426,7 +440,7 @@ public class MainUIData extends DataChangeBase implements ProfileChangeListener
|
||||
mChannelCategorySorting, mPlaylistsStyle, mCardTitleLinesNum, mIsCardTextAutoScrollEnabled,
|
||||
mIsUploadsOldLookEnabled, mIsUploadsAutoLoadEnabled, mCardTextScrollSpeed, mMenuItems, mTopButtons,
|
||||
null, mThumbQuality, mIsCardMultilineSubtitleEnabled, Helpers.mergeList(mMenuItemsOrdered),
|
||||
mIsChannelsFilterEnabled, mIsChannelSearchBarEnabled, mIsPinnedChannelRowsEnabled));
|
||||
mIsChannelsFilterEnabled, mIsChannelSearchBarEnabled, mIsPinnedChannelRowsEnabled, mAnimatedPreviewType));
|
||||
|
||||
onDataChange();
|
||||
}
|
||||
|
@ -688,4 +688,7 @@
|
||||
<string name="player_audio_focus">Аудиофокус (пауза, если обнаружены другие плееры)</string>
|
||||
<string name="paid_content_notification">Уведомление о платном содержимом</string>
|
||||
<string name="you_liked">вам понравилось</string>
|
||||
<string name="card_preview_muted">Видео без звука</string>
|
||||
<string name="card_preview_full">Видео со звуком</string>
|
||||
<string name="card_preview">Предпросмотр карточки</string>
|
||||
</resources>
|
@ -699,4 +699,7 @@
|
||||
<string name="player_audio_focus">Ses odaklama (diğer video oynatıcılar algılanırsa duraklatma)</string>
|
||||
<string name="paid_content_notification">Ücretli içerik bildirimleri</string>
|
||||
<string name="you_liked">sen beğendin</string>
|
||||
<string name="card_preview_muted">Sessiz video</string>
|
||||
<string name="card_preview_full">Sesli video</string>
|
||||
<string name="card_preview">Kart önizlemesi</string>
|
||||
</resources>
|
||||
|
@ -688,4 +688,7 @@
|
||||
<string name="player_audio_focus">Аудіо фокус (пауза, якщо виявлено інші плеєри)</string>
|
||||
<string name="paid_content_notification">Повідомлення про платний вміст</string>
|
||||
<string name="you_liked">вам сподобалося</string>
|
||||
<string name="card_preview_muted">Відео без звуку</string>
|
||||
<string name="card_preview_full">Відео зі звуком</string>
|
||||
<string name="card_preview">Попередній перегляд картки</string>
|
||||
</resources>
|
||||
|
@ -700,4 +700,7 @@
|
||||
<string name="premium_users_only">Premium users only. Fix for incomplete video format list</string>
|
||||
<string name="playback_buffering_fix">Playback buffering fix</string>
|
||||
<string name="oculus_quest_fix">Oculus Quest fix</string>
|
||||
<string name="card_preview_muted">Video without sound</string>
|
||||
<string name="card_preview_full">Video with sound</string>
|
||||
<string name="card_preview">Card preview</string>
|
||||
</resources>
|
||||
|
@ -32,6 +32,7 @@ public class ComplexImageView extends RelativeLayout {
|
||||
private int mPreviewHeight;
|
||||
private Runnable mCreateAndStartPlayer;
|
||||
private WeakReference<Video> mVideo;
|
||||
private boolean mPreferSimplePreview;
|
||||
|
||||
public ComplexImageView(Context context) {
|
||||
super(context);
|
||||
@ -127,7 +128,7 @@ public class ComplexImageView extends RelativeLayout {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getVideo().previewUrl != null) {
|
||||
if (getVideo().previewUrl != null && mPreferSimplePreview) {
|
||||
if (mPreviewImage == null) {
|
||||
mPreviewImage = new ImageView(getContext());
|
||||
mPreviewImage.setScaleType(ScaleType.CENTER_CROP);
|
||||
@ -171,12 +172,14 @@ public class ComplexImageView extends RelativeLayout {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getVideo().previewUrl != null) {
|
||||
mPreviewContainer.removeView(mPreviewImage);
|
||||
mPreviewContainer.setVisibility(View.GONE);
|
||||
mPreviewImage.setImageDrawable(null);
|
||||
Glide.with(getContext().getApplicationContext()).clear(mPreviewImage);
|
||||
mPreviewImage = null;
|
||||
if (getVideo().previewUrl != null && mPreferSimplePreview) {
|
||||
if (mPreviewImage != null) {
|
||||
mPreviewContainer.removeView(mPreviewImage);
|
||||
mPreviewContainer.setVisibility(View.GONE);
|
||||
mPreviewImage.setImageDrawable(null);
|
||||
Glide.with(getContext().getApplicationContext()).clear(mPreviewImage);
|
||||
mPreviewImage = null;
|
||||
}
|
||||
} else if (getVideo().videoId != null) {
|
||||
Utils.removeCallbacks(mCreateAndStartPlayer);
|
||||
|
||||
|
Reference in New Issue
Block a user