Confirm showing AMP

pull/194/merge
M66B 3 years ago
parent 39a6b428f5
commit 4e6fee79fa

@ -1913,8 +1913,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (attachment.available)
if (attachment.isInline() && attachment.isImage())
inlineImages++;
else if ("message/rfc822".equals(attachment.getMimeType()))
else {
String mimeType = attachment.getMimeType();
if ("text/x-amp-html".equals(mimeType) ||
"message/rfc822".equals(mimeType))
embeddedMessages++;
}
int lastInlineImages = 0;
int lastEmbeddedMessages = 0;
@ -1924,8 +1928,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (attachment.available)
if (attachment.isInline() && attachment.isImage())
lastInlineImages++;
else if ("message/rfc822".equals(attachment.getMimeType()))
else {
String mimeType = attachment.getMimeType();
if ("text/x-amp-html".equals(mimeType) ||
"message/rfc822".equals(mimeType))
lastEmbeddedMessages++;
}
boolean show_images = properties.getValue("images", message.id);
boolean inline = prefs.getBoolean("inline_images", false);
@ -2676,7 +2684,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean has_amp = false;
for (EntityAttachment attachment : attachments)
if ("text/x-amp-html".equals(attachment.type)) {
has_amp = true;
has_amp = attachment.available;
break;
}
args.putBoolean("has_amp", has_amp);
@ -4770,6 +4778,38 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onShowAmp(final TupleMessageEx message) {
boolean open_amp_confirmed = prefs.getBoolean("open_amp_confirmed", false);
if (open_amp_confirmed)
onShowAmpConfirmed(message);
else {
LayoutInflater inflater = LayoutInflater.from(context);
View dview = inflater.inflate(R.layout.dialog_ask_amp, null, false);
final TextView tvRemark = dview.findViewById(R.id.tvRemark);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
tvRemark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.view(v.getContext(), Uri.parse("https://amp.dev/about/email/"), true);
}
});
new AlertDialog.Builder(context)
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (cbNotAgain.isChecked())
prefs.edit().putBoolean("open_amp_confirmed", true).apply();
onShowAmpConfirmed(message);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
}
private void onShowAmpConfirmed(final TupleMessageEx message) {
Bundle args = new Bundle();
args.putLong("id", message.id);

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<eu.faircode.email.ScrollViewEx xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="24dp"
android:scrollbarStyle="outsideOverlay">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<eu.faircode.email.FixedTextView
android:id="@+id/tvMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableStart="@drawable/twotone_bolt_24"
android:drawablePadding="6dp"
android:paddingTop="6dp"
android:text="@string/title_ask_show_amp"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvRemark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="?android:attr/selectableItemBackground"
android:drawableEnd="@drawable/twotone_info_24"
android:drawablePadding="6dp"
android:text="@string/title_ask_show_amp_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
<CheckBox
android:id="@+id/cbNotAgain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_no_ask_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemark" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

@ -1212,6 +1212,7 @@
<string name="title_ask_show_image">Showing images can leak privacy sensitive information</string>
<string name="title_ask_show_image_hint">Images recognized as tracking images will not be shown</string>
<string name="title_ask_show_amp">Show AMP variant of the message?</string>
<string name="title_ask_show_amp_hint">AMP messages are designed to be dynamic and to interact with the internet and can therefore by definition used to track you</string>
<string name="title_ask_delete_local">Delete local messages? Messages will remain on the remote server.</string>
<string name="title_ask_help">Help improve FairEmail</string>
<string name="title_ask_reporting">Send error reports?</string>

Loading…
Cancel
Save