Sync frequency bug fixed
This commit is contained in:
@@ -152,8 +152,10 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
if (!Preferences.getBoolean(this, R.string.pref_set_auto_sync_on_startup)) {
|
||||
registerSync();
|
||||
registerSync(true);
|
||||
Preferences.setBoolean(this, R.string.pref_set_auto_sync_on_startup, true);
|
||||
} else {
|
||||
registerSync(false);
|
||||
}
|
||||
CustomNotificationManager.createNotificationChannel(this);
|
||||
/*getKVV().modules().list().recv(list -> {
|
||||
@@ -189,7 +191,7 @@ public class MainActivity extends AppCompatActivity
|
||||
updateNavigation();
|
||||
if (restoreResult == Login.RESTORE_STATUS_SUCCESS && !isLoggedInBeforePause) {
|
||||
changeFragment(getDefaultFragmentAfterLogin());
|
||||
registerSync();
|
||||
registerSync(true);
|
||||
} else if (restoreResult == Login.RESTORE_STATUS_INVALID_PASSWORD && isLoggedInBeforePause) {
|
||||
getKVV().account().logout(false);
|
||||
changeFragment(getDefaultFragmentAfterLogout());
|
||||
@@ -388,15 +390,16 @@ public class MainActivity extends AppCompatActivity
|
||||
changeFragment(newFragment);
|
||||
}
|
||||
|
||||
private void registerSync() {
|
||||
private void registerSync(boolean onLogin) {
|
||||
Account accountByType = mAccountManager.getAccountByType(AccountGeneral.ACCOUNT_TYPE);
|
||||
if (accountByType != null) {
|
||||
ContentResolver.setSyncAutomatically(accountByType, KVVContentProvider.PROVIDER_NAME, true);
|
||||
if (onLogin)
|
||||
ContentResolver.setSyncAutomatically(accountByType, KVVContentProvider.PROVIDER_NAME, true);
|
||||
ContentResolver.addPeriodicSync(
|
||||
accountByType,
|
||||
KVVContentProvider.PROVIDER_NAME,
|
||||
Bundle.EMPTY,
|
||||
Long.parseLong(Preferences.getStringArray(this, R.array.pref_sync_frequency)));
|
||||
Long.parseLong(Preferences.getStringArray(this, R.array.pref_sync_frequency))*60*60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,9 @@ public class FUAuthenticator extends AbstractAccountAuthenticator {
|
||||
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException {
|
||||
final AccountManager am = AccountManager.get(mContext);
|
||||
if (am.getAccountsByType(accountType).length > 0) {
|
||||
final Intent intent = new Intent(mContext, FUAuthenticatorActivity.class);
|
||||
intent.putExtra(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
|
||||
intent.putExtra(AccountManager.KEY_ERROR_MESSAGE, "Already an account added!");
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(AccountManager.KEY_INTENT, intent);
|
||||
bundle.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
|
||||
bundle.putString(AccountManager.KEY_ERROR_MESSAGE, "Already an account added!");
|
||||
return bundle;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user