Skip to content
Snippets Groups Projects
Verified Commit 1f3c9531 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Display smaller avatars for /me actions. Fixes #118

parent edb5db77
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -293,7 +293,12 @@ class MessageListFragment : ServiceBoundFragment() {
return list.mapReverse {
val date = it.time.atZone(ZoneId.systemDefault()).truncatedTo(ChronoUnit.DAYS)
val isSameDay = previousDate?.isEqual(date) ?: false
val isFollowUp = previous?.sender == it.sender && previous?.type == it.type && isSameDay
if (it.sender.startsWith("testcrc3")) {
println("$previous:$it")
}
val isFollowUp = previous?.sender == it.sender &&
(previous?.type?.hasFlag(Message_Type.Plain) == true || previous?.type == it.type) &&
isSameDay
previous = it
previousDate = date
DisplayMessage(
......
......@@ -26,6 +26,7 @@ import android.graphics.drawable.LayerDrawable
import android.os.Build
import android.text.SpannableStringBuilder
import android.util.TypedValue
import android.view.Gravity
import android.view.View
import android.widget.FrameLayout
import android.widget.LinearLayout
......@@ -165,15 +166,22 @@ class QuasselMessageRenderer @Inject constructor(
val contentSize = if (messageSettings.largerEmoji && isEmoji) textSize * 2f else textSize
viewHolder.content?.setTextSize(TypedValue.COMPLEX_UNIT_SP, contentSize)
viewHolder.combined?.setTextSize(TypedValue.COMPLEX_UNIT_SP, contentSize)
val avatarSize = TypedValue.applyDimension(
val avatarContainerSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
textSize * 2.5f,
viewHolder.itemView.context.resources.displayMetrics
).roundToInt()
viewHolder.avatar?.layoutParams =
FrameLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, avatarSize)
val avatarSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
if (messageType == Plain) textSize * 2.5f
else textSize * 1.5f,
viewHolder.itemView.context.resources.displayMetrics
).roundToInt()
viewHolder.avatar?.layoutParams = FrameLayout.LayoutParams(avatarSize, avatarSize).apply {
gravity = Gravity.END
}
avatarContainer?.layoutParams =
LinearLayout.LayoutParams(avatarSize, LinearLayout.LayoutParams.WRAP_CONTENT).apply {
LinearLayout.LayoutParams(avatarContainerSize, LinearLayout.LayoutParams.WRAP_CONTENT).apply {
val margin = viewHolder.itemView.context.resources.getDimensionPixelSize(R.dimen.message_horizontal)
setMargins(0, 0, margin, 0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
......@@ -181,7 +189,7 @@ class QuasselMessageRenderer @Inject constructor(
}
}
avatarPlaceholder?.layoutParams =
LinearLayout.LayoutParams(avatarSize, LinearLayout.LayoutParams.MATCH_PARENT).apply {
LinearLayout.LayoutParams(avatarContainerSize, LinearLayout.LayoutParams.MATCH_PARENT).apply {
val margin = viewHolder.itemView.context.resources.getDimensionPixelSize(R.dimen.message_horizontal)
setMargins(0, 0, margin, 0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
......@@ -257,7 +265,21 @@ class QuasselMessageRenderer @Inject constructor(
isSelected = message.isSelected
)
}
Message_Type.Action -> FormattedMessage(
Message_Type.Action -> {
val nickName = HostmaskHelper.nick(message.content.sender)
val senderColorIndex = SenderColorUtil.senderColor(nickName)
val rawInitial = nickName.trimStart('-', '_', '[', ']', '{', '}', '|', '`', '^', '.', '\\')
.firstOrNull() ?: nickName.firstOrNull()
val initial = rawInitial?.toUpperCase().toString()
val senderColor = when (messageSettings.colorizeNicknames) {
MessageSettings.ColorizeNicknamesMode.ALL -> senderColors[senderColorIndex]
MessageSettings.ColorizeNicknamesMode.ALL_BUT_MINE ->
if (message.content.flag.hasFlag(Message_Flag.Self)) selfColor
else senderColors[senderColorIndex]
MessageSettings.ColorizeNicknamesMode.NONE -> selfColor
}
FormattedMessage(
id = message.content.messageId,
time = timeFormatter.format(message.content.time.atZone(zoneId)),
dayChange = formatDayChange(message),
......@@ -267,11 +289,17 @@ class QuasselMessageRenderer @Inject constructor(
contentFormatter.formatNick(message.content.sender, self, monochromeForeground, false),
contentFormatter.formatContent(message.content.content, monochromeForeground)
),
avatarUrls = AvatarHelper.avatar(messageSettings, message.content, avatarSize),
fallbackDrawable = TextDrawable.builder().let {
if (messageSettings.squareAvatars) it.buildRect(initial, senderColor)
else it.buildRound(initial, senderColor)
},
hasDayChange = message.hasDayChange,
isMarkerLine = message.isMarkerLine,
isExpanded = message.isExpanded,
isSelected = message.isSelected
)
}
Message_Type.Notice -> FormattedMessage(
id = message.content.messageId,
time = timeFormatter.format(message.content.time.atZone(zoneId)),
......
......@@ -21,8 +21,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:showIn="@layout/fragment_messages">
android:orientation="vertical">
<include layout="@layout/widget_chatmessage_daychange" />
......@@ -49,25 +48,60 @@
android:layout_marginRight="@dimen/message_horizontal"
android:textColor="?attr/colorForegroundSecondary"
android:typeface="monospace"
tools:text="@sample/messages.json/data/time" />
tools:text="@sample/messages.json/data/time"
tools:visibility="gone" />
<Space
android:id="@+id/avatar_placeholder"
<FrameLayout
android:id="@+id/avatar_container"
android:layout_width="@dimen/avatar_size"
android:layout_height="match_parent"
android:layout_height="@dimen/avatar_size"
android:layout_marginEnd="@dimen/message_horizontal"
android:layout_marginRight="@dimen/message_horizontal"
android:visibility="gone" />
android:visibility="gone"
tools:ignore="UselessParent"
tools:visibility="visible">
<ImageView
android:id="@+id/avatar"
android:layout_width="21sp"
android:layout_height="21sp"
android:layout_gravity="end"
android:contentDescription="@string/label_avatar"
tools:src="@tools:sample/avatars" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|fill_horizontal"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<de.kuschku.quasseldroid.util.ui.RipplePassthroughTextView
android:id="@+id/content"
style="@style/Widget.RtlConformTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?attr/colorForeground"
android:visibility="gone"
tools:text="@sample/messages.json/data/content"
tools:visibility="visible" />
<de.kuschku.quasseldroid.util.ui.RipplePassthroughTextView
android:id="@+id/combined"
style="@style/Widget.RtlConformTextView"
android:layout_width="0dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="?attr/colorForegroundAction"
android:textStyle="italic"
tools:text="@sample/messages.json/data/message" />
android:textColor="?attr/colorForeground"
tools:text="@sample/messages.json/data/message"
tools:visibility="gone" />
</LinearLayout>
<TextView
android:id="@+id/time_right"
......@@ -84,3 +118,5 @@
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
......@@ -36,6 +36,7 @@
<dimen name="colorchooser_circlesize">56dp</dimen>
<dimen name="avatar_size">35sp</dimen>
<dimen name="avatar_size_action">20sp</dimen>
<dimen name="notification_avatar_width">64dp</dimen>
<dimen name="notification_avatar_height">64dp</dimen>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment