diff options
author | Christian S <christian@pix-art.de> | 2015-07-23 14:08:46 +0200 |
---|---|---|
committer | Christian S <christian@pix-art.de> | 2015-07-23 14:08:46 +0200 |
commit | a3319da5fc8888ffb02e9a2ddcc8f4c37e691f02 (patch) | |
tree | 4044416f699e7100d26bb8eebd8302a72dbe1588 | |
parent | bc7ea463e0f4284e8a7f951aba7b6548d2755107 (diff) | |
parent | 976ffb7b45fb3005d70d65bdb6591da72d13a0e7 (diff) |
add subtitle to ActionBar in chatviews
* display typing info in ActionBar as subtitle for single user chats
* display participants in ActionBar as subtitle in conferences
3 files changed, 36 insertions, 9 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 6d99e3588..b0e128ee8 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -344,6 +344,19 @@ public class Conversation extends AbstractEntity implements Blockable { } } + public String getParticipants() { + if (getMode() == MODE_MULTI) { + String generatedName = getMucOptions().createNameFromParticipants(); + if (generatedName != null) { + return generatedName; + } else { + return getJid().getLocalpart(); + } + } else { + return null; + } + } + public String getAccountUuid() { return this.accountUuid; } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 9980d3bab..3f8841f33 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -17,6 +17,7 @@ import android.provider.MediaStore; import android.support.v4.widget.SlidingPaneLayout; import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener; import android.util.Log; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -51,6 +52,7 @@ import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.ui.adapter.ConversationAdapter; import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.xmpp.OnUpdateBlocklist; +import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; @@ -306,12 +308,12 @@ public class ConversationActivity extends XmppActivity public void switchToConversation(Conversation conversation) { setSelectedConversation(conversation); runOnUiThread(new Runnable() { - @Override - public void run() { - ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation()); - openConversation(); - } - }); + @Override + public void run() { + ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation()); + openConversation(); + } + }); } private void updateActionBarTitle() { @@ -327,13 +329,25 @@ public class ConversationActivity extends XmppActivity ab.setHomeButtonEnabled(true); if (conversation.getMode() == Conversation.MODE_SINGLE || useSubjectToIdentifyConference()) { ab.setTitle(conversation.getName()); + if (conversation.getMode() == Conversation.MODE_SINGLE) { + ChatState state = conversation.getIncomingChatState(); + if (state == ChatState.COMPOSING) { + ab.setSubtitle(getString(R.string.contact_is_typing, conversation.getName())); + } else if (state == ChatState.PAUSED) { + ab.setSubtitle(null); + } + } else if (useSubjectToIdentifyConference()){ + ab.setSubtitle(conversation.getParticipants() + ", " + getText(R.string.you)); + } } else { ab.setTitle(conversation.getJid().toBareJid().toString()); + ab.setSubtitle(null); } } else { ab.setDisplayHomeAsUpEnabled(false); - ab.setHomeButtonEnabled(false); + ab.setHomeButtonEnabled(false); ab.setTitle(R.string.app_name); + ab.setSubtitle(null); } } } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 842447c1f..80f63d812 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -995,9 +995,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa if (conversation.getMode() == Conversation.MODE_SINGLE) { ChatState state = conversation.getIncomingChatState(); if (state == ChatState.COMPOSING) { - this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_is_typing, conversation.getName()))); + //this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_is_typing, conversation.getName()))); } else if (state == ChatState.PAUSED) { - this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_has_stopped_typing, conversation.getName()))); + //this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_has_stopped_typing, conversation.getName()))); } else { for (int i = this.messageList.size() - 1; i >= 0; --i) { if (this.messageList.get(i).getStatus() == Message.STATUS_RECEIVED) { |