Merge pull request #469 from tkterris/press-back-twice

Add toggle to disable "Press back again to exit"
This commit is contained in:
Tibor Kaputa
2021-05-18 17:42:23 +02:00
committed by GitHub
37 changed files with 70 additions and 1 deletions

View File

@ -330,7 +330,7 @@ class MainActivity : SimpleActivity() {
override fun onBackPressed() { override fun onBackPressed() {
if (fragment.mView.breadcrumbs.childCount <= 1) { if (fragment.mView.breadcrumbs.childCount <= 1) {
if (!wasBackJustPressed) { if (!wasBackJustPressed && config.pressBackTwice) {
wasBackJustPressed = true wasBackJustPressed = true
toast(R.string.press_back_again) toast(R.string.press_back_again)
Handler().postDelayed({ Handler().postDelayed({

View File

@ -31,6 +31,7 @@ class SettingsActivity : SimpleActivity() {
setupChangeDateTimeFormat() setupChangeDateTimeFormat()
setupFontSize() setupFontSize()
setupShowHidden() setupShowHidden()
setupPressBackTwice()
setupHiddenItemPasswordProtection() setupHiddenItemPasswordProtection()
setupAppPasswordProtection() setupAppPasswordProtection()
setupFileDeletionPasswordProtection() setupFileDeletionPasswordProtection()
@ -115,6 +116,14 @@ class SettingsActivity : SimpleActivity() {
config.showHidden = settings_show_hidden.isChecked config.showHidden = settings_show_hidden.isChecked
} }
private fun setupPressBackTwice() {
settings_press_back_twice.isChecked = config.pressBackTwice
settings_press_back_twice_holder.setOnClickListener {
settings_press_back_twice.toggle()
config.pressBackTwice = settings_press_back_twice.isChecked
}
}
private fun setupHiddenItemPasswordProtection() { private fun setupHiddenItemPasswordProtection() {
settings_password_protection.isChecked = config.isHiddenPasswordProtectionOn settings_password_protection.isChecked = config.isHiddenPasswordProtectionOn
settings_password_protection_holder.setOnClickListener { settings_password_protection_holder.setOnClickListener {

View File

@ -22,6 +22,10 @@ class Config(context: Context) : BaseConfig(context) {
var shouldShowHidden = showHidden || temporarilyShowHidden var shouldShowHidden = showHidden || temporarilyShowHidden
var pressBackTwice: Boolean
get() = prefs.getBoolean(PRESS_BACK_TWICE, true)
set(pressBackTwice) = prefs.edit().putBoolean(PRESS_BACK_TWICE, pressBackTwice).apply()
var homeFolder: String var homeFolder: String
get(): String { get(): String {
var path = prefs.getString(HOME_FOLDER, "")!! var path = prefs.getString(HOME_FOLDER, "")!!

View File

@ -5,6 +5,7 @@ const val MAX_COLUMN_COUNT = 20
// shared preferences // shared preferences
const val SHOW_HIDDEN = "show_hidden" const val SHOW_HIDDEN = "show_hidden"
const val PRESS_BACK_TWICE = "press_back_twice"
const val HOME_FOLDER = "home_folder" const val HOME_FOLDER = "home_folder"
const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden" const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
const val IS_ROOT_AVAILABLE = "is_root_available" const val IS_ROOT_AVAILABLE = "is_root_available"

View File

@ -129,6 +129,29 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/settings_press_back_twice_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_press_back_twice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:text="@string/press_back_twice"
app:switchPadding="@dimen/medium_margin" />
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/visibility_label" android:id="@+id/visibility_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">تفعيل الدخول الى مسار الروت</string> <string name="enable_root_access">تفعيل الدخول الى مسار الروت</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Root icazəsini aktivləşdir</string> <string name="enable_root_access">Root icazəsini aktivləşdir</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Povolit přístup ke kořenovým souborům</string> <string name="enable_root_access">Povolit přístup ke kořenovým souborům</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Galluogi mynediad craidd</string> <string name="enable_root_access">Galluogi mynediad craidd</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Aktiver root-adgang</string> <string name="enable_root_access">Aktiver root-adgang</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Root-Zugriff erlauben</string> <string name="enable_root_access">Root-Zugriff erlauben</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Ενεργοποιήστε την πρόσβαση ριζικού καταλόγου</string> <string name="enable_root_access">Ενεργοποιήστε την πρόσβαση ριζικού καταλόγου</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Activar acceso root</string> <string name="enable_root_access">Activar acceso root</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Ota käyttöön root-ominaisuudet</string> <string name="enable_root_access">Ota käyttöön root-ominaisuudet</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Activer les droits root</string> <string name="enable_root_access">Activer les droits root</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -42,6 +42,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">रूट एक्सेस</string> <string name="enable_root_access">रूट एक्सेस</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Omogući root pristup</string> <string name="enable_root_access">Omogući root pristup</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Enable root access</string> <string name="enable_root_access">Enable root access</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Aktifkan akses root</string> <string name="enable_root_access">Aktifkan akses root</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Aktifkan akses root</string> <string name="enable_root_access">Aktifkan akses root</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Abilita accesso root</string> <string name="enable_root_access">Abilita accesso root</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">ルートアクセスを有効にする</string> <string name="enable_root_access">ルートアクセスを有効にする</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">루트 접근 활성화</string> <string name="enable_root_access">루트 접근 활성화</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Įgalinti šakninę prieigą</string> <string name="enable_root_access">Įgalinti šakninę prieigą</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Aktiver root-tilgang</string> <string name="enable_root_access">Aktiver root-tilgang</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Root-toegang inschakelen</string> <string name="enable_root_access">Root-toegang inschakelen</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Zezwól na dostęp do uprawnień roota</string> <string name="enable_root_access">Zezwól na dostęp do uprawnień roota</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Ativar o acesso root</string> <string name="enable_root_access">Ativar o acesso root</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Ativar acesso root</string> <string name="enable_root_access">Ativar acesso root</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Включить root-доступ</string> <string name="enable_root_access">Включить root-доступ</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Povoliť prístup ku koreňovým súborom</string> <string name="enable_root_access">Povoliť prístup ku koreňovým súborom</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Aktivera rotåtkomst</string> <string name="enable_root_access">Aktivera rotåtkomst</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Root erişimini etkinleştir</string> <string name="enable_root_access">Root erişimini etkinleştir</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have --> <!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Активувати root-доступ</string> <string name="enable_root_access">Активувати root-доступ</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">启用 root 访问</string> <string name="enable_root_access">启用 root 访问</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">啟用root權限</string> <string name="enable_root_access">啟用root權限</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->

View File

@ -43,6 +43,7 @@
<!-- Settings --> <!-- Settings -->
<string name="enable_root_access">Enable root access</string> <string name="enable_root_access">Enable root access</string>
<string name="press_back_twice">Require pressing Back twice to leave the app</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have --> <!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it --> <!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->