Unverified Commit c51a97c7 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge branch 'develop-2.x' into project/dependencies-update

parents 93db630c 5505e764
...@@ -110,6 +110,8 @@ dependencies { ...@@ -110,6 +110,8 @@ dependencies {
androidTestImplementation(libraries.expressoCore, { androidTestImplementation(libraries.expressoCore, {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
implementation 'com.android.support:customtabs:27.0.2'
} }
kotlin { kotlin {
......
...@@ -73,6 +73,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView { ...@@ -73,6 +73,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
val searchItem = menu.findItem(R.id.action_search) val searchItem = menu.findItem(R.id.action_search)
searchView = searchItem?.actionView as SearchView searchView = searchItem?.actionView as SearchView
searchView?.maxWidth = Integer.MAX_VALUE
searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener { searchView?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean { override fun onQueryTextSubmit(query: String?): Boolean {
return queryChatRoomsByName(query) return queryChatRoomsByName(query)
......
...@@ -7,6 +7,7 @@ import android.content.Intent ...@@ -7,6 +7,7 @@ import android.content.Intent
import android.graphics.* import android.graphics.*
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.net.Uri import android.net.Uri
import android.support.customtabs.CustomTabsIntent
import android.provider.Browser import android.provider.Browser
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.support.v4.content.res.ResourcesCompat import android.support.v4.content.res.ResourcesCompat
...@@ -171,16 +172,12 @@ class MessageParser @Inject constructor(val context: Application, private val co ...@@ -171,16 +172,12 @@ class MessageParser @Inject constructor(val context: Application, private val co
if (!link.startsWith("@") && link !in consumed) { if (!link.startsWith("@") && link !in consumed) {
builder.setSpan(object : ClickableSpan() { builder.setSpan(object : ClickableSpan() {
override fun onClick(view: View) { override fun onClick(view: View) {
val uri = getUri(link) with (view) {
val context = view.context val tabsbuilder = CustomTabsIntent.Builder()
val intent = Intent(Intent.ACTION_VIEW, uri) tabsbuilder.setToolbarColor(ResourcesCompat.getColor(context.resources, R.color.colorPrimary, context.theme))
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.packageName) val customTabsIntent = tabsbuilder.build()
try { customTabsIntent.launchUrl(context, getUri(link))
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
Timber.e("Actvity was not found for intent, $intent")
} }
} }
}, matcher.start(0), matcher.end(0)) }, matcher.start(0), matcher.end(0))
consumed.add(link) consumed.add(link)
......
...@@ -9,6 +9,7 @@ import android.view.View ...@@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.util.extensions.setVisible
import java.util.* import java.util.*
class CategoryPagerAdapter(val listener: EmojiKeyboardListener) : PagerAdapter() { class CategoryPagerAdapter(val listener: EmojiKeyboardListener) : PagerAdapter() {
...@@ -24,11 +25,18 @@ class CategoryPagerAdapter(val listener: EmojiKeyboardListener) : PagerAdapter() ...@@ -24,11 +25,18 @@ class CategoryPagerAdapter(val listener: EmojiKeyboardListener) : PagerAdapter()
val recycler = view.findViewById(R.id.emojiRecyclerView) as RecyclerView val recycler = view.findViewById(R.id.emojiRecyclerView) as RecyclerView
val adapter = EmojiAdapter(layoutManager.spanCount, listener) val adapter = EmojiAdapter(layoutManager.spanCount, listener)
val category = EmojiCategory.values().get(position) val category = EmojiCategory.values().get(position)
val emojiNoRecentText : TextView = view.findViewById(R.id.text_no_recent_emoji)
val emojis = if (category != EmojiCategory.RECENTS) { val emojis = if (category != EmojiCategory.RECENTS) {
EmojiRepository.getEmojisByCategory(category) EmojiRepository.getEmojisByCategory(category)
} else { } else {
EmojiRepository.getRecents() EmojiRepository.getRecents()
} }
val recentEmojiSize = EmojiRepository.getRecents().size
if (category == EmojiCategory.RECENTS && recentEmojiSize == 0){
emojiNoRecentText.setVisible(true)
}else{
emojiNoRecentText.setVisible(false)
}
adapter.addEmojis(emojis) adapter.addEmojis(emojis)
recycler.layoutManager = layoutManager recycler.layoutManager = layoutManager
recycler.itemAnimator = DefaultItemAnimator() recycler.itemAnimator = DefaultItemAnimator()
......
...@@ -15,4 +15,14 @@ ...@@ -15,4 +15,14 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/text_no_recent_emoji"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/msg_no_recent_emoji"
android:layout_gravity="center"
android:elevation="10dp"
android:textSize="16sp"
android:visibility="gone"/>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
...@@ -138,4 +138,6 @@ ...@@ -138,4 +138,6 @@
<string name="Guggy_Command_Description">Gera um gif baseado no texto dado</string> <string name="Guggy_Command_Description">Gera um gif baseado no texto dado</string>
<string name="Slash_Topic_Description">Definir tópico</string> <string name="Slash_Topic_Description">Definir tópico</string>
<!-- Emoji message-->
<string name="msg_no_recent_emoji">Nenhum emoji recente</string>
</resources> </resources>
\ No newline at end of file
...@@ -139,4 +139,6 @@ ...@@ -139,4 +139,6 @@
<string name="Guggy_Command_Description">Generates a gif based upon the provided text</string> <string name="Guggy_Command_Description">Generates a gif based upon the provided text</string>
<string name="Slash_Topic_Description">Set topic</string> <string name="Slash_Topic_Description">Set topic</string>
<!-- Emoji message-->
<string name="msg_no_recent_emoji">No recent emoji</string>
</resources> </resources>
\ No newline at end of file
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