Skip to content

Commit

Permalink
Update settings page summary
Browse files Browse the repository at this point in the history
  • Loading branch information
VishalNehra committed Jul 14, 2024
1 parent adf4d6e commit c2d73ab
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ class MainActivity :
}

private fun exit() {
if (getFilesModel().backPressedToExitOnce) {
val confirmBeforeExitPref = getAppCommonSharedPreferences().getBoolean(
PreferencesConstants.KEY_CONFIRM_BEFORE_EXIT,
PreferencesConstants.DEFAULT_CONFIRM_BEFORE_EXIT
)
if (!confirmBeforeExitPref || getFilesModel().backPressedToExitOnce) {
finish()
} else {
getFilesModel().backPressedToExitOnce = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.preference.CheckBoxPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.amaze.fileutilities.R
Expand All @@ -35,6 +36,7 @@ class AppearancePrefFragment : PreferenceFragmentCompat(), Preference.OnPreferen

companion object {
private const val KEY_COLUMNS = "columns"
private const val KEY_CONFIRM_ON_EXIT = "pref_confirm_before_exit"
private val KEYS = listOf(
KEY_COLUMNS
)
Expand All @@ -43,6 +45,21 @@ class AppearancePrefFragment : PreferenceFragmentCompat(), Preference.OnPreferen
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.appearance_prefs)
val sharedPrefs = requireContext().getAppCommonSharedPreferences()
val enableConfirmOnExitChange = Preference.OnPreferenceChangeListener { pref, newValue ->
sharedPrefs.edit().putBoolean(
PreferencesConstants.KEY_CONFIRM_BEFORE_EXIT, newValue as Boolean
).apply()
true
}
val confirmOnExitCheckbox = findPreference<CheckBoxPreference>(KEY_CONFIRM_ON_EXIT)
confirmOnExitCheckbox?.setDefaultValue(
sharedPrefs.getBoolean(
PreferencesConstants.KEY_CONFIRM_BEFORE_EXIT,
PreferencesConstants.DEFAULT_CONFIRM_BEFORE_EXIT
)
)
confirmOnExitCheckbox?.onPreferenceChangeListener = enableConfirmOnExitChange
KEYS.forEach {
findPreference<Preference>(it)?.onPreferenceClickListener = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class PreferencesConstants {
const val KEY_TRASH_BIN_RETENTION_BYTES = "trash_bin_retention_bytes"
const val KEY_TRASH_BIN_RETENTION_NUM_OF_FILES = "trash_bin_retention_num_of_files"
const val KEY_TRASH_BIN_CLEANUP_INTERVAL_HOURS = "trash_bin_cleanup_interval_hours"
const val KEY_CONFIRM_BEFORE_EXIT = "pref_confirm_before_exit"

const val VAL_SEARCH_DUPLICATES_MEDIA_STORE = 0
const val VAL_SEARCH_DUPLICATES_INTERNAL_SHALLOW = 1
Expand Down Expand Up @@ -95,6 +96,7 @@ class PreferencesConstants {
const val DEFAULT_NEWLY_INSTALLED_APPS_DAYS = 7
const val DEFAULT_RECENTLY_UPDATED_APPS_DAYS = 7
const val DEFAULT_LARGE_SIZE_DIFF_APPS_DAYS = 7
const val DEFAULT_CONFIRM_BEFORE_EXIT = true

// max days that the size is stored in database and
// therefore the max days that the size diff can be calculated
Expand Down
1 change: 0 additions & 1 deletion app/src/main/play/release-notes/en-US/production.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Changelog:
- Add support for Android 13
- Bugfixes in video and audio players
- Analyse list of apps growing in size
- Improved performance
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1045,4 +1045,8 @@
<string name="terms_and_conditions">Terms and Conditions</string>
<!-- usage app opened in most used apps analysis -->
<string name="usage">Usage (hrs)</string>
<!-- confirm before exit app in general settings -->
<string name="confirm_before_exit">Confirm before exit</string>
<!-- general app settings summary -->
<string name="general_summary">Control general app behaviour</string>
</resources>
7 changes: 6 additions & 1 deletion app/src/main/res/xml/appearance_prefs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
app:key="pref_confirm_before_exit"
app:title="@string/confirm_before_exit"
app:defaultValue="true"
/>
<PreferenceCategory
app:title="@string/general">
app:title="@string/appearance">
<Preference
app:key="columns"
app:title="@string/columns_grid_title"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
app:key="appearance"
app:title="@string/appearance"
android:summary="@string/appearance_summary"
app:title="@string/general"
android:summary="@string/general_summary"
app:icon="@drawable/ic_pref_appearance"
/>
<Preference
Expand Down

0 comments on commit c2d73ab

Please sign in to comment.