Some fixes

This commit is contained in:
tom79 2019-08-07 11:34:05 +02:00
parent 8adb9d0fcc
commit 079d1c5ab5
4 changed files with 28 additions and 24 deletions

View File

@ -158,9 +158,7 @@ public class Notification implements Parcelable {
return;
final List<Emojis> emojisAccounts = status.getReblog() != null ?status.getReblog().getAccount().getEmojis():status.getAccount().getEmojis();
status.getAccount().makeAccountNameEmoji(context, null, status.getAccount());
//SpannableString displayNameSpan = status.getDisplayNameSpan();
SpannableString displayNameSpan = status.getDisplayNameSpan();
SpannableString contentSpan = status.getContentSpan();
SpannableString contentSpanCW = status.getContentSpanCW();
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
@ -221,7 +219,7 @@ public class Notification implements Parcelable {
}
}
}
/* if (displayNameSpan != null && displayNameSpan.toString().contains(targetedEmoji)) {
if (displayNameSpan != null && displayNameSpan.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = displayNameSpan.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
final int endPosition = startPosition + targetedEmoji.length();
@ -235,7 +233,6 @@ public class Notification implements Parcelable {
}
}
}
status.setDisplayNameSpan(displayNameSpan);*/
if (contentSpanCW != null && contentSpanCW.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = contentSpanCW.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
@ -263,6 +260,7 @@ public class Notification implements Parcelable {
if( i[0] == (emojis.size())) {
status.setContentSpan(contentSpan);
status.setContentSpanCW(contentSpanCW);
status.setDisplayNameSpan(displayNameSpan);
status.setEmojiFound(true);
listener.onRetrieveEmoji(notification);
}

View File

@ -20,7 +20,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
@ -46,15 +45,12 @@ import android.view.View;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.load.model.FileLoader;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition;
import com.github.penfeizhou.animation.FrameAnimationDrawable;
import com.github.penfeizhou.animation.apng.APNGDrawable;
import com.github.penfeizhou.animation.gif.GifDrawable;
import com.github.penfeizhou.animation.loader.AssetStreamLoader;
import java.io.File;
import java.net.URI;
@ -688,10 +684,10 @@ public class Status implements Parcelable{
if( spannableStringContent.length() > 0)
status.setContentSpan(treatment(context, spannableStringContent, status));
if( spannableStringCW.length() > 0)
status.setContentSpanCW(treatment(context, spannableStringCW, status));
status.setContentSpanCW(spannableStringCW);
SpannableString displayNameSpan = new SpannableString(status.reblog!=null?status.getReblog().getAccount().getDisplay_name():status.getAccount().getDisplay_name());
status.setDisplayNameSpan(displayNameSpan);
status.setClickable(true);
if( displayNameSpan.length() > 0)
status.setDisplayNameSpan(displayNameSpan);
}
@ -775,8 +771,6 @@ public class Status implements Parcelable{
}
}
SpannableString spannableStringT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
spannableStringT = new SpannableString(Html.fromHtml(spannableString.toString().replaceAll("^<p>","").replaceAll("<p>","<br/><br/>").replaceAll("</p>","").replaceAll("<br />","<br/>").replaceAll("[\\s]{2}","&nbsp;&nbsp;"), Html.FROM_HTML_MODE_LEGACY));
@ -1080,7 +1074,7 @@ public class Status implements Parcelable{
final List<Emojis> emojis = status.getReblog() != null ? status.getReblog().getEmojis() : status.getEmojis();
final List<Emojis> emojisAccounts = status.getReblog() != null ?status.getReblog().getAccount().getEmojis():status.getAccount().getEmojis();
status.getAccount().makeAccountNameEmoji(context, null, status.getAccount());
//Account.makeAccountNameEmoji(context, null, status.getAccount());
SpannableString displayNameSpan = status.getDisplayNameSpan();
SpannableString contentSpan = status.getContentSpan();
@ -1168,7 +1162,6 @@ public class Status implements Parcelable{
}
}
}
status.setDisplayNameSpan(displayNameSpan);
if (contentSpanCW != null && contentSpanCW.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
for (int startPosition = -1; (startPosition = contentSpanCW.toString().indexOf(targetedEmoji, startPosition + 1)) != -1; startPosition++) {
@ -1196,6 +1189,7 @@ public class Status implements Parcelable{
if( i[0] == (emojis.size())) {
status.setContentSpan(contentSpan);
status.setContentSpanCW(contentSpanCW);
status.setDisplayNameSpan(displayNameSpan);
status.setEmojiFound(true);
listener.onRetrieveEmoji(status, false);
}

View File

@ -438,12 +438,18 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
else
holder.status_document_container.setVisibility(View.VISIBLE);
if( !status.isClickable())
if( !status.isClickable()) {
status.setClickable(true);
Status.transform(context, status);
if( !status.isEmojiFound())
}
if( !status.isEmojiFound()) {
status.setEmojiFound(true);
Notification.makeEmojis(context, NotificationsListAdapter.this, notification);
if( !status.isImageFound())
}
if( !status.isImageFound()) {
status.setImageFound(true);
Status.makeImage(context, NotificationsListAdapter.this, status);
}
holder.notification_status_content.setText(status.getContentSpan(), TextView.BufferType.SPANNABLE);
holder.status_spoiler.setText(status.getContentSpanCW(), TextView.BufferType.SPANNABLE);
holder.status_spoiler.setMovementMethod(LinkMovementMethod.getInstance());

View File

@ -1546,12 +1546,18 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
Helper.changeDrawableColor(context, holder.hide_preview_h, R.color.white);
}
if (!status.isClickable())
if (!status.isClickable()) {
status.setClickable(true);
Status.transform(context, status);
if (!status.isEmojiFound())
}
if (!status.isEmojiFound()) {
status.setEmojiFound(true);
Status.makeEmojis(context, this, status);
if (!status.isImageFound())
}
if (!status.isImageFound()) {
status.setImageFound(true);
Status.makeImage(context, this, status);
}
holder.status_content.setOnTouchListener(new View.OnTouchListener() {
@Override
@ -1845,10 +1851,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
} else {
accountForUrl = status.getAccount();
holder.status_account_displayname.setVisibility(View.GONE);
if (status.getAccount().getdisplayNameSpan() == null || status.getAccount().getdisplayNameSpan().toString().trim().length() == 0)
if (status.getDisplayNameSpan() == null || status.getDisplayNameSpan().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.getAccount().getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
holder.status_account_displayname_owner.setText(status.getDisplayNameSpan(), TextView.BufferType.SPANNABLE);
}
//-------- END -> Displays name & emoji in toot header