Commit 37234d91 authored by Wilko Manger's avatar Wilko Manger

Make some links clickable

<a> tags don't seem to work, will fix later.

Fixes #39.
parent 58ef3a8d
Pipeline #273 passed with stages
in 4 minutes and 7 seconds
......@@ -20,12 +20,16 @@
package im.pattle.app.ui.main.chat
import android.content.Context
import android.text.method.LinkMovementMethod
import android.text.util.Linkify
import android.util.Log
import android.view.LayoutInflater
import android.view.View.GONE
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
......@@ -37,6 +41,7 @@ import im.pattle.app.ui.util.*
import kotlinx.android.synthetic.main.list_item_chat_recv_message.view.*
import kotlinx.android.synthetic.main.view_date_header.view.*
import kotlinx.android.synthetic.main.view_info.view.*
import org.jetbrains.anko.linkTextColor
import java.util.*
class ChatEventAdapter(private val isDirect: Boolean,
......@@ -144,7 +149,7 @@ class ChatEventAdapter(private val isDirect: Boolean,
.inflate(layout, parent, false)
}
return when(viewType) {
val holder = when(viewType) {
TEXT_MESSAGE_RECEIVED -> {
EventHolder(inflate(R.layout.list_item_chat_recv_message)
as ConstraintLayout)
......@@ -171,6 +176,16 @@ class ChatEventAdapter(private val isDirect: Boolean,
as ConstraintLayout)
}
}
// This is required for making links clickable
if (holder is EventHolder) {
holder.layout.content.linksClickable = true
holder.layout.content.autoLinkMask = Linkify.ALL
holder.layout.content.linkTextColor =
ContextCompat.getColor(context, R.color.colorSecondary)
}
return holder
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
......
......@@ -21,7 +21,7 @@ along with Pattle. If not, see <https://www.gnu.org/licenses/>.
android:shape="rectangle">
<!-- Background color -->
<solid android:color="@color/colorInfo"/>
<solid android:color="@color/colorSecondary"/>
<!-- Corner radius -->
<corners android:radius="@dimen/chat_item_corner_radius"/>
......
......@@ -22,11 +22,11 @@ along with Pattle. If not, see <https://www.gnu.org/licenses/>.
<color name="colorPrimary">#AA4139</color>
<color name="colorPrimaryDark">#801D15</color>
<color name="colorAccent">#779D34</color>
<color name="colorSecondary">#ebc6c4</color>
<color name="colorChatBackground">#f8ebea</color>
<color name="colorSentMessage">#c55951</color>
<color name="colorReceivedMessage">#fcf7f7</color>>
<color name="colorInfo">#ebc6c4</color>
<color name="colorNoticeText">#808080</color>
<color name="colorPhoneInputLayout">#E8E8E8</color>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment