diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 305f1e282a..41abd31776 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -7,6 +7,7 @@ import android.database.Cursor import android.graphics.Rect import android.os.Bundle import android.util.Log +import android.util.TypedValue import android.view.* import android.widget.RelativeLayout import androidx.loader.app.LoaderManager @@ -30,6 +31,7 @@ import org.thoughtcrime.securesms.conversation.v2.input_bar.mentions.MentionCand import org.thoughtcrime.securesms.conversation.v2.menus.ConversationActionModeCallback import org.thoughtcrime.securesms.conversation.v2.menus.ConversationMenuHelper import org.thoughtcrime.securesms.conversation.v2.messages.VisibleMessageView +import org.thoughtcrime.securesms.database.Database import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.DraftDatabase import org.thoughtcrime.securesms.database.DraftDatabase.Drafts @@ -100,6 +102,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe restoreDraftIfNeeded() addOpenGroupGuidelinesIfNeeded() scrollToBottomButton.setOnClickListener { conversationRecyclerView.smoothScrollToPosition(0) } + updateUnreadCount() } private fun setUpRecyclerView() { @@ -319,6 +322,15 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe (scrollButtonFullVisibilityThreshold - scrollButtonNoVisibilityThreshold) val alpha = max(min(rawAlpha, 1.0f), 0.0f) scrollToBottomButton.alpha = alpha + updateUnreadCount() + } + + private fun updateUnreadCount() { + val unreadCount = DatabaseFactory.getMmsSmsDatabase(this).getUnreadCount(threadID) + val formattedUnreadCount = if (unreadCount < 100) unreadCount.toString() else "99+" + unreadCountTextView.text = formattedUnreadCount + val textSize = if (unreadCount < 100) 12.0f else 9.0f + unreadCountTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize) } // endregion diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationRecyclerView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationRecyclerView.kt index e2d37c0fca..3bffcacc0e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationRecyclerView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationRecyclerView.kt @@ -5,6 +5,7 @@ import android.util.AttributeSet import android.util.Log import android.view.MotionEvent import android.view.VelocityTracker +import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.activity_conversation_v2.* import org.thoughtcrime.securesms.loki.utilities.disableClipping @@ -33,6 +34,8 @@ class ConversationRecyclerView : RecyclerView { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { bottomOffset += dy // FIXME: Not sure this is fully accurate, but it seems close enough + val layoutManager = recyclerView.layoutManager as LinearLayoutManager + Log.d("Test", "${layoutManager.findFirstVisibleItemPosition()}") delegate?.handleConversationRecyclerViewBottomOffsetChanged(abs(bottomOffset)) } }) diff --git a/app/src/main/res/layout/activity_conversation_v2.xml b/app/src/main/res/layout/activity_conversation_v2.xml index a975516701..db65017001 100644 --- a/app/src/main/res/layout/activity_conversation_v2.xml +++ b/app/src/main/res/layout/activity_conversation_v2.xml @@ -73,21 +73,48 @@ + android:alpha="1"> - + + + + + + + + + + + diff --git a/app/src/main/res/values-notnight-v21/colors.xml b/app/src/main/res/values-notnight-v21/colors.xml index cb728dfba3..84b91b29dd 100644 --- a/app/src/main/res/values-notnight-v21/colors.xml +++ b/app/src/main/res/values-notnight-v21/colors.xml @@ -31,6 +31,7 @@ #0F000000 #FCFCFC #99000000 + #E0E0E0 #ffffff #fcfcfc diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index fa24a3ecee..edf5373392 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -38,6 +38,7 @@ #000000 #171717 #99FFFFFF + #1F1F1F #5ff8b0