chats: fix stickers and emojis

main
Alibek Omarov 4 years ago
parent d8ffcaec30
commit 92a659fea4
  1. 18
      app/src/main/java/com/keylesspalace/tusky/components/chat/ChatActivity.kt
  2. 4
      app/src/main/java/com/keylesspalace/tusky/components/compose/view/ProgressImageView.java
  3. 4
      app/src/main/java/com/keylesspalace/tusky/components/compose/view/ProgressTextView.java

@ -205,12 +205,17 @@ class ChatActivity: BottomSheetActivity(),
subscribeToUpdates() subscribeToUpdates()
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
viewModel.tryFetchStickers = preferences.getBoolean("stickers", false)
setupHeader() setupHeader()
setupChat() setupChat()
setupAttachment() setupAttachment()
setupComposeField(savedInstanceState?.getString(MESSAGE_KEY)) setupComposeField(savedInstanceState?.getString(MESSAGE_KEY))
setupButtons() setupButtons()
viewModel.setup()
photoUploadUri = savedInstanceState?.getParcelable(PHOTO_UPLOAD_URI_KEY) photoUploadUri = savedInstanceState?.getParcelable(PHOTO_UPLOAD_URI_KEY)
eventHub.events eventHub.events
@ -229,6 +234,7 @@ class ChatActivity: BottomSheetActivity(),
} }
} }
tryCache() tryCache()
} }
@ -354,7 +360,7 @@ class ChatActivity: BottomSheetActivity(),
stickerKeyboard.setupStickerKeyboard(this@ChatActivity, stickers) stickerKeyboard.setupStickerKeyboard(this@ChatActivity, stickers)
} }
} }
viewModel.emoji.observe { emoji -> setEmojiList(emoji) } viewModel.emoji.observe { setEmojiList(it) }
viewModel.media.observe { viewModel.media.observe {
if(it.isNotEmpty()) { if(it.isNotEmpty()) {
val media = it[0] val media = it[0]
@ -467,9 +473,15 @@ class ChatActivity: BottomSheetActivity(),
attachmentButton.setOnClickListener { openPickDialog() } attachmentButton.setOnClickListener { openPickDialog() }
emojiButton.setOnClickListener { showEmojis() } emojiButton.setOnClickListener { showEmojis() }
stickerButton.setOnClickListener { showStickers() } if(viewModel.tryFetchStickers) {
stickerButton.setOnClickListener { showStickers() }
stickerButton.visibility = View.VISIBLE
enableButton(stickerButton, false, false)
} else {
stickerButton.visibility = View.GONE
}
enableButton(stickerButton, false, false) emojiView.layoutManager = GridLayoutManager(this, 3, GridLayoutManager.HORIZONTAL, false)
val textColor = ThemeUtils.getColor(this, android.R.attr.textColorTertiary) val textColor = ThemeUtils.getColor(this, android.R.attr.textColorTertiary)

@ -91,8 +91,8 @@ public final class ProgressImageView extends AppCompatImageView {
super.onDraw(canvas); super.onDraw(canvas);
float angle = (progress / 100f) * 360 - 90; float angle = (progress / 100f) * 360 - 90;
float halfWidth = getWidth() / 2; float halfWidth = getWidth() / 2.0f;
float halfHeight = getHeight() / 2; float halfHeight = getHeight() / 2.0f;
progressRect.set(halfWidth * 0.75f, halfHeight * 0.75f, halfWidth * 1.25f, halfHeight * 1.25f); progressRect.set(halfWidth * 0.75f, halfHeight * 0.75f, halfWidth * 1.25f, halfHeight * 1.25f);
biggerRect.set(progressRect); biggerRect.set(progressRect);
int margin = 8; int margin = 8;

@ -90,8 +90,8 @@ public final class ProgressTextView extends TextView {
canvas.translate(getScrollX(), 0); canvas.translate(getScrollX(), 0);
float angle = (progress / 100f) * 360 - 90; float angle = (progress / 100f) * 360 - 90;
float halfWidth = getWidth() / 2; float halfWidth = getWidth() / 2.0f;
float halfHeight = getHeight() / 2; float halfHeight = getHeight() / 2.0f;
progressRect.set(halfWidth * 0.75f, halfHeight * 0.75f, halfWidth * 1.25f, halfHeight * 1.25f); progressRect.set(halfWidth * 0.75f, halfHeight * 0.75f, halfWidth * 1.25f, halfHeight * 1.25f);
biggerRect.set(progressRect); biggerRect.set(progressRect);
int margin = 8; int margin = 8;

Loading…
Cancel
Save