Loading app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +63 −76 Original line number Diff line number Diff line Loading @@ -268,12 +268,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana } }); } else if (statusDraft != null) {//Restore a draft with all messages new Thread(() -> { if (statusDraft.statusReplyList != null) { statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList); } Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { if (statusDraft.statusReplyList != null) { statusList.addAll(statusDraft.statusReplyList); binding.recyclerView.addItemDecoration(new DividerDecorationSimple(ComposeActivity.this, statusList)); Loading @@ -286,15 +283,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana binding.recyclerView.setLayoutManager(mLayoutManager); binding.recyclerView.setAdapter(composeAdapter); binding.recyclerView.scrollToPosition(composeAdapter.getItemCount() - 1); }; mainHandler.post(myRunnable); }).start(); } else if (statusReply != null) { new Thread(() -> { statusReply = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusReply); Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { statusList.add(statusReply); int statusCount = statusList.size(); statusDraftList.get(0).in_reply_to_id = statusReply.id; Loading Loading @@ -345,9 +336,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana binding.recyclerView.setAdapter(composeAdapter); statusesVM.getContext(currentInstance, BaseMainActivity.currentToken, statusReply.id) .observe(ComposeActivity.this, this::initializeContextView); }; mainHandler.post(myRunnable); }).start(); } else { //Compose without replying statusList.addAll(statusDraftList); Loading @@ -359,7 +347,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana if (statusMention != null) { composeAdapter.loadMentions(statusMention); } } MastodonHelper.loadPPMastodon(binding.profilePicture, account.mastodon_account); LocalBroadcastManager.getInstance(this) Loading app/src/main/java/app/fedilab/android/activities/ProfileActivity.java +10 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.Html; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; import android.text.method.LinkMovementMethod; Loading Loading @@ -89,6 +90,7 @@ import app.fedilab.android.client.entities.app.WellKnownNodeinfo; import app.fedilab.android.databinding.ActivityProfileBinding; import app.fedilab.android.exception.DBException; import app.fedilab.android.helper.CrossActionHelper; import app.fedilab.android.helper.CustomEmoji; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.MastodonHelper; import app.fedilab.android.helper.SpannableHelper; Loading Loading @@ -362,7 +364,9 @@ public class ProfileActivity extends BaseActivity { if (account.span_display_name == null && account.display_name == null) { binding.accountDn.setText(account.username); } else { binding.accountDn.setText(account.span_display_name != null ? account.span_display_name : account.display_name, TextView.BufferType.SPANNABLE); Spannable textAccount = account.span_display_name != null ? account.span_display_name : new SpannableString(account.display_name); CustomEmoji.displayEmoji(ProfileActivity.this, account.emojis, textAccount, binding.accountDn, null, null); binding.accountDn.setText(textAccount, TextView.BufferType.SPANNABLE); } binding.accountUn.setText(String.format("@%s", account.acct)); Loading @@ -377,12 +381,13 @@ public class ProfileActivity extends BaseActivity { clipboard.setPrimaryClip(clip); return false; }); Spannable textNote; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) binding.accountNote.setText(account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note, Html.FROM_HTML_MODE_COMPACT)), TextView.BufferType.SPANNABLE); textNote = account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note, Html.FROM_HTML_MODE_COMPACT)); else binding.accountNote.setText(account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note)), TextView.BufferType.SPANNABLE); textNote = account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note)); CustomEmoji.displayEmoji(ProfileActivity.this, account.emojis, textNote, binding.accountNote, null, null); binding.accountNote.setText(textNote, TextView.BufferType.SPANNABLE); binding.accountNote.setMovementMethod(LinkMovementMethod.getInstance()); MastodonHelper.loadPPMastodon(binding.accountPp, account); Loading app/src/main/java/app/fedilab/android/client/entities/api/Account.java +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ public class Account implements Serializable { public transient Spannable span_display_name; public transient Spannable span_note; public transient RelationShip relationShip; public boolean emojiFetched = false; public transient boolean emojiFetched = false; public static class AccountParams implements Serializable { @SerializedName("discoverable") Loading app/src/main/java/app/fedilab/android/client/entities/api/Announcement.java +1 −0 Original line number Diff line number Diff line Loading @@ -51,4 +51,5 @@ public class Announcement { //Some extra spannable element - They will be filled automatically when fetching the status public transient Spannable span_content; public boolean emojiFetched = false; } app/src/main/java/app/fedilab/android/helper/CustomEmoji.java +8 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package app.fedilab.android.helper; import android.content.Context; import android.content.SharedPreferences; import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.text.Spannable; import android.text.style.ImageSpan; Loading @@ -28,7 +29,6 @@ import androidx.preference.PreferenceManager; import com.bumptech.glide.Glide; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; import com.github.penfeizhou.animation.apng.APNGDrawable; import java.util.List; import java.util.regex.Matcher; Loading @@ -54,13 +54,16 @@ public class CustomEmoji { @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { super.onLoadFailed(errorDrawable); if (finalCount == emojis.size()) { if (finalCount == emojis.size() && listener != null) { listener.allEmojisfound(id); } } @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { if (content == null) { return; } Matcher matcher = Pattern.compile(":" + emoji.shortcode + ":", Pattern.LITERAL) .matcher(content); while (matcher.find()) { Loading @@ -72,7 +75,7 @@ public class CustomEmoji { imageSpan, matcher.start(), matcher.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } if (animate && resource instanceof APNGDrawable) { if (animate && resource instanceof Animatable) { Drawable.Callback callback = resource.getCallback(); resource.setCallback(new Drawable.Callback() { @Override Loading @@ -97,10 +100,10 @@ public class CustomEmoji { } } }); ((APNGDrawable) resource).start(); ((Animatable) resource).start(); } if (finalCount == emojis.size()) { if (finalCount == emojis.size() && listener != null) { listener.allEmojisfound(id); } } Loading Loading
app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +63 −76 Original line number Diff line number Diff line Loading @@ -268,12 +268,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana } }); } else if (statusDraft != null) {//Restore a draft with all messages new Thread(() -> { if (statusDraft.statusReplyList != null) { statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList); } Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { if (statusDraft.statusReplyList != null) { statusList.addAll(statusDraft.statusReplyList); binding.recyclerView.addItemDecoration(new DividerDecorationSimple(ComposeActivity.this, statusList)); Loading @@ -286,15 +283,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana binding.recyclerView.setLayoutManager(mLayoutManager); binding.recyclerView.setAdapter(composeAdapter); binding.recyclerView.scrollToPosition(composeAdapter.getItemCount() - 1); }; mainHandler.post(myRunnable); }).start(); } else if (statusReply != null) { new Thread(() -> { statusReply = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusReply); Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { statusList.add(statusReply); int statusCount = statusList.size(); statusDraftList.get(0).in_reply_to_id = statusReply.id; Loading Loading @@ -345,9 +336,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana binding.recyclerView.setAdapter(composeAdapter); statusesVM.getContext(currentInstance, BaseMainActivity.currentToken, statusReply.id) .observe(ComposeActivity.this, this::initializeContextView); }; mainHandler.post(myRunnable); }).start(); } else { //Compose without replying statusList.addAll(statusDraftList); Loading @@ -359,7 +347,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana if (statusMention != null) { composeAdapter.loadMentions(statusMention); } } MastodonHelper.loadPPMastodon(binding.profilePicture, account.mastodon_account); LocalBroadcastManager.getInstance(this) Loading
app/src/main/java/app/fedilab/android/activities/ProfileActivity.java +10 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.Html; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; import android.text.method.LinkMovementMethod; Loading Loading @@ -89,6 +90,7 @@ import app.fedilab.android.client.entities.app.WellKnownNodeinfo; import app.fedilab.android.databinding.ActivityProfileBinding; import app.fedilab.android.exception.DBException; import app.fedilab.android.helper.CrossActionHelper; import app.fedilab.android.helper.CustomEmoji; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.MastodonHelper; import app.fedilab.android.helper.SpannableHelper; Loading Loading @@ -362,7 +364,9 @@ public class ProfileActivity extends BaseActivity { if (account.span_display_name == null && account.display_name == null) { binding.accountDn.setText(account.username); } else { binding.accountDn.setText(account.span_display_name != null ? account.span_display_name : account.display_name, TextView.BufferType.SPANNABLE); Spannable textAccount = account.span_display_name != null ? account.span_display_name : new SpannableString(account.display_name); CustomEmoji.displayEmoji(ProfileActivity.this, account.emojis, textAccount, binding.accountDn, null, null); binding.accountDn.setText(textAccount, TextView.BufferType.SPANNABLE); } binding.accountUn.setText(String.format("@%s", account.acct)); Loading @@ -377,12 +381,13 @@ public class ProfileActivity extends BaseActivity { clipboard.setPrimaryClip(clip); return false; }); Spannable textNote; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) binding.accountNote.setText(account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note, Html.FROM_HTML_MODE_COMPACT)), TextView.BufferType.SPANNABLE); textNote = account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note, Html.FROM_HTML_MODE_COMPACT)); else binding.accountNote.setText(account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note)), TextView.BufferType.SPANNABLE); textNote = account.span_note != null ? account.span_note : new SpannableString(Html.fromHtml(account.note)); CustomEmoji.displayEmoji(ProfileActivity.this, account.emojis, textNote, binding.accountNote, null, null); binding.accountNote.setText(textNote, TextView.BufferType.SPANNABLE); binding.accountNote.setMovementMethod(LinkMovementMethod.getInstance()); MastodonHelper.loadPPMastodon(binding.accountPp, account); Loading
app/src/main/java/app/fedilab/android/client/entities/api/Account.java +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ public class Account implements Serializable { public transient Spannable span_display_name; public transient Spannable span_note; public transient RelationShip relationShip; public boolean emojiFetched = false; public transient boolean emojiFetched = false; public static class AccountParams implements Serializable { @SerializedName("discoverable") Loading
app/src/main/java/app/fedilab/android/client/entities/api/Announcement.java +1 −0 Original line number Diff line number Diff line Loading @@ -51,4 +51,5 @@ public class Announcement { //Some extra spannable element - They will be filled automatically when fetching the status public transient Spannable span_content; public boolean emojiFetched = false; }
app/src/main/java/app/fedilab/android/helper/CustomEmoji.java +8 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package app.fedilab.android.helper; import android.content.Context; import android.content.SharedPreferences; import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.text.Spannable; import android.text.style.ImageSpan; Loading @@ -28,7 +29,6 @@ import androidx.preference.PreferenceManager; import com.bumptech.glide.Glide; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; import com.github.penfeizhou.animation.apng.APNGDrawable; import java.util.List; import java.util.regex.Matcher; Loading @@ -54,13 +54,16 @@ public class CustomEmoji { @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { super.onLoadFailed(errorDrawable); if (finalCount == emojis.size()) { if (finalCount == emojis.size() && listener != null) { listener.allEmojisfound(id); } } @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { if (content == null) { return; } Matcher matcher = Pattern.compile(":" + emoji.shortcode + ":", Pattern.LITERAL) .matcher(content); while (matcher.find()) { Loading @@ -72,7 +75,7 @@ public class CustomEmoji { imageSpan, matcher.start(), matcher.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } if (animate && resource instanceof APNGDrawable) { if (animate && resource instanceof Animatable) { Drawable.Callback callback = resource.getCallback(); resource.setCallback(new Drawable.Callback() { @Override Loading @@ -97,10 +100,10 @@ public class CustomEmoji { } } }); ((APNGDrawable) resource).start(); ((Animatable) resource).start(); } if (finalCount == emojis.size()) { if (finalCount == emojis.size() && listener != null) { listener.allEmojisfound(id); } } Loading