Don't try to delete contacts if we don't have permission anymore
This commit is contained in:
parent
22f4eb3e44
commit
f9557cca37
|
@ -135,23 +135,6 @@ public class ContactSyncAdapterService extends Service {
|
|||
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
|
||||
}
|
||||
|
||||
public static void deleteIfSyncDisabled(Context context) {
|
||||
if (!(ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
|
||||
== PackageManager.PERMISSION_GRANTED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Account account = KeychainApplication.createAccountIfNecessary(context);
|
||||
if (account == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if user has disabled automatic sync, delete linked OpenKeychain contacts
|
||||
if (!ContentResolver.getSyncAutomatically(account, ContactsContract.AUTHORITY)) {
|
||||
new ContactHelper(context).deleteAllContacts();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Import is currently disabled, until we implement proper origin management
|
||||
// private static void importKeys() {
|
||||
// importDone.set(false);
|
||||
|
|
|
@ -56,8 +56,6 @@ import org.sufficientlysecure.keychain.compatibility.AppCompatPreferenceActivity
|
|||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress;
|
||||
import org.sufficientlysecure.keychain.keysync.KeyserverSyncManager;
|
||||
import org.sufficientlysecure.keychain.network.orbot.OrbotHelper;
|
||||
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.Preferences;
|
||||
|
@ -86,7 +84,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
BaseActivity.onResumeChecks(this);
|
||||
|
||||
if (mThemeChanger.changeTheme()) {
|
||||
Intent intent = getIntent();
|
||||
|
@ -468,8 +465,6 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
}
|
||||
// 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);
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
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;
|
||||
|
@ -32,7 +32,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
||||
|
||||
/**
|
||||
|
@ -54,7 +53,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
onResumeChecks(this);
|
||||
|
||||
if (mThemeChanger != null && mThemeChanger.changeTheme()) {
|
||||
Intent intent = getIntent();
|
||||
|
@ -75,11 +73,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public static void onResumeChecks(Context context) {
|
||||
// in case user has disabled sync from Android account settings
|
||||
ContactSyncAdapterService.deleteIfSyncDisabled(context);
|
||||
}
|
||||
|
||||
protected void initLayout() {
|
||||
|
||||
}
|
||||
|
@ -191,5 +184,4 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
getSupportActionBar().setCustomView(customActionBarView, new ActionBar.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue