Skip to content
Snippets Groups Projects
Commit 11ebeef8 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Prepare for larger emoji

parent 2da52a44
Branches
Tags
No related merge requests found
Showing
with 77 additions and 27 deletions
...@@ -12,7 +12,8 @@ data class MessageSettings( ...@@ -12,7 +12,8 @@ data class MessageSettings(
val showHostmaskPlain: Boolean = false, val showHostmaskPlain: Boolean = false,
val nicksOnNewLine: Boolean = false, val nicksOnNewLine: Boolean = false,
val timeAtEnd: Boolean = false, val timeAtEnd: Boolean = false,
val showAvatars: Boolean = false val showAvatars: Boolean = false,
val largerEmoji: Boolean = false
) { ) {
enum class ColorizeNicknamesMode { enum class ColorizeNicknamesMode {
......
...@@ -81,6 +81,10 @@ object Settings { ...@@ -81,6 +81,10 @@ object Settings {
showAvatars = getBoolean( showAvatars = getBoolean(
context.getString(R.string.preference_show_avatars_key), context.getString(R.string.preference_show_avatars_key),
MessageSettings.DEFAULT.showAvatars MessageSettings.DEFAULT.showAvatars
),
largerEmoji = getBoolean(
context.getString(R.string.preference_larger_emoji_key),
MessageSettings.DEFAULT.largerEmoji
) )
) )
} }
......
...@@ -10,7 +10,8 @@ data class DisplayMessage( ...@@ -10,7 +10,8 @@ data class DisplayMessage(
val isFollowUp: Boolean, val isFollowUp: Boolean,
val isSelected: Boolean, val isSelected: Boolean,
val isExpanded: Boolean, val isExpanded: Boolean,
val isMarkerLine: Boolean val isMarkerLine: Boolean,
val isEmoji: Boolean
) { ) {
data class Tag( data class Tag(
val id: MsgId, val id: MsgId,
...@@ -18,10 +19,19 @@ data class DisplayMessage( ...@@ -18,10 +19,19 @@ data class DisplayMessage(
val isFollowUp: Boolean, val isFollowUp: Boolean,
val isSelected: Boolean, val isSelected: Boolean,
val isExpanded: Boolean, val isExpanded: Boolean,
val isMarkerLine: Boolean val isMarkerLine: Boolean,
val isEmoji: Boolean
) )
val tag = Tag(content.messageId, hasDayChange, isFollowUp, isSelected, isExpanded, isMarkerLine) val tag = Tag(
content.messageId,
hasDayChange,
isFollowUp,
isSelected,
isExpanded,
isMarkerLine,
isEmoji
)
val avatarUrl = content.sender.let { val avatarUrl = content.sender.let {
Regex("[us]id(\\d+)").matchEntire(HostmaskHelper.user(it))?.groupValues?.lastOrNull()?.let { Regex("[us]id(\\d+)").matchEntire(HostmaskHelper.user(it))?.groupValues?.lastOrNull()?.let {
"https://www.irccloud.com/avatar-redirect/$it" "https://www.irccloud.com/avatar-redirect/$it"
......
...@@ -13,9 +13,7 @@ import butterknife.BindView ...@@ -13,9 +13,7 @@ import butterknife.BindView
import butterknife.ButterKnife import butterknife.ButterKnife
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import de.kuschku.libquassel.protocol.Message_Flag import de.kuschku.libquassel.protocol.Message_Flag
import de.kuschku.libquassel.protocol.Message_Flags
import de.kuschku.libquassel.protocol.Message_Type import de.kuschku.libquassel.protocol.Message_Type
import de.kuschku.libquassel.protocol.Message_Types
import de.kuschku.libquassel.util.flag.hasFlag import de.kuschku.libquassel.util.flag.hasFlag
import de.kuschku.quasseldroid.GlideApp import de.kuschku.quasseldroid.GlideApp
import de.kuschku.quasseldroid.R import de.kuschku.quasseldroid.R
...@@ -82,16 +80,12 @@ class MessageAdapter @Inject constructor( ...@@ -82,16 +80,12 @@ class MessageAdapter @Inject constructor(
} }
override fun getItemViewType(position: Int) = getItem(position)?.let { override fun getItemViewType(position: Int) = getItem(position)?.let {
viewType(Message_Flags.of(it.content.type), Message_Flag.of(it.content.type).value or
Message_Flags.of(it.content.flag), (if (Message_Flag.of(it.content.flag).hasFlag(Message_Flag.Highlight)) MASK_HIGHLIGHT else 0x00) or
it.isFollowUp) (if (it.isFollowUp) MASK_FOLLOWUP else 0x00) or
(if (it.isEmoji) MASK_EMOJI else 0x00)
} ?: 0 } ?: 0
private fun viewType(type: Message_Types, flags: Message_Flags, followUp: Boolean) =
type.value or
(if (flags.hasFlag(Message_Flag.Highlight)) MASK_HIGHLIGHT else 0x00) or
(if (followUp) MASK_FOLLOWUP else 0x00)
override fun getItemId(position: Int): Long { override fun getItemId(position: Int): Long {
return getItem(position)?.content?.messageId?.toLong() ?: 0L return getItem(position)?.content?.messageId?.toLong() ?: 0L
} }
...@@ -103,11 +97,15 @@ class MessageAdapter @Inject constructor( ...@@ -103,11 +97,15 @@ class MessageAdapter @Inject constructor(
private fun isFollowUp(viewType: Int) = viewType and MASK_FOLLOWUP != 0 private fun isFollowUp(viewType: Int) = viewType and MASK_FOLLOWUP != 0
private fun isEmoji(viewType: Int) = viewType and MASK_EMOJI != 0
companion object { companion object {
const val SHIFT_HIGHLIGHT = 32 - 1 private const val SHIFT_HIGHLIGHT = 32 - 1
const val SHIFT_FOLLOWUP = SHIFT_HIGHLIGHT - 1 private const val SHIFT_FOLLOWUP = SHIFT_HIGHLIGHT - 1
private const val SHIFT_EMOJI = SHIFT_FOLLOWUP - 1
const val MASK_HIGHLIGHT = 0x01 shl SHIFT_HIGHLIGHT const val MASK_HIGHLIGHT = 0x01 shl SHIFT_HIGHLIGHT
const val MASK_FOLLOWUP = 0x01 shl SHIFT_FOLLOWUP const val MASK_FOLLOWUP = 0x01 shl SHIFT_FOLLOWUP
const val MASK_EMOJI = 0x01 shl SHIFT_EMOJI
const val MASK_TYPE = 0xFFFFFF const val MASK_TYPE = 0xFFFFFF
} }
...@@ -115,9 +113,10 @@ class MessageAdapter @Inject constructor( ...@@ -115,9 +113,10 @@ class MessageAdapter @Inject constructor(
val messageType = messageType(viewType) val messageType = messageType(viewType)
val hasHighlight = hasHiglight(viewType) val hasHighlight = hasHiglight(viewType)
val isFollowUp = isFollowUp(viewType) val isFollowUp = isFollowUp(viewType)
val isEmoji = isEmoji(viewType)
val viewHolder = QuasselMessageViewHolder( val viewHolder = QuasselMessageViewHolder(
LayoutInflater.from(parent.context).inflate( LayoutInflater.from(parent.context).inflate(
messageRenderer.layout(messageType, hasHighlight, isFollowUp), messageRenderer.layout(messageType, hasHighlight, isFollowUp, isEmoji),
parent, parent,
false false
), ),
...@@ -126,7 +125,7 @@ class MessageAdapter @Inject constructor( ...@@ -126,7 +125,7 @@ class MessageAdapter @Inject constructor(
expansionListener, expansionListener,
movementMethod movementMethod
) )
messageRenderer.init(viewHolder, messageType, hasHighlight, isFollowUp) messageRenderer.init(viewHolder, messageType, hasHighlight, isFollowUp, isEmoji)
return viewHolder return viewHolder
} }
......
...@@ -248,7 +248,8 @@ class MessageListFragment : ServiceBoundFragment() { ...@@ -248,7 +248,8 @@ class MessageListFragment : ServiceBoundFragment() {
isFollowUp = isFollowUp, isFollowUp = isFollowUp,
isSelected = selected.contains(it.messageId), isSelected = selected.contains(it.messageId),
isExpanded = expanded.contains(it.messageId), isExpanded = expanded.contains(it.messageId),
isMarkerLine = markerLine == it.messageId isMarkerLine = markerLine == it.messageId,
isEmoji = false
) )
}.asReversed() }.asReversed()
} }
......
...@@ -8,7 +8,7 @@ import de.kuschku.quasseldroid.viewmodel.data.FormattedMessage ...@@ -8,7 +8,7 @@ import de.kuschku.quasseldroid.viewmodel.data.FormattedMessage
interface MessageRenderer { interface MessageRenderer {
@LayoutRes @LayoutRes
fun layout(type: Message_Type?, hasHighlight: Boolean, isFollowUp: Boolean): Int fun layout(type: Message_Type?, hasHighlight: Boolean, isFollowUp: Boolean, isEmoji: Boolean): Int
fun bind(holder: MessageAdapter.QuasselMessageViewHolder, message: FormattedMessage, fun bind(holder: MessageAdapter.QuasselMessageViewHolder, message: FormattedMessage,
original: QuasselDatabase.DatabaseMessage) original: QuasselDatabase.DatabaseMessage)
...@@ -18,7 +18,7 @@ interface MessageRenderer { ...@@ -18,7 +18,7 @@ interface MessageRenderer {
fun init(viewHolder: MessageAdapter.QuasselMessageViewHolder, fun init(viewHolder: MessageAdapter.QuasselMessageViewHolder,
messageType: Message_Type?, messageType: Message_Type?,
hasHighlight: Boolean, hasHighlight: Boolean,
isFollowUp: Boolean) { isFollowUp: Boolean,
} isEmoji: Boolean) = Unit
} }
...@@ -45,7 +45,7 @@ class QuasselMessageRenderer @Inject constructor( ...@@ -45,7 +45,7 @@ class QuasselMessageRenderer @Inject constructor(
private val dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM) private val dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)
val monospaceItalic = Typeface.create(Typeface.MONOSPACE, Typeface.ITALIC) private val monospaceItalic = Typeface.create(Typeface.MONOSPACE, Typeface.ITALIC)
private fun timePattern(showSeconds: Boolean, private fun timePattern(showSeconds: Boolean,
use24hClock: Boolean) = when (use24hClock to showSeconds) { use24hClock: Boolean) = when (use24hClock to showSeconds) {
...@@ -62,7 +62,7 @@ class QuasselMessageRenderer @Inject constructor( ...@@ -62,7 +62,7 @@ class QuasselMessageRenderer @Inject constructor(
private val zoneId = ZoneId.systemDefault() private val zoneId = ZoneId.systemDefault()
override fun layout(type: Message_Type?, hasHighlight: Boolean, override fun layout(type: Message_Type?, hasHighlight: Boolean,
isFollowUp: Boolean) = when (type) { isFollowUp: Boolean, isEmoji: Boolean) = when (type) {
Notice -> R.layout.widget_chatmessage_notice Notice -> R.layout.widget_chatmessage_notice
Server -> R.layout.widget_chatmessage_server Server -> R.layout.widget_chatmessage_server
Error -> R.layout.widget_chatmessage_error Error -> R.layout.widget_chatmessage_error
...@@ -77,7 +77,8 @@ class QuasselMessageRenderer @Inject constructor( ...@@ -77,7 +77,8 @@ class QuasselMessageRenderer @Inject constructor(
override fun init(viewHolder: MessageAdapter.QuasselMessageViewHolder, override fun init(viewHolder: MessageAdapter.QuasselMessageViewHolder,
messageType: Message_Type?, messageType: Message_Type?,
hasHighlight: Boolean, hasHighlight: Boolean,
isFollowUp: Boolean) { isFollowUp: Boolean,
isEmoji: Boolean) {
if (hasHighlight) { if (hasHighlight) {
viewHolder.itemView.context.theme.styledAttributes( viewHolder.itemView.context.theme.styledAttributes(
R.attr.colorForegroundHighlight, R.attr.colorBackgroundHighlight, R.attr.colorForegroundHighlight, R.attr.colorBackgroundHighlight,
...@@ -119,9 +120,10 @@ class QuasselMessageRenderer @Inject constructor( ...@@ -119,9 +120,10 @@ class QuasselMessageRenderer @Inject constructor(
val textSize = messageSettings.textSize.toFloat() val textSize = messageSettings.textSize.toFloat()
viewHolder.timeLeft?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize) viewHolder.timeLeft?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize)
viewHolder.timeRight?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize * 0.9f) viewHolder.timeRight?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize * 0.9f)
viewHolder.content?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize)
viewHolder.combined?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize)
viewHolder.name?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize) viewHolder.name?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize)
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 avatarSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, TypedValue.COMPLEX_UNIT_SP,
textSize * 2.5f, textSize * 2.5f,
......
...@@ -133,6 +133,16 @@ class AboutSettingsFragment : DaggerFragment() { ...@@ -133,6 +133,16 @@ class AboutSettingsFragment : DaggerFragment() {
license = apache2, license = apache2,
url = "https://google.github.io/dagger/" url = "https://google.github.io/dagger/"
), ),
Library(
name = "emoji-java",
version = "4.0.0",
license = License(
shortName = "MIT",
fullName = "The MIT License (MIT)",
text = R.string.license_emojijava
),
url = "https://github.com/vdurmont/emoji-java"
),
Library( Library(
name = "Glide", name = "Glide",
version = "4.6.1", version = "4.6.1",
......
...@@ -57,6 +57,9 @@ ...@@ -57,6 +57,9 @@
<string name="preference_time_at_end_title">Rechts-Ausgerichtete Zeit</string> <string name="preference_time_at_end_title">Rechts-Ausgerichtete Zeit</string>
<string name="preference_time_at_end_summary">Zeigt die Zeit rechts in Nachrichten an</string> <string name="preference_time_at_end_summary">Zeigt die Zeit rechts in Nachrichten an</string>
<string name="preference_larger_emoji_title">Große Reaktionen</string>
<string name="preference_larger_emoji_summary">Zeigt Nachrichten, die nur Emoji enthalten, größer an</string>
<string name="preference_autocomplete_title">Autovervollständigung</string> <string name="preference_autocomplete_title">Autovervollständigung</string>
......
...@@ -50,6 +50,13 @@ ...@@ -50,6 +50,13 @@
<p>c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person&apos;s Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.</p> <p>c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person&apos;s Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.</p>
<p>d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.</p> <p>d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.</p>
]]></string> ]]></string>
<string name="license_emojijava" translatable="false" tools:ignore="TypographyOther"><![CDATA[
<h2>The MIT License (MIT)</h2>
<p>Copyright (c) 2014-present Vincent DURMONT vdurmont@gmail.com</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
]]></string>
<string name="license_materialdesignicons" translatable="false" tools:ignore="TypographyOther"><![CDATA[ <string name="license_materialdesignicons" translatable="false" tools:ignore="TypographyOther"><![CDATA[
<p>Copyright (c) 2014, Austin Andrews (<a href="http://materialdesignicons.com/">http://materialdesignicons.com/<a/>), with Reserved Font Name Material Design Icons.</p> <p>Copyright (c) 2014, Austin Andrews (<a href="http://materialdesignicons.com/">http://materialdesignicons.com/<a/>), with Reserved Font Name Material Design Icons.</p>
<p>Copyright (c) 2014, Google (<a href="http://www.google.com/design/">http://www.google.com/design/</a>) uses the license at <a href="https://github.com/google/material-design-icons/blob/master/LICENSE">https://github.com/google/material-design-icons/blob/master/LICENSE</a></p> <p>Copyright (c) 2014, Google (<a href="http://www.google.com/design/">http://www.google.com/design/</a>) uses the license at <a href="https://github.com/google/material-design-icons/blob/master/LICENSE">https://github.com/google/material-design-icons/blob/master/LICENSE</a></p>
......
...@@ -118,6 +118,11 @@ ...@@ -118,6 +118,11 @@
<string name="preference_time_at_end_title">Right-Aligned Timestamps</string> <string name="preference_time_at_end_title">Right-Aligned Timestamps</string>
<string name="preference_time_at_end_summary">Aligns timestamps at the end of each message</string> <string name="preference_time_at_end_summary">Aligns timestamps at the end of each message</string>
<string name="preference_larger_emoji_key" translatable="false">larger_emoji</string>
<string name="preference_larger_emoji_title">Larger Reactions</string>
<string name="preference_larger_emoji_summary">Increase the size of emoji-only messages</string>
<string name="preference_autocomplete_title">Autocomplete</string> <string name="preference_autocomplete_title">Autocomplete</string>
<string name="preference_autocomplete_button_key" translatable="false">autocomplete_button</string> <string name="preference_autocomplete_button_key" translatable="false">autocomplete_button</string>
......
...@@ -98,6 +98,14 @@ ...@@ -98,6 +98,14 @@
android:key="@string/preference_time_at_end_key" android:key="@string/preference_time_at_end_key"
android:summary="@string/preference_time_at_end_summary" android:summary="@string/preference_time_at_end_summary"
android:title="@string/preference_time_at_end_title" /> android:title="@string/preference_time_at_end_title" />
<!--
<SwitchPreference
android:defaultValue="false"
android:dependency="@string/preference_nicks_on_new_line_key"
android:key="@string/preference_larger_emoji_key"
android:title="@string/preference_larger_emoji_title"
android:summary="@string/preference_larger_emoji_summary" />
-->
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/preference_autocomplete_title"> <PreferenceCategory android:title="@string/preference_autocomplete_title">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment