Commit f28d2b39 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Fix load and skin tone on reactions

parent e02df06c
...@@ -165,8 +165,11 @@ class EmojiKeyboardPopup(context: Context, view: View) : OverKeyboardPopupWindow ...@@ -165,8 +165,11 @@ class EmojiKeyboardPopup(context: Context, view: View) : OverKeyboardPopupWindow
textView.setImageResource(category.resourceIcon()) textView.setImageResource(category.resourceIcon())
} }
val currentTab = if (EmojiRepository.getRecents().isEmpty()) EmojiCategory.PEOPLE.ordinal else val currentTab = if (EmojiRepository.getRecents().isEmpty()) {
EmojiCategory.PEOPLE.ordinal
} else {
EmojiCategory.RECENTS.ordinal EmojiCategory.RECENTS.ordinal
}
viewPager.currentItem = currentTab viewPager.currentItem = currentTab
} }
} }
......
...@@ -7,14 +7,19 @@ import android.view.LayoutInflater ...@@ -7,14 +7,19 @@ import android.view.LayoutInflater
import android.view.Window import android.view.Window
import android.view.WindowManager import android.view.WindowManager
import android.widget.ImageView import android.widget.ImageView
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.core.content.edit
import chat.rocket.android.emoji.internal.EmojiCategory import chat.rocket.android.emoji.internal.EmojiCategory
import chat.rocket.android.emoji.internal.EmojiPagerAdapter import chat.rocket.android.emoji.internal.EmojiPagerAdapter
import chat.rocket.android.emoji.internal.PREF_EMOJI_SKIN_TONE
import kotlinx.android.synthetic.main.emoji_picker.* import kotlinx.android.synthetic.main.emoji_picker.*
class EmojiPickerPopup(context: Context) : Dialog(context) { class EmojiPickerPopup(context: Context) : Dialog(context) {
var listener: EmojiKeyboardListener? = null var listener: EmojiKeyboardListener? = null
private lateinit var adapter: EmojiPagerAdapter
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -35,7 +40,7 @@ class EmojiPickerPopup(context: Context) : Dialog(context) { ...@@ -35,7 +40,7 @@ class EmojiPickerPopup(context: Context) : Dialog(context) {
} }
private fun setupViewPager() { private fun setupViewPager() {
pager_categories.adapter = EmojiPagerAdapter(object : EmojiKeyboardListener { adapter = EmojiPagerAdapter(object : EmojiKeyboardListener {
override fun onEmojiAdded(emoji: Emoji) { override fun onEmojiAdded(emoji: Emoji) {
EmojiRepository.addToRecents(emoji) EmojiRepository.addToRecents(emoji)
dismiss() dismiss()
...@@ -43,6 +48,14 @@ class EmojiPickerPopup(context: Context) : Dialog(context) { ...@@ -43,6 +48,14 @@ class EmojiPickerPopup(context: Context) : Dialog(context) {
} }
}) })
val sharedPreferences = context.getSharedPreferences("emoji", Context.MODE_PRIVATE)
sharedPreferences.getString(PREF_EMOJI_SKIN_TONE, "")?.let {
changeSkinTone(Fitzpatrick.valueOf(it))
}
pager_categories.adapter = adapter
pager_categories.offscreenPageLimit = EmojiCategory.values().size
for (category in EmojiCategory.values()) { for (category in EmojiCategory.values()) {
val tab = tabs.getTabAt(category.ordinal) val tab = tabs.getTabAt(category.ordinal)
val tabView = LayoutInflater.from(context).inflate(R.layout.emoji_picker_tab, null) val tabView = LayoutInflater.from(context).inflate(R.layout.emoji_picker_tab, null)
...@@ -51,8 +64,15 @@ class EmojiPickerPopup(context: Context) : Dialog(context) { ...@@ -51,8 +64,15 @@ class EmojiPickerPopup(context: Context) : Dialog(context) {
textView.setImageResource(category.resourceIcon()) textView.setImageResource(category.resourceIcon())
} }
val currentTab = if (EmojiRepository.getRecents().isEmpty()) EmojiCategory.PEOPLE.ordinal else val currentTab = if (EmojiRepository.getRecents().isEmpty()) {
EmojiCategory.PEOPLE.ordinal
} else {
EmojiCategory.RECENTS.ordinal EmojiCategory.RECENTS.ordinal
}
pager_categories.currentItem = currentTab pager_categories.currentItem = currentTab
} }
private fun changeSkinTone(tone: Fitzpatrick) {
adapter.setFitzpatrick(tone)
}
} }
\ 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