From d93d92dee3add2bf293a177fd5d8afdbd691f684 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 25 Jan 2019 22:28:04 +0100 Subject: make contact chooser (direct sharing) smart about sharing text in groups when http is not available --- src/main/AndroidManifest.xml | 6 ++++++ .../messenger/services/ContactChooserTargetService.java | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 4eeb4c367..9e92dd8bb 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -214,6 +214,12 @@ android:name=".ui.ShareWithActivity" android:label="@string/app_name" android:launchMode="singleTop"> + + + + + + diff --git a/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java b/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java index e4a98d63a..006b6e918 100644 --- a/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java +++ b/src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java @@ -23,10 +23,17 @@ import de.pixart.messenger.ui.ConversationsActivity; public class ContactChooserTargetService extends ChooserTargetService implements ServiceConnection { private final Object lock = new Object(); - + private final int MAX_TARGETS = 5; private XmppConnectionService mXmppConnectionService; - private final int MAX_TARGETS = 5; + private static boolean textOnly(IntentFilter filter) { + for (int i = 0; i < filter.countDataTypes(); ++i) { + if (!"text/plain".equals(filter.getDataType(i))) { + return false; + } + } + return true; + } @Override public List onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) { @@ -40,7 +47,8 @@ public class ContactChooserTargetService extends ChooserTargetService implements if (!mXmppConnectionService.areMessagesInitialized()) { return chooserTargets; } - mXmppConnectionService.populateWithOrderedConversations(conversations, false); + + mXmppConnectionService.populateWithOrderedConversations(conversations, textOnly(matchedFilter)); final ComponentName componentName = new ComponentName(this, ConversationsActivity.class); final int pixel = AvatarService.getSystemUiAvatarSize(this); for (Conversation conversation : conversations) { -- cgit v1.2.3