@ -1,5 +1,6 @@
// C r e a t e d b y M i c h a e l K i r k o n 1 1 / 1 8 / 1 6 .
//
// C o p y r i g h t © 2 0 1 6 O p e n W h i s p e r S y s t e m s . A l l r i g h t s r e s e r v e d .
// C o p y r i g h t ( c ) 2 0 1 7 O p e n W h i s p e r S y s t e m s . A l l r i g h t s r e s e r v e d .
//
import Foundation
import Foundation
import Social
import Social
@ -31,7 +32,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
super . init ( )
super . init ( )
actionSheetController . addAction ( dismissAction ( ) )
actionSheetController . addAction ( dismissAction ( ) )
if #available ( iOS 9.0 , * ) {
if #available ( iOS 9.0 , * ) {
if let messageAction = messageAction ( ) {
if let messageAction = messageAction ( ) {
actionSheetController . addAction ( messageAction )
actionSheetController . addAction ( messageAction )
@ -72,7 +73,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
twitterViewController . add ( # imageLiteral ( resourceName : " twitter_sharing_image " ) )
twitterViewController . add ( # imageLiteral ( resourceName : " twitter_sharing_image " ) )
let tweetTitle = NSLocalizedString ( " SHARE_ACTION_TWEET " , comment : " action sheet item " )
let tweetTitle = NSLocalizedString ( " SHARE_ACTION_TWEET " , comment : " action sheet item " )
return UIAlertAction ( title : tweetTitle , style : . default ) { action in
return UIAlertAction ( title : tweetTitle , style : . default ) { _ in
Logger . debug ( " \( self . TAG ) Chose tweet " )
Logger . debug ( " \( self . TAG ) Chose tweet " )
self . presentingViewController . present ( twitterViewController , animated : true , completion : nil )
self . presentingViewController . present ( twitterViewController , animated : true , completion : nil )
@ -80,7 +81,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
}
}
func dismissAction ( ) -> UIAlertAction {
func dismissAction ( ) -> UIAlertAction {
return UIAlertAction ( title : NSLocalizedString( " DISMISS_BUTTON_TEXT " , comment : " " ) , style : . cancel )
return UIAlertAction ( title : CommonStrings. dismissButton , style : . cancel )
}
}
// MARK: C o n t a c t s P i c k e r D e l e g a t e
// MARK: C o n t a c t s P i c k e r D e l e g a t e
@ -134,10 +135,10 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
}
}
let messageTitle = NSLocalizedString ( " SHARE_ACTION_MESSAGE " , comment : " action sheet item to open native messages app " )
let messageTitle = NSLocalizedString ( " SHARE_ACTION_MESSAGE " , comment : " action sheet item to open native messages app " )
return UIAlertAction ( title : messageTitle , style : . default ) { action in
return UIAlertAction ( title : messageTitle , style : . default ) { _ in
Logger . debug ( " \( self . TAG ) Chose message. " )
Logger . debug ( " \( self . TAG ) Chose message. " )
self . channel = . message
self . channel = . message
let picker = ContactsPicker ( delegate : self , multiSelection : true , subtitleCellType : . phoneNumber )
let picker = ContactsPicker ( delegate : self , multiSelection : true , subtitleCellType : . phoneNumber )
let navigationController = UINavigationController ( rootViewController : picker )
let navigationController = UINavigationController ( rootViewController : picker )
self . presentingViewController . present ( navigationController , animated : true )
self . presentingViewController . present ( navigationController , animated : true )
}
}
@ -173,7 +174,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
switch result {
switch result {
case . failed :
case . failed :
let warning = UIAlertController ( title : nil , message : NSLocalizedString ( " SEND_INVITE_FAILURE " , comment : " Alert body after invite failed " ) , preferredStyle : . alert )
let warning = UIAlertController ( title : nil , message : NSLocalizedString ( " SEND_INVITE_FAILURE " , comment : " Alert body after invite failed " ) , preferredStyle : . alert )
warning . addAction ( UIAlertAction ( title : NSLocalizedString( " DISMISS_BUTTON_TEXT " , comment : " " ) , style : . default , handler : nil ) )
warning . addAction ( UIAlertAction ( title : CommonStrings. dismissButton , style : . default , handler : nil ) )
self . presentingViewController . present ( warning , animated : true , completion : nil )
self . presentingViewController . present ( warning , animated : true , completion : nil )
case . sent :
case . sent :
Logger . debug ( " \( self . TAG ) user successfully invited their friends via SMS. " )
Logger . debug ( " \( self . TAG ) user successfully invited their friends via SMS. " )
@ -192,7 +193,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
}
}
let mailActionTitle = NSLocalizedString ( " SHARE_ACTION_MAIL " , comment : " action sheet item to open native mail app " )
let mailActionTitle = NSLocalizedString ( " SHARE_ACTION_MAIL " , comment : " action sheet item to open native mail app " )
return UIAlertAction ( title : mailActionTitle , style : . default ) { action in
return UIAlertAction ( title : mailActionTitle , style : . default ) { _ in
Logger . debug ( " \( self . TAG ) Chose mail. " )
Logger . debug ( " \( self . TAG ) Chose mail. " )
self . channel = . mail
self . channel = . mail
@ -216,8 +217,8 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
mailComposeViewController . setMessageBody ( body , isHTML : false )
mailComposeViewController . setMessageBody ( body , isHTML : false )
self . presentingViewController . dismiss ( animated : true ) {
self . presentingViewController . dismiss ( animated : true ) {
self . presentingViewController . navigationController ? . present ( mailComposeViewController , animated : true ) {
self . presentingViewController . navigationController ? . present ( mailComposeViewController , animated : true ) {
UIUtil . applySignalAppearence ( ) ;
UIUtil . applySignalAppearence ( )
}
}
}
}
}
}
@ -230,7 +231,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
switch result {
switch result {
case . failed :
case . failed :
let warning = UIAlertController ( title : nil , message : NSLocalizedString ( " SEND_INVITE_FAILURE " , comment : " Alert body after invite failed " ) , preferredStyle : . alert )
let warning = UIAlertController ( title : nil , message : NSLocalizedString ( " SEND_INVITE_FAILURE " , comment : " Alert body after invite failed " ) , preferredStyle : . alert )
warning . addAction ( UIAlertAction ( title : NSLocalizedString( " DISMISS_BUTTON_TEXT " , comment : " " ) , style : . default , handler : nil ) )
warning . addAction ( UIAlertAction ( title : CommonStrings. dismissButton , style : . default , handler : nil ) )
self . presentingViewController . present ( warning , animated : true , completion : nil )
self . presentingViewController . present ( warning , animated : true , completion : nil )
case . sent :
case . sent :
Logger . debug ( " \( self . TAG ) user successfully invited their friends via mail. " )
Logger . debug ( " \( self . TAG ) user successfully invited their friends via mail. " )