diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index 282de7670..755c1a9a4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -4,10 +4,12 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.Fragment; import android.app.assist.AssistContent; import android.content.Intent; +import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.Color; @@ -135,6 +137,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList private CoverImageView cover; private View avatarBorder; private TextView name, username, bio, followersCount, followersLabel, followingCount, followingLabel; + private ImageView lockIcon, botIcon; private ProgressBarButton actionButton, notifyButton; private ViewPager2 pager; private NestedRecyclerScrollView scrollView; @@ -237,6 +240,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList avatarBorder=content.findViewById(R.id.avatar_border); name=content.findViewById(R.id.name); username=content.findViewById(R.id.username); + lockIcon=content.findViewById(R.id.lock_icon); + botIcon=content.findViewById(R.id.bot_icon); bio=content.findViewById(R.id.bio); followersCount=content.findViewById(R.id.followers_count); followersLabel=content.findViewById(R.id.followers_label); @@ -409,7 +414,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList followersBtn.setOnClickListener(this::onFollowersOrFollowingClick); followingBtn.setOnClickListener(this::onFollowersOrFollowingClick); - username.setOnClickListener(v->{ + content.findViewById(R.id.username_wrap).setOnClickListener(v->{ try { new GetInstance() .setCallback(new Callback<>(){ @@ -430,7 +435,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList .execRemote(Uri.parse(account.url).getHost()); } catch (NullPointerException ignored) { // maybe the url was malformed? - Toast.makeText(getContext(), R.string.error, Toast.LENGTH_SHORT); + Toast.makeText(getContext(), R.string.error, Toast.LENGTH_SHORT).show(); } }); @@ -678,6 +683,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList } } + @SuppressLint("SetTextI18n") private void bindHeaderView(){ setTitle(account.displayName); setSubtitle(getResources().getQuantityString(R.plurals.x_posts, (int)(account.statusesCount%1000), account.statusesCount)); @@ -710,36 +716,16 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList String acct = ((isSelf || account.isRemote) ? account.getFullyQualifiedName() : account.acct); - if(account.locked){ - ssb=new SpannableStringBuilder("@"); - ssb.append(acct); - ssb.append(" "); - Drawable lock=username.getResources().getDrawable(R.drawable.ic_lock, getActivity().getTheme()).mutate(); - lock.setBounds(0, 0, lock.getIntrinsicWidth(), lock.getIntrinsicHeight()); - lock.setTint(username.getCurrentTextColor()); - ssb.append(getString(R.string.manually_approves_followers), new ImageSpan(lock, ImageSpan.ALIGN_BASELINE), 0); - username.setText(ssb); - }else if(account.bot){ - ssb=new SpannableStringBuilder("@"); - ssb.append(account.acct); - if(isSelf){ - ssb.append('@'); - ssb.append(AccountSessionManager.getInstance().getAccount(accountID).domain); - } - ssb.append(" "); - Drawable botIcon=username.getResources().getDrawable(R.drawable.ic_bot, getActivity().getTheme()).mutate(); - botIcon.setBounds(0, 0, botIcon.getIntrinsicWidth(), botIcon.getIntrinsicHeight()); - botIcon.setTint(username.getCurrentTextColor()); - ssb.append(getString(R.string.manually_approves_followers), new ImageSpan(botIcon, ImageSpan.ALIGN_BASELINE), 0); - username.setText(ssb); - }else{ - // noinspection SetTextI18n - username.setText('@'+acct); - } - CharSequence parsedBio = null; - if(account.note != null){ - parsedBio=HtmlParser.parse(account.note, account.emojis, Collections.emptyList(), Collections.emptyList(), accountID); - } + + username.setText('@'+acct); + + lockIcon.setVisibility(account.locked ? View.VISIBLE : View.GONE); + lockIcon.setImageTintList(ColorStateList.valueOf(username.getCurrentTextColor())); + + botIcon.setVisibility(account.bot ? View.VISIBLE : View.GONE); + botIcon.setImageTintList(ColorStateList.valueOf(username.getCurrentTextColor())); + + CharSequence parsedBio=HtmlParser.parse(account.note, account.emojis, Collections.emptyList(), Collections.emptyList(), accountID); if(TextUtils.isEmpty(parsedBio)){ bio.setVisibility(View.GONE); }else{ @@ -750,7 +736,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList followingCount.setText(UiUtils.abbreviateNumber(account.followingCount)); followersLabel.setText(getResources().getQuantityString(R.plurals.followers, (int)Math.min(999, account.followersCount))); followingLabel.setText(getResources().getQuantityString(R.plurals.following, (int)Math.min(999, account.followingCount))); - + if (account.followersCount < 0) followersBtn.setVisibility(View.GONE); if (account.followingCount < 0) followingBtn.setVisibility(View.GONE); if (account.followersCount < 0 || account.followingCount < 0) @@ -972,11 +958,12 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList notifyProgress.setIndeterminateTintList(notifyButton.getTextColors()); followsYouView.setVisibility(relationship.followedBy ? View.VISIBLE : View.GONE); notifyButton.setSelected(relationship.notifying); + notifyButton.setContentDescription(getString(relationship.notifying ? R.string.sk_user_post_notifications_on : R.string.sk_user_post_notifications_off, '@'+account.username)); + if (!isOwnProfile) { setNote(relationship.note); // aboutFragment.setNote(relationship.note, accountID, profileAccountID); } - notifyButton.setContentDescription(getString(relationship.notifying ? R.string.sk_user_post_notifications_on : R.string.sk_user_post_notifications_off, '@'+account.username)); } public ImageButton getFab() { diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index 15443333c..065b34177 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -148,6 +148,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ name=findViewById(R.id.name); time=findViewById(R.id.time); username=findViewById(R.id.username); + botIcon=findViewById(R.id.bot_icon); timeUsernameSeparator=findViewById(R.id.separator); avatar=findViewById(R.id.avatar); more=findViewById(R.id.more); diff --git a/mastodon/src/main/res/drawable/ic_fluent_bot_20_filled.xml b/mastodon/src/main/res/drawable/ic_fluent_bot_20_filled.xml index 56e754e5f..260c2c92b 100644 --- a/mastodon/src/main/res/drawable/ic_fluent_bot_20_filled.xml +++ b/mastodon/src/main/res/drawable/ic_fluent_bot_20_filled.xml @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/mastodon/src/main/res/drawable/ic_lock.xml b/mastodon/src/main/res/drawable/ic_lock.xml deleted file mode 100644 index 5bd09e680..000000000 --- a/mastodon/src/main/res/drawable/ic_lock.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/mastodon/src/main/res/drawable/ic_lock_fill1_20px.xml b/mastodon/src/main/res/drawable/ic_lock_fill1_20px.xml deleted file mode 100644 index 728a4208e..000000000 --- a/mastodon/src/main/res/drawable/ic_lock_fill1_20px.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/mastodon/src/main/res/layout/display_item_header.xml b/mastodon/src/main/res/layout/display_item_header.xml index 47626fd31..b89d32c0e 100644 --- a/mastodon/src/main/res/layout/display_item_header.xml +++ b/mastodon/src/main/res/layout/display_item_header.xml @@ -175,12 +175,13 @@ - + android:layout_marginStart="16dp" + android:layout_marginEnd="12dp" + android:layout_marginBottom="8dp"> + + + + + + + + + + + +