Make ContactHelper less static
This commit is contained in:
@@ -86,8 +86,9 @@ public class ImportKeysCloudFragment extends Fragment {
|
||||
|
||||
mQueryEditText = (AutoCompleteTextView) view.findViewById(R.id.cloud_import_server_query);
|
||||
|
||||
List<String> namesAndEmails = ContactHelper.getContactNames(getActivity());
|
||||
namesAndEmails.addAll(ContactHelper.getContactMails(getActivity()));
|
||||
ContactHelper contactHelper = new ContactHelper(getActivity());
|
||||
List<String> namesAndEmails = contactHelper.getContactNames();
|
||||
namesAndEmails.addAll(contactHelper.getContactMails());
|
||||
mQueryEditText.setThreshold(3);
|
||||
mQueryEditText.setAdapter(
|
||||
new ArrayAdapter<>
|
||||
|
||||
@@ -243,7 +243,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
||||
return;
|
||||
}
|
||||
if (mDataUri.getHost().equals(ContactsContract.AUTHORITY)) {
|
||||
mDataUri = ContactHelper.dataUriFromContactUri(this, mDataUri);
|
||||
mDataUri = new ContactHelper(this).dataUriFromContactUri(mDataUri);
|
||||
if (mDataUri == null) {
|
||||
Log.e(Constants.TAG, "Contact Data missing. Should be uri of key!");
|
||||
Toast.makeText(this, R.string.error_contacts_key_id_missing, Toast.LENGTH_LONG).show();
|
||||
@@ -855,8 +855,8 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
||||
AsyncTask<Long, Void, Bitmap> photoTask =
|
||||
new AsyncTask<Long, Void, Bitmap>() {
|
||||
protected Bitmap doInBackground(Long... mMasterKeyId) {
|
||||
return ContactHelper.loadPhotoByMasterKeyId(ViewKeyActivity.this,
|
||||
getContentResolver(), mMasterKeyId[0], true);
|
||||
return new ContactHelper(ViewKeyActivity.this)
|
||||
.loadPhotoByMasterKeyId(mMasterKeyId[0], true);
|
||||
}
|
||||
|
||||
protected void onPostExecute(Bitmap photo) {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
||||
return;
|
||||
}
|
||||
if (mDataUri.getHost().equals(ContactsContract.AUTHORITY)) {
|
||||
mDataUri = ContactHelper.dataUriFromContactUri(this, mDataUri);
|
||||
mDataUri = new ContactHelper(this).dataUriFromContactUri(mDataUri);
|
||||
if (mDataUri == null) {
|
||||
Log.e(Constants.TAG, "Contact Data missing. Should be uri of key!");
|
||||
Toast.makeText(this, R.string.error_contacts_key_id_missing, Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -224,17 +224,17 @@ public class ViewKeyFragment extends LoaderFragment implements
|
||||
if(contactId == -1) return;
|
||||
|
||||
final Context context = mSystemContactName.getContext();
|
||||
final ContentResolver resolver = context.getContentResolver();
|
||||
ContactHelper contactHelper = new ContactHelper(context);
|
||||
|
||||
String contactName = null;
|
||||
|
||||
if (mIsSecret) {//all secret keys are linked to "me" profile in contacts
|
||||
List<String> mainProfileNames = ContactHelper.getMainProfileContactName(context);
|
||||
List<String> mainProfileNames = contactHelper.getMainProfileContactName();
|
||||
if (mainProfileNames != null && mainProfileNames.size() > 0) {
|
||||
contactName = mainProfileNames.get(0);
|
||||
}
|
||||
} else {
|
||||
contactName = ContactHelper.getContactName(resolver, contactId);
|
||||
contactName = contactHelper.getContactName(contactId);
|
||||
}
|
||||
|
||||
if (contactName != null) {//contact name exists for given master key
|
||||
@@ -244,9 +244,9 @@ public class ViewKeyFragment extends LoaderFragment implements
|
||||
|
||||
Bitmap picture;
|
||||
if (mIsSecret) {
|
||||
picture = ContactHelper.loadMainProfilePhoto(getActivity(), resolver, false);
|
||||
picture = contactHelper.loadMainProfilePhoto(false);
|
||||
} else {
|
||||
picture = ContactHelper.loadPhotoByContactId(getActivity(), resolver, contactId, false);
|
||||
picture = contactHelper.loadPhotoByContactId(contactId, false);
|
||||
}
|
||||
if (picture != null) mSystemContactPicture.setImageBitmap(picture);
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class EmailEditText extends AppCompatAutoCompleteTextView {
|
||||
private void initAdapter() {
|
||||
setThreshold(1); // Start working from first character
|
||||
setAdapter(new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item,
|
||||
ContactHelper.getPossibleUserEmails(getContext())));
|
||||
new ContactHelper(getContext()).getPossibleUserEmails()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ public class NameEditText extends AppCompatAutoCompleteTextView {
|
||||
setThreshold(1); // Start working from first character
|
||||
setAdapter(new ArrayAdapter<>(
|
||||
getContext(), android.R.layout.simple_spinner_dropdown_item,
|
||||
ContactHelper.getPossibleUserNames(getContext())));
|
||||
new ContactHelper(getContext()).getPossibleUserNames()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user