Skip to content

Commit 0a3d7ed

Browse files
Hide QR code button on unsupported devices
1 parent 5efdc77 commit 0a3d7ed

File tree

6 files changed

+116
-4
lines changed

6 files changed

+116
-4
lines changed

Diff for: ChatSecure.xcodeproj/project.pbxproj

+20
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
D936D6CB1E8B1B34003B1343 /* FileTransferTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D936D6CA1E8B1B34003B1343 /* FileTransferTests.swift */; };
4242
D95AD2291B684AE1007DEBC3 /* xmpp-server-list in Resources */ = {isa = PBXBuildFile; fileRef = D95AD2281B684AE1007DEBC3 /* xmpp-server-list */; };
4343
D985BC7A1EBD32F700993D27 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D985BC791EBD32F700993D27 /* StoreKit.framework */; };
44+
D986C64C244564260066CC03 /* UIViewControllerPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = D986C64B244564260066CC03 /* UIViewControllerPreview.swift */; };
45+
D986C653244565C30066CC03 /* OTRInviteViewController_Previews.swift in Sources */ = {isa = PBXBuildFile; fileRef = D986C652244565C30066CC03 /* OTRInviteViewController_Previews.swift */; };
46+
D986C656244567B90066CC03 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D986C654244567090066CC03 /* SwiftUI.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
4447
D9B3EC221FA196CE00E63C7F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B3EC211FA196CE00E63C7F /* AppDelegate.swift */; };
4548
D9B7EEFB235D47C400AD1EEA /* OTRKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9B7EEF6235D477200AD1EEA /* OTRKit.framework */; };
4649
D9B7EEFC235D47CA00AD1EEA /* CPAProxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9B7EEE9235D476700AD1EEA /* CPAProxy.framework */; };
@@ -689,6 +692,9 @@
689692
D97070911EEF382D004FEBDE /* MediaDownloadView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = MediaDownloadView.xib; path = Interface/MediaDownloadView.xib; sourceTree = "<group>"; };
690693
D973D7051A2D4094004D353E /* Pods-ChatSecureCorePods-ChatSecure-acknowledgements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Pods-ChatSecureCorePods-ChatSecure-acknowledgements.plist"; path = "Pods/Target Support Files/Pods-ChatSecureCorePods-ChatSecure/Pods-ChatSecureCorePods-ChatSecure-acknowledgements.plist"; sourceTree = SOURCE_ROOT; };
691694
D985BC791EBD32F700993D27 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
695+
D986C64B244564260066CC03 /* UIViewControllerPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerPreview.swift; sourceTree = "<group>"; };
696+
D986C652244565C30066CC03 /* OTRInviteViewController_Previews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OTRInviteViewController_Previews.swift; sourceTree = "<group>"; };
697+
D986C654244567090066CC03 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/SwiftUI.framework; sourceTree = DEVELOPER_DIR; };
692698
D98BA36B1EDE47BB004475B6 /* HTMLPreviewView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = HTMLPreviewView.xib; path = Interface/HTMLPreviewView.xib; sourceTree = "<group>"; };
693699
D99F17891BAB946800604558 /* Branding.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Branding.plist; sourceTree = "<group>"; };
694700
D99F178B1BAB947E00604558 /* Secrets.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Secrets.plist; sourceTree = "<group>"; };
@@ -1116,6 +1122,7 @@
11161122
isa = PBXFrameworksBuildPhase;
11171123
buildActionMask = 2147483647;
11181124
files = (
1125+
D986C656244567B90066CC03 /* SwiftUI.framework in Frameworks */,
11191126
D9C52807235CB55C002B213A /* ChatSecureCore.framework in Frameworks */,
11201127
D985BC7A1EBD32F700993D27 /* StoreKit.framework in Frameworks */,
11211128
07BD06A9B424D601FC93AB82 /* libPods-ChatSecureCorePods-ChatSecure.a in Frameworks */,
@@ -1350,6 +1357,14 @@
13501357
path = xcconfig;
13511358
sourceTree = "<group>";
13521359
};
1360+
D986C651244565950066CC03 /* Previews */ = {
1361+
isa = PBXGroup;
1362+
children = (
1363+
D986C652244565C30066CC03 /* OTRInviteViewController_Previews.swift */,
1364+
);
1365+
path = Previews;
1366+
sourceTree = "<group>";
1367+
};
13531368
D9B7EEE0235D476700AD1EEA /* Products */ = {
13541369
isa = PBXGroup;
13551370
children = (
@@ -1401,6 +1416,7 @@
14011416
D9C52811235CB57F002B213A /* View Controllers */ = {
14021417
isa = PBXGroup;
14031418
children = (
1419+
D986C651244565950066CC03 /* Previews */,
14041420
D9C52812235CB57F002B213A /* OTRDoubleSettingViewController.m */,
14051421
D9C52813235CB57F002B213A /* OTRNewBuddyViewController.m */,
14061422
D9C52814235CB57F002B213A /* OTRChooseAccountViewController.m */,
@@ -1474,6 +1490,7 @@
14741490
D9C52846235CB580002B213A /* Utilities */ = {
14751491
isa = PBXGroup;
14761492
children = (
1493+
D986C64B244564260066CC03 /* UIViewControllerPreview.swift */,
14771494
D9C52847235CB580002B213A /* OTRConstants.m */,
14781495
D9C52848235CB580002B213A /* OTRColors.m */,
14791496
D9C52849235CB580002B213A /* OTRUtilities.h */,
@@ -1944,6 +1961,7 @@
19441961
DB9AACD6ED82090C7A6B0076 /* Frameworks */ = {
19451962
isa = PBXGroup;
19461963
children = (
1964+
D986C654244567090066CC03 /* SwiftUI.framework */,
19471965
D90DA4F2236F3C6800C585B7 /* Appirater.bundle */,
19481966
D90DA4F3236F3C6800C585B7 /* CPAProxy.bundle */,
19491967
D90DA4F4236F3C6800C585B7 /* TUSafariActivity.bundle */,
@@ -2630,6 +2648,7 @@
26302648
D9C52A5B235CB581002B213A /* OTRProtocolManager.m in Sources */,
26312649
D9C52A10235CB580002B213A /* OTRXMPPPresenceSubscriptionRequest.m in Sources */,
26322650
D9C52AD5235CB581002B213A /* UIApplication+ChatSecure.swift in Sources */,
2651+
D986C64C244564260066CC03 /* UIViewControllerPreview.swift in Sources */,
26332652
D9C52A8B235CB581002B213A /* ServerCheck.swift in Sources */,
26342653
D9C52A55235CB581002B213A /* PushDeserializer.swift in Sources */,
26352654
D9C52AA5235CB581002B213A /* OTRStatusMessageCell.m in Sources */,
@@ -2816,6 +2835,7 @@
28162835
D9C52A92235CB581002B213A /* SingleButtonTableViewCell.swift in Sources */,
28172836
D9C52A82235CB581002B213A /* OTRAudioPlaybackController.m in Sources */,
28182837
D9C52A4C235CB581002B213A /* OTROpenInTwitterActivity.m in Sources */,
2838+
D986C653244565C30066CC03 /* OTRInviteViewController_Previews.swift in Sources */,
28192839
D9C52A2F235CB581002B213A /* BuddyActions.swift in Sources */,
28202840
D9C52A49235CB581002B213A /* OTRActivityItemProvider.m in Sources */,
28212841
D9C52A30235CB581002B213A /* OTRIncomingMessage.m in Sources */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// UIViewControllerPreview.swift
3+
// ChatSecureCore
4+
//
5+
// Created by Chris Ballinger on 4/13/20.
6+
// Copyright © 2020 Chris Ballinger. All rights reserved.
7+
//
8+
// https://gist.github.com/mattt/ff6b58af8576c798485b449269d43607
9+
10+
import UIKit
11+
12+
#if canImport(SwiftUI) && DEBUG
13+
import SwiftUI
14+
15+
@available(iOS 13.0, *)
16+
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
17+
let viewController: ViewController
18+
19+
init(_ builder: @escaping () -> ViewController) {
20+
viewController = builder()
21+
}
22+
23+
// MARK: - UIViewControllerRepresentable
24+
func makeUIViewController(context: Context) -> ViewController {
25+
viewController
26+
}
27+
28+
func updateUIViewController(_ uiViewController: ViewController, context: UIViewControllerRepresentableContext<UIViewControllerPreview<ViewController>>) {
29+
return
30+
}
31+
}
32+
33+
#endif

Diff for: ChatSecureCore/Classes/View Controllers/OTRInviteViewController.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ - (void)viewDidLoad
103103
NSMutableArray *shareButtons = [[NSMutableArray alloc] initWithCapacity:2];
104104

105105
[shareButtons addObject:[self buttonWithIcon:FAEnvelope title:INVITE_LINK_STRING() type:BButtonTypeDefault action:@selector(linkShareButtonPressed:)]];
106-
[shareButtons addObject:[self buttonWithIcon:FACamera title:SCAN_QR_STRING() type:BButtonTypeDefault action:@selector(qrButtonPressed:)]];
106+
if ([QRCodeReader isAvailable]) {
107+
[shareButtons addObject:[self buttonWithIcon:FACamera title:SCAN_QR_STRING() type:BButtonTypeDefault action:@selector(qrButtonPressed:)]];
108+
}
107109

108110
self.shareButtons = shareButtons;
109111

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// OTRInviteViewController_Previews.swift
3+
// ChatSecureCore
4+
//
5+
// Created by Chris Ballinger on 4/13/20.
6+
// Copyright © 2020 Chris Ballinger. All rights reserved.
7+
//
8+
9+
#if DEBUG
10+
import SwiftUI
11+
12+
/// Unfortunately Xcode cannot seem to create Previews with our current build configuration
13+
@available(iOS 13.0, *)
14+
struct OTRInviteViewController_Previews: PreviewProvider {
15+
static var previews: some View {
16+
Group {
17+
UIViewControllerPreview {
18+
OTRInviteViewController(account: OTRAccount(username: "[email protected]", accountType: .jabber)!)
19+
}
20+
.previewDevice("iPhone 11 Pro Max")
21+
.previewLayout(.sizeThatFits)
22+
}
23+
}
24+
}
25+
26+
#endif

Diff for: OTRResources/Images/OTRImages.xcassets/chatsecure_logo_transparent.imageset/Contents.json

+34-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,48 @@
55
"scale" : "1x"
66
},
77
{
8+
"appearances" : [
9+
{
10+
"appearance" : "luminosity",
11+
"value" : "dark"
12+
}
13+
],
814
"idiom" : "universal",
15+
"scale" : "1x"
16+
},
17+
{
918
"filename" : "[email protected]",
19+
"idiom" : "universal",
20+
"scale" : "2x"
21+
},
22+
{
23+
"appearances" : [
24+
{
25+
"appearance" : "luminosity",
26+
"value" : "dark"
27+
}
28+
],
29+
"filename" : "[email protected]",
30+
"idiom" : "universal",
1031
"scale" : "2x"
1132
},
1233
{
1334
"idiom" : "universal",
1435
"scale" : "3x"
36+
},
37+
{
38+
"appearances" : [
39+
{
40+
"appearance" : "luminosity",
41+
"value" : "dark"
42+
}
43+
],
44+
"idiom" : "universal",
45+
"scale" : "3x"
1546
}
1647
],
1748
"info" : {
18-
"version" : 1,
19-
"author" : "xcode"
49+
"author" : "xcode",
50+
"version" : 1
2051
}
21-
}
52+
}
Loading

0 commit comments

Comments
 (0)