Revert "Precompute text"

This reverts commit f5fd230877.
pull/174/head
M66B 5 years ago
parent 82b9ac8add
commit 004b0a6f31

@ -103,8 +103,6 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.FileProvider;
import androidx.core.graphics.ColorUtils;
import androidx.core.text.PrecomputedTextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
@ -1807,16 +1805,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
s, e, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
}
try {
return PrecomputedTextCompat.getTextFuture(
builder,
TextViewCompat.getTextMetricsParams(tvBody),
executor)
.get();
} catch (Throwable ex) {
Log.w(ex);
return builder;
}
return builder;
}
}
@ -1834,12 +1823,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean has_images = args.getBoolean("has_images");
if (result instanceof PrecomputedTextCompat) {
TextViewCompat.setPrecomputedText(tvBody, (PrecomputedTextCompat) result);
tvBody.setTextIsSelectable(false);
tvBody.setTextIsSelectable(true);
tvBody.setMovementMethod(new TouchHandler(message));
} else if (result instanceof Spanned) {
if (result instanceof Spanned) {
tvBody.setText((Spanned) result);
tvBody.setTextIsSelectable(false);
tvBody.setTextIsSelectable(true);

@ -90,8 +90,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.FileProvider;
import androidx.core.text.PrecomputedTextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.cursoradapter.widget.SimpleCursorAdapter;
import androidx.documentfile.provider.DocumentFile;
import androidx.fragment.app.Fragment;
@ -4007,7 +4005,7 @@ public class FragmentCompose extends FragmentBase {
args.putLong("id", draft.id);
args.putBoolean("show_images", show_images);
new SimpleTask<Object[]>() {
new SimpleTask<Spanned[]>() {
@Override
protected void onPreExecute(Bundle args) {
// Needed to get width for images
@ -4031,7 +4029,7 @@ public class FragmentCompose extends FragmentBase {
}
@Override
protected Object[] onExecute(final Context context, Bundle args) throws Throwable {
protected Spanned[] onExecute(final Context context, Bundle args) throws Throwable {
final long id = args.getLong("id");
final boolean show_images = args.getBoolean("show_images", false);
@ -4096,24 +4094,12 @@ public class FragmentCompose extends FragmentBase {
args.putBoolean("ref_has_images", spannedRef != null &&
spannedRef.getSpans(0, spannedRef.length(), ImageSpan.class).length > 0);
PrecomputedTextCompat precomputed = null;
if (spannedRef != null)
try {
precomputed = PrecomputedTextCompat.getTextFuture(
spannedRef,
TextViewCompat.getTextMetricsParams(tvReference),
null)
.get();
} catch (Throwable ex) {
Log.w(ex);
}
return new Spanned[]{spannedBody, precomputed == null ? spannedRef : precomputed};
return new Spanned[]{spannedBody, spannedRef};
}
@Override
protected void onExecuted(Bundle args, Object[] text) {
etBody.setText((Spanned) text[0]);
protected void onExecuted(Bundle args, Spanned[] text) {
etBody.setText(text[0]);
etBody.setSelection(0);
grpBody.setVisibility(View.VISIBLE);
@ -4125,10 +4111,7 @@ public class FragmentCompose extends FragmentBase {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean ref_hint = prefs.getBoolean("compose_reference", true);
if (text[1] instanceof PrecomputedTextCompat)
TextViewCompat.setPrecomputedText(tvReference, (PrecomputedTextCompat) text[1]);
else
tvReference.setText((Spanned) text[1]);
tvReference.setText(text[1]);
tvReference.setVisibility(text[1] == null ? View.GONE : View.VISIBLE);
grpReferenceHint.setVisibility(text[1] == null || !ref_hint ? View.GONE : View.VISIBLE);
ibReferenceEdit.setVisibility(text[1] == null ? View.GONE : View.VISIBLE);

Loading…
Cancel
Save