Merge pull request #1932 from nextcloud/contactBackupRemoval

Contact backup removal
This commit is contained in:
Tobias Kaminsky 2018-01-09 08:48:28 +01:00 committed by GitHub
commit f993c0cd0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 13 deletions

View file

@ -38,6 +38,7 @@ import com.owncloud.android.datamodel.FilesystemDataProvider;
import com.owncloud.android.datamodel.SyncedFolder;
import com.owncloud.android.datamodel.SyncedFolderProvider;
import com.owncloud.android.datamodel.UploadsStorageManager;
import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
import com.owncloud.android.ui.events.AccountRemovedEvent;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.FilesSyncHelper;
@ -65,9 +66,12 @@ public class AccountRemovalJob extends Job implements AccountManagerCallback<Boo
Context context = MainApp.getAppContext();
PersistableBundleCompat bundle = params.getExtras();
Account account = AccountUtils.getOwnCloudAccountByName(context, bundle.getString(ACCOUNT, ""));
AccountManager am = (AccountManager) context.getSystemService(ACCOUNT_SERVICE);
if (account != null && am != null) {
// disable contact backup job
ContactsPreferenceActivity.cancelContactBackupJobForAccount(context, account);
if (account != null ) {
AccountManager am = (AccountManager) context.getSystemService(ACCOUNT_SERVICE);
am.removeAccount(account, this, null);
FileDataStorageManager storageManager = new FileDataStorageManager(account, context.getContentResolver());

View file

@ -129,17 +129,6 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag
.schedule();
}
public static void cancelAllContactBackupJobs(Context context) {
Log_OC.d(TAG, "disabling all contacts backup job");
JobManager jobManager = JobManager.create(context);
Set<JobRequest> jobs = jobManager.getAllJobRequestsForTag(ContactsBackupJob.TAG);
for (JobRequest jobRequest : jobs) {
jobManager.cancel(jobRequest.getJobId());
}
}
public static void cancelPreviousContactBackupJobForAccount(Context context, Account account) {
Log_OC.d(TAG, "disabling existing contacts backup job for account: " + account.name);