mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 12:43:39 +00:00
Apply correct message bubble margins
This commit is contained in:
parent
958cd54b75
commit
dc4a7d0761
@ -3,7 +3,9 @@ package org.thoughtcrime.securesms.conversation.v2.messages
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import kotlinx.android.synthetic.main.view_control_message.view.*
|
import kotlinx.android.synthetic.main.view_control_message.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||||
@ -30,6 +32,11 @@ class ControlMessageView : LinearLayout {
|
|||||||
|
|
||||||
// region Updating
|
// region Updating
|
||||||
fun bind(message: MessageRecord) {
|
fun bind(message: MessageRecord) {
|
||||||
|
iconImageView.visibility = View.GONE
|
||||||
|
if (message.isExpirationTimerUpdate) {
|
||||||
|
iconImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_timer, context.theme))
|
||||||
|
iconImageView.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
textView.text = message.getDisplayBody(context)
|
textView.text = message.getDisplayBody(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,15 @@ package org.thoughtcrime.securesms.conversation.v2.messages
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import androidx.core.graphics.BlendModeColorFilterCompat
|
import androidx.core.graphics.BlendModeColorFilterCompat
|
||||||
import androidx.core.graphics.BlendModeCompat
|
import androidx.core.graphics.BlendModeCompat
|
||||||
|
import androidx.core.view.setMargins
|
||||||
|
import androidx.core.view.setPadding
|
||||||
import kotlinx.android.synthetic.main.view_visible_message_content.view.*
|
import kotlinx.android.synthetic.main.view_visible_message_content.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.ThemeUtil
|
import org.session.libsession.utilities.ThemeUtil
|
||||||
@ -70,8 +73,10 @@ class VisibleMessageContentView : LinearLayout {
|
|||||||
// region Convenience
|
// region Convenience
|
||||||
private fun getBodyTextView(body: String): TextView {
|
private fun getBodyTextView(body: String): TextView {
|
||||||
val result = TextView(context)
|
val result = TextView(context)
|
||||||
|
result.setPadding(resources.getDimension(R.dimen.small_spacing).toInt())
|
||||||
result.text = body
|
result.text = body
|
||||||
// TODO: Styling
|
result.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.medium_font_size))
|
||||||
|
// TODO: Further styling
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
@ -62,8 +62,14 @@ class VisibleMessageView : LinearLayout {
|
|||||||
dateBreakTextView.visibility = View.GONE // TODO: Set this correctly
|
dateBreakTextView.visibility = View.GONE // TODO: Set this correctly
|
||||||
// Margins
|
// Margins
|
||||||
val messageContentViewLayoutParams = messageContentView.layoutParams as LinearLayout.LayoutParams
|
val messageContentViewLayoutParams = messageContentView.layoutParams as LinearLayout.LayoutParams
|
||||||
|
if (isGroupThread) {
|
||||||
messageContentViewLayoutParams.leftMargin = if (message.isOutgoing) resources.getDimension(R.dimen.very_large_spacing).toInt() else 0
|
messageContentViewLayoutParams.leftMargin = if (message.isOutgoing) resources.getDimension(R.dimen.very_large_spacing).toInt() else 0
|
||||||
messageContentViewLayoutParams.rightMargin = if (message.isOutgoing) 0 else resources.getDimension(R.dimen.very_large_spacing).toInt()
|
} else {
|
||||||
|
messageContentViewLayoutParams.leftMargin = if (message.isOutgoing) resources.getDimension(R.dimen.very_large_spacing).toInt()
|
||||||
|
else resources.getDimension(R.dimen.medium_spacing).toInt()
|
||||||
|
}
|
||||||
|
messageContentViewLayoutParams.rightMargin = if (message.isOutgoing) resources.getDimension(R.dimen.medium_spacing).toInt()
|
||||||
|
else resources.getDimension(R.dimen.very_large_spacing).toInt()
|
||||||
messageContentView.layoutParams = messageContentViewLayoutParams
|
messageContentView.layoutParams = messageContentViewLayoutParams
|
||||||
// TODO: Inter-message spacing
|
// TODO: Inter-message spacing
|
||||||
// Gravity
|
// Gravity
|
||||||
|
@ -3,14 +3,23 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
|
android:paddingVertical="@dimen/medium_spacing"
|
||||||
|
android:paddingHorizontal="@dimen/massive_spacing"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iconImageView"
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:layout_marginBottom="@dimen/small_spacing" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="@dimen/medium_font_size"
|
android:textSize="@dimen/medium_font_size"
|
||||||
android:textColor="@color/text" />
|
android:textColor="@color/text"
|
||||||
|
android:gravity="center" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user