Format contact names in MUC properly

This commit is contained in:
Sam Whited 2014-11-07 09:09:28 -05:00
parent 1f5908b1d1
commit dd426ca6de
2 changed files with 26 additions and 23 deletions

View File

@ -69,7 +69,7 @@ public class ConversationActivity extends XmppActivity implements
private View mContentView;
private List<Conversation> conversationList = new ArrayList<Conversation>();
private List<Conversation> conversationList = new ArrayList<>();
private Conversation selectedConversation = null;
private ListView listView;
private ConversationFragment mConversationFragment;
@ -160,8 +160,10 @@ public class ConversationActivity extends XmppActivity implements
this.listAdapter = new ConversationAdapter(this, conversationList);
listView.setAdapter(this.listAdapter);
getActionBar().setDisplayHomeAsUpEnabled(false);
getActionBar().setHomeButtonEnabled(false);
if (getActionBar() != null) {
getActionBar().setDisplayHomeAsUpEnabled(false);
getActionBar().setHomeButtonEnabled(false);
}
listView.setOnItemClickListener(new OnItemClickListener() {
@ -599,7 +601,7 @@ public class ConversationActivity extends XmppActivity implements
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (!isConversationsOverviewVisable()) {
showConversationsOverview();
@ -610,7 +612,7 @@ public class ConversationActivity extends XmppActivity implements
}
@Override
protected void onNewIntent(Intent intent) {
protected void onNewIntent(final Intent intent) {
if (xmppConnectionServiceBound) {
if (intent != null && VIEW_CONVERSATION.equals(intent.getType())) {
handleViewConversationIntent(intent);
@ -644,7 +646,7 @@ public class ConversationActivity extends XmppActivity implements
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
public void onSaveInstanceState(final Bundle savedInstanceState) {
Conversation conversation = getSelectedConversation();
if (conversation != null) {
savedInstanceState.putString(STATE_OPEN_CONVERSATION,
@ -713,11 +715,11 @@ public class ConversationActivity extends XmppActivity implements
}
private void selectConversationByUuid(String uuid) {
for (int i = 0; i < conversationList.size(); ++i) {
if (conversationList.get(i).getUuid().equals(uuid)) {
setSelectedConversation(conversationList.get(i));
}
}
for (Conversation aConversationList : conversationList) {
if (aConversationList.getUuid().equals(uuid)) {
setSelectedConversation(aConversationList);
}
}
}
public void registerListener() {
@ -831,7 +833,7 @@ public class ConversationActivity extends XmppActivity implements
try {
this.startIntentSenderForResult(pi.getIntentSender(), requestCode,
null, 0, 0, 0);
} catch (SendIntentException e1) {
} catch (final SendIntentException ignored) {
}
}

View File

@ -149,7 +149,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
info = contact.getDisplayName();
} else {
if (message.getPresence() != null) {
info = message.getPresence().toString();
info = message.getPresence().getResourcepart();
} else {
info = message.getCounterpart().toString();
}
@ -246,8 +246,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else {
to = message.getCounterpart();
}
privateMarker = activity.getString(
R.string.private_message_to, to);
privateMarker = activity.getString(R.string.private_message_to, to);
}
SpannableString span = new SpannableString(privateMarker + " "
+ message.getBody());
@ -436,7 +435,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.contact_picture.setImageBitmap(activity.avatarService().get(item.getConversation().getAccount(), activity.getPixel(48)));
}
if (viewHolder.contact_picture != null) {
if (viewHolder != null && viewHolder.contact_picture != null) {
viewHolder.contact_picture
.setOnClickListener(new OnClickListener() {
@ -501,14 +500,16 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else {
displayInfoMessage(viewHolder,
R.string.install_openkeychain);
viewHolder.message_box
.setOnClickListener(new OnClickListener() {
if (viewHolder != null) {
viewHolder.message_box
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
activity.showInstallPgpDialog();
}
});
@Override
public void onClick(View v) {
activity.showInstallPgpDialog();
}
});
}
}
} else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
displayDecryptionFailed(viewHolder);