mirror of https://github.com/M66B/FairEmail.git
At your service
This commit is contained in:
parent
cd471cc918
commit
d59bef2a70
|
@ -27,6 +27,7 @@ import android.app.Dialog;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
|
import android.app.Person;
|
||||||
import android.app.RemoteAction;
|
import android.app.RemoteAction;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
|
@ -92,6 +93,7 @@ import android.view.animation.AccelerateDecelerateInterpolator;
|
||||||
import android.view.textclassifier.ConversationAction;
|
import android.view.textclassifier.ConversationAction;
|
||||||
import android.view.textclassifier.ConversationActions;
|
import android.view.textclassifier.ConversationActions;
|
||||||
import android.view.textclassifier.TextClassificationManager;
|
import android.view.textclassifier.TextClassificationManager;
|
||||||
|
import android.view.textclassifier.TextClassifier;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
@ -155,10 +157,12 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
|
@ -1932,15 +1936,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
throw new IllegalStateException("Result=" + result);
|
throw new IllegalStateException("Result=" + result);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
llAction.removeAllViews();
|
||||||
ConversationActions cactions = args.getParcelable("actions");
|
ConversationActions cactions = args.getParcelable("actions");
|
||||||
if (cactions != null) {
|
if (cactions != null) {
|
||||||
List<ConversationAction> actions = cactions.getConversationActions();
|
List<ConversationAction> actions = cactions.getConversationActions();
|
||||||
for (ConversationAction action : actions) {
|
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 RemoteAction raction = action.getAction();
|
||||||
final CharSequence title = (raction == null ? action.getTextReply() : raction.getTitle());
|
final CharSequence title = (raction == null ? action.getTextReply() : raction.getTitle());
|
||||||
|
|
||||||
|
@ -1967,8 +1967,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
});
|
});
|
||||||
llAction.addView(button);
|
llAction.addView(button);
|
||||||
}
|
}
|
||||||
if (llAction.getChildCount() > 0)
|
llAction.setVisibility(llAction.getChildCount() > 0 ? View.VISIBLE : View.GONE);
|
||||||
llAction.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2027,15 +2026,30 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
if (tcm == null)
|
if (tcm == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ZonedDateTime dt = new Date(message.received).toInstant().atZone(ZoneId.systemDefault());
|
Person person = isOutgoing(message)
|
||||||
|
? ConversationActions.Message.PERSON_USER_SELF
|
||||||
|
: ConversationActions.Message.PERSON_USER_OTHERS;
|
||||||
|
ZonedDateTime dt = new Date(message.received)
|
||||||
|
.toInstant()
|
||||||
|
.atZone(ZoneId.systemDefault());
|
||||||
|
Set<String> excluded = Collections.unmodifiableSet(
|
||||||
|
new HashSet<>(Arrays.asList(
|
||||||
|
ConversationAction.TYPE_OPEN_URL,
|
||||||
|
ConversationAction.TYPE_SEND_EMAIL
|
||||||
|
)));
|
||||||
ConversationActions.Message cmessage =
|
ConversationActions.Message cmessage =
|
||||||
new ConversationActions.Message.Builder(ConversationActions.Message
|
new ConversationActions.Message.Builder(person)
|
||||||
.PERSON_USER_OTHERS)
|
|
||||||
.setReferenceTime(dt)
|
.setReferenceTime(dt)
|
||||||
.setText(document.text())
|
.setText(document.text())
|
||||||
.build();
|
.build();
|
||||||
|
TextClassifier.EntityConfig config =
|
||||||
|
new TextClassifier.EntityConfig.Builder()
|
||||||
|
.setExcludedTypes(excluded)
|
||||||
|
.build();
|
||||||
ConversationActions.Request crequest =
|
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);
|
return tcm.getTextClassifier().suggestConversationActions(crequest);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue