Commit bef19c08 authored by Sawyer Blatz's avatar Sawyer Blatz
Browse files

For #4675: Adds category for shortcut intents

parent 3ab7c79c
......@@ -64,6 +64,7 @@ class WebAppLauncherActivity : AppCompatActivity() {
@VisibleForTesting(otherwise = PRIVATE)
internal fun launchBrowser(startUrl: Uri) {
val intent = Intent(Intent.ACTION_VIEW, startUrl).apply {
addCategory(SHORTCUT_CATEGORY)
`package` = packageName
}
......
......@@ -38,6 +38,7 @@ import mozilla.components.feature.pwa.WebAppLauncherActivity.Companion.ACTION_PW
import mozilla.components.feature.pwa.ext.installableManifest
private val pwaIconMemoryCache = IconMemoryCache()
const val SHORTCUT_CATEGORY = "mozilla.components.pwa.category.SHORTCUT"
class WebAppShortcutManager(
context: Context,
......@@ -95,6 +96,7 @@ class WebAppShortcutManager(
/**
* Create a new basic pinned website shortcut using info from the session.
* Consuming `SHORTCUT_CATEGORY` in `AndroidManifest` is required for the package to be launched
*/
fun buildBasicShortcut(
context: Context,
......@@ -102,6 +104,7 @@ class WebAppShortcutManager(
overrideShortcutName: String? = null
): ShortcutInfoCompat {
val shortcutIntent = Intent(Intent.ACTION_VIEW, session.url.toUri()).apply {
addCategory(SHORTCUT_CATEGORY)
`package` = context.packageName
}
......
......@@ -12,6 +12,9 @@ permalink: /changelog/
* [Gecko](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Gecko.kt)
* [Configuration](https://github.com/mozilla-mobile/android-components/blob/master/buildSrc/src/main/java/Config.kt)
* **feature-pwa**
* ⚠️ **This is a breaking change**: Intent sent from the `WebAppShortcutManager` now require the consumption of the `SHORTCUT_CATEGORY` in your manifest
* **feature-customtabs**
* 'CustomTabIntentProcessor' can create private sessions now.
......
......@@ -47,6 +47,8 @@
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="mozilla.components.pwa.category.SHORTCUT" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment