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

Allow showing hostmask in join/part/quit messages

parent b9878e68
Branches
Tags 0.1.0
No related merge requests found
......@@ -52,6 +52,14 @@ class NickListFragment : ServiceBoundFragment() {
viewModel.nickData.map {
it.map {
it.copy(
modes = when (appearanceSettings.showPrefix) {
AppearanceSettings.ShowPrefixMode.ALL -> it.modes
else -> it.modes.substring(
0, Math.min(
it.modes.length, 1
)
)
},
realname = ircFormatDeserializer?.formatString(
it.realname.toString(), appearanceSettings.colorizeMirc
) ?: it.realname
......
......@@ -108,7 +108,7 @@ class QuasselMessageRenderer(
SpanFormatter.format(
context.getString(R.string.message_format_plain),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight),
formatNick(message.sender, self, highlight, false),
formatContent(message.content, highlight)
),
message.messageId == markerLine
......@@ -119,7 +119,7 @@ class QuasselMessageRenderer(
SpanFormatter.format(
context.getString(R.string.message_format_action),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight),
formatNick(message.sender, self, highlight, false),
formatContent(message.content, highlight)
),
message.messageId == markerLine
......@@ -130,7 +130,7 @@ class QuasselMessageRenderer(
SpanFormatter.format(
context.getString(R.string.message_format_notice),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight),
formatNick(message.sender, self, highlight, false),
formatContent(message.content, highlight)
),
message.messageId == markerLine
......@@ -144,15 +144,15 @@ class QuasselMessageRenderer(
SpanFormatter.format(
context.getString(R.string.message_format_nick_self),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, nickSelf, highlight)
formatNick(message.sender, nickSelf, highlight, false)
)
} else {
SpanFormatter.format(
context.getString(R.string.message_format_nick),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, nickSelf, highlight),
formatNick(message.sender, nickSelf, highlight, false),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.content, nickSelf, highlight)
formatNick(message.content, nickSelf, highlight, false)
)
},
message.messageId == markerLine
......@@ -165,7 +165,7 @@ class QuasselMessageRenderer(
context.getString(R.string.message_format_mode),
message.content,
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight)
formatNick(message.sender, self, highlight, true)
),
message.messageId == markerLine
)
......@@ -175,7 +175,7 @@ class QuasselMessageRenderer(
SpanFormatter.format(
context.getString(R.string.message_format_join),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight)
formatNick(message.sender, self, highlight, true)
),
message.messageId == markerLine
)
......@@ -186,13 +186,13 @@ class QuasselMessageRenderer(
SpanFormatter.format(
context.getString(R.string.message_format_part_1),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight)
formatNick(message.sender, self, highlight, true)
)
} else {
SpanFormatter.format(
context.getString(R.string.message_format_part_2),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight),
formatNick(message.sender, self, highlight, true),
message.content
)
},
......@@ -205,13 +205,13 @@ class QuasselMessageRenderer(
SpanFormatter.format(
context.getString(R.string.message_format_quit_1),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight)
formatNick(message.sender, self, highlight, true)
)
} else {
SpanFormatter.format(
context.getString(R.string.message_format_quit_2),
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight),
formatNick(message.sender, self, highlight, true),
message.content
)
},
......@@ -264,7 +264,7 @@ class QuasselMessageRenderer(
"[%d] %s%s: %s",
message.type,
formatPrefix(message.senderPrefixes, highlight),
formatNick(message.sender, self, highlight),
formatNick(message.sender, self, highlight, true),
message.content
),
message.messageId == markerLine
......@@ -324,32 +324,37 @@ class QuasselMessageRenderer(
}
}
private fun formatNickImpl(sender: String, colorize: Boolean): CharSequence {
private fun formatNickImpl(sender: String, colorize: Boolean, hostmask: Boolean): CharSequence {
val nick = IrcUserUtils.nick(sender)
val spannableString = SpannableString(nick)
val content = if (hostmask) sender else nick
val spannableString = SpannableString(content)
if (colorize) {
val senderColor = IrcUserUtils.senderColor(nick)
spannableString.setSpan(
ForegroundColorSpan(senderColors[senderColor % senderColors.size]),
0,
nick.length,
content.length,
SpannableString.SPAN_INCLUSIVE_EXCLUSIVE
)
}
spannableString.setSpan(
StyleSpan(Typeface.BOLD),
0,
nick.length,
content.length,
SpannableString.SPAN_INCLUSIVE_EXCLUSIVE
)
return spannableString
}
private fun formatNick(sender: String, self: Boolean,
highlight: Boolean) = when (appearanceSettings.colorizeNicknames) {
ColorizeNicknamesMode.ALL -> formatNickImpl(sender, !highlight)
ColorizeNicknamesMode.ALL_BUT_MINE -> formatNickImpl(sender, !self && !highlight)
ColorizeNicknamesMode.NONE -> formatNickImpl(sender, false)
highlight: Boolean, showHostmask: Boolean) =
when (appearanceSettings.colorizeNicknames) {
ColorizeNicknamesMode.ALL ->
formatNickImpl(sender, !highlight, appearanceSettings.showHostmask && showHostmask)
ColorizeNicknamesMode.ALL_BUT_MINE ->
formatNickImpl(sender, !self && !highlight, appearanceSettings.showHostmask && showHostmask)
ColorizeNicknamesMode.NONE ->
formatNickImpl(sender, false, appearanceSettings.showHostmask && showHostmask)
}
private fun formatPrefix(prefix: String,
......
......@@ -10,6 +10,7 @@ data class AppearanceSettings(
val useMonospace: Boolean = false,
val showSeconds: Boolean = false,
val use24hClock: Boolean = true,
val showHostmask: Boolean = false,
val showLag: Boolean = true,
val theme: Theme = Theme.QUASSEL_LIGHT
) {
......
......@@ -14,6 +14,18 @@ object Settings {
AppearanceSettings.DEFAULT.theme.name
)
),
useMonospace = getBoolean(
context.getString(R.string.preference_monospace_key),
AppearanceSettings.DEFAULT.useMonospace
),
showSeconds = getBoolean(
context.getString(R.string.preference_show_seconds_key),
AppearanceSettings.DEFAULT.showSeconds
),
use24hClock = getBoolean(
context.getString(R.string.preference_use_24h_clock_key),
AppearanceSettings.DEFAULT.use24hClock
),
showPrefix = ShowPrefixMode.valueOf(
getString(
context.getString(R.string.preference_show_prefix_key),
......@@ -30,17 +42,9 @@ object Settings {
context.getString(R.string.preference_colorize_mirc_key),
AppearanceSettings.DEFAULT.colorizeMirc
),
useMonospace = getBoolean(
context.getString(R.string.preference_monospace_key),
AppearanceSettings.DEFAULT.useMonospace
),
showSeconds = getBoolean(
context.getString(R.string.preference_show_seconds_key),
AppearanceSettings.DEFAULT.showSeconds
),
use24hClock = getBoolean(
context.getString(R.string.preference_use_24h_clock_key),
AppearanceSettings.DEFAULT.use24hClock
showHostmask = getBoolean(
context.getString(R.string.preference_hostmask_key),
AppearanceSettings.DEFAULT.showHostmask
),
showLag = getBoolean(
context.getString(R.string.preference_show_lag_key),
......
......@@ -30,6 +30,15 @@
<item>GRUVBOX_DARK</item>
</string-array>
<string name="preference_monospace_key" translatable="false">monospace</string>
<string name="preference_monospace_title">Use Monospace Font</string>
<string name="preference_show_seconds_key" translatable="false">show_seconds</string>
<string name="preference_show_seconds_title">Show Seconds</string>
<string name="preference_use_24h_clock_key" translatable="false">use_24h_clock</string>
<string name="preference_use_24h_clock_title">Use 24h Clock</string>
<string name="preference_colorize_mirc_key" translatable="false">colorize_mirc</string>
<string name="preference_colorize_mirc_title">Use mIRC Colors</string>
<string name="preference_colorize_mirc_summaryon">Show mIRC colors in messages</string>
......@@ -67,14 +76,9 @@
<item>NONE</item>
</string-array>
<string name="preference_monospace_key" translatable="false">monospace</string>
<string name="preference_monospace_title">Use Monospace Font</string>
<string name="preference_show_seconds_key" translatable="false">show_seconds</string>
<string name="preference_show_seconds_title">Show Seconds</string>
<string name="preference_use_24h_clock_key" translatable="false">use_24h_clock</string>
<string name="preference_use_24h_clock_title">Use 24h Clock</string>
<string name="preference_hostmask_key" translatable="false">hostmask</string>
<string name="preference_hostmask_title">Show Hostmask</string>
<string name="preference_hostmask_summary">Display the full nick!ident@host in messages</string>
<string name="preference_show_lag_key" translatable="false">show_lag</string>
<string name="preference_show_lag_title">Show lag</string>
......
......@@ -8,6 +8,21 @@
android:key="@string/preference_theme_key"
android:title="@string/preference_theme_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/preference_monospace_key"
android:title="@string/preference_monospace_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/preference_show_seconds_key"
android:title="@string/preference_show_seconds_title" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/preference_use_24h_clock_key"
android:title="@string/preference_use_24h_clock_title" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/preference_colorize_mirc_key"
......@@ -31,18 +46,9 @@
<SwitchPreference
android:defaultValue="false"
android:key="@string/preference_monospace_key"
android:title="@string/preference_monospace_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/preference_show_seconds_key"
android:title="@string/preference_show_seconds_title" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/preference_use_24h_clock_key"
android:title="@string/preference_use_24h_clock_title" />
android:key="@string/preference_hostmask_key"
android:summary="@string/preference_hostmask_summary"
android:title="@string/preference_hostmask_title" />
<SwitchPreference
android:defaultValue="false"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment