Implement direct share
(cherry picked from commit 4a5068b790dae7aa1c5c8e46693be6ffafef34c4)
This commit is contained in:
parent
238ce10c91
commit
439ec6d977
4 changed files with 19 additions and 0 deletions
7
src/cheogram/res/xml/shortcuts.xml
Normal file
7
src/cheogram/res/xml/shortcuts.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<share-target android:targetClass="eu.siacs.conversations.ui.ShareWithActivity">
|
||||||
|
<data android:mimeType="*/*" />
|
||||||
|
<category android:name="com.cheogram.android.SHARE_TARGET" />
|
||||||
|
</share-target>
|
||||||
|
</shortcuts>
|
|
@ -193,6 +193,7 @@
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ConversationsActivity"
|
android:name=".ui.ConversationsActivity"
|
||||||
|
|
|
@ -18,6 +18,7 @@ import androidx.core.graphics.drawable.IconCompat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
@ -99,6 +100,7 @@ public class ShortcutService {
|
||||||
.setIntent(getShortcutIntent(contact))
|
.setIntent(getShortcutIntent(contact))
|
||||||
.setIcon(IconCompat.createWithBitmap(xmppConnectionService.getAvatarService().getRoundedShortcut(contact)))
|
.setIcon(IconCompat.createWithBitmap(xmppConnectionService.getAvatarService().getRoundedShortcut(contact)))
|
||||||
.setIsConversation()
|
.setIsConversation()
|
||||||
|
.setCategories(Set.of("com.cheogram.android.SHARE_TARGET"))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +110,7 @@ public class ShortcutService {
|
||||||
.setIntent(getShortcutIntent(mucOptions))
|
.setIntent(getShortcutIntent(mucOptions))
|
||||||
.setIcon(IconCompat.createWithBitmap(xmppConnectionService.getAvatarService().getRoundedShortcut(mucOptions)))
|
.setIcon(IconCompat.createWithBitmap(xmppConnectionService.getAvatarService().getRoundedShortcut(mucOptions)))
|
||||||
.setIsConversation()
|
.setIsConversation()
|
||||||
|
.setCategories(Set.of("com.cheogram.android.SHARE_TARGET"))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,6 +178,14 @@ public class ShareWithActivity extends XmppActivity
|
||||||
final ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
final ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
||||||
this.share.uris = uris == null ? new ArrayList<>() : uris;
|
this.share.uris = uris == null ? new ArrayList<>() : uris;
|
||||||
}
|
}
|
||||||
|
final var shortcutId = intent.getStringExtra(Intent.EXTRA_SHORTCUT_ID);
|
||||||
|
if (shortcutId != null) {
|
||||||
|
final var index = shortcutId.indexOf('#');
|
||||||
|
if (index >= 0) {
|
||||||
|
this.share.account = shortcutId.substring(0, index);
|
||||||
|
this.share.contact = shortcutId.substring(index+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (xmppConnectionServiceBound) {
|
if (xmppConnectionServiceBound) {
|
||||||
xmppConnectionService.populateWithOrderedConversations(
|
xmppConnectionService.populateWithOrderedConversations(
|
||||||
mConversations, this.share.uris.isEmpty(), false);
|
mConversations, this.share.uris.isEmpty(), false);
|
||||||
|
|
Loading…
Reference in a new issue