aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-01-25 22:28:04 +0100
committerChristian Schneppe <christian@pix-art.de>2019-01-25 22:28:04 +0100
commitd93d92dee3add2bf293a177fd5d8afdbd691f684 (patch)
tree01816897b2186c93dd38f0ac1c76dcb082185666 /src
parent83258c8a19d64fc4e451a57fc8097391b0437b75 (diff)
make contact chooser (direct sharing) smart about sharing text in groups when http is not available
Diffstat (limited to '')
-rw-r--r--src/main/AndroidManifest.xml6
-rw-r--r--src/main/java/de/pixart/messenger/services/ContactChooserTargetService.java14
2 files changed, 17 insertions, 3 deletions
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
@@ -217,6 +217,12 @@
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="text/plain" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.SEND" />
+ <action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
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<ChooserTarget> 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) {