diff --git a/res/anim/fade_scale_out.xml b/res/anim/fade_scale_out.xml
index c87edc7ee6..7a48373a4e 100644
--- a/res/anim/fade_scale_out.xml
+++ b/res/anim/fade_scale_out.xml
@@ -5,7 +5,7 @@
android:interpolator="@android:anim/decelerate_interpolator">
diff --git a/res/anim/slide_from_left.xml b/res/anim/slide_from_left.xml
index 5369636d1e..0253917658 100644
--- a/res/anim/slide_from_left.xml
+++ b/res/anim/slide_from_left.xml
@@ -5,7 +5,7 @@
android:interpolator="@android:anim/decelerate_interpolator">
diff --git a/res/anim/slide_from_right.xml b/res/anim/slide_from_right.xml
index f94fbcc957..c9e7c215e6 100644
--- a/res/anim/slide_from_right.xml
+++ b/res/anim/slide_from_right.xml
@@ -5,7 +5,7 @@
android:interpolator="@android:anim/decelerate_interpolator">
diff --git a/res/drawable/profile_picture_view_medium_background.xml b/res/drawable/profile_picture_view_medium_background.xml
new file mode 100644
index 0000000000..287d6298e2
--- /dev/null
+++ b/res/drawable/profile_picture_view_medium_background.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/profile_picture_view_rss_medium_background.xml b/res/drawable/profile_picture_view_rss_medium_background.xml
new file mode 100644
index 0000000000..b060c41b4b
--- /dev/null
+++ b/res/drawable/profile_picture_view_rss_medium_background.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/profile_picture_view_small_background.xml b/res/drawable/profile_picture_view_small_background.xml
new file mode 100644
index 0000000000..2f44fefe9f
--- /dev/null
+++ b/res/drawable/profile_picture_view_small_background.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/conversation_view.xml b/res/layout/conversation_view.xml
index d91fbee0d4..531313a97c 100644
--- a/res/layout/conversation_view.xml
+++ b/res/layout/conversation_view.xml
@@ -1,5 +1,5 @@
-
-
+ android:layout_marginBottom="@dimen/medium_spacing" />
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/res/layout/fake_chat_content_view.xml b/res/layout/fake_chat_view.xml
similarity index 100%
rename from res/layout/fake_chat_content_view.xml
rename to res/layout/fake_chat_view.xml
diff --git a/res/layout/profile_picture_view.xml b/res/layout/profile_picture_view.xml
new file mode 100644
index 0000000000..660db39c45
--- /dev/null
+++ b/res/layout/profile_picture_view.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 96b204361d..a08282ab79 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -5,6 +5,7 @@
#00F782
#FFFFFF
#D8D8D8
+ #979797
#1B1B1B
#0C0C0C
#171717
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b673e861a1..81f5197b2e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -14,9 +14,11 @@
48dp
4dp
- 45dp
+ 36dp
+ 46dp
14dp
2dp
+ 1dp
56dp
8dp
224dp
diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/ConversationAdapter.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/ConversationAdapter.kt
index ca2728c09d..fbb9f16d7a 100644
--- a/src/org/thoughtcrime/securesms/loki/redesign/activities/ConversationAdapter.kt
+++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/ConversationAdapter.kt
@@ -16,7 +16,7 @@ class ConversationAdapter(context: Context, cursor: Cursor) : CursorRecyclerView
class ViewHolder(val view: ConversationView) : RecyclerView.ViewHolder(view)
override fun onCreateItemViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
- val view = ConversationView.get(context, parent)
+ val view = ConversationView(context)
view.setOnClickListener { conversationClickListener?.onConversationClick(view) }
view.setOnLongClickListener {
conversationClickListener?.onLongConversationClick(view)
diff --git a/src/org/thoughtcrime/securesms/loki/redesign/activities/DisplayNameActivity.kt b/src/org/thoughtcrime/securesms/loki/redesign/activities/DisplayNameActivity.kt
index 5bb483e7c5..4b376975f3 100644
--- a/src/org/thoughtcrime/securesms/loki/redesign/activities/DisplayNameActivity.kt
+++ b/src/org/thoughtcrime/securesms/loki/redesign/activities/DisplayNameActivity.kt
@@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.loki.redesign.utilities.setUpActionBarSessionL
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.api.crypto.ProfileCipher
+
class DisplayNameActivity : BaseActionBarActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -54,7 +55,8 @@ class DisplayNameActivity : BaseActionBarActivity() {
val servers = DatabaseFactory.getLokiThreadDatabase(this).getAllPublicChatServers()
servers.forEach { publicChatAPI.setDisplayName(displayName, it) }
}
- startActivity(Intent(this, ConversationListActivity::class.java))
+ val intent = Intent(this, ConversationListActivity::class.java)
+ intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
push(intent)
}
}
\ No newline at end of file
diff --git a/src/org/thoughtcrime/securesms/loki/redesign/views/ConversationView.kt b/src/org/thoughtcrime/securesms/loki/redesign/views/ConversationView.kt
index c2d292ee1e..59fbe28095 100644
--- a/src/org/thoughtcrime/securesms/loki/redesign/views/ConversationView.kt
+++ b/src/org/thoughtcrime/securesms/loki/redesign/views/ConversationView.kt
@@ -5,7 +5,6 @@ import android.graphics.Typeface
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
-import android.view.ViewGroup
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.conversation_view.view.*
import network.loki.messenger.R
@@ -13,26 +12,34 @@ import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.loki.LokiAPIUtilities.populateUserHexEncodedPublicKeyCacheIfNeeded
import org.thoughtcrime.securesms.loki.MentionUtilities.highlightMentions
import org.thoughtcrime.securesms.util.DateUtils
+import org.whispersystems.signalservice.loki.api.LokiAPI
import java.util.*
class ConversationView : LinearLayout {
var thread: ThreadRecord? = null
// region Lifecycle
- companion object {
-
- fun get(context: Context, parent: ViewGroup?): ConversationView {
- return LayoutInflater.from(context).inflate(R.layout.conversation_view, parent, false) as ConversationView
- }
+ constructor(context: Context) : super(context) {
+ setUpViewHierarchy()
}
- constructor(context: Context) : super(context)
+ constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
+ setUpViewHierarchy()
+ }
- constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
+ constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
+ setUpViewHierarchy()
+ }
- constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
+ constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
+ setUpViewHierarchy()
+ }
- constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
+ private fun setUpViewHierarchy() {
+ val inflater = context.applicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+ val contentView = inflater.inflate(R.layout.conversation_view, null)
+ addView(contentView)
+ }
// endregion
// region Updating
@@ -40,6 +47,18 @@ class ConversationView : LinearLayout {
this.thread = thread
populateUserHexEncodedPublicKeyCacheIfNeeded(thread.threadId, context) // FIXME: This is a terrible place to do this
unreadMessagesIndicatorView.visibility = if (thread.unreadCount > 0) View.VISIBLE else View.INVISIBLE
+ if (thread.recipient.isGroupRecipient) {
+ val users = LokiAPI.userHexEncodedPublicKeyCache[thread.threadId]?.toList() ?: listOf()
+ val randomUsers = users.sorted() // Sort to provide a level of stability
+ profilePictureView.hexEncodedPublicKey = randomUsers.getOrNull(0) ?: ""
+ profilePictureView.additionalHexEncodedPublicKey = randomUsers.getOrNull(1) ?: ""
+ profilePictureView.isRSSFeed = thread.recipient.name == "Loki News" || thread.recipient.name == "Loki Messenger Updates"
+ } else {
+ profilePictureView.hexEncodedPublicKey = thread.recipient.address.toString()
+ profilePictureView.additionalHexEncodedPublicKey = null
+ profilePictureView.isRSSFeed = false
+ }
+ profilePictureView.update()
val senderDisplayName = if (thread.recipient.isLocalNumber) context.getString(R.string.note_to_self) else thread.recipient.name
displayNameTextView.text = senderDisplayName
timestampTextView.text = DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), thread.date)
diff --git a/src/org/thoughtcrime/securesms/loki/redesign/views/FakeChatView.kt b/src/org/thoughtcrime/securesms/loki/redesign/views/FakeChatView.kt
index 88a739beb5..87ceda515c 100644
--- a/src/org/thoughtcrime/securesms/loki/redesign/views/FakeChatView.kt
+++ b/src/org/thoughtcrime/securesms/loki/redesign/views/FakeChatView.kt
@@ -7,7 +7,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ScrollView
-import kotlinx.android.synthetic.main.fake_chat_content_view.view.*
+import kotlinx.android.synthetic.main.fake_chat_view.view.*
import network.loki.messenger.R
class FakeChatView : ScrollView {
@@ -38,7 +38,7 @@ class FakeChatView : ScrollView {
private fun setUpViewHierarchy() {
val inflater = context.applicationContext.getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater
- val contentView = inflater.inflate(R.layout.fake_chat_content_view, null)
+ val contentView = inflater.inflate(R.layout.fake_chat_view, null)
addView(contentView)
isVerticalScrollBarEnabled = false
}
diff --git a/src/org/thoughtcrime/securesms/loki/redesign/views/ProfilePictureView.kt b/src/org/thoughtcrime/securesms/loki/redesign/views/ProfilePictureView.kt
new file mode 100644
index 0000000000..9c657d1a87
--- /dev/null
+++ b/src/org/thoughtcrime/securesms/loki/redesign/views/ProfilePictureView.kt
@@ -0,0 +1,47 @@
+package org.thoughtcrime.securesms.loki.redesign.views
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import android.view.View
+import android.widget.RelativeLayout
+import kotlinx.android.synthetic.main.profile_picture_view.view.*
+import network.loki.messenger.R
+
+class ProfilePictureView : RelativeLayout {
+ var hexEncodedPublicKey: String? = null
+ var additionalHexEncodedPublicKey: String? = null
+ var isRSSFeed = false
+
+ // region Lifecycle
+ constructor(context: Context) : super(context) {
+ setUpViewHierarchy()
+ }
+
+ constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
+ setUpViewHierarchy()
+ }
+
+ constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
+ setUpViewHierarchy()
+ }
+
+ constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
+ setUpViewHierarchy()
+ }
+
+ private fun setUpViewHierarchy() {
+ val inflater = context.applicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
+ val contentView = inflater.inflate(R.layout.profile_picture_view, null)
+ addView(contentView)
+ }
+
+ fun update() {
+ val hexEncodedPublicKey = hexEncodedPublicKey ?: return
+ val additionalHexEncodedPublicKey = additionalHexEncodedPublicKey
+ doubleModeImageViewContainer.visibility = if (additionalHexEncodedPublicKey != null && !isRSSFeed) View.VISIBLE else View.INVISIBLE
+ singleModeImageView.visibility = if (additionalHexEncodedPublicKey == null && !isRSSFeed) View.VISIBLE else View.INVISIBLE
+ rssTextView.visibility = if (isRSSFeed) View.VISIBLE else View.INVISIBLE
+ }
+ // endregion
+}
\ No newline at end of file