Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 243c134

Browse files
Sam1301kunall17
authored andcommitted
Register app as a way to share text
1 parent 0a562e6 commit 243c134

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@
5050
android:launchMode="singleTask">
5151
<intent-filter>
5252
<action android:name="android.intent.action.MAIN" />
53-
5453
<category android:name="android.intent.category.LAUNCHER" />
5554
</intent-filter>
5655
<intent-filter>
5756
<action android:name="android.intent.action.SEND" />
58-
5957
<category android:name="android.intent.category.DEFAULT" />
60-
58+
<data android:mimeType="text/plain" />
59+
</intent-filter>
60+
<intent-filter>
61+
<action android:name="android.intent.action.SEND" />
62+
<category android:name="android.intent.category.DEFAULT" />
6163
<data android:mimeType="image/*" />
6264
</intent-filter>
6365
</activity>

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ public Cursor runQuery(CharSequence charSequence) {
539539
if (type.startsWith("image/")) {
540540
// Handle single image being sent
541541
handleSentImage(intent);
542+
} else if ("text/plain".equals(type)) {
543+
// Handle text being sent
544+
handleSentText(intent);
542545
}
543546
}
544547
// if device doesn't have camera, disable camera button
@@ -866,6 +869,9 @@ protected void onNewIntent(Intent intent) {
866869
if (type.startsWith("image/")) {
867870
// Handle single image being sent
868871
handleSentImage(intent);
872+
} else if ("text/plain".equals(type)) {
873+
// Handle text being sent
874+
handleSentText(intent);
869875
}
870876
}
871877

@@ -904,6 +910,20 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
904910
}
905911
}
906912

913+
/**
914+
* Function invoked when a user shares a text with the zulip app
915+
* @param intent passed to the activity with action SEND
916+
*/
917+
private void handleSentText(Intent intent) {
918+
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
919+
if (sharedText != null) {
920+
// Update UI to reflect text being shared
921+
displayFAB(false);
922+
displayChatBox(true);
923+
messageEt.append(" " + sharedText);
924+
}
925+
}
926+
907927
/**
908928
* Function invoked when a user shares an image with the zulip app
909929
*

0 commit comments

Comments
 (0)