fixed #452

iNPUTmice created

Change summary

res/values/strings.xml                                         | 4 +
res/xml/preferences.xml                                        | 5 ++
src/eu/siacs/conversations/ui/ConversationActivity.java        | 6 ++
src/eu/siacs/conversations/ui/ConversationFragment.java        | 6 ++
src/eu/siacs/conversations/ui/XmppActivity.java                | 7 ++++
src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 6 ++
6 files changed, 30 insertions(+), 4 deletions(-)

Detailed changes

res/values/strings.xml πŸ”—

@@ -259,5 +259,7 @@
     <string name="pref_use_indicate_received_summary">Received masseges will be marked with a green tick. Be aware that this might no work in every case.</string>
     <string name="pref_use_send_button_to_indicate_status_summary">Colorize send button to indicate contact status</string>
     <string name="pref_expert_options_other">Other</string>
+    <string name="pref_conference_name">Conference name</string>
+    <string name="pref_conference_name_summary">Use room’s subject instead of JID to identify conferences</string>
 
-</resources>
+</resources>

res/xml/preferences.xml πŸ”—

@@ -63,6 +63,11 @@
             android:title="@string/pref_notification_grace_period" />
     </PreferenceCategory>
     <PreferenceCategory android:title="@string/pref_ui_options" >
+        <CheckBoxPreference
+            android:defaultValue="true"
+            android:key="use_subject"
+            android:summary="@string/pref_conference_name_summary"
+            android:title="@string/pref_conference_name" />
         <CheckBoxPreference
             android:defaultValue="false"
             android:key="use_larger_font"

src/eu/siacs/conversations/ui/ConversationActivity.java πŸ”—

@@ -154,7 +154,11 @@ public class ConversationActivity extends XmppActivity implements
 					if (ab != null) {
 						ab.setDisplayHomeAsUpEnabled(true);
 						ab.setHomeButtonEnabled(true);
-						ab.setTitle(getSelectedConversation().getName());
+						if (getSelectedConversation().getMode() == Conversation.MODE_SINGLE || activity.useSubjectToIdentifyConference()) {
+							ab.setTitle(getSelectedConversation().getName());
+						} else {
+							ab.setTitle(getSelectedConversation().getContactJid().split("/")[0]);
+						}
 					}
 					invalidateOptionsMenu();
 					if (!getSelectedConversation().isRead()) {

src/eu/siacs/conversations/ui/ConversationFragment.java πŸ”—

@@ -380,7 +380,11 @@ public class ConversationFragment extends Fragment {
 				activity.getSlidingPaneLayout().closePane();
 				activity.getActionBar().setDisplayHomeAsUpEnabled(true);
 				activity.getActionBar().setHomeButtonEnabled(true);
-				activity.getActionBar().setTitle(conversation.getName());
+				if (conversation.getMode() == Conversation.MODE_SINGLE || activity.useSubjectToIdentifyConference()) {
+					activity.getActionBar().setTitle(conversation.getName());
+				} else {
+					activity.getActionBar().setTitle(conversation.getContactJid().split("/")[0]);
+				}
 				activity.invalidateOptionsMenu();
 			}
 		}

src/eu/siacs/conversations/ui/XmppActivity.java πŸ”—

@@ -62,6 +62,8 @@ public abstract class XmppActivity extends Activity {
 	protected int mColorOrange;
 	protected int mColorGreen;
 	protected int mPrimaryColor;
+	
+	protected boolean mUseSubject = true;
 
 	private DisplayMetrics metrics;
 
@@ -207,12 +209,17 @@ public abstract class XmppActivity extends Activity {
 		if (getPreferences().getBoolean("use_larger_font", false)) {
 			setTheme(R.style.ConversationsTheme_LargerText);
 		}
+		mUseSubject = getPreferences().getBoolean("use_subject", true);
 	}
 
 	protected SharedPreferences getPreferences() {
 		return PreferenceManager
 				.getDefaultSharedPreferences(getApplicationContext());
 	}
+	
+	public boolean useSubjectToIdentifyConference() {
+		return mUseSubject;
+	}
 
 	public void switchToConversation(Conversation conversation) {
 		switchToConversation(conversation, null, false);

src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java πŸ”—

@@ -52,7 +52,11 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
 		}
 		TextView convName = (TextView) view
 				.findViewById(R.id.conversation_name);
-		convName.setText(conv.getName());
+		if (conv.getMode() == Conversation.MODE_SINGLE || activity.useSubjectToIdentifyConference()) {
+			convName.setText(conv.getName());
+		} else {
+			convName.setText(conv.getContactJid().split("/")[0]);
+		}
 		TextView convLastMsg = (TextView) view
 				.findViewById(R.id.conversation_lastmsg);
 		ImageView imagePreview = (ImageView) view