Properly Fixing the bot icon at the end of the username on the header of posts.

This commit is contained in:
LucasGGamerM 2023-01-17 22:26:54 -03:00
parent 734a8049a5
commit 7c7f3cc42a
3 changed files with 34 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import android.os.Build;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@ -135,7 +136,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
public static class Holder extends StatusDisplayItem.Holder<HeaderStatusDisplayItem> implements ImageLoaderViewHolder{
private final TextView name, username, timestamp, extraText, separator;
private final ImageView avatar, more, visibility, deleteNotification, unreadIndicator;
private final ImageView avatar, more, visibility, deleteNotification, unreadIndicator, botIcon;
private final PopupMenu optionsMenu;
private Relationship relationship;
private APIRequest<?> currentRelationshipRequest;
@ -158,6 +159,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
visibility=findViewById(R.id.visibility);
deleteNotification=findViewById(R.id.delete_notification);
unreadIndicator=findViewById(R.id.unread_indicator);
botIcon=findViewById(R.id.bot_icon);
extraText=findViewById(R.id.extra_text);
avatar.setOnClickListener(this::onAvaClick);
avatar.setOutlineProvider(roundCornersOutline);
@ -282,10 +284,23 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
public void onBind(HeaderStatusDisplayItem item){
name.setText(item.parsedName);
username.setText('@'+item.user.acct);
botIcon.setVisibility(item.user.bot ? View.VISIBLE : View.GONE);
botIcon.setColorFilter(username.getCurrentTextColor());
separator.setVisibility(View.VISIBLE);
// if(item.user.bot){
// SpannableStringBuilder ssb = new SpannableStringBuilder();
// ssb.append('@'+item.user.acct);
// ssb.append(" ");
// Drawable botIcon=username.getResources().getDrawable(R.drawable.ic_bot, itemView.getContext().getTheme()).mutate();
// botIcon.setBounds(0, 0, botIcon.getIntrinsicWidth(), botIcon.getIntrinsicHeight());
// botIcon.setTint(username.getCurrentTextColor());
// ssb.append(itemView.getContext().getString(R.string.manually_approves_followers), new ImageSpan(botIcon, ImageSpan.ALIGN_BASELINE), 0);
// username.setPaddingRelative(0,0,16,0);
// username.setText(ssb);
// }
username.setCompoundDrawablesWithIntrinsicBounds(item.user.bot ? R.drawable.ic_fluent_bot_24_filled : 0, 0, 0, 0);
// username.setCompoundDrawablesWithIntrinsicBounds(item.user.bot ? R.drawable.ic_fluent_bot_24_filled : 0, 0, 0, 0);
if (item.scheduledStatus!=null)
if (item.scheduledStatus.scheduledAt.isAfter(CreateStatus.DRAFTS_AFTER_INSTANT)) {

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M11.754,9.203C12.551,9.203 13.199,9.852 13.199,10.648L13.199,11.203L13.195,11.203C13.168,11.824 12.996,12.605 12.297,13.246C11.531,13.945 10.211,14.398 8,14.398C5.789,14.398 4.469,13.945 3.703,13.246C3.004,12.605 2.832,11.824 2.805,11.203L2.801,11.203L2.801,10.648C2.801,9.852 3.449,9.203 4.246,9.203ZM5.199,2.398C4.539,2.398 4,2.938 4,3.602L4,6.801C4,7.461 4.539,8 5.199,8L10.801,8C11.461,8 12,7.461 12,6.801L12,3.602C12,2.938 11.461,2.398 10.801,2.398L8.398,2.398C8.398,2.398 8.398,2.246 8.398,2C8.398,1.754 8.223,1.602 8,1.602C7.777,1.602 7.602,1.785 7.602,2C7.602,2.215 7.602,2.398 7.602,2.398ZM5.602,5.199C5.602,4.758 5.957,4.398 6.398,4.398C6.844,4.398 7.199,4.758 7.199,5.199C7.199,5.641 6.844,6 6.398,6C5.957,6 5.602,5.641 5.602,5.199ZM8.801,5.199C8.801,4.758 9.156,4.398 9.602,4.398C10.043,4.398 10.398,4.758 10.398,5.199C10.398,5.641 10.043,6 9.602,6C9.156,6 8.801,5.641 8.801,5.199ZM8.801,5.199"
android:fillColor="?android:textColorPrimary" />
</vector>

View File

@ -120,6 +120,14 @@
android:textAppearance="@style/m3_title_small"
tools:text="\@Gargron" />
<ImageView
android:id="@+id/bot_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
android:layout_marginTop="2dp"
android:src="@drawable/ic_fluent_bot_16_filled" />
<TextView
android:id="@+id/separator"
android:layout_width="wrap_content"