Added direct share support for chat rooms shortcuts + hidden shorcuts settings as chat room shortcuts are preferred

This commit is contained in:
Sylvain Berfini 2021-02-03 14:57:46 +01:00
parent 8c8de826b2
commit dcee88826d
6 changed files with 34 additions and 7 deletions

View file

@ -22,8 +22,11 @@ This version is a full rewrite of the app in kotlin, using modern Android compon
- Improved preview when sharing video files through the chat
- Android 11 people & conversation compliant
- New animations between fragments and for unread chat messages / missed calls counters (can be disabled)
- Bubble & conversation support for chat message notifications
- Direct share support for chat room shortcuts
- Option to mark messages as read when dismissing the notification
- More settings are available
- Call view can be displayed in full-screen
### Changed
@ -32,6 +35,7 @@ This version is a full rewrite of the app in kotlin, using modern Android compon
- Improved how Android native contacts are used
- Switched to material design for text input fields & switches
- Launcher shortcuts can be to either contacts or chat rooms
- UI changes
### Removed

View file

@ -45,6 +45,9 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity android:name=".activities.main.MainActivity"

View file

@ -214,7 +214,10 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
Intent.ACTION_VIEW_LOCUS -> {
if (corePreferences.disableChat) return
val locus = Compatibility.extractLocusIdFromIntent(intent)
if (locus != null) handleLocus(locus)
if (locus != null) {
Log.i("[Main Activity] Found chat room locus intent extra: $locus")
handleLocusOrShortcut(locus)
}
}
else -> {
when {
@ -365,14 +368,19 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
Log.i("[Main Activity] Starting deep link: $deepLink")
findNavController(R.id.nav_host_fragment).navigate(Uri.parse(deepLink))
} else {
val deepLink = "linphone-android://chat/"
Log.i("[Main Activity] Starting deep link: $deepLink")
findNavController(R.id.nav_host_fragment).navigate(Uri.parse(deepLink))
val shortcutId = intent.getStringExtra("android.intent.extra.shortcut.ID") // Intent.EXTRA_SHORTCUT_ID
if (shortcutId != null) {
Log.i("[Main Activity] Found shortcut ID: $shortcutId")
handleLocusOrShortcut(shortcutId)
} else {
val deepLink = "linphone-android://chat/"
Log.i("[Main Activity] Starting deep link: $deepLink")
findNavController(R.id.nav_host_fragment).navigate(Uri.parse(deepLink))
}
}
}
private fun handleLocus(id: String) {
Log.i("[Main Activity] Found chat room locus intent extra: $id")
private fun handleLocusOrShortcut(id: String) {
val split = id.split("~")
if (split.size == 2) {
val localAddress = split[0]
@ -380,7 +388,7 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
val deepLink = "linphone-android://chat-room/$localAddress/$peerAddress"
findNavController(R.id.nav_host_fragment).navigate(Uri.parse(deepLink))
} else {
Log.e("[Main Activity] Failed to parse locus id: $id")
Log.e("[Main Activity] Failed to parse shortcut/locus id: $id")
}
}
}

View file

@ -107,6 +107,7 @@
<include
layout="@layout/settings_widget_switch"
android:visibility="gone"
linphone:title="@{@string/chat_settings_launcher_shortcuts_title}"
linphone:subtitle="@{@string/chat_settings_launcher_shortcuts_summary}"
linphone:listener="@{viewModel.launcherShortcutsListener}"

View file

@ -98,6 +98,7 @@
<include
layout="@layout/settings_widget_switch"
android:visibility="gone"
linphone:title="@{@string/contacts_settings_launcher_shortcuts_title}"
linphone:subtitle="@{@string/contacts_settings_launcher_shortcuts_summary}"
linphone:listener="@{viewModel.launcherShortcutsListener}"

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<share-target android:targetClass="org.linphone.activities.main.MainActivity">
<data android:mimeType="text/*" />
<data android:mimeType="image/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="video/*" />
<category android:name="android.shortcut.conversation" />
</share-target>
</shortcuts>