diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2022-05-24 16:17:35 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 10:47:35 +0000 |
commit | 5f4bc7fafde92f18453571054dbdc3b29d196416 (patch) | |
tree | 23450a01b9d6119ec4ea4719661aa42abc9586ec /app/src/main | |
parent | 8550bede22d1e02a678a52cee5d6dd7da155bb34 (diff) |
Allow disabling pull-to-sync operation (#1922)
Diffstat (limited to 'app/src/main')
4 files changed, 16 insertions, 0 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt index 0d0f9cfc..117d1d49 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt @@ -29,6 +29,7 @@ import dev.msfjarvis.aps.R import dev.msfjarvis.aps.data.password.PasswordItem import dev.msfjarvis.aps.data.repo.PasswordRepository import dev.msfjarvis.aps.databinding.PasswordRecyclerViewBinding +import dev.msfjarvis.aps.injection.prefs.SettingsPreferences import dev.msfjarvis.aps.ui.adapters.PasswordItemRecyclerAdapter import dev.msfjarvis.aps.ui.dialogs.BasicBottomSheet import dev.msfjarvis.aps.ui.dialogs.ItemCreationBottomSheet @@ -55,6 +56,7 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) { @Inject lateinit var gitSettings: GitSettings @Inject lateinit var shortcutHandler: ShortcutHandler + @Inject @SettingsPreferences lateinit var prefs: SharedPreferences private lateinit var recyclerAdapter: PasswordItemRecyclerAdapter private lateinit var listener: OnFragmentInteractionListener private lateinit var settings: SharedPreferences @@ -290,6 +292,11 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) { } } + override fun onResume() { + super.onResume() + binding.swipeRefresher.isEnabled = !prefs.getBoolean(PreferenceKeys.DISABLE_SYNC_ACTION, false) + } + override fun onAttach(context: Context) { super.onAttach(context) runCatching { diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt index f78f2cb2..6d8ab5f6 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt @@ -42,6 +42,12 @@ class GeneralSettings(private val activity: FragmentActivity) : SettingsProvider titleRes = R.string.pref_sort_order_title } + checkBox(PreferenceKeys.DISABLE_SYNC_ACTION) { + titleRes = R.string.pref_disable_sync_on_pull_title + summaryRes = R.string.pref_disable_sync_on_pull_summary + defaultValue = false + } + checkBox(PreferenceKeys.FILTER_RECURSIVELY) { titleRes = R.string.pref_recursive_filter_title summaryRes = R.string.pref_recursive_filter_summary diff --git a/app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt b/app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt index 152275d6..7f4e0daf 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt @@ -84,4 +84,5 @@ object PreferenceKeys { const val DICEWARE_SEPARATOR = "diceware_separator" const val DICEWARE_LENGTH = "diceware_length" + const val DISABLE_SYNC_ACTION = "disable_sync_action" } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fcfc4ade..adac6d51 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -132,6 +132,8 @@ <string name="pref_rebase_on_pull_title">Rebase on pull</string> <string name="pref_rebase_on_pull_summary">When pulling or syncing, create a merge commit with upstream changes</string> <string name="pref_rebase_on_pull_summary_on">When pulling or syncing, rebase commits that are not present in the remote repository</string> + <string name="pref_disable_sync_on_pull_title">Disable pull to sync action</string> + <string name="pref_disable_sync_on_pull_summary">Prevent pulling down on the password list from triggering a Git sync</string> <!-- PasswordGenerator fragment --> <string name="pwgen_title">Generate Password</string> |