diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 777b051111..3d48420bf0 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -27,6 +27,7 @@ import android.app.Dialog; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; +import android.app.Person; import android.app.RemoteAction; import android.content.ClipData; import android.content.ClipboardManager; @@ -92,6 +93,7 @@ import android.view.animation.AccelerateDecelerateInterpolator; import android.view.textclassifier.ConversationAction; import android.view.textclassifier.ConversationActions; import android.view.textclassifier.TextClassificationManager; +import android.view.textclassifier.TextClassifier; import android.webkit.WebView; import android.widget.Button; import android.widget.CheckBox; @@ -155,10 +157,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; @@ -1932,15 +1936,11 @@ public class AdapterMessage extends RecyclerView.Adapter actions = cactions.getConversationActions(); for (ConversationAction action : actions) { - String type = action.getType(); - if (ConversationAction.TYPE_OPEN_URL.equals(type) || - ConversationAction.TYPE_SEND_EMAIL.equals(type)) - continue; - final RemoteAction raction = action.getAction(); final CharSequence title = (raction == null ? action.getTextReply() : raction.getTitle()); @@ -1967,8 +1967,7 @@ public class AdapterMessage extends RecyclerView.Adapter 0) - llAction.setVisibility(View.VISIBLE); + llAction.setVisibility(llAction.getChildCount() > 0 ? View.VISIBLE : View.GONE); } } @@ -2027,15 +2026,30 @@ public class AdapterMessage extends RecyclerView.Adapter excluded = Collections.unmodifiableSet( + new HashSet<>(Arrays.asList( + ConversationAction.TYPE_OPEN_URL, + ConversationAction.TYPE_SEND_EMAIL + ))); ConversationActions.Message cmessage = - new ConversationActions.Message.Builder(ConversationActions.Message - .PERSON_USER_OTHERS) + new ConversationActions.Message.Builder(person) .setReferenceTime(dt) .setText(document.text()) .build(); + TextClassifier.EntityConfig config = + new TextClassifier.EntityConfig.Builder() + .setExcludedTypes(excluded) + .build(); ConversationActions.Request crequest = - new ConversationActions.Request.Builder(Arrays.asList(cmessage)).build(); + new ConversationActions.Request.Builder(Arrays.asList(cmessage)) + .setTypeConfig(config) + .build(); return tcm.getTextClassifier().suggestConversationActions(crequest); }