summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-05-24 16:17:35 +0530
committerGitHub <noreply@github.com>2022-05-24 10:47:35 +0000
commit5f4bc7fafde92f18453571054dbdc3b29d196416 (patch)
tree23450a01b9d6119ec4ea4719661aa42abc9586ec /app/src/main/java
parent8550bede22d1e02a678a52cee5d6dd7da155bb34 (diff)
Allow disabling pull-to-sync operation (#1922)
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordFragment.kt7
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/settings/GeneralSettings.kt6
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/settings/PreferenceKeys.kt1
3 files changed, 14 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"
}