make contact chooser (direct sharing) smart about sharing text in groups when http is not available
This commit is contained in:
parent
8124b24479
commit
6ecf6f1149
|
@ -190,6 +190,16 @@
|
||||||
android:name=".ui.ShareWithActivity"
|
android:name=".ui.ShareWithActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleTop">
|
||||||
|
|
||||||
|
<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>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND"/>
|
<action android:name="android.intent.action.SEND"/>
|
||||||
<action android:name="android.intent.action.SEND_MULTIPLE"/>
|
<action android:name="android.intent.action.SEND_MULTIPLE"/>
|
||||||
|
|
|
@ -12,23 +12,28 @@ import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.service.chooser.ChooserTarget;
|
import android.service.chooser.ChooserTarget;
|
||||||
import android.service.chooser.ChooserTargetService;
|
import android.service.chooser.ChooserTargetService;
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.ui.ConversationsActivity;
|
import eu.siacs.conversations.ui.ConversationsActivity;
|
||||||
import eu.siacs.conversations.ui.ShareWithActivity;
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.M)
|
@TargetApi(Build.VERSION_CODES.M)
|
||||||
public class ContactChooserTargetService extends ChooserTargetService implements ServiceConnection {
|
public class ContactChooserTargetService extends ChooserTargetService implements ServiceConnection {
|
||||||
|
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
private final int MAX_TARGETS = 5;
|
||||||
private XmppConnectionService mXmppConnectionService;
|
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
|
@Override
|
||||||
public List<ChooserTarget> onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) {
|
public List<ChooserTarget> onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) {
|
||||||
|
@ -42,7 +47,8 @@ public class ContactChooserTargetService extends ChooserTargetService implements
|
||||||
if (!mXmppConnectionService.areMessagesInitialized()) {
|
if (!mXmppConnectionService.areMessagesInitialized()) {
|
||||||
return chooserTargets;
|
return chooserTargets;
|
||||||
}
|
}
|
||||||
mXmppConnectionService.populateWithOrderedConversations(conversations, false);
|
|
||||||
|
mXmppConnectionService.populateWithOrderedConversations(conversations, textOnly(matchedFilter));
|
||||||
final ComponentName componentName = new ComponentName(this, ConversationsActivity.class);
|
final ComponentName componentName = new ComponentName(this, ConversationsActivity.class);
|
||||||
final int pixel = AvatarService.getSystemUiAvatarSize(this);
|
final int pixel = AvatarService.getSystemUiAvatarSize(this);
|
||||||
for (Conversation conversation : conversations) {
|
for (Conversation conversation : conversations) {
|
||||||
|
|
Loading…
Reference in a new issue