Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #2227: Siri Shortcuts (Activity/Custom Intents) (#3579)
Browse files Browse the repository at this point in the history
Co-authored-by: Michał Buczek <[email protected]>
  • Loading branch information
soner-yuksel and iccub authored Jul 16, 2021
1 parent c0f1a16 commit 3a040a8
Show file tree
Hide file tree
Showing 55 changed files with 2,902 additions and 27 deletions.
204 changes: 204 additions & 0 deletions BraveShared/BraveStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,210 @@ extension Strings {
}
}

// MARK: - Shorcuts

extension Strings {
public struct Shortcuts {
public static let activityTypeNewTabTitle =
NSLocalizedString("shortcuts.activityTypeNewTabTitle",
bundle: .braveShared,
value: "Open a New Browser Tab",
comment: "")

public static let activityTypeNewPrivateTabTitle =
NSLocalizedString("shortcuts.activityTypeNewPrivateTabTitle",
bundle: .braveShared,
value: "Open a New Private Browser Tab",
comment: "")

public static let activityTypeClearHistoryTitle =
NSLocalizedString("shortcuts.activityTypeClearHistoryTitle",
bundle: .braveShared,
value: "Clear Brave Browsing History",
comment: "")

public static let activityTypeEnableVPNTitle =
NSLocalizedString("shortcuts.activityTypeEnableVPNTitle",
bundle: .braveShared,
value: "Open Brave Browser and Enable VPN",
comment: "")

public static let activityTypeOpenBraveNewsTitle =
NSLocalizedString("shortcuts.activityTypeOpenBraveNewsTitle",
bundle: .braveShared,
value: "Open Brave News",
comment: "")

public static let activityTypeOpenPlaylistTitle =
NSLocalizedString("shortcuts.activityTypeOpenPlaylistTitle",
bundle: .braveShared,
value: "Open Playlist",
comment: "")

public static let activityTypeTabDescription =
NSLocalizedString("shortcuts.activityTypeTabDescription",
bundle: .braveShared,
value: "Start Searching the Web Securely with Brave",
comment: "")

public static let activityTypeClearHistoryDescription =
NSLocalizedString("shortcuts.activityTypeClearHistoryDescription",
bundle: .braveShared,
value: "Open Browser in a New Tab and Delete All Private Browser History Data",
comment: "")

public static let activityTypeEnableVPNDescription =
NSLocalizedString("shortcuts.activityTypeEnableVPNDescription",
bundle: .braveShared,
value: "Open Browser in a New Tab and Enable VPN",
comment: "")

public static let activityTypeBraveNewsDescription =
NSLocalizedString("shortcuts.activityTypeBraveNewsDescription",
bundle: .braveShared,
value: "Open Brave News and Check Today's Top Stories",
comment: "")

public static let activityTypeOpenPlaylistDescription =
NSLocalizedString("shortcuts.activityTypeOpenPlaylistDescription",
bundle: .braveShared,
value: "Start Playing your Videos in Playlist",
comment: "")

public static let activityTypeNewTabSuggestedPhrase =
NSLocalizedString("shortcuts.activityTypeNewTabSuggestedPhrase",
bundle: .braveShared,
value: "Open New Tab",
comment: "")

public static let activityTypeNewPrivateTabSuggestedPhrase =
NSLocalizedString("shortcuts.activityTypeNewPrivateTabSuggestedPhrase",
bundle: .braveShared,
value: "Open New Private Tab",
comment: "")

public static let activityTypeClearHistorySuggestedPhrase =
NSLocalizedString("shortcuts.activityTypeClearHistorySuggestedPhrase",
bundle: .braveShared,
value: "Clear Browser History",
comment: "")

public static let activityTypeEnableVPNSuggestedPhrase =
NSLocalizedString("shortcuts.activityTypeEnableVPNSuggestedPhrase",
bundle: .braveShared,
value: "Enable VPN",
comment: "")

public static let activityTypeOpenBraveNewsSuggestedPhrase =
NSLocalizedString("shortcuts.activityTypeOpenBraveTodaySuggestedPhrase",
bundle: .braveShared,
value: "Open Brave News",
comment: "")

public static let activityTypeOpenPlaylistSuggestedPhrase =
NSLocalizedString("shortcuts.activityTypeOpenPlaylistSuggestedPhrase",
bundle: .braveShared,
value: "Open Playlist",
comment: "")

public static let customIntentOpenWebsiteSuggestedPhrase =
NSLocalizedString("shortcuts.customIntentOpenWebsiteSuggestedPhrase",
bundle: .braveShared,
value: "Open Website",
comment: "")

public static let customIntentOpenHistorySuggestedPhrase =
NSLocalizedString("shortcuts.customIntentOpenHistorySuggestedPhrase",
bundle: .braveShared,
value: "Open History Website",
comment: "")

public static let customIntentOpenBookmarkSuggestedPhrase =
NSLocalizedString("shortcuts.customIntentOpenBookmarkSuggestedPhrase",
bundle: .braveShared,
value: "Open Bookmark Website",
comment: "")

public static let shortcutSettingsTitle =
NSLocalizedString("shortcuts.shorcutSettingsTitle",
bundle: .braveShared,
value: "Siri Shorcuts",
comment: "")

public static let shortcutSettingsOpenNewTabTitle =
NSLocalizedString("shortcuts.shortcutSettingsOpenNewTabTitle",
bundle: .braveShared,
value: "Open New Tab",
comment: "")

public static let shortcutSettingsOpenNewTabDescription =
NSLocalizedString("shortcuts.shortcutSettingsOpenNewTabDescription",
bundle: .braveShared,
value: "Use Shortcuts to open a new tab via Siri - Voice Assistant",
comment: "")

public static let shortcutSettingsOpenNewPrivateTabTitle =
NSLocalizedString("shortcuts.shortcutSettingsOpenNewPrivateTabTitle",
bundle: .braveShared,
value: "Open New Private Tab",
comment: "")

public static let shortcutSettingsOpenNewPrivateTabDescription =
NSLocalizedString("shortcuts.shortcutSettingsOpenNewPrivateTabDescription",
bundle: .braveShared,
value: "Use Shortcuts to open a new private tab via Siri - Voice Assistant",
comment: "")

public static let shortcutSettingsClearBrowserHistoryTitle =
NSLocalizedString("shortcuts.shortcutSettingsClearBrowserHistoryTitle",
bundle: .braveShared,
value: "Clear Browser History",
comment: "")

public static let shortcutSettingsClearBrowserHistoryDescription =
NSLocalizedString("shortcuts.shortcutSettingsClearBrowserHistoryDescription",
bundle: .braveShared,
value: "Use Shortcuts to open a new tab via Siri - Voice Assistant",
comment: "")

public static let shortcutSettingsEnableVPNTitle =
NSLocalizedString("shortcuts.shortcutSettingsEnableVPNTitle",
bundle: .braveShared,
value: "Enable VPN",
comment: "")

public static let shortcutSettingsEnableVPNDescription =
NSLocalizedString("shortcuts.shortcutSettingsEnableVPNDescription",
bundle: .braveShared,
value: "Use Shortcuts to enable Brave VPN via Siri - Voice Assistant",
comment: "")

public static let shortcutSettingsOpenBraveNewsTitle =
NSLocalizedString("shortcuts.shortcutSettingsOpenBraveNewsTitle",
bundle: .braveShared,
value: "Open Brave News",
comment: "")

public static let shortcutSettingsOpenBraveNewsDescription =
NSLocalizedString("shortcuts.shortcutSettingsOpenBraveNewsDescription",
bundle: .braveShared,
value: "Use Shortcuts to Open a New Tab & Show Brave News Feed via Siri - Voice Assistant",
comment: "Description of Open Brave News Siri Shortcut in Settings Screen")

public static let shortcutSettingsOpenPlaylistTitle =
NSLocalizedString("shortcuts.shortcutSettingsOpenPlaylistTitle",
bundle: .braveShared,
value: "Open Playlist",
comment: "")

public static let shorcutSettingsOpenPlaylistDescription =
NSLocalizedString("shortcuts.shorcutSettingsOpenPlaylistDescription",
bundle: .braveShared,
value: "Use Shortcuts to enable Brave VPN via Siri - Voice Assistant",
comment: "Use Shortcuts to Open Playlist via Siri - Voice Assistant")
}
}

// MARK: - VPN
extension Strings {
public struct VPN {
Expand Down
10 changes: 10 additions & 0 deletions BrowserIntents/BrowserIntents.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.brave.ios.BrowserBeta.unique</string>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions BrowserIntents/BrowserIntentsBeta.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.brave.ios.browser</string>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions BrowserIntents/BrowserIntentsDebug.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.$(LOCAL_BUNDLE_ID)</string>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions BrowserIntents/BrowserIntentsEnterprise.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.brave.ios.enterprise.Browser</string>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions BrowserIntents/BrowserIntentsRelease (AppStore).entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.brave.ios.browser</string>
</array>
</dict>
</plist>
10 changes: 10 additions & 0 deletions BrowserIntents/BrowserIntentsRelease.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.brave.ios.browser</string>
</array>
</dict>
</plist>
44 changes: 44 additions & 0 deletions BrowserIntents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>BrowserIntents</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>IntentsRestrictedWhileLocked</key>
<array/>
<key>IntentsRestrictedWhileProtectedDataUnavailable</key>
<array/>
<key>IntentsSupported</key>
<array>
<string>OpenBookmarkWebsiteIntent</string>
<string>OpenHistoryWebsiteIntent</string>
<string>OpenWebsiteIntent</string>
</array>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.intents-service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).IntentHandler</string>
</dict>
</dict>
</plist>
25 changes: 25 additions & 0 deletions BrowserIntents/IntentHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2021 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import Intents

class IntentHandler: INExtension {

override func handler(for intent: INIntent) -> Any {
if intent is OpenWebsiteIntent {
return OpenWebsiteIntentHandler()
}

if intent is OpenHistoryWebsiteIntent {
return OpenHistoryWebsiteIntentHandler()
}

if intent is OpenBookmarkWebsiteIntent {
return OpenBookmarkWebsiteIntent()
}

return self
}
}
Loading

0 comments on commit 3a040a8

Please sign in to comment.