Reactions visual improvements
(cherry picked from commit 2c89fea7324a3135c91cfbcc7b992c411c8432d0)
This commit is contained in:
parent
2e570463fb
commit
5cba7472a6
4 changed files with 31 additions and 17 deletions
|
@ -1,6 +1,8 @@
|
|||
package eu.siacs.conversations.ui;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import com.google.android.material.chip.Chip;
|
||||
import com.google.android.material.chip.ChipGroup;
|
||||
|
@ -41,6 +43,9 @@ public class BindingAdapters {
|
|||
final Consumer<Collection<String>> onModifiedReactions,
|
||||
final Runnable addReaction) {
|
||||
final var context = chipGroup.getContext();
|
||||
final var size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35, context.getResources().getDisplayMetrics());
|
||||
final var corner = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35, context.getResources().getDisplayMetrics());
|
||||
final var layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, size);
|
||||
final List<Map.Entry<String, Integer>> reactions = aggregated.reactions;
|
||||
if (reactions == null || reactions.isEmpty()) {
|
||||
chipGroup.setVisibility(View.GONE);
|
||||
|
@ -51,9 +56,13 @@ public class BindingAdapters {
|
|||
final var emoji = reaction.getKey();
|
||||
final var count = reaction.getValue();
|
||||
final Chip chip = new Chip(chipGroup.getContext());
|
||||
chip.setEnsureMinTouchTargetSize(false);
|
||||
//chip.setEnsureMinTouchTargetSize(false);
|
||||
chip.setChipMinHeight(size-32.0f);
|
||||
chip.ensureAccessibleTouchTarget(size);
|
||||
chip.setChipStartPadding(0.0f);
|
||||
chip.setChipEndPadding(0.0f);
|
||||
chip.setChipCornerRadius(corner);
|
||||
chip.setLayoutParams(layoutParams);
|
||||
if (count == 1) {
|
||||
chip.setText(emoji);
|
||||
} else {
|
||||
|
@ -91,22 +100,26 @@ public class BindingAdapters {
|
|||
});
|
||||
chipGroup.addView(chip);
|
||||
}
|
||||
if (onReceived) {
|
||||
if (addReaction != null) {
|
||||
final Chip chip = new Chip(chipGroup.getContext());
|
||||
chip.setChipMinHeight(size-32.0f);
|
||||
chip.ensureAccessibleTouchTarget(size);
|
||||
chip.setLayoutParams(layoutParams);
|
||||
chip.setChipCornerRadius(corner);
|
||||
chip.setChipIconResource(R.drawable.ic_add_reaction_24dp);
|
||||
chip.setChipStrokeColor(
|
||||
MaterialColors.getColorStateListOrNull(
|
||||
chipGroup.getContext(),
|
||||
com.google.android.material.R.attr.colorTertiary));
|
||||
//chip.setChipStrokeColor(
|
||||
// MaterialColors.getColorStateListOrNull(
|
||||
// chipGroup.getContext(),
|
||||
// com.google.android.material.R.attr.colorTertiary));
|
||||
chip.setChipBackgroundColor(
|
||||
MaterialColors.getColorStateListOrNull(
|
||||
chipGroup.getContext(),
|
||||
com.google.android.material.R.attr.colorTertiaryContainer));
|
||||
com.google.android.material.R.attr.colorSurfaceContainerLow));
|
||||
chip.setChipIconTint(
|
||||
MaterialColors.getColorStateListOrNull(
|
||||
chipGroup.getContext(),
|
||||
com.google.android.material.R.attr.colorOnTertiaryContainer));
|
||||
chip.setEnsureMinTouchTargetSize(false);
|
||||
com.google.android.material.R.attr.colorOnSurface));
|
||||
//chip.setEnsureMinTouchTargetSize(false);
|
||||
chip.setTextEndPadding(0.0f);
|
||||
chip.setTextStartPadding(0.0f);
|
||||
chip.setOnClickListener(v -> addReaction.run());
|
||||
|
|
|
@ -1622,10 +1622,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
reactions -> sendReactions(message, reactions),
|
||||
() -> addReaction(message));
|
||||
} else if (type == SENT) {
|
||||
BindingAdapters.setReactionsOnSent(
|
||||
BindingAdapters.setReactionsOnReceived(
|
||||
viewHolder.reactions,
|
||||
message.getAggregatedReactions(),
|
||||
reactions -> sendReactions(message, reactions));
|
||||
reactions -> sendReactions(message, reactions),
|
||||
() -> addReaction(message));
|
||||
}
|
||||
|
||||
if (type == RECEIVED || type == SENT) {
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
android:id="@+id/reactions_anchor"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/message_box"
|
||||
app:layout_constraintStart_toStartOf="@+id/message_box" />
|
||||
|
||||
|
@ -154,10 +154,10 @@
|
|||
android:id="@+id/reactions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible"
|
||||
app:chipSpacingHorizontal="4dp"
|
||||
app:chipSpacingHorizontal="2dp"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/message_box"
|
||||
app:layout_constraintTop_toBottomOf="@+id/reactions_anchor" />
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
android:id="@+id/reactions_anchor"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/message_box"
|
||||
app:layout_constraintEnd_toEndOf="@+id/message_box" />
|
||||
|
||||
|
@ -162,10 +162,10 @@
|
|||
android:id="@+id/reactions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginEnd="7dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible"
|
||||
app:chipSpacingHorizontal="4dp"
|
||||
app:chipSpacingHorizontal="2dp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/message_box"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintTop_toBottomOf="@+id/reactions_anchor" />
|
||||
|
|
Loading…
Reference in a new issue