Made custom rendering an experiment

This commit is contained in:
M66B 2020-04-24 16:12:07 +02:00
parent bd0b1e5c11
commit a6e4296b1d
6 changed files with 11 additions and 11 deletions

2
FAQ.md
View File

@ -2537,7 +2537,7 @@ Reformatting and displaying such messages will take too long. You can try to use
<a name="faq125"></a>
**(125) What are the current experimental features?**
Currently, there are no experimental features.
* Custom rendering of reformatted messages
<br />

View File

@ -179,7 +179,7 @@ public class ActivityEML extends ActivityBase {
if (html != null) {
Document parsed = JsoupEx.parse(html);
Document document = HtmlHelper.sanitizeView(context, parsed, false);
result.body = HtmlHelper.fromDocument(document);
result.body = HtmlHelper.fromDocument(context, document);
}
return result;

View File

@ -1924,7 +1924,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
// Draw images
Spanned spanned = HtmlHelper.fromDocument(document, new Html.ImageGetter() {
Spanned spanned = HtmlHelper.fromDocument(context, document, new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
Drawable drawable = ImageHelper.decodeImage(context, message.id, source, show_images, zoom, tvBody);

View File

@ -78,7 +78,7 @@ public class EditTextCompose extends FixedEditText {
html = "<div>" + HtmlHelper.formatPre(text.toString()) + "</div>";
}
Document document = HtmlHelper.sanitizeCompose(context, html, false);
Spanned paste = HtmlHelper.fromDocument(document);
Spanned paste = HtmlHelper.fromDocument(context, document);
int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);

View File

@ -1756,12 +1756,15 @@ public class HtmlHelper {
return false;
}
static Spanned fromDocument(@NonNull Document document) {
return fromDocument(document, null, null);
static Spanned fromDocument(Context context, @NonNull Document document) {
return fromDocument(context, document, null, null);
}
static Spanned fromDocument(@NonNull Document document, @Nullable Html.ImageGetter imageGetter, @Nullable Html.TagHandler tagHandler) {
if (BuildConfig.DEBUG) {
static Spanned fromDocument(Context context, @NonNull Document document, @Nullable Html.ImageGetter imageGetter, @Nullable Html.TagHandler tagHandler) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean experiments = prefs.getBoolean("experiments", false);
if (experiments) {
// https://developer.android.com/guide/topics/text/spans
SpannableStringBuilder ssb = new SpannableStringBuilder();

View File

@ -187,9 +187,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_experiments"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUpdates"
@ -205,7 +203,6 @@
android:text="@string/title_advanced_experiments_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swExperiments" />