Commit 83b36aec authored by Andreas Buff's avatar Andreas Buff
Browse files

Merge branch 'master' into 1.1.260

parents dc7114bd d55c0063
......@@ -53,4 +53,9 @@ extension Message {
public var viewableNotInlinedAttachments: [Attachment] {
return viewableAttachments().filter{ !$0.isInlined && $0.fileName != nil && !$0.isCidContained }
}
/// - returns: All the attachments that must be shown to the user
public func icsAttachments() -> [Attachment] {
return attachments.filter { $0.isICS }
}
}
......@@ -15,6 +15,7 @@ public typealias MimeTypeString = String
extension MimeTypeUtils {
public enum MimeType: String {
case defaultMimeType = "application/octet-stream"
case pgpKeys = "application/pgp-keys"
......@@ -35,6 +36,9 @@ extension MimeTypeUtils {
case csv = "text/csv"
case rtf = "text/rtf"
case ics = "text/calendar"
case appICS = "application/ics"
// Microsoft Office
case msword, dot, word, w6w = "application/msword"
case docx = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
......@@ -60,6 +64,7 @@ extension MimeTypeUtils {
case ppsm = "application/vnd.ms-powerpoint.slideshow.macroenabled.12"
case potm = "application/vnd.ms-powerpoint.template.macroenabled.12"
case mdb, accda, accdb, accde, accdr, accdt, ade, adp, adn, mde, mdf, mdn, mdt, mdw = "application/msaccess"
case wri = "application/mswrite"
......
......@@ -54,7 +54,9 @@ public class MimeTypeUtils {
MimeType.pgp.rawValue,
MimeType.pEpSync.rawValue,
MimeType.pEpSign.rawValue,
MimeType.pEpDistribution.rawValue])
MimeType.pEpDistribution.rawValue,
MimeType.ics.rawValue,
MimeType.appICS.rawValue])
}
/**
......
......@@ -38,6 +38,11 @@ extension Attachment {
return mimeType == "text/plain" && isInlined
}
/// Indicates if it's a calendar attachment
var isICS: Bool {
return mimeType == MimeTypeUtils.MimeType.ics.rawValue
}
/// Indicates if the attachment is Cid contained.
public var isCidContained: Bool {
var cidContained = false
......
......@@ -311,7 +311,6 @@
434C1A8025D40B0400F622DB /* SplitViewHandlingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7B0E8F224094BB1003A34DC /* SplitViewHandlingProtocol.swift */; };
434C1A8325D40B4000F622DB /* PEPSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00D3CD3D20B58976009ABBC9 /* PEPSplitViewController.swift */; };
434C1A8625D40B6E00F622DB /* UIStoryboard+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 437E9BA8237AFB7F00E9A847 /* UIStoryboard+Constants.swift */; };
434C1A8925D40BEA00F622DB /* UIUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 150B8EB21FCEB93D00374438 /* UIUtils.swift */; };
434C1A9125D40CEC00F622DB /* UIUtils+ShowError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 434C1A9025D40CEC00F622DB /* UIUtils+ShowError.swift */; };
434C1A9625D40D6500F622DB /* UIUtils+ActionSheets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1521B792241BDD33000EAE57 /* UIUtils+ActionSheets.swift */; };
434C1A9925D40DB700F622DB /* Mailto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B4A7189252CC4A500436FCF /* Mailto.swift */; };
......@@ -472,6 +471,7 @@
5B41C6082418F15100C268CE /* TutorialStep3iPhoneViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B41C6072418F15100C268CE /* TutorialStep3iPhoneViewController.swift */; };
5B41F9CF25CD517700E55EDF /* MockAppSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B41F9CE25CD517700E55EDF /* MockAppSettings.swift */; };
5B4A718A252CC4A500436FCF /* Mailto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B4A7189252CC4A500436FCF /* Mailto.swift */; };
5B5BBC2B26A8240500430F73 /* UIUtils+CalendarEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5BBC2A26A8240500430F73 /* UIUtils+CalendarEvents.swift */; };
5B5C2A8825D28CDB00F9C18A /* UIPopoverPresentationControllerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5C2A8725D28CDB00F9C18A /* UIPopoverPresentationControllerProtocol.swift */; };
5B5C2A9225D2902C00F9C18A /* MessageAttachmentCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5C2A9125D2902C00F9C18A /* MessageAttachmentCell.swift */; };
5B5C2A9C25D2918800F9C18A /* AttachmentCellBackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5C2A9B25D2918800F9C18A /* AttachmentCellBackgroundView.swift */; };
......@@ -482,6 +482,7 @@
5B71016E243619CF00BAE405 /* TrustedServerSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B71016D243619CF00BAE405 /* TrustedServerSettingsViewController.swift */; };
5B7235D125E0013100033F88 /* TutorialStep0iPadViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B7235D025E0013100033F88 /* TutorialStep0iPadViewController.swift */; };
5B74C00D249B7EA300802704 /* FolderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B74C00C249B7EA300802704 /* FolderTableViewCell.swift */; };
5B75F8F426D4FB5D0097B6D5 /* UIUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 150B8EB21FCEB93D00374438 /* UIUtils.swift */; };
5B818DC325E3FEC2004D04F0 /* TutorialStep1iPadViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B818DC225E3FEC2004D04F0 /* TutorialStep1iPadViewController.swift */; };
5B884B44257A90FE006B2022 /* EditableAccountSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B884B43257A90FE006B2022 /* EditableAccountSettingsViewController.swift */; };
5B885DB225E7B0350027DD24 /* Tutorial_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5B885DB425E7B0350027DD24 /* Tutorial_iPad.storyboard */; };
......@@ -503,6 +504,9 @@
5BBE80CF24B733C0008DE0E5 /* AccountSettingsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BBE80CA24B733C0008DE0E5 /* AccountSettingsTableViewCell.swift */; };
5BBEA012252F062300B34979 /* ComposeViewModel+Factory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BBEA011252F062300B34979 /* ComposeViewModel+Factory.swift */; };
5BC0738D25B218DB00ECE3FC /* TextFieldWithoutSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC0738C25B218DB00ECE3FC /* TextFieldWithoutSelection.swift */; };
5BC0F93826A9953D0089760D /* UIUtils+SystemSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC0F93726A9953D0089760D /* UIUtils+SystemSettings.swift */; };
5BC0F94D26AAAB640089760D /* CalendarEventDescriptionTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC0F94C26AAAB640089760D /* CalendarEventDescriptionTableViewCell.swift */; };
5BC0F96726AEE8ED0089760D /* EdgeInsetLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC0F96626AEE8ED0089760D /* EdgeInsetLabel.swift */; };
5BC14ABF23E2EE78005F0AF3 /* TrustManagementViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC14ABE23E2EE78005F0AF3 /* TrustManagementViewModel.swift */; };
5BC14AC923E47A55005F0AF3 /* TrustManagementViewModelTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC14AC823E47A55005F0AF3 /* TrustManagementViewModelTest.swift */; };
5BC14AF023EB19B5005F0AF3 /* TrustManagementViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC14AEF23EB19B5005F0AF3 /* TrustManagementViewController.swift */; };
......@@ -511,6 +515,11 @@
5BC8C72325ADDAF1000AAC7A /* TwoLinesButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC8C72225ADDAF1000AAC7A /* TwoLinesButton.swift */; };
5BC9F1E226385974002377B6 /* EmailViewModel+CollectionViewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC9F1E126385974002377B6 /* EmailViewModel+CollectionViewViewModel.swift */; };
5BC9F1E6263888C3002377B6 /* Message+Recipients.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC9F1E5263888C3002377B6 /* Message+Recipients.swift */; };
5BCD37A2269D924C0052A030 /* EKEventStoreUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCD37A1269D924C0052A030 /* EKEventStoreUtil.swift */; };
5BCD37C0269EE9C00052A030 /* CalendarEventBannerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCD37BF269EE9C00052A030 /* CalendarEventBannerViewController.swift */; };
5BCD37C3269EFA5C0052A030 /* CalendarEventBannerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCD37C2269EFA5C0052A030 /* CalendarEventBannerViewModel.swift */; };
5BCD37D2269F236D0052A030 /* CornerRadiusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCD37D1269F236D0052A030 /* CornerRadiusView.swift */; };
5BCD37D3269F236D0052A030 /* CornerRadiusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCD37D1269F236D0052A030 /* CornerRadiusView.swift */; };
5BCD37DC269F3CBF0052A030 /* UIImageView+ContactImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCD37DB269F3CBF0052A030 /* UIImageView+ContactImage.swift */; };
5BCD37DD269F3CBF0052A030 /* UIImageView+ContactImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCD37DB269F3CBF0052A030 /* UIImageView+ContactImage.swift */; };
5BCFE663252470F4001323C3 /* ComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCFE662252470F4001323C3 /* ComposeViewController.swift */; };
......@@ -1115,6 +1124,7 @@
5B41C6072418F15100C268CE /* TutorialStep3iPhoneViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TutorialStep3iPhoneViewController.swift; sourceTree = "<group>"; };
5B41F9CE25CD517700E55EDF /* MockAppSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAppSettings.swift; sourceTree = "<group>"; };
5B4A7189252CC4A500436FCF /* Mailto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Mailto.swift; sourceTree = "<group>"; };
5B5BBC2A26A8240500430F73 /* UIUtils+CalendarEvents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIUtils+CalendarEvents.swift"; sourceTree = "<group>"; };
5B5C2A8725D28CDB00F9C18A /* UIPopoverPresentationControllerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIPopoverPresentationControllerProtocol.swift; sourceTree = "<group>"; };
5B5C2A9125D2902C00F9C18A /* MessageAttachmentCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageAttachmentCell.swift; sourceTree = "<group>"; };
5B5C2A9B25D2918800F9C18A /* AttachmentCellBackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttachmentCellBackgroundView.swift; sourceTree = "<group>"; };
......@@ -1152,6 +1162,9 @@
5BBE80CA24B733C0008DE0E5 /* AccountSettingsTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AccountSettingsTableViewCell.swift; path = pEpForiOS/UI/Settings/Setting/AccountSettings/Cells/AccountSettingsTableViewCell.swift; sourceTree = SOURCE_ROOT; };
5BBEA011252F062300B34979 /* ComposeViewModel+Factory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ComposeViewModel+Factory.swift"; sourceTree = "<group>"; };
5BC0738C25B218DB00ECE3FC /* TextFieldWithoutSelection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldWithoutSelection.swift; sourceTree = "<group>"; };
5BC0F93726A9953D0089760D /* UIUtils+SystemSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIUtils+SystemSettings.swift"; sourceTree = "<group>"; };
5BC0F94C26AAAB640089760D /* CalendarEventDescriptionTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarEventDescriptionTableViewCell.swift; sourceTree = "<group>"; };
5BC0F96626AEE8ED0089760D /* EdgeInsetLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EdgeInsetLabel.swift; sourceTree = "<group>"; };
5BC14ABE23E2EE78005F0AF3 /* TrustManagementViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustManagementViewModel.swift; sourceTree = "<group>"; };
5BC14AC823E47A55005F0AF3 /* TrustManagementViewModelTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustManagementViewModelTest.swift; sourceTree = "<group>"; };
5BC14AEF23EB19B5005F0AF3 /* TrustManagementViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustManagementViewController.swift; sourceTree = "<group>"; };
......@@ -1160,6 +1173,10 @@
5BC8C72225ADDAF1000AAC7A /* TwoLinesButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoLinesButton.swift; sourceTree = "<group>"; };
5BC9F1E126385974002377B6 /* EmailViewModel+CollectionViewViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EmailViewModel+CollectionViewViewModel.swift"; sourceTree = "<group>"; };
5BC9F1E5263888C3002377B6 /* Message+Recipients.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Message+Recipients.swift"; sourceTree = "<group>"; };
5BCD37A1269D924C0052A030 /* EKEventStoreUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EKEventStoreUtil.swift; sourceTree = "<group>"; };
5BCD37BF269EE9C00052A030 /* CalendarEventBannerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarEventBannerViewController.swift; sourceTree = "<group>"; };
5BCD37C2269EFA5C0052A030 /* CalendarEventBannerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarEventBannerViewModel.swift; sourceTree = "<group>"; };
5BCD37D1269F236D0052A030 /* CornerRadiusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerRadiusView.swift; sourceTree = "<group>"; };
5BCD37DB269F3CBF0052A030 /* UIImageView+ContactImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageView+ContactImage.swift"; sourceTree = "<group>"; };
5BCFE662252470F4001323C3 /* ComposeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeViewController.swift; sourceTree = "<group>"; };
5BD4465F24F65DE300422594 /* EmailListViewController+Keyboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "EmailListViewController+Keyboard.swift"; sourceTree = "<group>"; };
......@@ -1379,6 +1396,9 @@
children = (
15F136F224B6293C00A7F810 /* UserInputProvider */,
150B8EB21FCEB93D00374438 /* UIUtils.swift */,
5BC0F93726A9953D0089760D /* UIUtils+SystemSettings.swift */,
5B5BBC2A26A8240500430F73 /* UIUtils+CalendarEvents.swift */,
5BCD37A1269D924C0052A030 /* EKEventStoreUtil.swift */,
434C1A9025D40CEC00F622DB /* UIUtils+ShowError.swift */,
1521B790241BDCD9000EAE57 /* UIUtils+Alerts.swift */,
5B0B339C24AC85E800CABD0B /* UIUtils+Passphrase.swift */,
......@@ -2340,8 +2360,9 @@
43AA82511E9B925000ABD5A8 /* Util */ = {
isa = PBXGroup;
children = (
5BC0738C25B218DB00ECE3FC /* TextFieldWithoutSelection.swift */,
5BB7C74824D85BD600D5F328 /* PEPWebviewController */,
5BC0738C25B218DB00ECE3FC /* TextFieldWithoutSelection.swift */,
5BC0F96626AEE8ED0089760D /* EdgeInsetLabel.swift */,
1521B78B241BDA66000EAE57 /* UIUtils */,
B7DB7FC22215C484003968DA /* Extensions */,
15D43998216E695500EB3933 /* AccountPicker */,
......@@ -2438,6 +2459,7 @@
43ED53611CC77F95006AB156 /* UI */ = {
isa = PBXGroup;
children = (
5BCD37C1269EE9DD0052A030 /* CalendarEventBanner */,
B706C0EF1EA8C378006B2F6C /* StoryboardFiles */,
158A564E2403F00A003C0D7E /* ClientCertificateManagement */,
15146C8F237F030A00D69495 /* BaseClasses */,
......@@ -2644,6 +2666,17 @@
path = PEPWebviewController;
sourceTree = "<group>";
};
5BCD37C1269EE9DD0052A030 /* CalendarEventBanner */ = {
isa = PBXGroup;
children = (
5BCD37BF269EE9C00052A030 /* CalendarEventBannerViewController.swift */,
5BC0F94C26AAAB640089760D /* CalendarEventDescriptionTableViewCell.swift */,
5BCD37C2269EFA5C0052A030 /* CalendarEventBannerViewModel.swift */,
5BCD37D1269F236D0052A030 /* CornerRadiusView.swift */,
);
path = CalendarEventBanner;
sourceTree = "<group>";
};
5BE35AA5249219AD00AC605C /* Cells */ = {
isa = PBXGroup;
children = (
......@@ -3188,6 +3221,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5BCD37D3269F236D0052A030 /* CornerRadiusView.swift in Sources */,
434C19E325D3E3F700F622DB /* ComposeUtil.swift in Sources */,
43BDE03F25DE7D1A00FC0C68 /* node.c in Sources */,
434C1A9625D40D6500F622DB /* UIUtils+ActionSheets.swift in Sources */,
......@@ -3238,7 +3272,6 @@
434A6C7925D2A3EE00179335 /* WrappedCell.swift in Sources */,
43BDE03C25DE7D0E00FC0C68 /* blocks.c in Sources */,
434A6C5625D2A3B100179335 /* AccountCellViewModel.swift in Sources */,
434C1A8925D40BEA00F622DB /* UIUtils.swift in Sources */,
434C1B0825D4290700F622DB /* URL+Extensions.swift in Sources */,
434C19B725D3DC8C00F622DB /* NSAttributedString+pEp.swift in Sources */,
434C1B4025D433D600F622DB /* HtmlTagParser.swift in Sources */,
......@@ -3275,6 +3308,7 @@
434C19DD25D3E35E00F622DB /* SuggestViewModel.swift in Sources */,
434C1A3D25D400D500F622DB /* Constants.swift in Sources */,
4375B2EC2625855A0049A0C0 /* KeyInputView.swift in Sources */,
5B75F8F426D4FB5D0097B6D5 /* UIUtils.swift in Sources */,
43BDE04525DE7F0800FC0C68 /* houdini_href_e.c in Sources */,
434A6C5925D2A3B500179335 /* AttachmentCell.swift in Sources */,
434C19C425D3E09C00F622DB /* String+PEPSignature.swift in Sources */,
......@@ -3327,6 +3361,7 @@
4351C2D11F4441190053381F /* houdini_html_u.c in Sources */,
B70A3C401E817CFA0036876F /* FolderViewModel.swift in Sources */,
0038494A20D25576008000EA /* ProfilePictureComposerProtocol.swift in Sources */,
5BCD37C0269EE9C00052A030 /* CalendarEventBannerViewController.swift in Sources */,
1543B6A822ABDAAE002B59AB /* Identity+pEp.swift in Sources */,
1546CBF6252B53CC00A7AA7D /* CreditsWebViewController.swift in Sources */,
152A39D821905C3E00D9F8E4 /* BodyCellViewModel.swift in Sources */,
......@@ -3344,6 +3379,7 @@
150DF6D02052A13700A9DCF7 /* SecureWebViewController.swift in Sources */,
375BA08A238BFC4100BBFE7C /* ManualAccountSetupContainerView.swift in Sources */,
B764D0222451A21E001C4BCA /* ErrorSubscriber.swift in Sources */,
5BC0F93826A9953D0089760D /* UIUtils+SystemSettings.swift in Sources */,
4351C2D71F4441190053381F /* node.c in Sources */,
434C1AA625D40F3B00F622DB /* UIUtils+DraftsPreview.swift in Sources */,
154660D42334E2FC008D2137 /* Message+SecurityBadge.swift in Sources */,
......@@ -3360,6 +3396,7 @@
43498CDB200CF20F006DC947 /* LoginViewModelLoginErrorDelegate.swift in Sources */,
B7DB7FDA221ADDAF003968DA /* UIBarButtonItem+Extension.swift in Sources */,
002375D320DCDC7300663961 /* FullMessageCell+SecureWebViewControllerDelegate.swift in Sources */,
5BC0F94D26AAAB640089760D /* CalendarEventDescriptionTableViewCell.swift in Sources */,
4351C2C91F4441190053381F /* buffer.c in Sources */,
152A39C621905C3E00D9F8E4 /* ComposeViewModelState.swift in Sources */,
5BB7C73B24D2EC6300D5F328 /* UnifiedInbox.swift in Sources */,
......@@ -3410,6 +3447,7 @@
3A2119E1241251A80030C3E4 /* ClientCertificateManagementTableViewCell.swift in Sources */,
B716056020D3ECC900A733D6 /* MoveToFolderTableViewController.swift in Sources */,
5BCFE663252470F4001323C3 /* ComposeViewController.swift in Sources */,
5BCD37C3269EFA5C0052A030 /* CalendarEventBannerViewModel.swift in Sources */,
43269D202552AA04001E18C6 /* ConnectionTransport+LocalizedString.swift in Sources */,
1543B6B022ABF53C002B59AB /* KeySyncDeviceGroupUtil.swift in Sources */,
15874BCB2127493E00A3A4A6 /* AccountVerificationResultDelegate.swift in Sources */,
......@@ -3476,6 +3514,7 @@
4351C2C81F4441190053381F /* blocks.c in Sources */,
5B102FAD2652AF3400A758D2 /* MessageHeaderCellViewModel.swift in Sources */,
5BEB569225E69BEE00304A38 /* TutorialStep2iPadViewController.swift in Sources */,
5BC0F96726AEE8ED0089760D /* EdgeInsetLabel.swift in Sources */,
3A796BAB242CC31F00083BB5 /* NSAttributedString+Html.swift in Sources */,
3A796BA9242CC26100083BB5 /* HtmlConversions.swift in Sources */,
15BBBC6C1FD05F4300B9DCC8 /* DisplayUserError.swift in Sources */,
......@@ -3511,6 +3550,7 @@
5B5C2A9F25D293F300F9C18A /* EmailViewModel.swift in Sources */,
433E7438225B564400B84CD9 /* Account+Extension.swift in Sources */,
005A21FB20CAA5F50082D19F /* ThreadedEmailViewModel.swift in Sources */,
5B5BBC2B26A8240500430F73 /* UIUtils+CalendarEvents.swift in Sources */,
1546CBFA252B5B9F00A7AA7D /* CreditsViewModel.swift in Sources */,
5B818DC325E3FEC2004D04F0 /* TutorialStep1iPadViewController.swift in Sources */,
3A085A6E23FAF4D50013C63E /* PEPHeaderView.swift in Sources */,
......@@ -3525,6 +3565,7 @@
37156E4E234DCE2B00845A28 /* UIViewController+LoadingInterface.swift in Sources */,
15874BC72127493E00A3A4A6 /* SettingDefaultAccountTableViewController.swift in Sources */,
4388A0E22008F813008CB98D /* (null) in Sources */,
5BCD37D2269F236D0052A030 /* CornerRadiusView.swift in Sources */,
152A39D021905C3E00D9F8E4 /* AttachmentCell.swift in Sources */,
0033C08120D7F3C600224E61 /* ThreadViewController+ViewModelDelegate.swift in Sources */,
4351C2DB1F4441190053381F /* utf8.c in Sources */,
......@@ -3611,6 +3652,7 @@
3705096822CF6AD100CB73D6 /* KeySyncHandshakeViewController.swift in Sources */,
152A39CF21905C3E00D9F8E4 /* ComposeUtil.swift in Sources */,
152A39C821905C3E00D9F8E4 /* ComposeViewModel+InitData.swift in Sources */,
5BCD37A2269D924C0052A030 /* EKEventStoreUtil.swift in Sources */,
0038494C20D2587F008000EA /* PepPictureComposer.swift in Sources */,
5BB7C73724D2EC0800D5F328 /* UnifiedDraft.swift in Sources */,
4356FFE721354A4B00804089 /* ReplyAllPossibleCheckerProtocol.swift in Sources */,
......
This diff is collapsed.
......@@ -91,6 +91,8 @@
<string>Enables you to save photos to the Photo Gallery</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Enables you to pick photos from the Photo Gallery</string>
<key>NSCalendarsUsageDescription</key>
<string>Enables you to add events to your calendar</string>
<key>OAUTH2_GMAIL_CLIENT_ID</key>
<string>${OAUTH2_GMAIL_CLIENT_ID}</string>
<key>OAUTH2_GMAIL_REDIRECT_URL_SCHEME</key>
......
{
"images" : [
{
"filename" : "calendar-close-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.361",
"green" : "0.345",
"red" : "0.345"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.361",
"green" : "0.345",
"red" : "0.345"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
//
// CalendarEventBannerViewController.swift
// pEp
//
// Created by Martín Brude on 14/7/21.
// Copyright © 2021 p≡p Security S.A. All rights reserved.
//
import UIKit
import pEpIOSToolbox
import EventKit
import EventKitUI
class CalendarEventBannerViewController: UIViewController {
@IBOutlet private weak var tableView: UITableView!
@IBOutlet private weak var dayOfTheWeekLabel: UILabel!
@IBOutlet private weak var dayNumberLabel: UILabel!
@IBOutlet private weak var titleLabel: UILabel!
public var viewModel: CalendarEventsBannerViewModel?
override func viewDidLoad() {
super.viewDidLoad()
setup()
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
calculatePreferredSize()
}
}
// MARK: - UITableViewDataSource
extension CalendarEventBannerViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard let vm = viewModel else {
// Valid case: The storyboard intanciates the VC before we have the chance to set a VM.
return 0
}
return vm.numberOfEvents
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let vm = viewModel else {
Log.shared.errorAndCrash("VM not found")
return UITableViewCell()
}
guard let cell = tableView.dequeueReusableCell(withIdentifier: CalendarEventDescriptionTableViewCell.cellIdentifier, for: indexPath) as? CalendarEventDescriptionTableViewCell else {
return UITableViewCell()
}
let event = vm.events[indexPath.row]
let cellViewModel = ICSEventCellViewModel(event: event)
cell.config(cellViewModel: cellViewModel, delegate: self)
return cell
}
}
extension CalendarEventBannerViewController: EKEventEditViewDelegate {
func eventEditViewController(_ controller: EKEventEditViewController, didCompleteWith action: EKEventEditViewAction) {
controller.dismiss(animated: true, completion: nil)
}
}
// MARK: - Cell Delegate
extension CalendarEventBannerViewController: CalendarEventDescriptionTableViewCellDelegate {
func didPressViewButton(event: ICSEvent) {
UIUtils.presentEditEventCalendarView(event: event, eventEditViewDelegate: self, delegate: self) { [weak self] eventDetailPresentationResult in
guard let me = self else {
Log.shared.errorAndCrash("Lost myself")
return
}
switch eventDetailPresentationResult {
case .success:
Log.shared.info("The calendar view was succesfully presented. Nothing to do")
case .failure(let error):
me.showErrorAlert(error: error)
}
} addEventCallback: { [weak self] addEventResult in
guard let me = self else {
Log.shared.errorAndCrash("Lost myself")
return
}
switch addEventResult {
case .success:
Log.shared.info("An Event was successfully added. Nothing to do")
case .failure(let error):
me.showErrorAlert(error: error)
}
}
}
}
// MARK: - Trait Collection
extension CalendarEventBannerViewController {
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
guard let thePreviousTraitCollection = previousTraitCollection else {
// Valid case: optional value from Apple.
return
}
if #available(iOS 13.0, *) {
if thePreviousTraitCollection.hasDifferentColorAppearance(comparedTo: traitCollection) {
setup()
view.layoutIfNeeded()
}
}
}
}
// MARK: - UINavigationControllerDelegate
extension CalendarEventBannerViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
/// EKEventEditViewController contains a table view that behaves buggy when scrolling.
/// The background color of the cells that are dequeued again changes for no reason.
/// This workaround prevents a wrong layout.
if let tableViewController = viewController as? UITableViewController {
if #available(iOS 13.0, *) {
if UITraitCollection.current.userInterfaceStyle == .light {
tableViewController.view.backgroundColor = UIColor.white
tableViewController.tableView.backgroundColor = UIColor.white
} else {
tableViewController.view.backgroundColor = UIColor.secondarySystemBackground
tableViewController.tableView.backgroundColor = UIColor.secondarySystemBackground
}
} else {
tableViewController.view.backgroundColor = UIColor.white
tableViewController.tableView.backgroundColor = UIColor.white
}
tableViewController.tableView.backgroundView = .none
}
}
}
//MARK: - Private
extension CalendarEventBannerViewController {
private func setup() {
if #available(iOS 13.0, *) {
if UITraitCollection.current.userInterfaceStyle == .dark {
view.backgroundColor = UIColor.pEpBackgroundGray2
titleLabel.textColor = .white
} else {
view.backgroundColor = UIColor.black
}
} else {
view.backgroundColor = UIColor.black
}
guard let vm = viewModel, vm.numberOfEvents > 0 else {
//Valid case. The view won't be visible.
return
}
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 12
titleLabel.text = vm.title
dayNumberLabel.text = vm.dayNumber
dayOfTheWeekLabel.text = vm.dayOfTheWeekLabel
tableView.reloadData()
}
@IBAction private func closeButtonTapped() {
guard let vm = viewModel else {
Log.shared.errorAndCrash("VM not found")
return
}
vm.handleCloseButtonTapped()
}
private func calculatePreferredSize() {
/// Expected banner height
guard let vm = viewModel else {
//Valid case: VM isn't setup yet.
return
}
let margin: CGFloat = vm.numberOfEvents > 1 ? 0.0 : 8.0
let height = tableView.contentSize.height + titleLabel.frame.size.height + titleLabel.frame.origin.y + margin
preferredContentSize = CGSize(width: view.bounds.width, height: height)
}
private func showErrorAlert(error: EKEventStoreUtil.CalendarError) {
UIUtils.showTwoButtonAlert(withTitle: NSLocalizedString("Error", comment: "Error title"),
message: error.errorDescription,
cancelButtonText: NSLocalizedString("Cancel", comment: "Cancel - button title"),
positiveButtonText: NSLocalizedString("Settings", comment: "Settings - button title"),
cancelButtonAction: { [weak self] in
guard let me = self else {
Log.shared.errorAndCrash("Lost myself")
return
}
me.showSettings()
}, positiveButtonAction: { })
}
private func showSettings() {
UIUtils.openSystemSettings()
}
}
//
// CalendarEventBannerViewModel.swift
// pEp
//
// Created by Martín Brude on 14/7/21.
// Copyright © 2021 p≡p Security S.A. All rights reserved.
//
import UIKit
import MessageModel
import pEpIOSToolbox