respect "animate emojis" setting in emoji picker (#2996)
This commit is contained in:
parent
564caf4e9d
commit
bdeb88c41f
3 changed files with 19 additions and 9 deletions
|
@ -27,7 +27,8 @@ import java.util.Locale
|
||||||
|
|
||||||
class EmojiAdapter(
|
class EmojiAdapter(
|
||||||
emojiList: List<Emoji>,
|
emojiList: List<Emoji>,
|
||||||
private val onEmojiSelectedListener: OnEmojiSelectedListener
|
private val onEmojiSelectedListener: OnEmojiSelectedListener,
|
||||||
|
private val animate: Boolean
|
||||||
) : RecyclerView.Adapter<BindingHolder<ItemEmojiButtonBinding>>() {
|
) : RecyclerView.Adapter<BindingHolder<ItemEmojiButtonBinding>>() {
|
||||||
|
|
||||||
private val emojiList: List<Emoji> = emojiList.filter { emoji -> emoji.visibleInPicker == null || emoji.visibleInPicker }
|
private val emojiList: List<Emoji> = emojiList.filter { emoji -> emoji.visibleInPicker == null || emoji.visibleInPicker }
|
||||||
|
@ -44,9 +45,16 @@ class EmojiAdapter(
|
||||||
val emoji = emojiList[position]
|
val emoji = emojiList[position]
|
||||||
val emojiImageView = holder.binding.root
|
val emojiImageView = holder.binding.root
|
||||||
|
|
||||||
|
if (animate) {
|
||||||
Glide.with(emojiImageView)
|
Glide.with(emojiImageView)
|
||||||
.load(emoji.url)
|
.load(emoji.url)
|
||||||
.into(emojiImageView)
|
.into(emojiImageView)
|
||||||
|
} else {
|
||||||
|
Glide.with(emojiImageView)
|
||||||
|
.asBitmap()
|
||||||
|
.load(emoji.url)
|
||||||
|
.into(emojiImageView)
|
||||||
|
}
|
||||||
|
|
||||||
emojiImageView.setOnClickListener {
|
emojiImageView.setOnClickListener {
|
||||||
onEmojiSelectedListener.onEmojiSelected(emoji.shortcode)
|
onEmojiSelectedListener.onEmojiSelected(emoji.shortcode)
|
||||||
|
|
|
@ -122,7 +122,7 @@ class AnnouncementsActivity : BottomSheetActivity(), AnnouncementActionListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.emojis.observe(this) {
|
viewModel.emojis.observe(this) {
|
||||||
picker.adapter = EmojiAdapter(it, this)
|
picker.adapter = EmojiAdapter(it, this, animateEmojis)
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.load()
|
viewModel.load()
|
||||||
|
|
|
@ -138,6 +138,8 @@ class ComposeActivity :
|
||||||
private var finishingUploadDialog: ProgressDialog? = null
|
private var finishingUploadDialog: ProgressDialog? = null
|
||||||
private var photoUploadUri: Uri? = null
|
private var photoUploadUri: Uri? = null
|
||||||
|
|
||||||
|
private val preferences by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
var maximumTootCharacters = InstanceInfoRepository.DEFAULT_CHARACTER_LIMIT
|
var maximumTootCharacters = InstanceInfoRepository.DEFAULT_CHARACTER_LIMIT
|
||||||
var charactersReservedPerUrl = InstanceInfoRepository.DEFAULT_CHARACTERS_RESERVED_PER_URL
|
var charactersReservedPerUrl = InstanceInfoRepository.DEFAULT_CHARACTERS_RESERVED_PER_URL
|
||||||
|
@ -205,7 +207,6 @@ class ComposeActivity :
|
||||||
accountManager.setActiveAccount(accountId)
|
accountManager.setActiveAccount(accountId)
|
||||||
}
|
}
|
||||||
|
|
||||||
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
|
|
||||||
val theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT)
|
val theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT)
|
||||||
if (theme == "black") {
|
if (theme == "black") {
|
||||||
setTheme(R.style.TuskyDialogActivityBlackTheme)
|
setTheme(R.style.TuskyDialogActivityBlackTheme)
|
||||||
|
@ -216,7 +217,7 @@ class ComposeActivity :
|
||||||
// do not do anything when not logged in, activity will be finished in super.onCreate() anyway
|
// do not do anything when not logged in, activity will be finished in super.onCreate() anyway
|
||||||
val activeAccount = accountManager.activeAccount ?: return
|
val activeAccount = accountManager.activeAccount ?: return
|
||||||
|
|
||||||
setupAvatar(preferences, activeAccount)
|
setupAvatar(activeAccount)
|
||||||
val mediaAdapter = MediaPreviewAdapter(
|
val mediaAdapter = MediaPreviewAdapter(
|
||||||
this,
|
this,
|
||||||
onAddCaption = { item ->
|
onAddCaption = { item ->
|
||||||
|
@ -562,7 +563,7 @@ class ComposeActivity :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAvatar(preferences: SharedPreferences, activeAccount: AccountEntity) {
|
private fun setupAvatar(activeAccount: AccountEntity) {
|
||||||
val actionBarSizeAttr = intArrayOf(R.attr.actionBarSize)
|
val actionBarSizeAttr = intArrayOf(R.attr.actionBarSize)
|
||||||
val a = obtainStyledAttributes(null, actionBarSizeAttr)
|
val a = obtainStyledAttributes(null, actionBarSizeAttr)
|
||||||
val avatarSize = a.getDimensionPixelSize(0, 1)
|
val avatarSize = a.getDimensionPixelSize(0, 1)
|
||||||
|
@ -1148,7 +1149,8 @@ class ComposeActivity :
|
||||||
|
|
||||||
private fun setEmojiList(emojiList: List<Emoji>?) {
|
private fun setEmojiList(emojiList: List<Emoji>?) {
|
||||||
if (emojiList != null) {
|
if (emojiList != null) {
|
||||||
binding.emojiView.adapter = EmojiAdapter(emojiList, this@ComposeActivity)
|
val animateEmojis = preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false)
|
||||||
|
binding.emojiView.adapter = EmojiAdapter(emojiList, this@ComposeActivity, animateEmojis)
|
||||||
enableButton(binding.composeEmojiButton, true, emojiList.isNotEmpty())
|
enableButton(binding.composeEmojiButton, true, emojiList.isNotEmpty())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue