only change actionbar display options when changed

This commit is contained in:
Daniel Gultsch 2017-02-18 18:08:37 +01:00
parent 79858278e0
commit abaabae853
1 changed files with 9 additions and 7 deletions

View File

@ -203,9 +203,9 @@ public class ConversationActivity extends XmppActivity
this.listAdapter = new ConversationAdapter(this, conversationList); this.listAdapter = new ConversationAdapter(this, conversationList);
listView.setAdapter(this.listAdapter); listView.setAdapter(this.listAdapter);
if (getActionBar() != null) { final ActionBar actionBar = getActionBar();
getActionBar().setDisplayHomeAsUpEnabled(false); if (actionBar != null) {
getActionBar().setHomeButtonEnabled(false); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);
} }
listView.setOnItemClickListener(new OnItemClickListener() { listView.setOnItemClickListener(new OnItemClickListener() {
@ -351,16 +351,18 @@ public class ConversationActivity extends XmppActivity
final Conversation conversation = getSelectedConversation(); final Conversation conversation = getSelectedConversation();
if (ab != null) { if (ab != null) {
if (titleShouldBeName && conversation != null) { if (titleShouldBeName && conversation != null) {
ab.setDisplayHomeAsUpEnabled(true); if ((ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != ActionBar.DISPLAY_HOME_AS_UP) {
ab.setHomeButtonEnabled(true); ab.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
}
if (conversation.getMode() == Conversation.MODE_SINGLE || useSubjectToIdentifyConference()) { if (conversation.getMode() == Conversation.MODE_SINGLE || useSubjectToIdentifyConference()) {
ab.setTitle(conversation.getName()); ab.setTitle(conversation.getName());
} else { } else {
ab.setTitle(conversation.getJid().toBareJid().toString()); ab.setTitle(conversation.getJid().toBareJid().toString());
} }
} else { } else {
ab.setDisplayHomeAsUpEnabled(false); if ((ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) == ActionBar.DISPLAY_HOME_AS_UP) {
ab.setHomeButtonEnabled(false); ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);
}
ab.setTitle(R.string.app_name); ab.setTitle(R.string.app_name);
} }
} }