open sync interval selector right away - fixes #840
Signed-off-by: David Luhmer <david-dev@live.de>
This commit is contained in:
parent
6d0c744c73
commit
21addcb2b8
3 changed files with 20 additions and 12 deletions
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<string name="auto_sync_string">Auto sync</string>
|
||||
<string name="app_name" translatable="false">News</string>
|
||||
<string name="title_activity_sync_interval_selector">Sync Interval Selector</string>
|
||||
<string name="title_activity_sync_interval_selector">Sync Interval</string>
|
||||
<string name="title_activity_news_detail">NewsDetailActivity</string>
|
||||
<string name="empty_view_content">No items here</string>
|
||||
<string name="toast_GettingMoreItems">Download of more items started… Please wait.</string>
|
||||
|
@ -406,6 +406,7 @@
|
|||
</string-array>
|
||||
|
||||
|
||||
<string name="array_sync_interval_min_0">Never</string>
|
||||
<string name="array_sync_interval_min_5">5 Minutes</string>
|
||||
<string name="array_sync_interval_min_15">15 Minutes</string>
|
||||
<string name="array_sync_interval_min_30">30 Minutes</string>
|
||||
|
@ -418,6 +419,7 @@
|
|||
<string name="array_sync_interval_hour_24">24 Hours</string>
|
||||
|
||||
<string-array name="array_sync_interval" translatable="false">
|
||||
<item>@string/array_sync_interval_min_0</item>
|
||||
<item>@string/array_sync_interval_min_5</item>
|
||||
<item>@string/array_sync_interval_min_15</item>
|
||||
<item>@string/array_sync_interval_min_30</item>
|
||||
|
@ -430,6 +432,7 @@
|
|||
<item>@string/array_sync_interval_hour_24</item>
|
||||
</string-array>
|
||||
<string-array name="array_sync_interval_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>5</item>
|
||||
<item>15</item>
|
||||
<item>30</item>
|
||||
|
|
Loading…
Reference in a new issue