diff --git a/app/src/main/java/de/kuschku/quasseldroid/settings/MessageSettings.kt b/app/src/main/java/de/kuschku/quasseldroid/settings/MessageSettings.kt index 708fbbce8ed43238755797d97b41b71be01d90e2..11503a159be2d3eba8a998d8569445cbc7619e69 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/settings/MessageSettings.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/settings/MessageSettings.kt @@ -12,7 +12,8 @@ data class MessageSettings( val showHostmaskPlain: Boolean = false, val nicksOnNewLine: Boolean = false, val timeAtEnd: Boolean = false, - val showAvatars: Boolean = false + val showAvatars: Boolean = false, + val largerEmoji: Boolean = false ) { enum class ColorizeNicknamesMode { diff --git a/app/src/main/java/de/kuschku/quasseldroid/settings/Settings.kt b/app/src/main/java/de/kuschku/quasseldroid/settings/Settings.kt index 1ced8c036ad8575af679148d57c30a875876df98..abd7bf37475bbe36726a4932a6c0782dabfd1642 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/settings/Settings.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/settings/Settings.kt @@ -81,6 +81,10 @@ object Settings { showAvatars = getBoolean( context.getString(R.string.preference_show_avatars_key), MessageSettings.DEFAULT.showAvatars + ), + largerEmoji = getBoolean( + context.getString(R.string.preference_larger_emoji_key), + MessageSettings.DEFAULT.largerEmoji ) ) } diff --git a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/DisplayMessage.kt b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/DisplayMessage.kt index ab5633dfad1b70f38f8da2ce702f05dc3cb96807..444f3c0542b90828535a5db44e1fffe0590b2337 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/DisplayMessage.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/DisplayMessage.kt @@ -10,7 +10,8 @@ data class DisplayMessage( val isFollowUp: Boolean, val isSelected: Boolean, val isExpanded: Boolean, - val isMarkerLine: Boolean + val isMarkerLine: Boolean, + val isEmoji: Boolean ) { data class Tag( val id: MsgId, @@ -18,10 +19,19 @@ data class DisplayMessage( val isFollowUp: Boolean, val isSelected: 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 { Regex("[us]id(\\d+)").matchEntire(HostmaskHelper.user(it))?.groupValues?.lastOrNull()?.let { "https://www.irccloud.com/avatar-redirect/$it" diff --git a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageAdapter.kt b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageAdapter.kt index bdeb76b0d4c0ecc73a420720ef7a229a2ce97613..eb54e1f35e4697f8b4a5f9aa188eeb50fbf1051c 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageAdapter.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageAdapter.kt @@ -13,9 +13,7 @@ import butterknife.BindView import butterknife.ButterKnife import com.bumptech.glide.request.RequestOptions 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_Types import de.kuschku.libquassel.util.flag.hasFlag import de.kuschku.quasseldroid.GlideApp import de.kuschku.quasseldroid.R @@ -82,16 +80,12 @@ class MessageAdapter @Inject constructor( } override fun getItemViewType(position: Int) = getItem(position)?.let { - viewType(Message_Flags.of(it.content.type), - Message_Flags.of(it.content.flag), - it.isFollowUp) + Message_Flag.of(it.content.type).value or + (if (Message_Flag.of(it.content.flag).hasFlag(Message_Flag.Highlight)) MASK_HIGHLIGHT else 0x00) or + (if (it.isFollowUp) MASK_FOLLOWUP else 0x00) or + (if (it.isEmoji) MASK_EMOJI else 0x00) } ?: 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 { return getItem(position)?.content?.messageId?.toLong() ?: 0L } @@ -103,11 +97,15 @@ class MessageAdapter @Inject constructor( private fun isFollowUp(viewType: Int) = viewType and MASK_FOLLOWUP != 0 + private fun isEmoji(viewType: Int) = viewType and MASK_EMOJI != 0 + companion object { - const val SHIFT_HIGHLIGHT = 32 - 1 - const val SHIFT_FOLLOWUP = SHIFT_HIGHLIGHT - 1 + private const val SHIFT_HIGHLIGHT = 32 - 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_FOLLOWUP = 0x01 shl SHIFT_FOLLOWUP + const val MASK_EMOJI = 0x01 shl SHIFT_EMOJI const val MASK_TYPE = 0xFFFFFF } @@ -115,9 +113,10 @@ class MessageAdapter @Inject constructor( val messageType = messageType(viewType) val hasHighlight = hasHiglight(viewType) val isFollowUp = isFollowUp(viewType) + val isEmoji = isEmoji(viewType) val viewHolder = QuasselMessageViewHolder( LayoutInflater.from(parent.context).inflate( - messageRenderer.layout(messageType, hasHighlight, isFollowUp), + messageRenderer.layout(messageType, hasHighlight, isFollowUp, isEmoji), parent, false ), @@ -126,7 +125,7 @@ class MessageAdapter @Inject constructor( expansionListener, movementMethod ) - messageRenderer.init(viewHolder, messageType, hasHighlight, isFollowUp) + messageRenderer.init(viewHolder, messageType, hasHighlight, isFollowUp, isEmoji) return viewHolder } diff --git a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageListFragment.kt b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageListFragment.kt index abfe089374e67264cc3579a4cae46b89a6853217..28dc3c523da437a956493499d85d6d2437305d53 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageListFragment.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageListFragment.kt @@ -248,7 +248,8 @@ class MessageListFragment : ServiceBoundFragment() { isFollowUp = isFollowUp, isSelected = selected.contains(it.messageId), isExpanded = expanded.contains(it.messageId), - isMarkerLine = markerLine == it.messageId + isMarkerLine = markerLine == it.messageId, + isEmoji = false ) }.asReversed() } diff --git a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageRenderer.kt b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageRenderer.kt index 185bc59e2acef0b5c80ebfda6dd6e4d92009e9b3..3a34a3bc71cc9bf05aaa572c5d697c1d78ddc2a6 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageRenderer.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/MessageRenderer.kt @@ -8,7 +8,7 @@ import de.kuschku.quasseldroid.viewmodel.data.FormattedMessage interface MessageRenderer { @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, original: QuasselDatabase.DatabaseMessage) @@ -18,7 +18,7 @@ interface MessageRenderer { fun init(viewHolder: MessageAdapter.QuasselMessageViewHolder, messageType: Message_Type?, hasHighlight: Boolean, - isFollowUp: Boolean) { - } + isFollowUp: Boolean, + isEmoji: Boolean) = Unit } diff --git a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/QuasselMessageRenderer.kt b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/QuasselMessageRenderer.kt index c9f61c45f11468722ebc82ef6d658edadae13577..9c0badeca9da0f80978af3b7edc13dbacaf52e83 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/QuasselMessageRenderer.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/ui/chat/messages/QuasselMessageRenderer.kt @@ -45,7 +45,7 @@ class QuasselMessageRenderer @Inject constructor( 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, use24hClock: Boolean) = when (use24hClock to showSeconds) { @@ -62,7 +62,7 @@ class QuasselMessageRenderer @Inject constructor( private val zoneId = ZoneId.systemDefault() override fun layout(type: Message_Type?, hasHighlight: Boolean, - isFollowUp: Boolean) = when (type) { + isFollowUp: Boolean, isEmoji: Boolean) = when (type) { Notice -> R.layout.widget_chatmessage_notice Server -> R.layout.widget_chatmessage_server Error -> R.layout.widget_chatmessage_error @@ -77,7 +77,8 @@ class QuasselMessageRenderer @Inject constructor( override fun init(viewHolder: MessageAdapter.QuasselMessageViewHolder, messageType: Message_Type?, hasHighlight: Boolean, - isFollowUp: Boolean) { + isFollowUp: Boolean, + isEmoji: Boolean) { if (hasHighlight) { viewHolder.itemView.context.theme.styledAttributes( R.attr.colorForegroundHighlight, R.attr.colorBackgroundHighlight, @@ -119,9 +120,10 @@ class QuasselMessageRenderer @Inject constructor( val textSize = messageSettings.textSize.toFloat() viewHolder.timeLeft?.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize) 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) + 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( TypedValue.COMPLEX_UNIT_SP, textSize * 2.5f, diff --git a/app/src/main/java/de/kuschku/quasseldroid/ui/clientsettings/about/AboutSettingsFragment.kt b/app/src/main/java/de/kuschku/quasseldroid/ui/clientsettings/about/AboutSettingsFragment.kt index 5c19bca4cd5bdea9446b0981d139e8a87e654cb7..88c1d69bc08fcc146c338948a093ecadd59d0c77 100644 --- a/app/src/main/java/de/kuschku/quasseldroid/ui/clientsettings/about/AboutSettingsFragment.kt +++ b/app/src/main/java/de/kuschku/quasseldroid/ui/clientsettings/about/AboutSettingsFragment.kt @@ -133,6 +133,16 @@ class AboutSettingsFragment : DaggerFragment() { license = apache2, 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( name = "Glide", version = "4.6.1", diff --git a/app/src/main/res/values-de/strings_preferences.xml b/app/src/main/res/values-de/strings_preferences.xml index f6034f065a540f3d884c18a49d6ee53dbc733629..a3f8d985968830e1b4a09bfd6c21a2ffa8c28522 100644 --- a/app/src/main/res/values-de/strings_preferences.xml +++ b/app/src/main/res/values-de/strings_preferences.xml @@ -57,6 +57,9 @@ <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_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> diff --git a/app/src/main/res/values/strings_licenses.xml b/app/src/main/res/values/strings_licenses.xml index 8cf18d55ceb70cc3d23a873481489726fb9c6f8d..43a1a979b03444f2ec341cc19957fee7a6a86b6d 100644 --- a/app/src/main/res/values/strings_licenses.xml +++ b/app/src/main/res/values/strings_licenses.xml @@ -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'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> ]]></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[ <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> diff --git a/app/src/main/res/values/strings_preferences.xml b/app/src/main/res/values/strings_preferences.xml index e41c6ca283cda249211f992a5ce3aeb03817e1f8..4a557e59569b0b84b076e1fa38a76220a4a07812 100644 --- a/app/src/main/res/values/strings_preferences.xml +++ b/app/src/main/res/values/strings_preferences.xml @@ -118,6 +118,11 @@ <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_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_button_key" translatable="false">autocomplete_button</string> diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index a4dd6a264f45d3a4c5af39e6aff9b76198046343..12b68e147ab95db7eaf741d2c6864eb709f63132 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -98,6 +98,14 @@ android:key="@string/preference_time_at_end_key" android:summary="@string/preference_time_at_end_summary" 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 android:title="@string/preference_autocomplete_title">