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

Commit

Permalink
Fix #6166: Add QR Code shortcut and adjust search shortcut behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Oct 13, 2022
1 parent 7a3b65e commit c1f331b
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 147 deletions.
16 changes: 13 additions & 3 deletions App/BraveWidgets/Base.lproj/BraveWidgets.intentdefinition
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@
<key>INEnumValueName</key>
<string>wallet</string>
</dict>
<dict>
<key>INEnumValueDisplayName</key>
<string>Scan QR Code</string>
<key>INEnumValueDisplayNameID</key>
<string>qKrzyX</string>
<key>INEnumValueIndex</key>
<integer>9</integer>
<key>INEnumValueName</key>
<string>scanQRCode</string>
</dict>
</array>
</dict>
</array>
Expand All @@ -166,11 +176,11 @@
<key>INIntentDefinitionNamespace</key>
<string>88xZPY</string>
<key>INIntentDefinitionSystemVersion</key>
<string>21G83</string>
<string>21G115</string>
<key>INIntentDefinitionToolsBuildVersion</key>
<string>14A5294g</string>
<string>14B5033e</string>
<key>INIntentDefinitionToolsVersion</key>
<string>14.0</string>
<string>14.1</string>
<key>INIntents</key>
<array>
<dict>
Expand Down
6 changes: 5 additions & 1 deletion App/BraveWidgets/ShortcutsWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ extension WidgetShortcut {
return Strings.Widgets.searchShortcutTitle
case .wallet:
return Strings.Widgets.walletShortcutTitle
case .scanQRCode:
return Strings.scanQRCodeViewTitle
@unknown default:
assertionFailure()
return ""
Expand Down Expand Up @@ -161,6 +163,8 @@ extension WidgetShortcut {
return Image(braveSystemName: "brave.magnifyingglass")
case .wallet:
return Image(braveSystemName: "brave.wallet")
case .scanQRCode:
return Image(braveSystemName: "brave.qr-code")
@unknown default:
assertionFailure()
return Image(systemName: "xmark.octagon")
Expand Down Expand Up @@ -219,7 +223,7 @@ struct ShortcutsWidget_Previews: PreviewProvider {
.previewContext(WidgetPreviewContext(family: .systemMedium))
ShortcutsView(slots: [.downloads, .history, .playlist])
.previewContext(WidgetPreviewContext(family: .systemMedium))
ShortcutsView(slots: [.wallet, .search, .newTab])
ShortcutsView(slots: [.wallet, .search, .scanQRCode])
.previewContext(WidgetPreviewContext(family: .systemMedium))
}
}
Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,8 @@ public class BrowserViewController: UIViewController {
guard freshTab == self.tabManager.selectedTab else { return }
if let text = searchText {
self.topToolbar.submitLocation(text)
} else {
self.focusURLBar()
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion Client/Frontend/Browser/NavigationRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ public enum NavigationPath: Equatable {
switch path {
case .unknown, .search:
// Search
bvc.focusURLBar()
if let url = bvc.tabManager.selectedTab?.url, InternalURL(url)?.isAboutHomeURL == true {
bvc.focusURLBar()
} else {
bvc.openBlankNewTab(attemptLocationFieldFocus: true, isPrivate: PrivateBrowsingManager.shared.isPrivateBrowsing)
}
case .newTab:
bvc.openBlankNewTab(attemptLocationFieldFocus: true, isPrivate: PrivateBrowsingManager.shared.isPrivateBrowsing)
case .newPrivateTab:
Expand All @@ -122,6 +126,8 @@ public enum NavigationPath: Equatable {
bvc.navigationHelper.openPlaylist()
case .wallet:
bvc.navigationHelper.openWallet()
case .scanQRCode:
bvc.scanQRCode()
@unknown default:
assertionFailure()
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"symbols" : [
{
"filename" : "brave.qr-code.svg",
"filename" : "brave.qrcode.svg",
"idiom" : "universal"
}
]
Expand Down

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c1f331b

Please sign in to comment.