mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-22 21:06:09 +03:00
SyncWorker called for update settings into running
This commit is contained in:
parent
398cb4f8ab
commit
bab97f32a4
2 changed files with 19 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
package it.niedermann.owncloud.notes.importaccount;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
@ -8,6 +10,7 @@ import android.view.View;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.nextcloud.android.sso.AccountImporter;
|
||||
import com.nextcloud.android.sso.exceptions.AccountImportCancelledException;
|
||||
|
@ -24,6 +27,7 @@ import it.niedermann.owncloud.notes.exception.ExceptionDialogFragment;
|
|||
import it.niedermann.owncloud.notes.exception.ExceptionHandler;
|
||||
import it.niedermann.owncloud.notes.persistence.CapabilitiesClient;
|
||||
import it.niedermann.owncloud.notes.persistence.SSOClient;
|
||||
import it.niedermann.owncloud.notes.persistence.SyncWorker;
|
||||
import it.niedermann.owncloud.notes.persistence.entity.Account;
|
||||
import it.niedermann.owncloud.notes.shared.model.Capabilities;
|
||||
import it.niedermann.owncloud.notes.shared.model.IResponseCallback;
|
||||
|
@ -86,8 +90,17 @@ public class ImportAccountActivity extends AppCompatActivity {
|
|||
Log.i(TAG, "Loading capabilities for " + ssoAccount.name);
|
||||
final Capabilities capabilities = CapabilitiesClient.getCapabilities(getApplicationContext(), ssoAccount, null);
|
||||
importAccountViewModel.addAccount(ssoAccount.url, ssoAccount.userId, ssoAccount.name, capabilities, new IResponseCallback<Account>() {
|
||||
|
||||
/**
|
||||
* Update syncing when adding account
|
||||
* https://github.com/stefan-niedermann/nextcloud-deck/issues/531
|
||||
* @param account the account to add
|
||||
*/
|
||||
@Override
|
||||
public void onSuccess(Account account) {
|
||||
Context context = getApplicationContext();
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SyncWorker.update(context, !sharedPreferences.getString("backgroundSync", "on").equals("off"));
|
||||
runOnUiThread(() -> {
|
||||
Log.i(TAG, capabilities.toString());
|
||||
BrandingUtil.saveBrandColors(ImportAccountActivity.this, capabilities.getColor(), capabilities.getTextColor());
|
||||
|
|
|
@ -8,6 +8,8 @@ import androidx.preference.PreferenceManager;
|
|||
import androidx.room.migration.Migration;
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
|
||||
import it.niedermann.owncloud.notes.persistence.SyncWorker;
|
||||
|
||||
/**
|
||||
* Enabling backgroundSync, set from {@link String} values to {@link Boolean} values
|
||||
* https://github.com/stefan-niedermann/nextcloud-notes/issues/1168
|
||||
|
@ -30,10 +32,14 @@ public class Migration_21_22 extends Migration {
|
|||
if (sharedPreferences.getString("backgroundSync", "on").equals("off")) {
|
||||
editor.remove("backgroundSync");
|
||||
editor.putBoolean("backgroundSync", false);
|
||||
SyncWorker.update(context, false);
|
||||
} else {
|
||||
editor.remove("backgroundSync");
|
||||
editor.putBoolean("backgroundSync", true);
|
||||
SyncWorker.update(context, true);
|
||||
}
|
||||
} else {
|
||||
SyncWorker.update(context, true);
|
||||
}
|
||||
editor.apply();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue