Skip to content
Snippets Groups Projects
Commit 64454fd2 authored by wieseoli's avatar wieseoli
Browse files

Merge branch 'feature/inviteButton' into 'master'

Different actions for Invite Button in send view

See merge request !15
parents ddb3a70a 2fef8d9d
Branches
Tags
1 merge request!15Different actions for Invite Button in send view
...@@ -14,6 +14,7 @@ enum DialogOption { ...@@ -14,6 +14,7 @@ enum DialogOption {
case invitationCode(code: String) case invitationCode(code: String)
case invitationWelcome case invitationWelcome
case invitationStep case invitationStep
case invitationHelp
var color: UIColor { var color: UIColor {
switch self { switch self {
...@@ -21,6 +22,7 @@ enum DialogOption { ...@@ -21,6 +22,7 @@ enum DialogOption {
case .invitationCode : return UIColor.Invitation.orange case .invitationCode : return UIColor.Invitation.orange
case .invitationWelcome : return UIColor.Invitation.orange case .invitationWelcome : return UIColor.Invitation.orange
case .invitationStep : return UIColor.Invitation.orange case .invitationStep : return UIColor.Invitation.orange
case .invitationHelp : return UIColor.Invitation.orange
} }
} }
...@@ -28,7 +30,7 @@ enum DialogOption { ...@@ -28,7 +30,7 @@ enum DialogOption {
switch self { switch self {
case .postcard : return nil case .postcard : return nil
case .invitationCode : return nil case .invitationCode : return nil
case .invitationWelcome : case .invitationWelcome, .invitationHelp :
if StudySettings.invitationsmode == InvitationMode.Censorship { if StudySettings.invitationsmode == InvitationMode.Censorship {
var images = [UIImage]() var images = [UIImage]()
if let sender = UIImage(named: "bg_inviation_censor_sender"), let receiver = UIImage(named: "bg_inviation_censor_receiver") { if let sender = UIImage(named: "bg_inviation_censor_sender"), let receiver = UIImage(named: "bg_inviation_censor_receiver") {
...@@ -47,7 +49,8 @@ enum DialogOption { ...@@ -47,7 +49,8 @@ enum DialogOption {
switch self { switch self {
case .postcard : return UIImage(named: "letter") case .postcard : return UIImage(named: "letter")
case .invitationCode : return UIImage(named: "ic_secure_card") case .invitationCode : return UIImage(named: "ic_secure_card")
case .invitationWelcome : return nil case .invitationWelcome,
.invitationHelp : return nil
case .invitationStep : return UIImage(named: "ic_secure_card") case .invitationStep : return UIImage(named: "ic_secure_card")
} }
} }
...@@ -56,7 +59,8 @@ enum DialogOption { ...@@ -56,7 +59,8 @@ enum DialogOption {
switch self { switch self {
case .postcard : return "Welcome" case .postcard : return "Welcome"
case .invitationCode : return NSLocalizedString("Invitation.Code.Title", comment: "") case .invitationCode : return NSLocalizedString("Invitation.Code.Title", comment: "")
case .invitationWelcome : return NSLocalizedString("Invitation.Welcome.Title", comment: "") case .invitationWelcome,
.invitationHelp : return NSLocalizedString("Invitation.Welcome.Title", comment: "")
case .invitationStep : return NSLocalizedString("Invitation.Step.Title", comment: "") case .invitationStep : return NSLocalizedString("Invitation.Step.Title", comment: "")
} }
} }
...@@ -64,7 +68,8 @@ enum DialogOption { ...@@ -64,7 +68,8 @@ enum DialogOption {
var message: String? { var message: String? {
switch self { switch self {
case .postcard : return "Message\nMultiline and long texts are allowed, btw second button is hidden" case .postcard : return "Message\nMultiline and long texts are allowed, btw second button is hidden"
case .invitationWelcome : case .invitationWelcome,
.invitationHelp :
if StudySettings.invitationsmode == InvitationMode.Censorship{ if StudySettings.invitationsmode == InvitationMode.Censorship{
return NSLocalizedString("Invitation.Welcome.Message.Censor", comment: "") return NSLocalizedString("Invitation.Welcome.Message.Censor", comment: "")
} }
...@@ -84,6 +89,7 @@ enum DialogOption { ...@@ -84,6 +89,7 @@ enum DialogOption {
case .invitationCode : return NSLocalizedString("Invitation.Code.Share", comment: "") case .invitationCode : return NSLocalizedString("Invitation.Code.Share", comment: "")
case .invitationWelcome : return NSLocalizedString("Invitation.Welcome.Try", comment: "") case .invitationWelcome : return NSLocalizedString("Invitation.Welcome.Try", comment: "")
case .invitationStep : return NSLocalizedString("Invitation.Step.CTA", comment: "") case .invitationStep : return NSLocalizedString("Invitation.Step.CTA", comment: "")
case .invitationHelp : return NSLocalizedString("Done", comment: "")
} }
} }
...@@ -93,6 +99,7 @@ enum DialogOption { ...@@ -93,6 +99,7 @@ enum DialogOption {
case .invitationCode : return nil case .invitationCode : return nil
case .invitationWelcome : return NSLocalizedString("Invitation.Welcome.Later", comment: "") case .invitationWelcome : return NSLocalizedString("Invitation.Welcome.Later", comment: "")
case .invitationStep : return nil case .invitationStep : return nil
case .invitationHelp : return nil
} }
} }
...@@ -102,6 +109,7 @@ enum DialogOption { ...@@ -102,6 +109,7 @@ enum DialogOption {
case .invitationCode : return NSLocalizedString("Invitation.Code.Done", comment: "") case .invitationCode : return NSLocalizedString("Invitation.Code.Done", comment: "")
case .invitationWelcome : return NSLocalizedString("Invitation.Welcome.Dont.Ask", comment: "") case .invitationWelcome : return NSLocalizedString("Invitation.Welcome.Dont.Ask", comment: "")
case .invitationStep : return NSLocalizedString("Invitation.Step.Undo", comment: "") case .invitationStep : return NSLocalizedString("Invitation.Step.Undo", comment: "")
case .invitationHelp : return nil
} }
} }
} }
...@@ -192,6 +192,7 @@ extension SendViewController { ...@@ -192,6 +192,7 @@ extension SendViewController {
let controller = DialogViewController.present(on: self, with: .invitationWelcome) { [weak self] in let controller = DialogViewController.present(on: self, with: .invitationWelcome) { [weak self] in
self?.view.endEditing(true) self?.view.endEditing(true)
} }
controller?.ctaAction = { controller?.ctaAction = {
controller?.hideDialog(completion: nil) controller?.hideDialog(completion: nil)
} }
...@@ -210,6 +211,7 @@ extension SendViewController { ...@@ -210,6 +211,7 @@ extension SendViewController {
self.view.endEditing(true) self.view.endEditing(true)
InvitationUserDefaults.shouldNotShowSecondDialog.set(true) InvitationUserDefaults.shouldNotShowSecondDialog.set(true)
let controller = DialogViewController.present(on: self, with: .invitationStep) let controller = DialogViewController.present(on: self, with: .invitationStep)
controller?.ctaAction = { controller?.ctaAction = {
controller?.hideDialog(completion: nil) controller?.hideDialog(completion: nil)
} }
...@@ -219,6 +221,14 @@ extension SendViewController { ...@@ -219,6 +221,14 @@ extension SendViewController {
self?.layoutText() self?.layoutText()
} }
} }
func showHelpDialog() {
let controller = DialogViewController.present(on: self, with: .invitationHelp)
controller?.ctaAction = {
controller?.hideDialog(completion: nil)
}
}
} }
// MARK: - MarkHandler // MARK: - MarkHandler
......
...@@ -215,8 +215,7 @@ class SendViewController: UIViewController { ...@@ -215,8 +215,7 @@ class SendViewController: UIViewController {
self.ccCollectionview.reloadData() self.ccCollectionview.reloadData()
self.ccCollectionviewHeight.constant = 100 self.ccCollectionviewHeight.constant = 100
self.ccCollectionview.isHidden = false self.ccCollectionview.isHidden = false
} } else {
else {
self.ccCollectionviewHeight.constant = 1 self.ccCollectionviewHeight.constant = 1
self.ccCollectionview.isHidden = true self.ccCollectionview.isHidden = true
} }
...@@ -226,8 +225,7 @@ class SendViewController: UIViewController { ...@@ -226,8 +225,7 @@ class SendViewController: UIViewController {
self.toCollectionview.reloadData() self.toCollectionview.reloadData()
self.toCollectionviewHeight.constant = 100 self.toCollectionviewHeight.constant = 100
self.toCollectionview.isHidden = false self.toCollectionview.isHidden = false
} } else {
else {
self.toCollectionviewHeight.constant = 1 self.toCollectionviewHeight.constant = 1
self.toCollectionview.isHidden = true self.toCollectionview.isHidden = true
} }
...@@ -235,7 +233,6 @@ class SendViewController: UIViewController { ...@@ -235,7 +233,6 @@ class SendViewController: UIViewController {
self.toCollectionview.reloadData() self.toCollectionview.reloadData()
self.ccCollectionview.reloadData() self.ccCollectionview.reloadData()
} }
} }
...@@ -300,15 +297,16 @@ class SendViewController: UIViewController { ...@@ -300,15 +297,16 @@ class SendViewController: UIViewController {
} }
} }
let mail = EphemeralMail(to: NSSet.init(array: to), cc: NSSet.init(array: cc), bcc: NSSet.init(), date: Date(), subject: NSLocalizedString("inviteSubject", comment: "Subject for the invitation mail"), body: "", uid: 0, predecessor: nil) let mail = EphemeralMail(to: NSSet.init(array: to), cc: NSSet.init(array: cc), bcc: NSSet.init(), date: Date(), subject: NSLocalizedString("inviteSubject", comment: "Subject for the invitation mail"), body: "\n\nMehr Informationen unter https://userpage.fu-berlin.de/wieseoli/letterbox/", uid: 0, predecessor: nil)
controller.prefilledMail = mail controller.prefilledMail = mail
let alert = UIAlertController(title: "abc", message: "xyz", preferredStyle: .alert) //TODO: @Olli add your Text here
alert.addAction(UIAlertAction(title: "OK", style: .cancel)) // let alert = UIAlertController(title: "abc", message: "xyz", preferredStyle: .alert) //TODO: @Olli add your Text here
DispatchQueue.main.async(execute: { // alert.addAction(UIAlertAction(title: "OK", style: .cancel))
controller.present(alert, animated: true, completion: nil) // DispatchQueue.main.async(execute: {
}) // controller.present(alert, animated: true, completion: nil)
// })
} }
} }
} }
...@@ -344,8 +342,7 @@ class SendViewController: UIViewController { ...@@ -344,8 +342,7 @@ class SendViewController: UIViewController {
self.toCollectionview.reloadData() self.toCollectionview.reloadData()
self.toCollectionviewHeight.constant = 100 self.toCollectionviewHeight.constant = 100
self.toCollectionview.isHidden = false self.toCollectionview.isHidden = false
} } else {
else {
self.toCollectionviewHeight.constant = 1 self.toCollectionviewHeight.constant = 1
self.toCollectionview.isHidden = true self.toCollectionview.isHidden = true
} }
...@@ -354,8 +351,7 @@ class SendViewController: UIViewController { ...@@ -354,8 +351,7 @@ class SendViewController: UIViewController {
self.ccCollectionview.reloadData() self.ccCollectionview.reloadData()
self.ccCollectionviewHeight.constant = 100 self.ccCollectionviewHeight.constant = 100
self.ccCollectionview.isHidden = false self.ccCollectionview.isHidden = false
} } else {
else {
self.ccCollectionviewHeight.constant = 1 self.ccCollectionviewHeight.constant = 1
self.ccCollectionview.isHidden = true self.ccCollectionview.isHidden = true
} }
...@@ -452,8 +448,7 @@ class SendViewController: UIViewController { ...@@ -452,8 +448,7 @@ class SendViewController: UIViewController {
self.scrollview.setContentOffset(desiredOffset, animated: false) self.scrollview.setContentOffset(desiredOffset, animated: false)
self.view.layoutIfNeeded() self.view.layoutIfNeeded()
}, completion: nil) }, completion: nil)
} } else {
else {
var info = notification.userInfo! var info = notification.userInfo!
let keyboardFrame: CGRect = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue let keyboardFrame: CGRect = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
keyboardY = keyboardFrame.origin.y keyboardY = keyboardFrame.origin.y
...@@ -506,8 +501,7 @@ class SendViewController: UIViewController { ...@@ -506,8 +501,7 @@ class SendViewController: UIViewController {
self.additionalSafeAreaInsets.bottom = intersection.height self.additionalSafeAreaInsets.bottom = intersection.height
self.view.layoutIfNeeded() self.view.layoutIfNeeded()
}, completion: nil) }, completion: nil)
} } else {
else {
UIView.animate(withDuration: animationDuration, delay: 0, options: animationCurve, animations: { UIView.animate(withDuration: animationDuration, delay: 0, options: animationCurve, animations: {
self.scrollViewBottom.constant += self.keyboardHeight self.scrollViewBottom.constant += self.keyboardHeight
self.keyboardY = 0 self.keyboardY = 0
...@@ -639,11 +633,20 @@ class SendViewController: UIViewController { ...@@ -639,11 +633,20 @@ class SendViewController: UIViewController {
if subjectText.inputText() != NSLocalizedString("inviteSubject", comment: "") && !currentSecurityState && !UserDefaults.standard.bool(forKey: "hideFreeTextInvitation") { if subjectText.inputText() != NSLocalizedString("inviteSubject", comment: "") && !currentSecurityState && !UserDefaults.standard.bool(forKey: "hideFreeTextInvitation") {
alert.addAction(UIAlertAction(title: freeTextInviationTitle, style: .default, handler: { alert.addAction(UIAlertAction(title: freeTextInviationTitle, style: .default, handler: {
(action: UIAlertAction) -> Void in (action: UIAlertAction) -> Void in
let segue = self.freeTextInvitationCall() switch StudySettings.invitationsmode {
// Logger.queue.async(flags: .barrier) { case .InviteMail:
Logger.log(close: url, mail: nil, action: segue)
// }
self.performSegue(withIdentifier: "inviteSegue", sender: nil) self.performSegue(withIdentifier: "inviteSegue", sender: nil)
case .FreeText:
self.performSegue(withIdentifier: "inviteSegueStudy", sender: nil)
case .Censorship, .PasswordEnc:
DispatchQueue.main.async {
self.showHelpDialog()
}
}
// TODO: add logging
// let segue = self.freeTextInvitationCall()
// Logger.log(close: url, mail: nil, action: segue)
// self.performSegue(withIdentifier: "inviteSegue", sender: nil)
})) }))
} }
} else { } else {
...@@ -653,35 +656,25 @@ class SendViewController: UIViewController { ...@@ -653,35 +656,25 @@ class SendViewController: UIViewController {
if someoneWithKeyPresent { if someoneWithKeyPresent {
if sendEncryptedIfPossible { if sendEncryptedIfPossible {
alert.addAction(UIAlertAction(title: someoneWithoutKeyPresent ? NSLocalizedString("sendInsecureAll", comment: "This mail should be send insecurely to everyone, including contacts with keys") : NSLocalizedString("sendInsecure", comment: "This mail should be send insecurely"), style: .default, handler: { (action: UIAlertAction!) -> Void in alert.addAction(UIAlertAction(title: someoneWithoutKeyPresent ? NSLocalizedString("sendInsecureAll", comment: "This mail should be send insecurely to everyone, including contacts with keys") : NSLocalizedString("sendInsecure", comment: "This mail should be send insecurely"), style: .default, handler: { (action: UIAlertAction!) -> Void in
// Logger.queue.async(flags: .barrier) {
Logger.log(close: url, mail: nil, action: "sendInsecure") Logger.log(close: url, mail: nil, action: "sendInsecure")
// }
self.sendEncryptedIfPossible = false self.sendEncryptedIfPossible = false
DispatchQueue.main.async { self.animateIfNeeded() } DispatchQueue.main.async { self.animateIfNeeded() }
})) }))
} else { } else {
alert.addAction(UIAlertAction(title: someoneWithoutKeyPresent ? NSLocalizedString("sendSecureIfPossible", comment: "This mail should be send securely to people with keys") : NSLocalizedString("sendSecure", comment: "This mail should be send securely"), style: .default, handler: { (action: UIAlertAction!) -> Void in alert.addAction(UIAlertAction(title: someoneWithoutKeyPresent ? NSLocalizedString("sendSecureIfPossible", comment: "This mail should be send securely to people with keys") : NSLocalizedString("sendSecure", comment: "This mail should be send securely"), style: .default, handler: { (action: UIAlertAction!) -> Void in
// Logger.queue.async(flags: .barrier) {
Logger.log(close: url, mail: nil, action: "sendSecureIfPossible") Logger.log(close: url, mail: nil, action: "sendSecureIfPossible")
// }
self.sendEncryptedIfPossible = true self.sendEncryptedIfPossible = true
DispatchQueue.main.async { self.animateIfNeeded() } DispatchQueue.main.async { self.animateIfNeeded() }
})) }))
} }
} }
// Logger.queue.async(flags: .barrier) {
Logger.log(open: url, mail: nil) Logger.log(open: url, mail: nil)
// }
alert.addAction(UIAlertAction(title: NSLocalizedString("MoreInformation", comment: "More Information label"), style: .default, handler: { (action: UIAlertAction!) -> Void in alert.addAction(UIAlertAction(title: NSLocalizedString("MoreInformation", comment: "More Information label"), style: .default, handler: { (action: UIAlertAction!) -> Void in
// Logger.queue.async(flags: .barrier) {
Logger.log(close: url, mail: nil, action: "openURL") Logger.log(close: url, mail: nil, action: "openURL")
// }
UIApplication.shared.openURL(URL(string: url)!) UIApplication.shared.openURL(URL(string: url)!)
})) }))
alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: { (action: UIAlertAction!) -> Void in alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: { (action: UIAlertAction!) -> Void in
// Logger.queue.async(flags: .barrier) {
Logger.log(close: url, mail: nil, action: "OK") Logger.log(close: url, mail: nil, action: "OK")
// }
})) }))
DispatchQueue.main.async(execute: { DispatchQueue.main.async(execute: {
self.present(alert, animated: true, completion: nil) self.present(alert, animated: true, completion: nil)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment