Fix display name
This commit is contained in:
parent
5e6f992782
commit
7171360785
|
@ -1,8 +1,9 @@
|
|||
Changed:
|
||||
- One logout entry in the menu (it will remove the account from the app)
|
||||
- Improve memory management
|
||||
- Improve scroll
|
||||
- One logout entry in the menu (it will remove the account from the app)
|
||||
- Clear push notifications when visiting notifications tab
|
||||
|
||||
Fixed:
|
||||
- Long press to store media download the preview image
|
||||
- Fix pagination with Nitter timelines
|
|
@ -2067,7 +2067,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
@Override
|
||||
public void onRetrieveEmojiAccount(Account account) {
|
||||
TextView displayedName = headerLayout.findViewById(R.id.displayedName);
|
||||
displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
displayedName.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -951,7 +951,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
|
|||
@Override
|
||||
public void onRetrieveEmojiAccount(Account account) {
|
||||
account_note.setText(account.getNoteSpan(), TextView.BufferType.SPANNABLE);
|
||||
account_dn.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
account_dn.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
LinkedHashMap<String, Boolean> fieldsVerified = account.getFieldsVerified();
|
||||
if (account.getFieldsSpan() != null && account.getFieldsSpan().size() > 0) {
|
||||
HashMap<SpannableString, SpannableString> fieldsSpan = account.getFieldsSpan();
|
||||
|
|
|
@ -18,7 +18,6 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
@ -68,7 +67,6 @@ import app.fedilab.android.interfaces.OnRetrieveEmojiAccountInterface;
|
|||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY;
|
||||
import static app.fedilab.android.helper.Helper.drawableToBitmap;
|
||||
import static app.fedilab.android.helper.Helper.hashtagPattern;
|
||||
|
||||
|
||||
|
@ -205,8 +203,8 @@ public class Account implements Parcelable {
|
|||
if (((Activity) context).isFinishing())
|
||||
return;
|
||||
|
||||
account.setdisplayNameSpan(new SpannableString(account.getDisplay_name()));
|
||||
SpannableString displayNameSpan = account.getdisplayNameSpan();
|
||||
account.setDisplayNameSpan(new SpannableString(account.getDisplay_name()));
|
||||
SpannableString displayNameSpan = account.getDisplayNameSpan();
|
||||
if (displayNameSpan == null)
|
||||
return;
|
||||
final List<Emojis> emojis = account.getEmojis();
|
||||
|
@ -218,7 +216,7 @@ public class Account implements Parcelable {
|
|||
try {
|
||||
Glide.with(context)
|
||||
.asDrawable()
|
||||
.load(emoji.getUrl())
|
||||
.load(disableAnimatedEmoji ? emoji.getStatic_url() : emoji.getUrl())
|
||||
.into(new SimpleTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
|
@ -228,17 +226,9 @@ public class Account implements Parcelable {
|
|||
for (int startPosition = -1; (startPosition = displayNameSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
|
||||
final int endPosition = startPosition + targetedEmoji.length();
|
||||
if (endPosition <= displayNameSpan.toString().length() && endPosition >= startPosition) {
|
||||
ImageSpan imageSpan;
|
||||
if (!disableAnimatedEmoji) {
|
||||
resource.setBounds(0, 0, (int) Helper.convertDpToPixel(20, context), (int) Helper.convertDpToPixel(20, context));
|
||||
resource.setVisible(true, true);
|
||||
imageSpan = new ImageSpan(resource);
|
||||
} else {
|
||||
Bitmap bitmap = drawableToBitmap(resource.getCurrent());
|
||||
imageSpan = new ImageSpan(context,
|
||||
Bitmap.createScaledBitmap(bitmap, (int) Helper.convertDpToPixel(20, context),
|
||||
(int) Helper.convertDpToPixel(20, context), false));
|
||||
}
|
||||
ImageSpan imageSpan = new ImageSpan(resource);
|
||||
displayNameSpan.setSpan(
|
||||
imageSpan, startPosition,
|
||||
endPosition, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
|
@ -531,11 +521,11 @@ public class Account implements Parcelable {
|
|||
this.username = username;
|
||||
}
|
||||
|
||||
public SpannableString getdisplayNameSpan() {
|
||||
public SpannableString getDisplayNameSpan() {
|
||||
return displayNameSpan;
|
||||
}
|
||||
|
||||
public void setdisplayNameSpan(SpannableString displayNameSpan) {
|
||||
public void setDisplayNameSpan(SpannableString displayNameSpan) {
|
||||
this.displayNameSpan = displayNameSpan;
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ public class Status implements Parcelable {
|
|||
private boolean isVisible = true;
|
||||
private boolean fetchMore = false;
|
||||
private String content, contentCW, contentTranslated;
|
||||
private SpannableString contentSpan, displayNameSpan, contentSpanCW, contentSpanTranslated;
|
||||
private SpannableString contentSpan, contentSpanCW, contentSpanTranslated;
|
||||
private RetrieveFeedsAsyncTask.Type type;
|
||||
private int itemViewType;
|
||||
private String conversationId;
|
||||
|
@ -230,7 +230,6 @@ public class Status implements Parcelable {
|
|||
this.contentCW = in.readString();
|
||||
this.contentTranslated = in.readString();
|
||||
this.contentSpan = (SpannableString) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
this.displayNameSpan = (SpannableString) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
this.contentSpanCW = (SpannableString) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
this.contentSpanTranslated = (SpannableString) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
int tmpType = in.readInt();
|
||||
|
@ -366,9 +365,6 @@ public class Status implements Parcelable {
|
|||
status.setContentSpan(treatment(context, spannableStringContent, status));
|
||||
if (spannableStringCW.length() > 0)
|
||||
status.setContentSpanCW(spannableStringCW);
|
||||
SpannableString displayNameSpan = new SpannableString(status.reblog != null ? status.getReblog().getAccount().getDisplay_name() : status.getAccount().getDisplay_name());
|
||||
if (displayNameSpan.length() > 0)
|
||||
status.setDisplayNameSpan(displayNameSpan);
|
||||
|
||||
}
|
||||
|
||||
|
@ -822,12 +818,7 @@ public class Status implements Parcelable {
|
|||
spannableStringTranslated = new SpannableString(Html.fromHtml(status.getContentTranslated()));
|
||||
|
||||
status.setContentSpanTranslated(treatment(context, spannableStringTranslated, status));
|
||||
String displayName;
|
||||
if (status.getReblog() != null) {
|
||||
displayName = status.getReblog().getAccount().getDisplay_name();
|
||||
} else {
|
||||
displayName = status.getAccount().getDisplay_name();
|
||||
}
|
||||
|
||||
SpannableString contentSpanTranslated = status.getContentSpanTranslated();
|
||||
Matcher matcherALink = Patterns.WEB_URL.matcher(contentSpanTranslated.toString());
|
||||
while (matcherALink.find()) {
|
||||
|
@ -856,8 +847,6 @@ public class Status implements Parcelable {
|
|||
|
||||
}
|
||||
status.setContentSpanTranslated(contentSpanTranslated);
|
||||
SpannableString displayNameSpan = new SpannableString(displayName);
|
||||
status.setDisplayNameSpan(displayNameSpan);
|
||||
}
|
||||
|
||||
private static void makeEmojis(final Context context, Status status) {
|
||||
|
@ -871,7 +860,6 @@ public class Status implements Parcelable {
|
|||
final List<Emojis> emojis = status.getReblog() != null ? status.getReblog().getEmojis() : status.getEmojis();
|
||||
|
||||
|
||||
SpannableString displayNameSpan = status.getDisplayNameSpan();
|
||||
SpannableString contentSpan = status.getContentSpan();
|
||||
SpannableString contentSpanCW = status.getContentSpanCW();
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
@ -1176,7 +1164,6 @@ public class Status implements Parcelable {
|
|||
dest.writeString(this.contentCW);
|
||||
dest.writeString(this.contentTranslated);
|
||||
TextUtils.writeToParcel(this.contentSpan, dest, flags);
|
||||
TextUtils.writeToParcel(this.displayNameSpan, dest, flags);
|
||||
TextUtils.writeToParcel(this.contentSpanCW, dest, flags);
|
||||
TextUtils.writeToParcel(this.contentSpanTranslated, dest, flags);
|
||||
dest.writeInt(this.type == null ? -1 : this.type.ordinal());
|
||||
|
@ -1306,13 +1293,6 @@ public class Status implements Parcelable {
|
|||
this.favourites_count = favourites_count;
|
||||
}
|
||||
|
||||
public SpannableString getDisplayNameSpan() {
|
||||
return this.displayNameSpan;
|
||||
}
|
||||
|
||||
public void setDisplayNameSpan(SpannableString displayNameSpan) {
|
||||
this.displayNameSpan = displayNameSpan;
|
||||
}
|
||||
|
||||
public boolean isReblogged() {
|
||||
return reblogged;
|
||||
|
|
|
@ -68,23 +68,23 @@ public class AccountsAdminListAdapter extends RecyclerView.Adapter implements On
|
|||
Account account = accountAdmin.getAccount();
|
||||
|
||||
|
||||
if (account.getdisplayNameSpan() == null || account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||
if (account.getDisplayNameSpan() == null || account.getDisplayNameSpan().toString().trim().equals("")) {
|
||||
if (account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn.setText(account.getDisplay_name());
|
||||
else if (account.getDisplay_name() != null) {
|
||||
holder.account_dn.setText(account.getDisplay_name().replace("@", ""));
|
||||
}
|
||||
} else
|
||||
holder.account_dn.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_dn.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
|
||||
if (account.getdisplayNameSpan() == null || account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||
if (account.getDisplayNameSpan() == null || account.getDisplayNameSpan().toString().trim().equals("")) {
|
||||
if (account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn.setText(account.getDisplay_name());
|
||||
else if (account.getDisplay_name() != null) {
|
||||
holder.account_dn.setText(account.getDisplay_name().replace("@", ""));
|
||||
}
|
||||
} else
|
||||
holder.account_dn.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_dn.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_un.setText(String.format("@%s", account.getUsername()));
|
||||
holder.account_ac.setText(account.getAcct());
|
||||
if (account.getDisplay_name().equals(account.getAcct()))
|
||||
|
|
|
@ -167,13 +167,13 @@ public class AccountsListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
holder.account_follow.hide();
|
||||
}
|
||||
|
||||
if (account.getdisplayNameSpan() == null || account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||
if (account.getDisplayNameSpan() == null || account.getDisplayNameSpan().toString().trim().equals("")) {
|
||||
if (account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn.setText(account.getDisplay_name());
|
||||
else
|
||||
holder.account_dn.setText(account.getUsername().replace("@", ""));
|
||||
} else
|
||||
holder.account_dn.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_dn.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_un.setText(String.format("@%s", account.getUsername()));
|
||||
holder.account_ac.setText(account.getAcct());
|
||||
if (account.getUsername().equals(account.getAcct()))
|
||||
|
|
|
@ -185,8 +185,8 @@ public class ArtListAdapter extends RecyclerView.Adapter implements OnPostAction
|
|||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
if (status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.art_username.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
if (status.getAccount().getDisplayNameSpan() != null && status.getAccount().getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.art_username.setText(status.getAccount().getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.art_username.setText(status.getAccount().getUsername());
|
||||
|
||||
|
|
|
@ -327,11 +327,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
}
|
||||
|
||||
|
||||
if (notification.getAccount().getdisplayNameSpan() == null) {
|
||||
if (notification.getAccount().getDisplayNameSpan() == null) {
|
||||
holder.notification_type.setText(typeString);
|
||||
notification.getAccount().setStored_displayname(notification.getAccount().getDisplay_name());
|
||||
} else
|
||||
holder.notification_type.setText(notification.getAccount().getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.notification_type.setText(notification.getAccount().getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
|
||||
if (imgH != null) {
|
||||
DrawableCompat.setTint(imgH, ContextCompat.getColor(context, R.color.cyanea_accent));
|
||||
|
|
|
@ -944,8 +944,8 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
|
|||
});
|
||||
|
||||
|
||||
if (status.getDisplayNameSpan() != null && status.getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.pf_username.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
if (status.getAccount().getDisplayNameSpan() != null && status.getAccount().getDisplayNameSpan().toString().trim().length() > 0)
|
||||
holder.pf_username.setText(status.getAccount().getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.pf_username.setText(status.getAccount().getUsername());
|
||||
|
||||
|
|
|
@ -67,15 +67,15 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
|||
Report report = reports.get(position);
|
||||
Account account = report.getAccount().getAccount();
|
||||
Account target_account = report.getTarget_account().getAccount();
|
||||
if (account.getdisplayNameSpan() == null || account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||
if (account.getDisplayNameSpan() == null || account.getDisplayNameSpan().toString().trim().equals("")) {
|
||||
if (account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn_reporter.setText(account.getDisplay_name());
|
||||
else
|
||||
holder.account_dn_reporter.setText(account.getUsername().replace("@", ""));
|
||||
} else
|
||||
holder.account_dn_reporter.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.account_dn_reporter.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
|
||||
if (target_account.getdisplayNameSpan() == null || target_account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||
if (target_account.getDisplayNameSpan() == null || target_account.getDisplayNameSpan().toString().trim().equals("")) {
|
||||
if (target_account.getDisplay_name() != null && !target_account.getDisplay_name().trim().equals(""))
|
||||
holder.account_dn.setText(target_account.getDisplay_name());
|
||||
else {
|
||||
|
@ -84,8 +84,8 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (target_account.getdisplayNameSpan() != null) {
|
||||
holder.account_dn.setText(target_account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
if (target_account.getDisplayNameSpan() != null) {
|
||||
holder.account_dn.setText(target_account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1593,6 +1593,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
//Displays name & emoji in toot header
|
||||
final Account accountForUrl;
|
||||
SpannableString displayNameSpan = status.getReblog() != null ? status.getReblog().getAccount().getDisplayNameSpan():status.getAccount().getDisplayNameSpan();
|
||||
if (status.getReblog() != null) {
|
||||
accountForUrl = status.getReblog().getAccount();
|
||||
holder.status_account_displayname.setVisibility(View.VISIBLE);
|
||||
|
@ -1604,8 +1605,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
intent.putExtras(b);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
if (status.getReblog().getAccount().getDisplay_name().length() > 0)
|
||||
holder.status_account_displayname_owner.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.status_account_displayname_owner.setText(displayNameSpan, TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.status_account_displayname_owner.setText(status.getReblog().getAccount().getAcct().replace("@", ""));
|
||||
holder.status_account_displayname_owner.setVisibility(View.VISIBLE);
|
||||
|
@ -1615,10 +1617,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
} else {
|
||||
accountForUrl = status.getAccount();
|
||||
holder.status_account_displayname.setVisibility(View.GONE);
|
||||
if (status.getDisplayNameSpan() == null || status.getDisplayNameSpan().toString().trim().length() == 0)
|
||||
if (displayNameSpan == null || displayNameSpan.toString().trim().length() == 0)
|
||||
holder.status_account_displayname_owner.setText(status.getAccount().getUsername().replace("@", ""), TextView.BufferType.SPANNABLE);
|
||||
else
|
||||
holder.status_account_displayname_owner.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
holder.status_account_displayname_owner.setText(displayNameSpan, TextView.BufferType.SPANNABLE);
|
||||
}
|
||||
//-------- END -> Displays name & emoji in toot header
|
||||
|
||||
|
|
|
@ -1884,7 +1884,7 @@ public class Helper {
|
|||
} else {
|
||||
Account.makeAccountNameEmoji(activity, account);
|
||||
username.setText(String.format("@%s", account.getUsername() + "@" + account.getInstance()));
|
||||
displayedName.setText(account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
displayedName.setText(account.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||
loadGiF(activity, account, profilePicture);
|
||||
String urlHeader = !disableGif ? account.getHeader() : account.getHeader_static();
|
||||
if (urlHeader.startsWith("/")) {
|
||||
|
|
Loading…
Reference in New Issue