#1168 Enable background synchronization by default

This commit is contained in:
Stefan Niedermann 2021-05-10 14:36:18 +02:00
parent ecff7bb0e7
commit d508552b93
3 changed files with 5 additions and 6 deletions

View file

@ -102,15 +102,14 @@ public class ImportAccountActivity extends AppCompatActivity {
*/ */
@Override @Override
public void onSuccess(Account account) { public void onSuccess(Account account) {
Context context = getApplicationContext();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
SyncWorker.update(context, sharedPreferences.getBoolean(context.getString(R.string.pref_key_background_sync), true));
runOnUiThread(() -> { runOnUiThread(() -> {
Log.i(TAG, capabilities.toString()); Log.i(TAG, capabilities.toString());
BrandingUtil.saveBrandColors(ImportAccountActivity.this, capabilities.getColor(), capabilities.getTextColor()); BrandingUtil.saveBrandColors(ImportAccountActivity.this, capabilities.getColor(), capabilities.getTextColor());
setResult(RESULT_OK); setResult(RESULT_OK);
finish(); finish();
}); });
SyncWorker.update(ImportAccountActivity.this, PreferenceManager.getDefaultSharedPreferences(ImportAccountActivity.this)
.getBoolean(getString(R.string.pref_key_background_sync), true));
} }
@Override @Override

View file

@ -28,11 +28,10 @@ public class Migration_21_22 extends Migration {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
if (sharedPreferences.contains("backgroundSync")) { if (sharedPreferences.contains("backgroundSync")) {
if (sharedPreferences.getString("backgroundSync", "").equals("off")) {
editor.remove("backgroundSync"); editor.remove("backgroundSync");
if (sharedPreferences.getString("backgroundSync", "").equals("off")) {
editor.putBoolean("backgroundSync", false); editor.putBoolean("backgroundSync", false);
} else { } else {
editor.remove("backgroundSync");
editor.putBoolean("backgroundSync", true); editor.putBoolean("backgroundSync", true);
SyncWorker.update(context, true); SyncWorker.update(context, true);
} }

View file

@ -1,3 +1,4 @@
- 🌐 Enhanced linkifying - by @Cui-Yusong - 🌐 Enhanced linkifying - by @Cui-Yusong
- ⚙️ Use Retrofit for API calls (#1167) - ⚙️ Use Retrofit for API calls (#1167)
- ⚙ Switched based for markdown rendering in widgets - ⚙ Switched based for markdown rendering in widgets
- ⚙ Enable background synchronization by default (#1168) - by @MasterWanna