Skip to content

Commit ae8caad

Browse files
feat: use a pref to control whether to enable exit app confirmation
1 parent 53d8fe2 commit ae8caad

13 files changed

Lines changed: 53 additions & 26 deletions

File tree

app/src/main/java/org/schabi/newpipe/MainActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,13 @@ public void onBackPressed() {
678678
}
679679
}
680680

681+
final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
682+
681683
// Show toast and exit logic only when we're about to exit the app
682-
if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
684+
if (getSupportFragmentManager().getBackStackEntryCount() == 1 ) {
683685
long currentTime = System.currentTimeMillis();
684686

685-
if (currentTime - lastBackPressTime < BACK_PRESS_TIMEOUT) {
687+
if (!pref.getBoolean(getString(R.string.exit_app_confirmation_key), true) || currentTime - lastBackPressTime < BACK_PRESS_TIMEOUT) {
686688
// Second back press within timeout - exit the app
687689
finish();
688690
return;

app/src/main/res/values-de/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,4 +975,6 @@
975975
<string name="feed_groups_grid_layout_summary">Auf der Abonnementseite werden Kanalgruppen in einem Raster anstelle eines horizontalen Bildlaufs angezeigt</string>
976976
<string name="press_back_again_to_exit">Drücken Sie erneut zurück, um zu beenden</string>
977977
<string name="need_login_hint"> Dieser Inhalt erfordert ein Konto, um angezeigt zu werden. Melden Sie sich über die Einstellungen an, um fortzufahren.</string>
978+
<string name="exit_app_confirmation_message">Zeigen Sie einen "Drücken Sie erneut zurück, um zu beenden" Toast, um versehentliches Beenden zu vermeiden</string>
979+
<string name="exit_app_confirmation_title">Bestätigung zum Beenden der App</string>
978980
</resources>

app/src/main/res/values-es/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,4 +1038,6 @@
10381038
<string name="feed_groups_grid_layout_summary">En la página de Suscripciones, mostrar grupos de canales en una cuadrícula en lugar de desplazamiento horizontal</string>
10391039
<string name="press_back_again_to_exit">Presiona atrás nuevamente para salir</string>
10401040
<string name="need_login_hint"> Este contenido requiere una cuenta para ver. Inicia sesión a través de la configuración para continuar.</string>
1041+
<string name="exit_app_confirmation_message">Mostrar un toast de "presiona atrás de nuevo para salir" para evitar salir accidentalmente</string>
1042+
<string name="exit_app_confirmation_title">Confirmación de salida de la aplicación</string>
10411043
</resources>

app/src/main/res/values-fr/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,4 +928,6 @@ Vous devez l\'accepter pour nous envoyer le rapport de bug.</string>
928928
<string name="feed_groups_grid_layout_summary">Dans la page des abonnements, afficher les groupes de chaînes dans une grille au lieu d\'un défilement horizontal</string>
929929
<string name="press_back_again_to_exit">Appuyez à nouveau sur retour pour quitter</string>
930930
<string name="need_login_hint"> Ce contenu nécessite un compte pour être consulté. Connectez-vous via les paramètres pour continuer.</string>
931+
<string name="exit_app_confirmation_message">Afficher un toast "appuyez à nouveau sur retour pour quitter" pour éviter de quitter accidentellement</string>
932+
<string name="exit_app_confirmation_title">Confirmation de sortie de l\'application</string>
931933
</resources>

app/src/main/res/values-it/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,4 +895,6 @@
895895
<string name="feed_groups_grid_layout_summary">Nella pagina delle iscrizioni, mostra i gruppi di canali in una griglia invece di scorrere orizzontalmente</string>
896896
<string name="press_back_again_to_exit">Premi di nuovo indietro per uscire</string>
897897
<string name="need_login_hint"> Questo contenuto richiede un account per essere visualizzato. Accedi tramite le impostazioni per continuare.</string>
898+
<string name="exit_app_confirmation_message">Mostra un toast "premi di nuovo indietro per uscire" per evitare uscite accidentali</string>
899+
<string name="exit_app_confirmation_title">Conferma uscita dall\'app</string>
898900
</resources>

app/src/main/res/values-ja/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,4 +991,6 @@
991991
<string name="feed_groups_grid_layout_summary">サブスクリプションページで、チャンネルグループを水平スクロールの代わりにグリッドで表示する</string>
992992
<string name="press_back_again_to_exit">もう一度戻るボタンを押して終了します</string>
993993
<string name="need_login_hint"> このコンテンツを表示するにはアカウントが必要です。設定からログインして続行してください。</string>
994+
<string name="exit_app_confirmation_message">「もう一度戻るボタンを押すと終了します」というトーストを表示して、誤って終了するのを防ぎます</string>
995+
<string name="exit_app_confirmation_title">アプリ終了の確認</string>
994996
</resources>

app/src/main/res/values-vi/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,4 +1081,6 @@ nSự khác biệt giữa hai loại này là cái nào nhanh thường thiếu
10811081
<string name="feed_groups_grid_layout_summary">Trong trang Đăng ký, hiển thị các nhóm kênh dưới dạng lưới thay vì cuộn ngang</string>
10821082
<string name="press_back_again_to_exit">Nhấn quay lại lần nữa để thoát</string>
10831083
<string name="need_login_hint"> Nội dung này yêu cầu tài khoản để xem. Đăng nhập qua cài đặt để tiếp tục.</string>
1084+
<string name="exit_app_confirmation_message">Hiển thị thông báo "nhấn quay lại lần nữa để thoát" để tránh thoát nhầm</string>
1085+
<string name="exit_app_confirmation_title">Xác nhận thoát ứng dụng</string>
10841086
</resources>

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,4 +1037,6 @@
10371037
<string name="feed_groups_grid_layout_summary">在订阅页面中,将频道组显示为网格而不是水平滚动</string>
10381038
<string name="press_back_again_to_exit">再次按返回键退出</string>
10391039
<string name="need_login_hint"> 此内容需要账户才能查看。通过设置登录以继续。</string>
1040+
<string name="exit_app_confirmation_message">显示“再次按返回键退出”提示以避免意外退出</string>
1041+
<string name="exit_app_confirmation_title">退出应用确认</string>
10401042
</resources>

app/src/main/res/values-zh-rTW/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,4 +1029,6 @@
10291029
<string name="feed_groups_grid_layout_summary">在訂閱頁面中,將頻道群組顯示為網格而不是水平滾動</string>
10301030
<string name="press_back_again_to_exit">再次按返回键以退出</string>
10311031
<string name="need_login_hint"> 此內容需要帳戶才能查看。通過設置登錄以繼續。</string>
1032+
<string name="exit_app_confirmation_message">顯示“再次按返回退出”的提示,以避免意外退出</string>
1033+
<string name="exit_app_confirmation_title">退出應用程式確認</string>
10321034
</resources>

app/src/main/res/values/settings_keys.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,7 @@
16531653
<string name="auto_ellipsize_key">auto_ellipsize_key</string>
16541654
<string name="enable_max_rows_customization_key">enable_max_rows_customization_key</string>
16551655
<string name="always_list_mode_for_bookmark_key">always_list_mode_for_bookmark_key</string>
1656+
<string name="exit_app_confirmation_key">exit_app_confirmation_key</string>
16561657
<string-array name="filter_type_entries">
16571658
<item>@string/search_result</item>
16581659
<item>@string/recommended_videos</item>

0 commit comments

Comments
 (0)