Skip to content

Commit

Permalink
Added iMessage extension back
Browse files Browse the repository at this point in the history
  • Loading branch information
arguiot committed May 6, 2020
1 parent 6a7e81a commit 34aac05
Show file tree
Hide file tree
Showing 26 changed files with 688 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CrypTool-iMessage/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "iphone_29x29_2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "iphone_29x29_3x.png",
"scale" : "3x"
},
{
"size" : "60x45",
"idiom" : "iphone",
"filename" : "iphone_60x45_2x.png",
"scale" : "2x"
},
{
"size" : "60x45",
"idiom" : "iphone",
"filename" : "iphone_60x45_3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "ipad_29x29_2x.png",
"scale" : "2x"
},
{
"size" : "67x50",
"idiom" : "ipad",
"filename" : "iMessage iPad.png",
"scale" : "2x"
},
{
"size" : "74x55",
"idiom" : "ipad",
"filename" : "iMessage iPad Pro.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "ios-marketing_1024x1024_1x.png",
"scale" : "1x"
},
{
"size" : "27x20",
"idiom" : "universal",
"filename" : "iMessage.png",
"scale" : "2x",
"platform" : "ios"
},
{
"size" : "27x20",
"idiom" : "universal",
"filename" : "iMessage3.png",
"scale" : "3x",
"platform" : "ios"
},
{
"size" : "32x24",
"idiom" : "universal",
"filename" : "universal_32x24_2x.png",
"scale" : "2x",
"platform" : "ios"
},
{
"size" : "32x24",
"idiom" : "universal",
"filename" : "universal_32x24_3x.png",
"scale" : "3x",
"platform" : "ios"
},
{
"size" : "1024x768",
"idiom" : "ios-marketing",
"filename" : "ios-marketing_1024x768_1x.png",
"scale" : "1x",
"platform" : "ios"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_arrow_back_white_48pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_arrow_back_white_48pt_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_arrow_back_white_48pt_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions CrypTool-iMessage/Base.lproj/MainInterface.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ObA-dk-sSI">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="RobotoMono-Regular.ttf">
<string>RobotoMono-Regular</string>
</array>
</customFonts>
<scenes>
<!--Messages View Controller-->
<scene sceneID="7MM-of-jgj">
<objects>
<viewController id="ObA-dk-sSI" customClass="MessagesViewController" customModule="CrypTool_iMessage" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="zMn-AG-sqS">
<rect key="frame" x="0.0" y="0.0" width="320" height="528"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="ecd-Bq-L1G">
<rect key="frame" x="16" y="0.0" width="288" height="508"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="A52-66-zL9">
<rect key="frame" x="85" y="239" width="150" height="50"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="150" id="5Rb-eR-t6N"/>
<constraint firstAttribute="height" constant="50" id="Vgx-2s-JiU"/>
</constraints>
<fontDescription key="fontDescription" name="RobotoMono-Regular" family="Roboto Mono" pointSize="20"/>
<state key="normal" title="Decrypt">
<color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="Decrypt:" destination="ObA-dk-sSI" eventType="touchUpInside" id="rvB-eR-Stw"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Copy a message and click on the button below" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ouu-Dv-P0n">
<rect key="frame" x="57" y="131" width="206" height="100"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="OyG-3q-puX"/>
</constraints>
<fontDescription key="fontDescription" name="RobotoMono-Regular" family="Roboto Mono" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="u5f-ry-7Pe">
<rect key="frame" x="136" y="460" width="48" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="570-yt-8fG"/>
<constraint firstAttribute="height" constant="48" id="cR0-rs-q4L"/>
</constraints>
<state key="normal" image="ic_arrow_back_white_48pt"/>
<connections>
<action selector="BackButtonAction:" destination="ObA-dk-sSI" eventType="touchUpInside" id="cpe-Uk-FCp"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.16078431372549018" green="0.16078431372549018" blue="0.16078431372549018" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<gestureRecognizers/>
<constraints>
<constraint firstItem="ecd-Bq-L1G" firstAttribute="centerX" secondItem="zMn-AG-sqS" secondAttribute="centerX" id="3tx-ZQ-nvZ"/>
<constraint firstItem="LDy-ih-0nr" firstAttribute="bottom" secondItem="ecd-Bq-L1G" secondAttribute="bottom" constant="20" id="4Ed-aP-Kjn"/>
<constraint firstItem="LDy-ih-0nr" firstAttribute="trailing" secondItem="ouu-Dv-P0n" secondAttribute="trailing" constant="57" id="Aif-nW-rex"/>
<constraint firstItem="A52-66-zL9" firstAttribute="centerX" secondItem="zMn-AG-sqS" secondAttribute="centerX" id="KVP-Qp-nA6"/>
<constraint firstItem="ecd-Bq-L1G" firstAttribute="top" secondItem="LDy-ih-0nr" secondAttribute="top" id="NZn-EE-xLh"/>
<constraint firstItem="A52-66-zL9" firstAttribute="top" secondItem="ouu-Dv-P0n" secondAttribute="bottom" constant="8" id="QIr-6D-shI"/>
<constraint firstItem="LDy-ih-0nr" firstAttribute="trailing" secondItem="ecd-Bq-L1G" secondAttribute="trailing" constant="16" id="R6f-fH-TeL"/>
<constraint firstItem="ecd-Bq-L1G" firstAttribute="centerY" secondItem="zMn-AG-sqS" secondAttribute="centerY" id="RJh-Qc-MqV"/>
<constraint firstItem="ouu-Dv-P0n" firstAttribute="centerX" secondItem="zMn-AG-sqS" secondAttribute="centerX" id="Ras-FE-hb4"/>
<constraint firstItem="A52-66-zL9" firstAttribute="centerY" secondItem="zMn-AG-sqS" secondAttribute="centerY" id="fOC-kY-eQ9"/>
<constraint firstItem="ouu-Dv-P0n" firstAttribute="leading" secondItem="LDy-ih-0nr" secondAttribute="leading" constant="57" id="flU-rz-n5Z"/>
<constraint firstItem="ecd-Bq-L1G" firstAttribute="leading" secondItem="LDy-ih-0nr" secondAttribute="leading" constant="16" id="gEL-pY-gyr"/>
<constraint firstItem="LDy-ih-0nr" firstAttribute="bottom" secondItem="u5f-ry-7Pe" secondAttribute="bottom" constant="20" id="u3j-Js-DpB"/>
<constraint firstItem="u5f-ry-7Pe" firstAttribute="centerX" secondItem="zMn-AG-sqS" secondAttribute="centerX" id="zco-8i-Pbv"/>
</constraints>
<viewLayoutGuide key="safeArea" id="LDy-ih-0nr"/>
<connections>
<outletCollection property="gestureRecognizers" destination="2Kt-CN-eau" appends="YES" id="pvt-Sd-JJM"/>
</connections>
</view>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="528"/>
<connections>
<outlet property="BackButton" destination="u5f-ry-7Pe" id="tVW-mP-5Ai"/>
<outlet property="Button" destination="A52-66-zL9" id="kmA-dp-HkL"/>
<outlet property="TextView" destination="ecd-Bq-L1G" id="6IQ-Ut-UG3"/>
<outlet property="Tutorial" destination="ouu-Dv-P0n" id="Iqg-et-Bst"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="X47-rx-isc" userLabel="First Responder" sceneMemberID="firstResponder"/>
<screenEdgePanGestureRecognizer minimumNumberOfTouches="1" id="2Kt-CN-eau">
<connections>
<action selector="Back:" destination="ObA-dk-sSI" id="iIe-V0-kdf"/>
</connections>
</screenEdgePanGestureRecognizer>
</objects>
<point key="canvasLocation" x="116.8" y="118.74062968515743"/>
</scene>
</scenes>
<resources>
<image name="ic_arrow_back_white_48pt" width="48" height="48"/>
</resources>
</document>
31 changes: 31 additions & 0 deletions CrypTool-iMessage/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>CrypTool-iMessage</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.message-payload-provider</string>
</dict>
</dict>
</plist>
123 changes: 123 additions & 0 deletions CrypTool-iMessage/MessagesViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
//
// MessagesViewController.swift
// CrypTool-iMessage
//
// Created by Arthur Guiot on 2020-05-06.
// Copyright © 2020 Arthur Guiot. All rights reserved.
//

import UIKit
import Messages

class MessagesViewController: MSMessagesAppViewController {

@IBOutlet weak var TextView: UITextView!
@IBOutlet weak var Tutorial: UILabel!
@IBOutlet weak var Button: UIButton!
@IBOutlet weak var BackButton: UIButton!

var cipher = Cipher()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
TextView.isHidden = true
BackButton.isHidden = true
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

// MARK: - Conversation Handling

override func willBecomeActive(with conversation: MSConversation) {
// Called when the extension is about to move from the inactive to active state.
// This will happen when the extension is about to present UI.

// Use this method to configure the extension and restore previously stored state.
}

override func didResignActive(with conversation: MSConversation) {
// Called when the extension is about to move from the active to inactive state.
// This will happen when the user dissmises the extension, changes to a different
// conversation or quits Messages.

// Use this method to release shared resources, save user data, invalidate timers,
// and store enough state information to restore your extension to its current state
// in case it is terminated later.
}

override func didReceive(_ message: MSMessage, conversation: MSConversation) {
// Called when a message arrives that was generated by another instance of this
// extension on a remote device.

// Use this method to trigger UI updates in response to the message.
}

override func didStartSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user taps the send button.
}

override func didCancelSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user deletes the message without sending it.

// Use this to clean up state related to the deleted message.
}

override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called before the extension transitions to a new presentation style.

// Use this method to prepare for the change in presentation style.
}

override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called after the extension transitions to a new presentation style.

// Use this method to finalize any behaviors associated with the change in presentation style.
}
@IBAction func Decrypt(_ sender: UIButton) {
let text = UIPasteboard.general.string ?? ""

let parsed = Parser(text)

if parsed.valid {
let cipherName = parsed.cipher
let text = parsed.text
let key = parsed.key

let cipher = self.cipher.getDecrypt(cipherName)

TextView.text = cipher(text, key)

Button.isHidden = true
Tutorial.isHidden = true
TextView.isHidden = false
BackButton.isHidden = false
} else {
let alertController = UIAlertController(title: "Error", message:
"Text couldn't be parsed. Try again.", preferredStyle: .alert)
self.present(alertController, animated: true) {
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.dismissAlertController))
alertController.view.superview?.subviews[0].addGestureRecognizer(tapGesture)
}
}
}

@objc func dismissAlertController(_ sender: UITapGestureRecognizer) {
self.dismiss(animated: true, completion: nil)
}
@IBAction func Back(_ sender: Any) {
back()
}
@IBAction func BackButtonAction(_ sender: Any) {
back()
}
func back() {
TextView.isHidden = true
BackButton.isHidden = true
Button.isHidden = false
Tutorial.isHidden = false
}

}
Loading

0 comments on commit 34aac05

Please sign in to comment.