Skip to content

Commit

Permalink
Merge pull request #469 from tkterris/press-back-twice
Browse files Browse the repository at this point in the history
Add toggle to disable "Press back again to exit"
  • Loading branch information
tibbi authored May 18, 2021
2 parents 6b54b0e + ffb1f73 commit e99cfd4
Show file tree
Hide file tree
Showing 37 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class MainActivity : SimpleActivity() {

override fun onBackPressed() {
if (fragment.mView.breadcrumbs.childCount <= 1) {
if (!wasBackJustPressed) {
if (!wasBackJustPressed && config.pressBackTwice) {
wasBackJustPressed = true
toast(R.string.press_back_again)
Handler().postDelayed({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class SettingsActivity : SimpleActivity() {
setupChangeDateTimeFormat()
setupFontSize()
setupShowHidden()
setupPressBackTwice()
setupHiddenItemPasswordProtection()
setupAppPasswordProtection()
setupFileDeletionPasswordProtection()
Expand Down Expand Up @@ -115,6 +116,14 @@ class SettingsActivity : SimpleActivity() {
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() {
settings_password_protection.isChecked = config.isHiddenPasswordProtectionOn
settings_password_protection_holder.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Config(context: Context) : BaseConfig(context) {

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
get(): String {
var path = prefs.getString(HOME_FOLDER, "")!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const val MAX_COLUMN_COUNT = 20

// shared preferences
const val SHOW_HIDDEN = "show_hidden"
const val PRESS_BACK_TWICE = "press_back_twice"
const val HOME_FOLDER = "home_folder"
const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden"
const val IS_ROOT_AVAILABLE = "is_root_available"
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,29 @@

</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
android:id="@+id/visibility_label"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-az/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-cy/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-id/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<!-- Settings -->
<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 -->
<!-- App title has to have less than 50 characters. If you cannot squeeze it, just remove a part of it -->
Expand Down

0 comments on commit e99cfd4

Please sign in to comment.