Fix sticker manager text wrapping issues.

master
Greyson Parrelli 2019-12-17 19:35:31 -05:00
parent a3521681e7
commit b6d59f1d46
3 changed files with 85 additions and 68 deletions

View File

@ -1,27 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/sticker_management_horizontal_margin"
android:layout_marginEnd="@dimen/sticker_management_horizontal_margin">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
android:src="@drawable/sticker_management_empty_background"
android:tint="?sticker_management_empty_background_color"/>
android:tint="?sticker_management_empty_background_color"
app:layout_constraintTop_toTopOf="@id/sticker_management_empty_text"
app:layout_constraintBottom_toBottomOf="@id/sticker_management_empty_text"/>
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/sticker_management_empty_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="13sp"
android:padding="12dp"
style="@style/Signal.Text.Caption"
tools:text="@string/StickerManagementAdapter_no_stickers_installed"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:text="With great power there must also come -- great responsibility!"/>
<!-- TODO: THEME!! -->
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -15,64 +15,53 @@
android:layout_width="64dp"
android:layout_height="64dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/sticker_management_divider"
tools:src="@drawable/ic_person_white_24dp"
tools:tint="@color/core_blue"/>
<LinearLayout
android:id="@+id/sticker_management_text_container"
android:id="@+id/sticker_management_title_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="4dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="4dp"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="@id/sticker_management_cover"
app:layout_constraintBottom_toBottomOf="@id/sticker_management_cover"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/sticker_management_divider"
app:layout_constraintStart_toEndOf="@id/sticker_management_cover"
app:layout_constraintEnd_toStartOf="@id/sticker_management_share_button">
app:layout_constraintEnd_toStartOf="@id/sticker_management_button_barrier">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/sticker_management_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Signal.Text.Body"
android:maxLines="2"
android:ellipsize="end"
tools:text="Spider-Man"/>
<ImageView
android:id="@+id/sticker_management_blessed_badge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginTop="1dp"
android:src="@drawable/ic_check_circle_white_18dp"
android:tint="@color/core_blue"/>
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/sticker_management_author"
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/sticker_management_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Signal.Text.Body"
android:maxLines="2"
android:ellipsize="end"
app:emoji_maxLength="45"
tools:text="Spider-Man"/>
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/sticker_management_author"
style="@style/Signal.Text.Body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/core_grey_60"
tools:text="Peter Parker"/>
tools:text="Peter Parker" />
</LinearLayout>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/sticker_management_button_barrier"
android:layout_width="0dp"
android:layout_height="match_parent"
app:barrierDirection="start"
app:constraint_referenced_ids="sticker_management_action_button,sticker_management_share_button"/>
<View
android:id="@+id/sticker_management_share_button"
android:layout_width="40dp"
@ -80,8 +69,8 @@
android:layout_marginEnd="4dp"
android:background="?sticker_management_icon"
app:layout_constraintEnd_toStartOf="@id/sticker_management_action_button"
app:layout_constraintTop_toTopOf="@id/sticker_management_text_container"
app:layout_constraintBottom_toBottomOf="@id/sticker_management_text_container" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<ImageView
android:id="@+id/sticker_management_share_button_image"
@ -100,8 +89,8 @@
android:layout_height="40dp"
android:background="?sticker_management_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/sticker_management_text_container"
app:layout_constraintBottom_toBottomOf="@id/sticker_management_text_container" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<ImageView
android:id="@+id/sticker_management_action_button_image"
@ -119,9 +108,8 @@
android:layout_width="0dp"
android:layout_height="1dp"
android:background="?sticker_management_divider_color"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="@id/sticker_management_text_container"
app:layout_constraintTop_toBottomOf="@id/sticker_management_cover"
app:layout_constraintStart_toStartOf="@id/sticker_management_title_container"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -2,8 +2,14 @@ package org.thoughtcrime.securesms.stickers;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import android.text.style.ImageSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -13,7 +19,9 @@ import android.widget.TextView;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
import org.thoughtcrime.securesms.database.model.StickerPackRecord;
import org.thoughtcrime.securesms.jobmanager.Constraint;
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.util.FeatureFlags;
@ -181,15 +189,15 @@ final class StickerManagementAdapter extends SectionedRecyclerViewAdapter<String
static class StickerViewHolder extends RecyclerView.ViewHolder {
private final ImageView cover;
private final TextView title;
private final TextView author;
private final View badge;
private final View divider;
private final View actionButton;
private final ImageView actionButtonImage;
private final View shareButton;
private final ImageView shareButtonImage;
private final ImageView cover;
private final EmojiTextView title;
private final TextView author;
private final View divider;
private final View actionButton;
private final ImageView actionButtonImage;
private final View shareButton;
private final ImageView shareButtonImage;
private final CharSequence blessedBadge;
StickerViewHolder(@NonNull View itemView) {
super(itemView);
@ -197,12 +205,12 @@ final class StickerManagementAdapter extends SectionedRecyclerViewAdapter<String
this.cover = itemView.findViewById(R.id.sticker_management_cover);
this.title = itemView.findViewById(R.id.sticker_management_title);
this.author = itemView.findViewById(R.id.sticker_management_author);
this.badge = itemView.findViewById(R.id.sticker_management_blessed_badge);
this.divider = itemView.findViewById(R.id.sticker_management_divider);
this.actionButton = itemView.findViewById(R.id.sticker_management_action_button);
this.actionButtonImage = itemView.findViewById(R.id.sticker_management_action_button_image);
this.shareButton = itemView.findViewById(R.id.sticker_management_share_button);
this.shareButtonImage = itemView.findViewById(R.id.sticker_management_share_button_image);
this.blessedBadge = buildBlessedBadge(itemView.getContext());
}
void bind(@NonNull GlideRequests glideRequests,
@ -213,7 +221,12 @@ final class StickerManagementAdapter extends SectionedRecyclerViewAdapter<String
title.setText(stickerPack.getTitle().or(itemView.getResources().getString(R.string.StickerManagementAdapter_untitled)));
author.setText(stickerPack.getAuthor().or(itemView.getResources().getString(R.string.StickerManagementAdapter_unknown)));
divider.setVisibility(lastInList ? View.GONE : View.VISIBLE);
badge.setVisibility(BlessedPacks.contains(stickerPack.getPackId()) ? View.VISIBLE : View.GONE);
if (BlessedPacks.contains(stickerPack.getPackId())) {
title.setOverflowText(blessedBadge);
} else {
title.setOverflowText(null);
}
glideRequests.load(new DecryptableUri(stickerPack.getCover().getUri()))
.transition(DrawableTransitionOptions.withCrossFade())
@ -243,6 +256,17 @@ final class StickerManagementAdapter extends SectionedRecyclerViewAdapter<String
shareButton.setOnClickListener(null);
itemView.setOnClickListener(null);
}
private static @NonNull CharSequence buildBlessedBadge(@NonNull Context context) {
SpannableString badgeSpan = new SpannableString(" ");
Drawable badge = ContextCompat.getDrawable(context, R.drawable.ic_check_circle_white_18dp);
badge.setBounds(0, 0, badge.getIntrinsicWidth(), badge.getIntrinsicHeight());
badge.setColorFilter(ContextCompat.getColor(context, R.color.core_blue), PorterDuff.Mode.MULTIPLY);
badgeSpan.setSpan(new ImageSpan(badge), 1, badgeSpan.length(), 0);
return badgeSpan;
}
}
static class HeaderViewHolder extends RecyclerView.ViewHolder {