Skip to content

Commit

Permalink
Bug 1293512 - Support QR Code on iOS (#2737)
Browse files Browse the repository at this point in the history
* Bug 1293512 - Support QR Code on iOS

* Prevent QR scanner menu item from appearing on devices without a video capture device (e.g. simulator).
  • Loading branch information
justindarc committed May 25, 2017
1 parent e190984 commit 39ee047
Show file tree
Hide file tree
Showing 33 changed files with 486 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Client.xcodeproj/project.pbxproj
Expand Up @@ -749,6 +749,8 @@
FA6B2AC21D41F02D00429414 /* Punycode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA6B2AC11D41F02D00429414 /* Punycode.swift */; };
FA6B2AC31D41F02D00429414 /* Punycode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA6B2AC11D41F02D00429414 /* Punycode.swift */; };
FA6B2AC41D41F02D00429414 /* Punycode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA6B2AC11D41F02D00429414 /* Punycode.swift */; };
FA9293D41D6580E100AC8D33 /* QRCodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA9293D31D6580E100AC8D33 /* QRCodeViewController.swift */; };
FA9294011D6584A200AC8D33 /* QRCode.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FA9294001D6584A200AC8D33 /* QRCode.xcassets */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -1965,6 +1967,8 @@
F8708D261A0970990051AB07 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F8708D291A0970990051AB07 /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
FA6B2AC11D41F02D00429414 /* Punycode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Punycode.swift; sourceTree = "<group>"; };
FA9293D31D6580E100AC8D33 /* QRCodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QRCodeViewController.swift; sourceTree = "<group>"; };
FA9294001D6584A200AC8D33 /* QRCode.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = QRCode.xcassets; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -3047,6 +3051,8 @@
74821FC41DB56A2500EEEA72 /* OpenWithSettingsViewController.swift */,
7482205B1DBAB56300EEEA72 /* MailProviders.swift */,
744ED5601DBFEB8D00A2B5BE /* MailtoLinkHandler.swift */,
FA9293D31D6580E100AC8D33 /* QRCodeViewController.swift */,
FA9294001D6584A200AC8D33 /* QRCode.xcassets */,
);
path = Browser;
sourceTree = "<group>";
Expand Down Expand Up @@ -4809,6 +4815,7 @@
3B4262E51E538EC400CA681C /* MetadataHelper.js in Resources */,
E47536FC1C85415F0022CC69 /* PrintHelper.js in Resources */,
74821FFE1DB6D3AC00EEEA72 /* MailSchemes.plist in Resources */,
FA9294011D6584A200AC8D33 /* QRCode.xcassets in Resources */,
D308EE561CBF0BF5006843F2 /* CertError.css in Resources */,
E4B7B7641A793CF20022C5E0 /* CharisSILR.ttf in Resources */,
D3BA7E0C1B0E902A00153782 /* ContextMenu.js in Resources */,
Expand Down Expand Up @@ -5420,6 +5427,7 @@
E689C6FA1E0C6E98008BAADB /* FxAContentViewController.swift in Sources */,
C4E3983D1D21F1E7004E89BA /* TopTabsViews.swift in Sources */,
3B0943811D6CC4FC004F24E1 /* FilledPageControl.swift in Sources */,
FA9293D41D6580E100AC8D33 /* QRCodeViewController.swift in Sources */,
0BB5B2891AC0A2B90052877D /* Toolbar.swift in Sources */,
E6108FF91C84E91C005D25E8 /* BasePasscodeViewController.swift in Sources */,
E4CD9F2D1A6DC91200318571 /* TabLocationView.swift in Sources */,
Expand Down
16 changes: 16 additions & 0 deletions Client/Frontend/Browser/BrowserViewController.swift
Expand Up @@ -1423,6 +1423,8 @@ extension BrowserViewController: MenuActionDelegate {
NightModeHelper.setNightMode(self.profile.prefs, tabManager: self.tabManager, enabled: false)
case .hideNightMode:
NightModeHelper.setNightMode(self.profile.prefs, tabManager: self.tabManager, enabled: true)
case .openQRCode:
self.openQRCode()
case .openSettings:
self.openSettings()
case .openTopSites:
Expand Down Expand Up @@ -1458,6 +1460,20 @@ extension BrowserViewController: MenuActionDelegate {
default: break
}
}

fileprivate func openQRCode() {
let qrCodeViewController = QRCodeViewController()
qrCodeViewController.qrCodeDelegate = self
let controller = UINavigationController(rootViewController: qrCodeViewController)
self.present(controller, animated: true, completion: nil)
}
}

extension BrowserViewController: QRCodeViewControllerDelegate {
func scanSuccessOpenNewTabWithData(data: String) {
self.openBlankNewTab()
self.urlBar(self.urlBar, didSubmitText: data)
}
}

extension BrowserViewController: SettingsDelegate {
Expand Down
6 changes: 6 additions & 0 deletions Client/Frontend/Browser/QRCode.xcassets/Contents.json
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "qrcode-goBack.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "qrcode-goBack@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "qrcode-goBack@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "qrcode-isLighting.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "qrcode-isLighting@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "qrcode-isLighting@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "qrcode-light.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "qrcode-light@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "qrcode-light@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "qrcode-scanBorder.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "qrcode-scanLine.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
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 39ee047

Please sign in to comment.