Add button and sms sending code.

This commit is contained in:
Benjamin Verdier 2018-07-23 17:06:26 +02:00
parent 9d1afa7cee
commit cefb35d792
6 changed files with 65 additions and 32 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
@ -18,6 +18,7 @@
<outlet property="deleteButton" destination="C2f-aP-xjR" id="sxr-th-6rq"/>
<outlet property="editTextfield" destination="dTn-Hc-bGM" id="bkN-xg-S9D"/>
<outlet property="editView" destination="rAa-qu-PDc" id="cGz-D2-GiI"/>
<outlet property="inviteButton" destination="lgb-5W-T0c" id="iOl-Fl-AXH"/>
<outlet property="linphoneImage" destination="ZaI-29-AOK" id="dY1-vO-spk"/>
</connections>
</placeholder>
@ -95,6 +96,14 @@
<rect key="frame" x="342" y="51" width="25" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="lgb-5W-T0c">
<rect key="frame" x="288" y="48" width="46" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<connections>
<action selector="onSMSInviteClick:" destination="-1" eventType="touchUpInside" id="E8o-h2-mml"/>
</connections>
</button>
</subviews>
</view>
</subviews>

View file

@ -18,6 +18,7 @@
*/
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import "UIIconButton.h"
@ -36,6 +37,7 @@
@property(weak, nonatomic) IBOutlet UIIconButton *chatButton;
@property (weak, nonatomic) IBOutlet UIImageView *linphoneImage;
@property (weak, nonatomic) UIView *waitView;
@property (strong, nonatomic) IBOutlet UIButton *inviteButton;
- (id)initWithIdentifier:(NSString *)identifier;
- (void)setAddress:(NSString *)address;
@ -45,4 +47,5 @@
- (IBAction)onCallClick:(id)sender;
- (IBAction)onChatClick:(id)sender;
- (IBAction)onDeleteClick:(id)sender;
- (IBAction)onSMSInviteClick:(id)sender;
@end

View file

@ -61,13 +61,13 @@
_linphoneImage.hidden = TRUE;
if (contact) {
self.linphoneImage.hidden =
self.inviteButton.hidden = !(self.linphoneImage.hidden =
!((contact.friend &&
linphone_presence_model_get_basic_status(linphone_friend_get_presence_model_for_uri_or_tel(
contact.friend, _addressLabel.text.UTF8String)) == LinphonePresenceBasicStatusOpen) ||
(!linphone_proxy_config_is_phone_number(linphone_core_get_default_proxy_config(LC),
_addressLabel.text.UTF8String) &&
[FastAddressBook isSipURIValid:_addressLabel.text]));
[FastAddressBook isSipURIValid:_addressLabel.text])));
}
if (addr) {
@ -147,4 +147,17 @@
forRowAtIndexPath:indexPath];
}
#pragma mark - SMS invite
- (IBAction)onSMSInviteClick:(id)sender {
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText]) {
controller.body = NSLocalizedString(@"Hello! Join me on Linphone! You can download it at: http://www.linphone.org/technical-corner/linphone/downloads",nil);
controller.recipients = [NSArray arrayWithObjects:[self.addressLabel text], nil];
controller.messageComposeDelegate = PhoneMainView.instance;
[PhoneMainView.instance presentViewController:controller animated:YES completion:nil];
}
}
@end

View file

@ -18,6 +18,7 @@
*/
#import <MediaPlayer/MediaPlayer.h>
#import <MessageUI/MessageUI.h>
/* These imports are here so that we can import PhoneMainView.h without bothering to import all the rest of the view headers */
#import "StatusBarView.h"
@ -74,7 +75,7 @@
@end
@interface PhoneMainView : UIViewController<IncomingCallViewDelegate> {
@interface PhoneMainView : UIViewController<IncomingCallViewDelegate, MFMessageComposeViewControllerDelegate> {
@private
NSMutableArray *inhibitedEvents;
}
@ -104,6 +105,7 @@
- (void)startUp;
- (void)displayIncomingCall:(LinphoneCall*) call;
- (void)setVolumeHidden:(BOOL)hidden;
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result;
- (void)addInhibitedEvent:(id)event;
- (BOOL)removeInhibitedEvent:(id)event;

View file

@ -977,4 +977,10 @@ void main_view_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomSta
}
}
#pragma mark - SMS invite callback
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
[controller dismissModalViewControllerAnimated:YES];
}
@end

View file

@ -2036,6 +2036,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D37DC7181594AF3400B2A5EB /* MessageUI.framework in Frameworks */,
61F1997520C6B1D5006B069A /* AVKit.framework in Frameworks */,
249660951FD6A35F001D55AA /* Photos.framework in Frameworks */,
24E1C7C01F9A235600D3F981 /* Contacts.framework in Frameworks */,
@ -2066,7 +2067,6 @@
22276E8913C73DC000210156 /* CoreMedia.framework in Frameworks */,
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
F0B89C2218DC89E30050B60E /* MediaPlayer.framework in Frameworks */,
D37DC7181594AF3400B2A5EB /* MessageUI.framework in Frameworks */,
226EF06C15FA256B005865C7 /* MobileCoreServices.framework in Frameworks */,
8C3EA9F01EB8A78C00B732B6 /* msx264.framework in Frameworks */,
70E542F313E147E3002BA2C0 /* OpenGLES.framework in Frameworks */,
@ -2464,39 +2464,20 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
61F1996E20C6B1D5006B069A /* AVKit.framework */,
8C435FA520BC34DA004CCA25 /* belr.framework */,
8C435F8B20BBF862004CCA25 /* belcard.framework */,
8C601FD220B462B0004FF95C /* mediastreamer2.framework */,
8C1A1F7C1FA331D40064BE00 /* libsoci_sqlite3.a */,
8CD0B3BE1FA22CBA008FEB16 /* libsoci_core.a */,
249660941FD6A359001D55AA /* Photos.framework */,
24E1C7B91F9A235500D3F981 /* Contacts.framework */,
8C3EAA191EB8D9C300B732B6 /* linphonetester.framework */,
8C5BCEC61EB3859200A9AAEF /* bctoolbox-tester.framework */,
8C3EA9EF1EB8A78C00B732B6 /* msx264.framework */,
8C3EA9E01EB892D600B732B6 /* msamr.framework */,
8C3EA9E11EB892D600B732B6 /* mscodec2.framework */,
8C3EA9E21EB892D600B732B6 /* msopenh264.framework */,
8C5BCEC71EB3859200A9AAEF /* bctoolbox.framework */,
8C5BCEC81EB3859200A9AAEF /* linphone.framework */,
8C5BCEC91EB3859200A9AAEF /* mediastreamer_base.framework */,
8C5BCECA1EB3859200A9AAEF /* mediastreamer_voip.framework */,
8C5BCECB1EB3859200A9AAEF /* mssilk.framework */,
8C5BCECC1EB3859200A9AAEF /* mswebrtc.framework */,
8C5BCECD1EB3859200A9AAEF /* ortp.framework */,
8C2595DE1DEDCC8E007A6424 /* CallKit.framework */,
8C73477B1D9BA3A00022EE8C /* UserNotifications.framework */,
8CA2004B1D8158440095F859 /* PushKit.framework */,
570742661D5A63DB004B9C84 /* StoreKit.framework */,
63CE583F1C85EBF400304800 /* VideoToolbox.framework */,
22B5F03410CE6B2F00777D97 /* AddressBook.framework */,
22B5EFA210CE50BD00777D97 /* AddressBookUI.framework */,
22405EED1600B4E400B92522 /* AssetsLibrary.framework */,
2274402E106F335E006EC466 /* AudioToolbox.framework */,
F0BB8C311936246600974404 /* AudioUnit.framework */,
224567C1107B968500F10948 /* AVFoundation.framework */,
61F1996E20C6B1D5006B069A /* AVKit.framework */,
8C5BCEC61EB3859200A9AAEF /* bctoolbox-tester.framework */,
8C5BCEC71EB3859200A9AAEF /* bctoolbox.framework */,
8C435F8B20BBF862004CCA25 /* belcard.framework */,
8C435FA520BC34DA004CCA25 /* belr.framework */,
8C2595DE1DEDCC8E007A6424 /* CallKit.framework */,
228697C311AC29B800E9E0CA /* CFNetwork.framework */,
24E1C7B91F9A235500D3F981 /* Contacts.framework */,
22744019106F31BD006EC466 /* CoreAudio.framework */,
22744056106F9BC9006EC466 /* CoreFoundation.framework */,
288765FC0DF74451002DB57D /* CoreGraphics.framework */,
@ -2512,6 +2493,8 @@
63EEE40D1BBA9B250087D3AF /* libiconv.tbd */,
F0BB8C34193624C800974404 /* libresolv.9.dylib */,
22D1B68012A3E0BE001AE361 /* libresolv.dylib */,
8CD0B3BE1FA22CBA008FEB16 /* libsoci_core.a */,
8C1A1F7C1FA331D40064BE00 /* libsoci_sqlite3.a */,
D32B6E2E15A5C0AC0033019F /* libsqlite3.dylib */,
63EEE40B1BBA9B1B0087D3AF /* libsqlite3.tbd */,
344ABDF014850AE9007420B6 /* libstdc++.6.dylib */,
@ -2519,17 +2502,34 @@
152F22351B15E889008C0621 /* libxml2.dylib */,
63EEE4091BBA9B110087D3AF /* libxml2.tbd */,
F05BAA611A5D594E00411815 /* libz.dylib */,
8C5BCEC81EB3859200A9AAEF /* linphone.framework */,
8C3EAA191EB8D9C300B732B6 /* linphonetester.framework */,
F0B89C2118DC89E30050B60E /* MediaPlayer.framework */,
8C5BCEC91EB3859200A9AAEF /* mediastreamer_base.framework */,
8C5BCECA1EB3859200A9AAEF /* mediastreamer_voip.framework */,
8C601FD220B462B0004FF95C /* mediastreamer2.framework */,
D37DC7171594AF3400B2A5EB /* MessageUI.framework */,
226EF06B15FA256B005865C7 /* MobileCoreServices.framework */,
8C3EA9E01EB892D600B732B6 /* msamr.framework */,
8C3EA9E11EB892D600B732B6 /* mscodec2.framework */,
8C3EA9E21EB892D600B732B6 /* msopenh264.framework */,
8C5BCECB1EB3859200A9AAEF /* mssilk.framework */,
8C5BCECC1EB3859200A9AAEF /* mswebrtc.framework */,
8C3EA9EF1EB8A78C00B732B6 /* msx264.framework */,
5EF0C33820C806A5005081B0 /* NotificationCenter.framework */,
70E542F213E147E3002BA2C0 /* OpenGLES.framework */,
8C5BCECD1EB3859200A9AAEF /* ortp.framework */,
249660941FD6A359001D55AA /* Photos.framework */,
8CA2004B1D8158440095F859 /* PushKit.framework */,
70E542F413E147EB002BA2C0 /* QuartzCore.framework */,
22744043106F33FC006EC466 /* Security.framework */,
F0181B6B18BF7B1200A9A357 /* SenTestingKit.framework */,
570742661D5A63DB004B9C84 /* StoreKit.framework */,
2264B6D111200342002C2C53 /* SystemConfiguration.framework */,
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
5EF0C33820C806A5005081B0 /* NotificationCenter.framework */,
8C73477B1D9BA3A00022EE8C /* UserNotifications.framework */,
5E58962520DCE5700030868C /* UserNotificationsUI.framework */,
63CE583F1C85EBF400304800 /* VideoToolbox.framework */,
);
name = Frameworks;
sourceTree = "<group>";