diff --git a/CrypTool-iMessage/Info.plist b/CrypTool-iMessage/Info.plist
index 4fa6848..89e8a87 100644
--- a/CrypTool-iMessage/Info.plist
+++ b/CrypTool-iMessage/Info.plist
@@ -17,9 +17,9 @@
CFBundlePackageType
$(PRODUCT_BUNDLE_PACKAGE_TYPE)
CFBundleShortVersionString
- 1.0
+ $(MARKETING_VERSION)
CFBundleVersion
- 1
+ $(CURRENT_PROJECT_VERSION)
NSExtension
NSExtensionMainStoryboard
diff --git a/CrypTool.xcodeproj/project.pbxproj b/CrypTool.xcodeproj/project.pbxproj
index f338442..040eacf 100644
--- a/CrypTool.xcodeproj/project.pbxproj
+++ b/CrypTool.xcodeproj/project.pbxproj
@@ -45,7 +45,7 @@
68C9AABA246330A30066563F /* MessagesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68C9AAB9246330A30066563F /* MessagesViewController.swift */; };
68C9AABD246330A30066563F /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 68C9AABB246330A30066563F /* MainInterface.storyboard */; };
68C9AABF246330AA0066563F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 68C9AABE246330AA0066563F /* Assets.xcassets */; };
- 68C9AAC3246330AA0066563F /* CrypTool-iMessage.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 68C9AAB4246330A30066563F /* CrypTool-iMessage.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
+ 68C9AAC3246330AA0066563F /* CrypTool-iMessage.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 68C9AAB4246330A30066563F /* CrypTool-iMessage.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
68C9AAC9246330CD0066563F /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68C9AAC8246330CD0066563F /* Parser.swift */; };
68C9AACA246331380066563F /* caesar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6814226F242A681B005C1F5C /* caesar.swift */; };
68C9AACB246331380066563F /* sha256.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68142270242A681B005C1F5C /* sha256.swift */; };
@@ -59,6 +59,7 @@
68C9AAD3246331380066563F /* ROT13.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68142278242A681B005C1F5C /* ROT13.swift */; };
68C9AAD4246331380066563F /* Rail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68142279242A681B005C1F5C /* Rail.swift */; };
68C9AAD52463313F0066563F /* Ciphers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68142288242A74BD005C1F5C /* Ciphers.swift */; };
+ 68D9F85F247C694B0046AFE6 /* imessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68D9F85E247C694B0046AFE6 /* imessage.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -144,6 +145,7 @@
68C9AABE246330AA0066563F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
68C9AAC0246330AA0066563F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
68C9AAC8246330CD0066563F /* Parser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Parser.swift; sourceTree = ""; };
+ 68D9F85E247C694B0046AFE6 /* imessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = imessage.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -313,6 +315,7 @@
6885B0B2242A41F50075C219 /* Down.swift */,
68142290242A798A005C1F5C /* LoadingActivity.swift */,
6805279B242BB5BE0021F146 /* TextView.swift */,
+ 68D9F85E247C694B0046AFE6 /* imessage.swift */,
);
path = "Special Views";
sourceTree = "";
@@ -527,6 +530,7 @@
683C6BE324297609007A73DE /* LevelCell.swift in Sources */,
6814227D242A681B005C1F5C /* md5.swift in Sources */,
6814227E242A681B005C1F5C /* b64.swift in Sources */,
+ 68D9F85F247C694B0046AFE6 /* imessage.swift in Sources */,
6885B0B3242A41F50075C219 /* Down.swift in Sources */,
683C6BE624298170007A73DE /* Level.swift in Sources */,
68142289242A74BD005C1F5C /* Ciphers.swift in Sources */,
@@ -592,6 +596,7 @@
};
68C9AAC2246330AA0066563F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
+ platformFilter = ios;
target = 68C9AAB3246330A30066563F /* CrypTool-iMessage */;
targetProxy = 68C9AAC1246330AA0066563F /* PBXContainerItemProxy */;
};
@@ -738,6 +743,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = CrypTool/CrypTool.entitlements;
CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"CrypTool/Preview Content\"";
DEVELOPMENT_TEAM = 73CCF549YB;
ENABLE_PREVIEWS = YES;
@@ -762,6 +768,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = CrypTool/CrypTool.entitlements;
CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"CrypTool/Preview Content\"";
DEVELOPMENT_TEAM = 73CCF549YB;
ENABLE_PREVIEWS = YES;
@@ -868,6 +875,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = "iMessage App Icon";
CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 73CCF549YB;
INFOPLIST_FILE = "CrypTool-iMessage/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
@@ -875,6 +883,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
+ MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.ArthurG.CrypTools.CrypTool-iMessage";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@@ -888,6 +897,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = "iMessage App Icon";
CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 73CCF549YB;
INFOPLIST_FILE = "CrypTool-iMessage/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
@@ -895,6 +905,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
+ MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.ArthurG.CrypTools.CrypTool-iMessage";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
diff --git a/CrypTool.xcodeproj/xcuserdata/arguiot.xcuserdatad/xcschemes/xcschememanagement.plist b/CrypTool.xcodeproj/xcuserdata/arguiot.xcuserdatad/xcschemes/xcschememanagement.plist
index 2a93189..faa79a7 100644
--- a/CrypTool.xcodeproj/xcuserdata/arguiot.xcuserdatad/xcschemes/xcschememanagement.plist
+++ b/CrypTool.xcodeproj/xcuserdata/arguiot.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -7,12 +7,12 @@
CrypTool-iMessage.xcscheme_^#shared#^_
orderHint
- 1
+ 0
CrypTool.xcscheme_^#shared#^_
orderHint
- 0
+ 1
diff --git a/CrypTool/Controllers/ContentView.swift b/CrypTool/Controllers/ContentView.swift
index 4f3e880..17847aa 100644
--- a/CrypTool/Controllers/ContentView.swift
+++ b/CrypTool/Controllers/ContentView.swift
@@ -27,10 +27,8 @@ struct ContentView: View {
if #available(iOS 13.0, *) {
return UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.top ?? 0 > 20
}else{
- return UIApplication.shared.delegate?.window??.safeAreaInsets.top ?? 0 > 20
+ return UIApplication.shared.delegate?.window??.safeAreaInsets.top ?? 0 > 20
}
-
- return false
}
var isMac: Bool {
@@ -76,7 +74,9 @@ struct ContentView: View {
.font(.system(size: 18, weight: .bold, design: .monospaced))
}
}.tag(1)
- }.edgesIgnoringSafeArea(hasTopNotch ? [.top] : []).accentColor(Color(#colorLiteral(red: 0.07058823529, green: 0.4666666667, blue: 0.9215686275, alpha: 1)))
+ }
+// .edgesIgnoringSafeArea(hasTopNotch ? [.top] : [])
+ .accentColor(Color(#colorLiteral(red: 0.07058823529, green: 0.4666666667, blue: 0.9215686275, alpha: 1)))
}
}
diff --git a/CrypTool/Controllers/EncryptView.swift b/CrypTool/Controllers/EncryptView.swift
index 6136e3f..db0d44b 100644
--- a/CrypTool/Controllers/EncryptView.swift
+++ b/CrypTool/Controllers/EncryptView.swift
@@ -7,6 +7,7 @@
//
import SwiftUI
+import MessageUI
struct EncryptView: View {
@State private var isOpen = false
@@ -17,6 +18,17 @@ struct EncryptView: View {
@State private var key = ""
@State private var encrypted = ""
+
+ @State var result: Result? = nil
+ @State var isShowingMessageView = false
+
+ var shareableString: String {
+ """
+ ---------- \(self.ciphers.name[self.selection]) ----------
+ \(self.ciphers.get(self.ciphers.name[self.selection])(self.message, self.key))
+ ---------- \(key) ----------
+ """
+ }
var body: some View {
ZStack(alignment: .top) {
ScrollView {
@@ -68,12 +80,31 @@ struct EncryptView: View {
.frame(width: geometry.size.width - 40)
.overlay(RoundedRectangle(cornerRadius: 4).stroke(Color.black))
- Button(action: {
- UIPasteboard.general.string = self.ciphers.get(self.ciphers.name[self.selection])(self.message, self.key)
- }) {
- Text("Copy")
- }
- .padding()
+ HStack {
+ Button(action: {
+ UIPasteboard.general.string = self.ciphers.get(self.ciphers.name[self.selection])(self.message, self.key)
+ }) {
+ VStack {
+ Image(systemName: "doc.on.doc")
+ Text("Copy")
+ }
+ }
+ .padding()
+
+ Button(action: {
+ self.isShowingMessageView.toggle()
+ }) {
+ VStack {
+ Image(systemName: "message")
+ Text("Message")
+ }
+ }
+ .padding()
+ .disabled(!MFMessageComposeViewController.canSendText())
+ .sheet(isPresented: self.$isShowingMessageView) {
+ MessageView(result: self.$result, content: self.shareableString)
+ }
+ }.padding()
}
}
}
diff --git a/CrypTool/Controllers/LearnView.swift b/CrypTool/Controllers/LearnView.swift
index a889bd1..704f5b5 100644
--- a/CrypTool/Controllers/LearnView.swift
+++ b/CrypTool/Controllers/LearnView.swift
@@ -79,7 +79,7 @@ struct LearnView: View {
AF.request(location).responseJSON {
response in
if (response.error != nil) {
- print(response.error?.localizedDescription)
+ print(response.error?.localizedDescription ?? "Error")
return
}
do {
diff --git a/CrypTool/Info.plist b/CrypTool/Info.plist
index 1e09107..4dc9532 100644
--- a/CrypTool/Info.plist
+++ b/CrypTool/Info.plist
@@ -17,7 +17,7 @@
CFBundleShortVersionString
$(MARKETING_VERSION)
CFBundleVersion
- 1
+ $(CURRENT_PROJECT_VERSION)
LSApplicationCategoryType
public.app-category.utilities
LSRequiresIPhoneOS
diff --git a/CrypTool/Special Views/imessage.swift b/CrypTool/Special Views/imessage.swift
new file mode 100644
index 0000000..49ebdd6
--- /dev/null
+++ b/CrypTool/Special Views/imessage.swift
@@ -0,0 +1,53 @@
+//
+// imessage.swift
+// CrypTool
+//
+// Created by Arthur Guiot on 2020-05-25.
+// Copyright © 2020 Arthur Guiot. All rights reserved.
+//
+
+import SwiftUI
+import MessageUI
+
+struct MessageView: UIViewControllerRepresentable {
+
+ @Environment(\.presentationMode) var presentation
+ @Binding var result: Result?
+ var content: String
+
+ class Coordinator: NSObject, MFMessageComposeViewControllerDelegate {
+ func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
+ defer {
+ $presentation.wrappedValue.dismiss()
+ }
+ self.result = .success(result)
+ }
+
+
+ @Binding var presentation: PresentationMode
+ @Binding var result: Result?
+
+ init(presentation: Binding,
+ result: Binding?>) {
+ _presentation = presentation
+ _result = result
+ }
+ }
+
+ func makeCoordinator() -> Coordinator {
+ return Coordinator(presentation: presentation,
+ result: $result)
+ }
+
+ func makeUIViewController(context: UIViewControllerRepresentableContext) -> MFMessageComposeViewController {
+ let vc = MFMessageComposeViewController()
+ vc.messageComposeDelegate = context.coordinator
+ vc.body = self.content
+ return vc
+ }
+
+ func updateUIViewController(_ uiViewController: MFMessageComposeViewController,
+ context: UIViewControllerRepresentableContext) {
+
+ }
+}