Create avatar's for JID's w/o localparts

This commit is contained in:
Sam Whited 2014-11-07 22:34:54 -05:00
parent 5ce0cd3802
commit 1a3327f2b1
4 changed files with 13 additions and 29 deletions

View File

@ -78,14 +78,16 @@ public class Contact implements ListItem {
public String getDisplayName() {
if (this.systemName != null) {
return this.systemName;
} else if (this.serverName != null) {
return this.serverName;
return this.systemName;
} else if (this.serverName != null) {
return this.serverName;
} else if (this.presenceName != null) {
return this.presenceName;
return this.presenceName;
} else if (jid.hasLocalpart()) {
return jid.getLocalpart();
} else {
return jid.getLocalpart();
}
return jid.getDomainpart();
}
}
public String getProfilePhoto() {

View File

@ -36,7 +36,7 @@ public class AvatarService {
this.mXmppConnectionService = service;
}
public Bitmap get(Contact contact, int size) {
public Bitmap get(final Contact contact, final int size) {
final String KEY = key(contact, size);
Bitmap avatar = this.mXmppConnectionService.getBitmapCache().get(KEY);
if (avatar != null) {
@ -49,7 +49,7 @@ public class AvatarService {
avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatar(), size);
}
if (avatar == null) {
avatar = get(contact.getDisplayName(), size);
avatar = get(contact.getDisplayName(), size);
}
this.mXmppConnectionService.getBitmapCache().put(KEY, avatar);
return avatar;
@ -196,7 +196,7 @@ public class AvatarService {
+ String.valueOf(size);
}
public Bitmap get(String name, int size) {
public Bitmap get(final String name, final int size) {
final String KEY = key(name, size);
Bitmap bitmap = mXmppConnectionService.getBitmapCache().get(KEY);
if (bitmap != null) {

View File

@ -1,15 +1,10 @@
package eu.siacs.conversations.ui;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -27,21 +22,8 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.util.Hashtable;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.utils.UIHelper;
@ -111,7 +93,7 @@ public class EditAccountActivity extends XmppActivity {
if (mAccount != null) {
mAccount.setPassword(password);
try {
mAccount.setUsername(jid.hasLocalPart() ? jid.getLocalpart() : "");
mAccount.setUsername(jid.hasLocalpart() ? jid.getLocalpart() : "");
mAccount.setServer(jid.getDomainpart());
} catch (final InvalidJidException ignored) {
}

View File

@ -162,7 +162,7 @@ public final class Jid {
return result;
}
public boolean hasLocalPart() {
public boolean hasLocalpart() {
return !localpart.isEmpty();
}