search: double back exit

This commit is contained in:
Yuriy Liskov
2025-04-14 03:43:55 +03:00
parent e35d8ccb06
commit 83b10e7bb6
8 changed files with 35 additions and 2 deletions

View File

@ -497,6 +497,14 @@ public class GeneralSettingsPresenter extends BasePresenter<Void> {
private void appendMiscCategory(AppDialogPresenter settingsPresenter) {
List<OptionItem> options = new ArrayList<>();
options.add(UiOptionItem.from( getContext().getString(R.string.player_exit_shortcut) + ": " + getContext().getString(R.string.app_double_back_exit),
option -> mGeneralData.setPlayerExitShortcut(option.isSelected() ? GeneralData.EXIT_DOUBLE_BACK : GeneralData.EXIT_SINGLE_BACK),
mGeneralData.getPlayerExitShortcut() == GeneralData.EXIT_DOUBLE_BACK));
options.add(UiOptionItem.from(getContext().getString(R.string.search_exit_shortcut) + ": " + getContext().getString(R.string.app_double_back_exit),
option -> mGeneralData.setSearchExitShortcut(option.isSelected() ? GeneralData.EXIT_DOUBLE_BACK : GeneralData.EXIT_SINGLE_BACK),
mGeneralData.getSearchExitShortcut() == GeneralData.EXIT_DOUBLE_BACK));
options.add(UiOptionItem.from(getContext().getString(R.string.return_to_launcher),
option -> mGeneralData.enableReturnToLauncher(option.isSelected()),
mGeneralData.isReturnToLauncherEnabled()));

View File

@ -535,7 +535,7 @@ public class PlayerSettingsPresenter extends BasePresenter<Void> {
option -> mSearchData.enableTempBackgroundMode(option.isSelected()),
mSearchData.isTempBackgroundModeEnabled()));
options.add(UiOptionItem.from(getContext().getString(R.string.app_double_back_exit) + " " + getContext().getString(R.string.player_exit_shortcut),
options.add(UiOptionItem.from(getContext().getString(R.string.player_exit_shortcut) + ": " + getContext().getString(R.string.app_double_back_exit),
option -> mGeneralData.setPlayerExitShortcut(option.isSelected() ? GeneralData.EXIT_DOUBLE_BACK : GeneralData.EXIT_SINGLE_BACK),
mGeneralData.getPlayerExitShortcut() == GeneralData.EXIT_DOUBLE_BACK));

View File

@ -30,6 +30,7 @@ public class GeneralData implements ProfileChangeListener {
private final AppPrefs mPrefs;
private int mAppExitShortcut;
private int mPlayerExitShortcut;
private int mSearchExitShortcut;
private boolean mIsReturnToLauncherEnabled;
private int mBackgroundShortcut;
private boolean mIsHideShortsFromSubscriptionsEnabled;
@ -119,6 +120,15 @@ public class GeneralData implements ProfileChangeListener {
persistState();
}
public int getSearchExitShortcut() {
return mSearchExitShortcut;
}
public void setSearchExitShortcut(int type) {
mSearchExitShortcut = type;
persistState();
}
public void enableReturnToLauncher(boolean enable) {
mIsReturnToLauncherEnabled = enable;
persistState();
@ -747,6 +757,7 @@ public class GeneralData implements ProfileChangeListener {
mIsDeviceSpecificBackupEnabled = Helpers.parseBoolean(split, 65, false);
mIsAutoBackupEnabled = Helpers.parseBoolean(split, 66, false);
mIsRemapPageDownToSpeedEnabled = Helpers.parseBoolean(split, 67, false);
mSearchExitShortcut = Helpers.parseInt(split, 68, EXIT_SINGLE_BACK);
}
private void persistState() {
@ -765,7 +776,7 @@ public class GeneralData implements ProfileChangeListener {
mIsRemapDpadUpToVolumeEnabled, mIsRemapDpadLeftToVolumeEnabled, mIsRemapNextToFastForwardEnabled, mIsHideWatchedFromNotificationsEnabled,
mChangelog, mPlayerExitShortcut, null, mIsFullscreenModeEnabled, null,
mRememberPinnedPosition, mSelectedItems, mIsFirstUseTooltipEnabled, mIsDeviceSpecificBackupEnabled, mIsAutoBackupEnabled,
mIsRemapPageDownToSpeedEnabled));
mIsRemapPageDownToSpeedEnabled, mSearchExitShortcut));
}
@Override

View File

@ -140,6 +140,7 @@
<string name="open_channel_uploads">Открыть загрузки</string>
<string name="app_exit_shortcut">Выход из приложения</string>
<string name="player_exit_shortcut">Выход из плеера</string>
<string name="search_exit_shortcut">Выход из поиска</string>
<string name="app_exit_none">Не выходить</string>
<string name="app_double_back_exit">Двойное назад</string>
<string name="app_single_back_exit">Одинарное назад</string>

View File

@ -140,6 +140,7 @@
<string name="open_channel_uploads">Kanal yüklemelerini aç</string>
<string name="app_exit_shortcut">Uygulamadan çıkış</string>
<string name="player_exit_shortcut">Oynatıcıdan çıkış</string>
<string name="search_exit_shortcut">Aramadan çıkış</string>
<string name="app_exit_none">Çıkış yapma</string>
<string name="app_double_back_exit">Çift geri</string>
<string name="app_single_back_exit">Tek geri</string>

View File

@ -140,6 +140,7 @@
<string name="open_channel_uploads">Відкрити завантаження</string>
<string name="app_exit_shortcut">Вихід з застосунку</string>
<string name="player_exit_shortcut">Вихід з плеєру</string>
<string name="search_exit_shortcut">Вихід з пошуку</string>
<string name="app_exit_none">Не виходити</string>
<string name="app_double_back_exit">Подвійне назад</string>
<string name="app_single_back_exit">Одиночне назад</string>

View File

@ -140,6 +140,7 @@
<string name="open_channel_uploads">Open channel uploads</string>
<string name="app_exit_shortcut">Exit from the app</string>
<string name="player_exit_shortcut">Exit from the player</string>
<string name="search_exit_shortcut">Exit from the search</string>
<string name="app_exit_none">Don\'t exit</string>
<string name="app_double_back_exit">Double back</string>
<string name="app_single_back_exit">Single back</string>

View File

@ -15,6 +15,7 @@ import com.liskovsoft.smartyoutubetv2.common.prefs.GeneralData;
import com.liskovsoft.smartyoutubetv2.common.utils.Utils;
import com.liskovsoft.smartyoutubetv2.tv.ui.common.keyhandler.DoubleBackManager2;
import com.liskovsoft.smartyoutubetv2.tv.ui.playback.PlaybackActivity;
import com.liskovsoft.smartyoutubetv2.tv.ui.search.tags.SearchTagsActivity;
/**
* This parent class contains common methods that run in every activity such as search.
@ -114,6 +115,15 @@ public abstract class LeanbackActivity extends MotherActivity {
finishReally();
break;
}
} else if (this instanceof SearchTagsActivity) {
switch (getGeneralData().getSearchExitShortcut()) {
case GeneralData.EXIT_DOUBLE_BACK:
mDoubleBackManager.enableDoubleBackExit(this::finishReally);
break;
case GeneralData.EXIT_SINGLE_BACK:
finishReally();
break;
}
} else {
finishReally();
}