player: Enter PIP on search/open channel

This commit is contained in:
Yuriy Liskov
2022-08-22 02:31:34 +03:00
parent 8c6189030f
commit 36f2e82a76
9 changed files with 48 additions and 25 deletions

View File

@@ -125,9 +125,7 @@ public class PlayerUIManager extends PlayerEventListenerHelper implements Metada
@Override
public void onChannelClicked() {
if (SearchData.instance(getActivity()).isBackgroundPlaybackEnabled()) {
onPipClicked();
}
startTempBackgroundMode();
ChannelPresenter.instance(getActivity()).openChannel(getController().getVideo());
}
@@ -204,6 +202,9 @@ public class PlayerUIManager extends PlayerEventListenerHelper implements Metada
return;
}
// Reset temp mode.
SearchData.instance(getActivity()).startTempBackgroundMode(false);
// Activate debug infos when restoring after PIP.
getController().showDebugInfo(mDebugViewEnabled);
getController().setDebugButtonState(mDebugViewEnabled);
@@ -421,9 +422,7 @@ public class PlayerUIManager extends PlayerEventListenerHelper implements Metada
@Override
public void onSearchClicked() {
if (SearchData.instance(getActivity()).isBackgroundPlaybackEnabled()) {
onPipClicked();
}
startTempBackgroundMode();
SearchPresenter.instance(getActivity()).startSearch(null);
}
@@ -647,4 +646,12 @@ public class PlayerUIManager extends PlayerEventListenerHelper implements Metada
getController().setSpeedButtonState(speed != 1.0f);
}
}
private void startTempBackgroundMode() {
SearchData searchData = SearchData.instance(getActivity());
if (searchData.isTempBackgroundModeEnabled()) {
searchData.startTempBackgroundMode(true);
onPipClicked();
}
}
}

View File

@@ -75,10 +75,6 @@ public class SearchPresenter extends BasePresenter<SearchView> implements VideoG
mSearchText = null;
mSearchOptions = 0;
if (mSearchData.isBackgroundPlaybackEnabled() && PlaybackPresenter.instance(getContext()).isRunningInBackground()) {
ViewManager.instance(getContext()).startView(SplashView.class);
}
}
@Override

View File

@@ -7,12 +7,16 @@ import com.liskovsoft.smartyoutubetv2.common.app.models.data.Playlist;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.Video;
import com.liskovsoft.smartyoutubetv2.common.app.models.data.VideoGroup;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.BrowsePresenter;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.PlaybackPresenter;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.dialogs.BootDialogPresenter;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.interfaces.Presenter;
import com.liskovsoft.smartyoutubetv2.common.app.views.BrowseView;
import com.liskovsoft.smartyoutubetv2.common.app.views.ChannelUploadsView;
import com.liskovsoft.smartyoutubetv2.common.app.views.ChannelView;
import com.liskovsoft.smartyoutubetv2.common.app.views.SearchView;
import com.liskovsoft.smartyoutubetv2.common.app.views.SplashView;
import com.liskovsoft.smartyoutubetv2.common.app.views.ViewManager;
import com.liskovsoft.smartyoutubetv2.common.prefs.SearchData;
import com.liskovsoft.smartyoutubetv2.common.utils.Utils;
import java.lang.ref.WeakReference;
@@ -109,7 +113,11 @@ public abstract class BasePresenter<T> implements Presenter<T> {
@Override
public void onFinish() {
// NOP
if (SearchData.instance(getContext()).isTempBackgroundModeStarted() &&
PlaybackPresenter.instance(getContext()).isRunningInBackground()) {
SearchData.instance(getContext()).startTempBackgroundMode(false);
ViewManager.instance(getContext()).startView(SplashView.class);
}
}
public void setOnDone(Runnable onDone) {

View File

@@ -12,6 +12,7 @@ import com.liskovsoft.smartyoutubetv2.common.app.presenters.AppDialogPresenter;
import com.liskovsoft.smartyoutubetv2.common.app.presenters.base.BasePresenter;
import com.liskovsoft.smartyoutubetv2.common.prefs.PlayerData;
import com.liskovsoft.smartyoutubetv2.common.prefs.PlayerTweaksData;
import com.liskovsoft.smartyoutubetv2.common.prefs.SearchData;
import com.liskovsoft.smartyoutubetv2.common.utils.AppDialogUtil;
import java.util.ArrayList;
@@ -20,11 +21,13 @@ import java.util.List;
public class PlayerSettingsPresenter extends BasePresenter<Void> {
private final PlayerData mPlayerData;
private final PlayerTweaksData mPlayerTweaksData;
private final SearchData mSearchData;
private PlayerSettingsPresenter(Context context) {
super(context);
mPlayerData = PlayerData.instance(context);
mPlayerTweaksData = PlayerTweaksData.instance(context);
mSearchData = SearchData.instance(context);
}
public static PlayerSettingsPresenter instance(Context context) {
@@ -409,6 +412,10 @@ public class PlayerSettingsPresenter extends BasePresenter<Void> {
// option -> mPlayerData.enableSeekMemory(option.isSelected()),
// mPlayerData.isSeekMemoryEnabled()));
options.add(UiOptionItem.from(getContext().getString(R.string.search_background_playback),
option -> mSearchData.enableTempBackgroundMode(option.isSelected()),
mSearchData.isTempBackgroundModeEnabled()));
options.add(UiOptionItem.from(getContext().getString(R.string.real_channel_icon),
option -> mPlayerTweaksData.enableRealChannelIcon(option.isSelected()),
mPlayerTweaksData.isRealChannelIconEnabled()));

View File

@@ -63,10 +63,6 @@ public class SearchSettingsPresenter extends BasePresenter<Void> {
option -> mSearchData.enableKeyboardAutoShow(option.isSelected()),
mSearchData.isKeyboardAutoShowEnabled()));
options.add(UiOptionItem.from(getContext().getString(R.string.search_background_playback),
option -> mSearchData.enableBackgroundPlayback(option.isSelected()),
mSearchData.isBackgroundPlaybackEnabled()));
settingsPresenter.appendCheckedCategory(getContext().getString(R.string.player_other), options);
}
}

View File

@@ -16,7 +16,8 @@ public class SearchData {
private int mSearchOptions;
private boolean mIsFocusOnResultsEnabled;
private boolean mIsKeyboardAutoShowEnabled;
private boolean mIsBackgroundPlaybackEnabled;
private boolean mIsTempBackgroundModeEnabled;
private boolean mIsTempBackgroundModeStarted;
private int mSpeechRecognizerType;
private SearchData(Context context) {
@@ -68,13 +69,21 @@ public class SearchData {
return mIsKeyboardAutoShowEnabled;
}
public void enableBackgroundPlayback(boolean enabled) {
mIsBackgroundPlaybackEnabled = enabled;
public void enableTempBackgroundMode(boolean enabled) {
mIsTempBackgroundModeEnabled = enabled;
persistData();
}
public boolean isBackgroundPlaybackEnabled() {
return mIsBackgroundPlaybackEnabled;
public boolean isTempBackgroundModeEnabled() {
return mIsTempBackgroundModeEnabled;
}
public void startTempBackgroundMode(boolean start) {
mIsTempBackgroundModeStarted = start;
}
public boolean isTempBackgroundModeStarted() {
return mIsTempBackgroundModeStarted;
}
public void setSpeechRecognizerType(int type) {
@@ -98,7 +107,7 @@ public class SearchData {
mSearchOptions = Helpers.parseInt(split, 1, 0);
mIsFocusOnResultsEnabled = Helpers.parseBoolean(split, 2, true);
mIsKeyboardAutoShowEnabled = Helpers.parseBoolean(split, 3, false);
mIsBackgroundPlaybackEnabled = Helpers.parseBoolean(split, 4, false);
mIsTempBackgroundModeEnabled = Helpers.parseBoolean(split, 4, false);
//mIsAltSpeechRecognizerEnabled
mSpeechRecognizerType = Helpers.parseInt(split, 6, SPEECH_RECOGNIZER_SYSTEM);
}
@@ -106,6 +115,6 @@ public class SearchData {
private void persistData() {
mAppPrefs.setData(SEARCH_DATA,
Helpers.mergeObject(mIsInstantVoiceSearchEnabled, mSearchOptions, mIsFocusOnResultsEnabled,
mIsKeyboardAutoShowEnabled, mIsBackgroundPlaybackEnabled, null, mSpeechRecognizerType));
mIsKeyboardAutoShowEnabled, mIsTempBackgroundModeEnabled, null, mSpeechRecognizerType));
}
}

View File

@@ -312,7 +312,7 @@
<string name="cancel_dialog">Отменить</string>
<string name="msg_player_error_source2">Источник видео не работает или неправильное время</string>
<string name="hide_upcoming">Скрывать анонсы из Подписок</string>
<string name="search_background_playback">Переходить в режим Картинка в картинке, если поиск запущен из плеера</string>
<string name="search_background_playback">Переходить в режим Картинка в картинке при поиске/открытии канала</string>
<string name="trending_row_name">В тренде</string>
<string name="player_seek_type">Поведение перемотки</string>
<string name="player_seek_regular">Обычное</string>

View File

@@ -312,7 +312,7 @@
<string name="cancel_dialog">Скасувати</string>
<string name="msg_player_error_source2">Джерело відео не працює або невірний час</string>
<string name="hide_upcoming">Приховувати анонси з Підписок</string>
<string name="search_background_playback">Переходити у режим Картинка в картинці, якщо пошук запущено з плеєру</string>
<string name="search_background_playback">Переходити у режим Картинка в картинці при пошуку/відкритті каналу</string>
<string name="trending_row_name">Популярне</string>
<string name="player_seek_type">Поведінка перемотування</string>
<string name="player_seek_regular">Звичайна</string>

View File

@@ -316,7 +316,7 @@
<string name="cancel_dialog">Cancel</string>
<string name="msg_player_error_source2">Video source isn\'t working or incorrect time</string>
<string name="hide_upcoming">Hide upcoming from Subscriptions</string>
<string name="search_background_playback">Enter PIP when searching from player</string>
<string name="search_background_playback">Enter PIP on search/open channel</string>
<string name="trending_row_name">Trending</string>
<string name="player_seek_type">Seek behavior</string>
<string name="player_seek_regular">Regular</string>