Browse Source

Add (read-only for now) description to the conversation info

Signed-off-by: Joas Schilling <coding@schilljs.com>
Joas Schilling 4 years ago
parent
commit
bc2fadb4c5

+ 11 - 0
app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt

@@ -125,6 +125,12 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
     @BindView(R.id.display_name_text)
     lateinit var conversationDisplayName: EmojiTextView
 
+    @BindView(R.id.conversation_description)
+    lateinit var descriptionCategoryView: MaterialPreferenceCategory
+
+    @BindView(R.id.description_text)
+    lateinit var conversationDescription: EmojiTextView
+
     @BindView(R.id.participants_list_category)
     lateinit var participantsListCategory: MaterialPreferenceCategory
 
@@ -600,6 +606,11 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
 
                         conversationDisplayName.text = conversation!!.displayName
 
+                        if (conversation!!.description != null && !conversation!!.description.isEmpty()) {
+                            conversationDescription.text = conversation!!.description
+                            descriptionCategoryView.visibility = View.VISIBLE
+                        }
+
                         loadConversationAvatar()
                         adjustNotificationLevelUI()
 

+ 15 - 0
app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java

@@ -46,6 +46,8 @@ public class Conversation {
     public String name;
     @JsonField(name = "displayName")
     public String displayName;
+    @JsonField(name = "description")
+    public String description;
     @JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class)
     public ConversationType type;
     @JsonField(name = "lastPing")
@@ -158,6 +160,10 @@ public class Conversation {
         return this.name;
     }
 
+    public String getDescription() {
+        return this.description;
+    }
+
     public String getDisplayName() {
         return this.displayName;
     }
@@ -246,6 +252,10 @@ public class Conversation {
         this.name = name;
     }
 
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
     public void setDisplayName(String displayName) {
         this.displayName = displayName;
     }
@@ -374,6 +384,9 @@ public class Conversation {
         if (displayName != null ? !displayName.equals(that.displayName) : that.displayName != null) {
             return false;
         }
+        if (description != null ? !description.equals(that.description) : that.description != null) {
+            return false;
+        }
         if (type != that.type) {
             return false;
         }
@@ -423,6 +436,7 @@ public class Conversation {
         result = 31 * result + token.hashCode();
         result = 31 * result + (name != null ? name.hashCode() : 0);
         result = 31 * result + (displayName != null ? displayName.hashCode() : 0);
+        result = 31 * result + (description != null ? description.hashCode() : 0);
         result = 31 * result + type.hashCode();
         result = 31 * result + (int) (lastPing ^ (lastPing >>> 32));
         result = 31 * result + (participants != null ? participants.hashCode() : 0);
@@ -454,6 +468,7 @@ public class Conversation {
                 ", token='" + token + '\'' +
                 ", name='" + name + '\'' +
                 ", displayName='" + displayName + '\'' +
+                ", description='" + description + '\'' +
                 ", type=" + type +
                 ", lastPing=" + lastPing +
                 ", participants=" + participants +

+ 22 - 1
app/src/main/res/layout/controller_conversation_info.xml

@@ -82,10 +82,31 @@
             </com.yarolegovich.mp.MaterialPreferenceCategory>
 
             <com.yarolegovich.mp.MaterialPreferenceCategory
-                android:id="@+id/otherRoomOptions"
+                android:id="@+id/conversation_description"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_below="@id/conversation_info_name"
+                android:animateLayoutChanges="true"
+                android:visibility="gone"
+                apc:cardBackgroundColor="@color/bg_default"
+                apc:cardElevation="0dp"
+                tools:visibility="visible">
+
+                <androidx.emoji.widget.EmojiTextView
+                    android:id="@+id/description_text"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_centerHorizontal="true"
+                    android:layout_margin="@dimen/standard_margin"
+                    android:layout_marginTop="@dimen/margin_between_elements"
+                    tools:text="Hello world!" />
+            </com.yarolegovich.mp.MaterialPreferenceCategory>
+
+            <com.yarolegovich.mp.MaterialPreferenceCategory
+                android:id="@+id/otherRoomOptions"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/conversation_description"
                 android:visibility="gone"
                 apc:cardBackgroundColor="@color/bg_default"
                 apc:cardElevation="0dp"

+ 1 - 1
scripts/analysis/lint-results.txt

@@ -1,2 +1,2 @@
 DO NOT TOUCH; GENERATED BY DRONE
-      <span class="mdl-layout-title">Lint Report: 3 errors and 346 warnings</span>
+      <span class="mdl-layout-title">Lint Report: 3 errors and 348 warnings</span>