Commit c17322c6 authored by Thomas's avatar Thomas
Browse files

Some tries

parent 455e5666
Loading
Loading
Loading
Loading
+63 −76
Original line number Diff line number Diff line
@@ -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));
@@ -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;
@@ -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);
@@ -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)
+10 −5
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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));
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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")
+1 −0
Original line number Diff line number Diff line
@@ -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;
}
+8 −5
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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()) {
@@ -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
@@ -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