From 21addcb2b8ea44c071fd73fa3d68f3d3d74c8db9 Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Tue, 17 Mar 2020 17:52:36 +0100 Subject: [PATCH] open sync interval selector right away - fixes #840 Signed-off-by: David Luhmer --- .../owncloudnewsreader/SettingsFragment.java | 12 ++++++++---- .../SyncIntervalSelectorActivity.java | 15 ++++++++------- News-Android-App/src/main/res/values/strings.xml | 5 ++++- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java index e8c5808f..fb39dc32 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SettingsFragment.java @@ -264,12 +264,16 @@ public class SettingsFragment extends PreferenceFragmentCompat { private void bindDataSyncPreferences(final PreferenceFragmentCompat prefFrag) { - String[] authorities = { "de.luhmer.owncloudnewsreader" }; - Intent intentSyncSettings = new Intent(Settings.ACTION_SYNC_SETTINGS); - intentSyncSettings.putExtra(Settings.EXTRA_AUTHORITIES, authorities); - + // String[] authorities = { "de.luhmer.owncloudnewsreader" }; + // Intent intentSyncSettings = new Intent(Settings.ACTION_SYNC_SETTINGS); + // intentSyncSettings.putExtra(Settings.EXTRA_AUTHORITIES, authorities); + // String[] authorities = { "de.luhmer.owncloudnewsreader" }; + // Intent intentSyncSettings = new Intent(Settings.ACTION_SYNC_SETTINGS); + // intentSyncSettings.putExtra(Settings.EXTRA_AUTHORITIES, authorities); + Intent intentSyncSettings = new Intent(getActivity(), SyncIntervalSelectorActivity.class); prefFrag.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings); + //bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_ITEMS_SYNC)); Preference clearCachePref = prefFrag.findPreference(EDT_CLEAR_CACHE); bindPreferenceSummaryToValue(prefFrag.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING)); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SyncIntervalSelectorActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SyncIntervalSelectorActivity.java index b5ae2b9f..d5efc5b4 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SyncIntervalSelectorActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/SyncIntervalSelectorActivity.java @@ -96,13 +96,11 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity { public static void setAccountSyncInterval(Context context, SharedPreferences mPrefs) { int minutes = mPrefs.getInt(SYNC_INTERVAL_IN_MINUTES_STRING, 0); - if(minutes != 0) { - long SYNC_INTERVAL = minutes * SECONDS_PER_MINUTE; - - AccountManager mAccountManager = AccountManager.get(context); - Account[] accounts = mAccountManager.getAccountsByType(AccountGeneral.ACCOUNT_TYPE); - for (Account account : accounts) { - + AccountManager mAccountManager = AccountManager.get(context); + Account[] accounts = mAccountManager.getAccountsByType(AccountGeneral.ACCOUNT_TYPE); + for (Account account : accounts) { + if (minutes != 0) { + long SYNC_INTERVAL = minutes * SECONDS_PER_MINUTE; ContentResolver.setSyncAutomatically(account, AccountGeneral.ACCOUNT_TYPE, true); Bundle bundle = new Bundle(); @@ -111,6 +109,9 @@ public class SyncIntervalSelectorActivity extends AppCompatActivity { AccountGeneral.ACCOUNT_TYPE, bundle, SYNC_INTERVAL); + + } else { + ContentResolver.setSyncAutomatically(account, AccountGeneral.ACCOUNT_TYPE, false); } } } diff --git a/News-Android-App/src/main/res/values/strings.xml b/News-Android-App/src/main/res/values/strings.xml index 2a536716..d10e3d9e 100644 --- a/News-Android-App/src/main/res/values/strings.xml +++ b/News-Android-App/src/main/res/values/strings.xml @@ -3,7 +3,7 @@ Auto sync News - Sync Interval Selector + Sync Interval NewsDetailActivity No items here Download of more items started… Please wait. @@ -406,6 +406,7 @@ + Never 5 Minutes 15 Minutes 30 Minutes @@ -418,6 +419,7 @@ 24 Hours + @string/array_sync_interval_min_0 @string/array_sync_interval_min_5 @string/array_sync_interval_min_15 @string/array_sync_interval_min_30 @@ -430,6 +432,7 @@ @string/array_sync_interval_hour_24 + 0 5 15 30