emojireactions: implement coloring buttons

main
Alibek Omarov 5 years ago
parent 82c6809623
commit 3824d4c3ba
  1. 9
      app/src/main/java/com/keylesspalace/tusky/adapter/StatusDetailedViewHolder.java
  2. 5
      app/src/main/res/color/emoji_reaction_button.xml
  3. 3
      app/src/main/res/layout/item_emoji_reaction.xml

@ -16,7 +16,7 @@ import android.widget.Toast;
import android.util.Log; import android.util.Log;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.emoji.widget.EmojiButton; import androidx.emoji.widget.EmojiAppCompatButton;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.google.android.flexbox.FlexboxLayoutManager; import com.google.android.flexbox.FlexboxLayoutManager;
@ -130,7 +130,7 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
} }
private class EmojiReactionViewHolder extends RecyclerView.ViewHolder { private class EmojiReactionViewHolder extends RecyclerView.ViewHolder {
public EmojiButton emojiReaction; public EmojiAppCompatButton emojiReaction;
EmojiReactionViewHolder(View view) { EmojiReactionViewHolder(View view) {
super(view); super(view);
emojiReaction = view.findViewById(R.id.status_emoji_reaction); emojiReaction = view.findViewById(R.id.status_emoji_reaction);
@ -155,11 +155,12 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
@Override @Override
public void onBindViewHolder(EmojiReactionViewHolder holder, int position) { public void onBindViewHolder(EmojiReactionViewHolder holder, int position) {
EmojiReaction reaction = reactions.get(position); EmojiReaction reaction = reactions.get(position);
String str = reaction.getEmoji() + " " + reaction.getCount(); String str = reaction.getName() + " " + reaction.getCount();
// no custom emoji yet! // no custom emoji yet!
holder.emojiReaction.setText(str); holder.emojiReaction.setText(str);
holder.emojiReaction.setActivated(reaction.getMe());
holder.emojiReaction.setOnClickListener(v -> {});
} }
// total number of rows // total number of rows

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="false" android:color="@color/tusky_grey_50"/>
<item android:state_activated="true" android:color="@color/tusky_blue"/>
</selector>

@ -6,7 +6,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<!-- not a best way but I'm lazy to do proper button --> <!-- not a best way but I'm lazy to do proper button -->
<androidx.emoji.widget.EmojiButton <androidx.emoji.widget.EmojiAppCompatButton
android:id="@+id/status_emoji_reaction" android:id="@+id/status_emoji_reaction"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -17,6 +17,7 @@
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
app:backgroundTint="@color/emoji_reaction_button"
tools:text="A 0" /> tools:text="A 0" />
</FrameLayout> </FrameLayout>

Loading…
Cancel
Save