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

Properly handle mIRC colors in topics and realnames

parent 75ef652e
No related branches found
No related tags found
No related merge requests found
......@@ -142,7 +142,7 @@ class BufferListAdapter(
val info: BufferInfo,
val network: INetwork.NetworkInfo,
val bufferStatus: BufferStatus,
val description: String,
val description: CharSequence,
val activity: Buffer_Activity,
val highlights: Int = 0
)
......
......@@ -19,11 +19,13 @@ import de.kuschku.libquassel.session.SessionManager
import de.kuschku.libquassel.util.and
import de.kuschku.libquassel.util.hasFlag
import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.ui.settings.data.RenderingSettings
import de.kuschku.quasseldroid_ng.util.AndroidHandlerThread
import de.kuschku.quasseldroid_ng.util.helper.map
import de.kuschku.quasseldroid_ng.util.helper.or
import de.kuschku.quasseldroid_ng.util.helper.switchMap
import de.kuschku.quasseldroid_ng.util.helper.switchMapRx
import de.kuschku.quasseldroid_ng.util.irc.format.IrcFormatDeserializer
import de.kuschku.quasseldroid_ng.util.service.ServiceBoundFragment
import io.reactivex.Observable
import java.util.concurrent.TimeUnit
......@@ -72,6 +74,14 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
}
}
val ircFormatDeserializer = IrcFormatDeserializer(context!!)
val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true,
timeFormat = ""
)
private val adapter = BufferViewConfigAdapter(this, bufferViewConfigs)
private val bufferIdList = selectedBufferViewConfig.switchMapRx(BufferViewConfig::live_buffers)
......@@ -124,7 +134,9 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
away -> BufferListAdapter.BufferStatus.AWAY
else -> BufferListAdapter.BufferStatus.ONLINE
},
description = realName,
description = ircFormatDeserializer.formatString(
realName, renderingSettings.colorizeMirc
),
activity = activity
)
}
......@@ -143,7 +155,9 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
IrcChannel.NULL -> BufferListAdapter.BufferStatus.OFFLINE
else -> BufferListAdapter.BufferStatus.ONLINE
},
description = topic,
description = ircFormatDeserializer.formatString(
topic, renderingSettings.colorizeMirc
),
activity = activity
)
}
......
......@@ -81,7 +81,7 @@ class NickListAdapter(
val nick: String,
val modes: String,
val lowestMode: Int,
val realname: String,
val realname: CharSequence,
val away: Boolean,
val networkCasemapping: String
)
......
......@@ -17,10 +17,12 @@ import de.kuschku.libquassel.session.Backend
import de.kuschku.libquassel.session.SessionManager
import de.kuschku.libquassel.util.hasFlag
import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.ui.settings.data.RenderingSettings
import de.kuschku.quasseldroid_ng.util.AndroidHandlerThread
import de.kuschku.quasseldroid_ng.util.helper.map
import de.kuschku.quasseldroid_ng.util.helper.switchMap
import de.kuschku.quasseldroid_ng.util.helper.switchMapRx
import de.kuschku.quasseldroid_ng.util.irc.format.IrcFormatDeserializer
import de.kuschku.quasseldroid_ng.util.service.ServiceBoundFragment
import io.reactivex.Observable
import io.reactivex.Observable.zip
......@@ -32,6 +34,14 @@ class NickListFragment : ServiceBoundFragment() {
@BindView(R.id.nickList)
lateinit var nickList: RecyclerView
val ircFormatDeserializer = IrcFormatDeserializer(context!!)
val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true,
timeFormat = ""
)
val currentBuffer: MutableLiveData<LiveData<BufferId?>?> = MutableLiveData()
val buffer = currentBuffer.switchMap { it }
......@@ -64,7 +74,7 @@ class NickListFragment : ServiceBoundFragment() {
user.nick(),
network.modesToPrefixes(userModes),
lowestMode,
realName,
ircFormatDeserializer.formatString(realName, renderingSettings.colorizeMirc),
away,
network.support("CASEMAPPING")
)
......
......@@ -19,7 +19,9 @@ import de.kuschku.libquassel.session.SessionManager
import de.kuschku.libquassel.util.hasFlag
import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.ui.settings.data.DisplaySettings
import de.kuschku.quasseldroid_ng.ui.settings.data.RenderingSettings
import de.kuschku.quasseldroid_ng.util.helper.*
import de.kuschku.quasseldroid_ng.util.irc.format.IrcFormatDeserializer
import de.kuschku.quasseldroid_ng.util.service.ServiceBoundFragment
import io.reactivex.Observable
......@@ -43,6 +45,14 @@ class ToolbarFragment : ServiceBoundFragment() {
showLag = true
)
val ircFormatDeserializer = IrcFormatDeserializer(context!!)
val renderingSettings = RenderingSettings(
showPrefix = RenderingSettings.ShowPrefixMode.FIRST,
colorizeNicknames = RenderingSettings.ColorizeNicknamesMode.ALL_BUT_MINE,
colorizeMirc = true,
timeFormat = ""
)
private val bufferData: LiveData<BufferData?> = sessionManager.switchMap { manager ->
buffer.switchMapRx { id ->
manager.session.switchMap {
......@@ -71,7 +81,9 @@ class ToolbarFragment : ServiceBoundFragment() {
BufferData(
info = info,
network = network.networkInfo(),
description = realName
description = ircFormatDeserializer.formatString(
realName, renderingSettings.colorizeMirc
)
)
}
}
......@@ -84,7 +96,9 @@ class ToolbarFragment : ServiceBoundFragment() {
BufferData(
info = info,
network = network.networkInfo(),
description = topic
description = ircFormatDeserializer.formatString(
topic, renderingSettings.colorizeMirc
)
)
}
}
......@@ -163,7 +177,7 @@ class ToolbarFragment : ServiceBoundFragment() {
if (description.isNullOrBlank()) {
this.subtitle = "Lag: ${lag}ms"
} else {
this.subtitle = "Lag: ${lag}ms ${description}"
this.subtitle = "Lag: ${lag}ms | $description"
}
}
}
......@@ -176,7 +190,7 @@ class ToolbarFragment : ServiceBoundFragment() {
data class BufferData(
val info: BufferInfo? = null,
val network: INetwork.NetworkInfo? = null,
val description: String? = null
val description: CharSequence? = null
)
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment