remove more unused code

This commit is contained in:
Vincent Breitmoser 2017-02-23 13:25:10 +01:00
parent e18466c290
commit 110179deb5

View file

@ -13,7 +13,6 @@ import android.os.Bundle;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.PhoneLookup;
import android.provider.ContactsContract.QuickContact;
import android.provider.ContactsContract.RawContacts;
import android.util.AttributeSet;
@ -31,19 +30,8 @@ import android.widget.ImageView;
* https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/QuickContactBadge.java
*/
public class ContactBadge extends ImageView implements OnClickListener {
private Uri mContactUri;
private String mContactEmail;
private String mContactPhone;
private QueryHandler mQueryHandler;
private Bundle mExtras = null;
protected String[] mExcludeMimes = null;
static final private int TOKEN_EMAIL_LOOKUP = 0;
static final private int TOKEN_PHONE_LOOKUP = 1;
static final private int TOKEN_EMAIL_LOOKUP_AND_TRIGGER = 2;
static final private int TOKEN_PHONE_LOOKUP_AND_TRIGGER = 3;
static final private int TOKEN_EMAIL_LOOKUP_AND_TRIGGER = 1;
static final private String EXTRA_URI_CONTENT = "uri_content";
@ -54,12 +42,11 @@ public class ContactBadge extends ImageView implements OnClickListener {
static final int EMAIL_ID_COLUMN_INDEX = 0;
static final int EMAIL_LOOKUP_STRING_COLUMN_INDEX = 1;
static final String[] PHONE_LOOKUP_PROJECTION = new String[] {
PhoneLookup._ID,
PhoneLookup.LOOKUP_KEY,
};
static final int PHONE_ID_COLUMN_INDEX = 0;
static final int PHONE_LOOKUP_STRING_COLUMN_INDEX = 1;
private Uri contactUri;
private String contactEmail;
private QueryHandler queryHandler;
private Bundle extras = null;
public ContactBadge(Context context) {
@ -72,7 +59,7 @@ public class ContactBadge extends ImageView implements OnClickListener {
public ContactBadge(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mQueryHandler = new QueryHandler(context.getContentResolver());
queryHandler = new QueryHandler(context.getContentResolver());
setOnClickListener(this);
}
@ -97,7 +84,7 @@ public class ContactBadge extends ImageView implements OnClickListener {
* True if a contact, an email address or a phone number has been assigned
*/
private boolean isAssigned() {
return mContactUri != null || mContactEmail != null || mContactPhone != null;
return contactUri != null || contactEmail != null;
}
/**
@ -111,9 +98,8 @@ public class ContactBadge extends ImageView implements OnClickListener {
* {@link Contacts#CONTENT_LOOKUP_URI} style URI.
*/
public void assignContactUri(Uri contactUri) {
mContactUri = contactUri;
mContactEmail = null;
mContactPhone = null;
this.contactUri = contactUri;
contactEmail = null;
onContactUriChanged();
}
@ -150,14 +136,14 @@ public class ContactBadge extends ImageView implements OnClickListener {
*/
public void assignContactFromEmail(String emailAddress, boolean lazyLookup, Bundle extras) {
mContactEmail = emailAddress;
mExtras = extras;
contactEmail = emailAddress;
this.extras = extras;
if (!lazyLookup) {
mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP, null,
Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
queryHandler.startQuery(TOKEN_EMAIL_LOOKUP, null,
Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(contactEmail)),
EMAIL_LOOKUP_PROJECTION, null, null, null);
} else {
mContactUri = null;
contactUri = null;
onContactUriChanged();
}
}
@ -171,20 +157,15 @@ public class ContactBadge extends ImageView implements OnClickListener {
// If contact has been assigned, mExtras should no longer be null, but do a null check
// anyway just in case assignContactFromPhone or Email was called with a null bundle or
// wasn't assigned previously.
final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
if (mContactUri != null) {
QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri,
QuickContact.MODE_LARGE, mExcludeMimes);
} else if (mContactEmail != null) {
extras.putString(EXTRA_URI_CONTENT, mContactEmail);
mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
final Bundle extras = (this.extras == null) ? new Bundle() : this.extras;
if (contactUri != null) {
QuickContact.showQuickContact(getContext(), ContactBadge.this, contactUri,
QuickContact.MODE_LARGE, null);
} else if (contactEmail != null) {
extras.putString(EXTRA_URI_CONTENT, contactEmail);
queryHandler.startQuery(TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(contactEmail)),
EMAIL_LOOKUP_PROJECTION, null, null, null);
} else if (mContactPhone != null) {
extras.putString(EXTRA_URI_CONTENT, mContactPhone);
mQueryHandler.startQuery(TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
PHONE_LOOKUP_PROJECTION, null, null, null);
}
}
@ -211,23 +192,9 @@ public class ContactBadge extends ImageView implements OnClickListener {
Uri lookupUri = null;
Uri createUri = null;
boolean trigger = false;
final Bundle extras = (cookie != null) ? (Bundle) cookie : new Bundle();
Bundle extras = (cookie != null) ? (Bundle) cookie : new Bundle();
try {
switch (token) {
case TOKEN_PHONE_LOOKUP_AND_TRIGGER:
trigger = true;
createUri = Uri.fromParts("tel", extras.getString(EXTRA_URI_CONTENT), null);
//$FALL-THROUGH$
case TOKEN_PHONE_LOOKUP: {
if (cursor != null && cursor.moveToFirst()) {
long contactId = cursor.getLong(PHONE_ID_COLUMN_INDEX);
String lookupKey = cursor.getString(PHONE_LOOKUP_STRING_COLUMN_INDEX);
lookupUri = Contacts.getLookupUri(contactId, lookupKey);
}
break;
}
case TOKEN_EMAIL_LOOKUP_AND_TRIGGER:
trigger = true;
createUri = Uri.fromParts("mailto",
@ -249,13 +216,13 @@ public class ContactBadge extends ImageView implements OnClickListener {
}
}
mContactUri = lookupUri;
contactUri = lookupUri;
onContactUriChanged();
if (trigger && lookupUri != null) {
// Found contact, so trigger QuickContact
QuickContact.showQuickContact(getContext(), ContactBadge.this, lookupUri,
QuickContact.MODE_LARGE, ContactBadge.this.mExcludeMimes);
QuickContact.showQuickContact(
getContext(), ContactBadge.this, lookupUri, QuickContact.MODE_LARGE, null);
} else if (createUri != null) {
// Prompt user to add this person to contacts
final Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, createUri);