delete linked contacts on turning off contact sync
This commit is contained in:
@@ -51,6 +51,8 @@ import android.widget.LinearLayout;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.AppCompatPreferenceActivity;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
@@ -79,6 +81,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
BaseActivity.onResumeChecks(this);
|
||||
|
||||
if (mThemeChanger.changeTheme()) {
|
||||
Intent intent = getIntent();
|
||||
@@ -463,6 +466,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
} else {
|
||||
// disable syncs
|
||||
ContentResolver.setSyncAutomatically(account, authority, false);
|
||||
// immediately delete any linked contacts
|
||||
ContactSyncAdapterService.deleteIfSyncDisabled(getActivity());
|
||||
// cancel any ongoing/pending syncs
|
||||
ContentResolver.cancelSync(account, authority);
|
||||
setSummary(syncCheckBox, authority, false);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.sufficientlysecure.keychain.ui.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
@@ -30,6 +31,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.service.KeyserverSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
||||
|
||||
@@ -52,7 +54,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
KeyserverSyncAdapterService.cancelUpdates(this);
|
||||
onResumeChecks(this);
|
||||
|
||||
if (mThemeChanger.changeTheme()) {
|
||||
Intent intent = getIntent();
|
||||
@@ -63,6 +65,12 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public static void onResumeChecks(Context context) {
|
||||
KeyserverSyncAdapterService.cancelUpdates(context);
|
||||
// in case user has disabled sync from settings
|
||||
ContactSyncAdapterService.deleteIfSyncDisabled(context);
|
||||
}
|
||||
|
||||
protected void initLayout() {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user