From c1f331bc6d57e3ba53c7e744587653602990b40a Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Thu, 13 Oct 2022 11:30:19 -0400 Subject: [PATCH] Fix #6166: Add QR Code shortcut and adjust search shortcut behavior --- .../Base.lproj/BraveWidgets.intentdefinition | 16 +- App/BraveWidgets/ShortcutsWidget.swift | 6 +- .../Browser/BrowserViewController.swift | 2 + .../Frontend/Browser/NavigationRouter.swift | 8 +- .../brave.qr-code.symbolset/Contents.json | 2 +- .../brave.qr-code.symbolset/brave.qr-code.svg | 141 ------------------ .../brave.qr-code.symbolset/brave.qrcode.svg | 89 +++++++++++ 7 files changed, 117 insertions(+), 147 deletions(-) delete mode 100644 Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/brave.qr-code.svg create mode 100644 Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/brave.qrcode.svg diff --git a/App/BraveWidgets/Base.lproj/BraveWidgets.intentdefinition b/App/BraveWidgets/Base.lproj/BraveWidgets.intentdefinition index c3927d493bd..477e0b86ffd 100644 --- a/App/BraveWidgets/Base.lproj/BraveWidgets.intentdefinition +++ b/App/BraveWidgets/Base.lproj/BraveWidgets.intentdefinition @@ -158,6 +158,16 @@ INEnumValueName wallet + + INEnumValueDisplayName + Scan QR Code + INEnumValueDisplayNameID + qKrzyX + INEnumValueIndex + 9 + INEnumValueName + scanQRCode + @@ -166,11 +176,11 @@ INIntentDefinitionNamespace 88xZPY INIntentDefinitionSystemVersion - 21G83 + 21G115 INIntentDefinitionToolsBuildVersion - 14A5294g + 14B5033e INIntentDefinitionToolsVersion - 14.0 + 14.1 INIntents diff --git a/App/BraveWidgets/ShortcutsWidget.swift b/App/BraveWidgets/ShortcutsWidget.swift index b64243147b7..56d5ef43e6d 100644 --- a/App/BraveWidgets/ShortcutsWidget.swift +++ b/App/BraveWidgets/ShortcutsWidget.swift @@ -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 "" @@ -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") @@ -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)) } } diff --git a/Client/Frontend/Browser/BrowserViewController.swift b/Client/Frontend/Browser/BrowserViewController.swift index 383d1a3bf5b..9e12a27d1ec 100644 --- a/Client/Frontend/Browser/BrowserViewController.swift +++ b/Client/Frontend/Browser/BrowserViewController.swift @@ -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() } } } diff --git a/Client/Frontend/Browser/NavigationRouter.swift b/Client/Frontend/Browser/NavigationRouter.swift index a71221e9e78..f5a4e9a18d7 100644 --- a/Client/Frontend/Browser/NavigationRouter.swift +++ b/Client/Frontend/Browser/NavigationRouter.swift @@ -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: @@ -122,6 +126,8 @@ public enum NavigationPath: Equatable { bvc.navigationHelper.openPlaylist() case .wallet: bvc.navigationHelper.openWallet() + case .scanQRCode: + bvc.scanQRCode() @unknown default: assertionFailure() break diff --git a/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/Contents.json b/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/Contents.json index 93889845732..4866836f7a9 100644 --- a/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/Contents.json +++ b/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/Contents.json @@ -5,7 +5,7 @@ }, "symbols" : [ { - "filename" : "brave.qr-code.svg", + "filename" : "brave.qrcode.svg", "idiom" : "universal" } ] diff --git a/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/brave.qr-code.svg b/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/brave.qr-code.svg deleted file mode 100644 index e4b4eae8963..00000000000 --- a/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/brave.qr-code.svg +++ /dev/null @@ -1,141 +0,0 @@ - - - brave.qr-code - - - - - - - Weight/Scale Variations - - - Ultralight - - - Thin - - - Light - - - Regular - - - Medium - - - Semibold - - - Bold - - - Heavy - - - Black - - - - - - - - - - - - - Design Variations - - - Symbols are supported in up to nine weights and three scales. - - - For optimal layout with text and other symbols, vertically align - - - symbols with the adjacent text. - - - - - - - - Margins - - - Leading and trailing margins on the left and right side of each symbol - - - can be adjusted by modifying the x-location of the margin guidelines. - - - Modifications are automatically applied proportionally to all - - - scales and weights. - - - - - - Exporting - - - Symbols should be outlined when exporting to ensure the - - - design is preserved when submitting to Xcode. - - - Template v.2.0 - - - Requires Xcode 12 or greater - - - Generated from qrcode - - - Typeset at 100 points - - - Small - - - Medium - - - Large - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/brave.qrcode.svg b/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/brave.qrcode.svg new file mode 100644 index 00000000000..bd274e107b7 --- /dev/null +++ b/Sources/DesignSystem/Icons/Symbols.xcassets/brave.qr-code.symbolset/brave.qrcode.svg @@ -0,0 +1,89 @@ + + + + + + + + + Weight/Scale Variations + Ultralight + Thin + Light + Regular + Medium + Semibold + Bold + Heavy + Black + + + + + + + + + + + Design Variations + Symbols are supported in up to nine weights and three scales. + For optimal layout with text and other symbols, vertically align + symbols with the adjacent text. + + + + + + Margins + Leading and trailing margins on the left and right side of each symbol + can be adjusted by modifying the x-location of the margin guidelines. + Modifications are automatically applied proportionally to all + scales and weights. + + + + Exporting + Symbols should be outlined when exporting to ensure the + design is preserved when submitting to Xcode. + Template v.2.0 + Requires Xcode 12 or greater + Generated from brave.qrcode + Typeset at 100 points + Small + Medium + Large + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +