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

@ -83,8 +83,10 @@ public class Contact implements ListItem {
return this.serverName; return this.serverName;
} else if (this.presenceName != null) { } else if (this.presenceName != null) {
return this.presenceName; return this.presenceName;
} else { } else if (jid.hasLocalpart()) {
return jid.getLocalpart(); return jid.getLocalpart();
} else {
return jid.getDomainpart();
} }
} }

View file

@ -36,7 +36,7 @@ public class AvatarService {
this.mXmppConnectionService = service; 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); final String KEY = key(contact, size);
Bitmap avatar = this.mXmppConnectionService.getBitmapCache().get(KEY); Bitmap avatar = this.mXmppConnectionService.getBitmapCache().get(KEY);
if (avatar != null) { if (avatar != null) {
@ -196,7 +196,7 @@ public class AvatarService {
+ String.valueOf(size); + 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); final String KEY = key(name, size);
Bitmap bitmap = mXmppConnectionService.getBitmapCache().get(KEY); Bitmap bitmap = mXmppConnectionService.getBitmapCache().get(KEY);
if (bitmap != null) { if (bitmap != null) {

View file

@ -1,15 +1,10 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.AlertDialog;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -27,21 +22,8 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; 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.R;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.UIHelper;
@ -111,7 +93,7 @@ public class EditAccountActivity extends XmppActivity {
if (mAccount != null) { if (mAccount != null) {
mAccount.setPassword(password); mAccount.setPassword(password);
try { try {
mAccount.setUsername(jid.hasLocalPart() ? jid.getLocalpart() : ""); mAccount.setUsername(jid.hasLocalpart() ? jid.getLocalpart() : "");
mAccount.setServer(jid.getDomainpart()); mAccount.setServer(jid.getDomainpart());
} catch (final InvalidJidException ignored) { } catch (final InvalidJidException ignored) {
} }

View file

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