Skip to content

Commit

Permalink
Fixed link coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne committed Feb 4, 2019
1 parent 0f1aadc commit d46ab2f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class ContentFormatter @Inject constructor(
}
}

spans.reverse()
for (span in spans) {
span.apply(formattedText)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ package de.kuschku.quasseldroid.util.irc.format.model
import android.text.Spannable
import android.text.Spanned
import de.kuschku.libquassel.protocol.NetworkId
import de.kuschku.quasseldroid.util.irc.format.ChannelLinkSpan
import de.kuschku.quasseldroid.util.irc.format.QuasselURLSpan
import de.kuschku.quasseldroid.util.irc.format.spans.*

sealed class IrcFormat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package de.kuschku.quasseldroid.util.irc.format
package de.kuschku.quasseldroid.util.irc.format.spans

import android.text.TextPaint
import android.text.style.ClickableSpan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,26 @@

package de.kuschku.quasseldroid.util.irc.format.spans

import android.text.TextPaint
import android.text.style.ForegroundColorSpan
import androidx.annotation.ColorInt

sealed class IrcForegroundColorSpan<T : IrcForegroundColorSpan<T>>(@ColorInt color: Int) :
ForegroundColorSpan(color), Copyable<T> {

override fun updateDrawState(ds: TextPaint?) {
if (ds != null) {
ds.color = foregroundColor
ds.linkColor = foregroundColor
}
}

class MIRC(private val mircColor: Int, @ColorInt color: Int) :
IrcForegroundColorSpan<MIRC>(color), Copyable<MIRC> {
override fun copy() = MIRC(mircColor, foregroundColor)
override fun toString(): String {
return "IrcForegroundColorSpan.MIRC(mircColor=$mircColor, color=${foregroundColor.toString(16)})"
return "IrcForegroundColorSpan.MIRC(mircColor=$mircColor, color=${foregroundColor.toUInt().toString(
16)})"
}

override fun equals(other: Any?) = when (other) {
Expand All @@ -43,7 +51,7 @@ sealed class IrcForegroundColorSpan<T : IrcForegroundColorSpan<T>>(@ColorInt col
IrcForegroundColorSpan<HEX>(color), Copyable<HEX> {
override fun copy() = HEX(foregroundColor)
override fun toString(): String {
return "IrcBackgroundColorSpan.HEX(color=${foregroundColor.toString(16)})"
return "IrcBackgroundColorSpan.HEX(color=${foregroundColor.toUInt().toString(16)})"
}

override fun equals(other: Any?) = when (other) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package de.kuschku.quasseldroid.util.irc.format
package de.kuschku.quasseldroid.util.irc.format.spans

import android.text.TextPaint
import android.text.style.URLSpan
Expand Down

0 comments on commit d46ab2f

Please sign in to comment.