4.1 popup confirmation view before security call

This commit is contained in:
Danmei Chen 2018-11-09 10:56:52 +01:00
parent a58d549b9a
commit 8d2081df6b
12 changed files with 132 additions and 15 deletions

View file

@ -28,6 +28,7 @@
#import "UIBackToCallButton.h"
#import "Utils/HPGrowingTextView/HPGrowingTextView.h"
#import "UIImageViewDeletable.h"
#import "UIConfirmationDialog.h"
#include "linphone/linphonecore.h"
@ -37,6 +38,7 @@
OrderedDictionary *imageQualities;
BOOL scrollOnGrowingEnabled;
BOOL composingVisible;
UIConfirmationDialog *securityDialog;
}
@property(nonatomic) LinphoneChatRoom *chatRoom;

View file

@ -37,6 +37,7 @@ static NSString* groupName = @"group.belledonne-communications.linphone";
scrollOnGrowingEnabled = TRUE;
_chatRoom = NULL;
_chatRoomCbs = NULL;
securityDialog = NULL;
imageQualities = [[OrderedDictionary alloc]
initWithObjectsAndKeys:[NSNumber numberWithFloat:0.9], NSLocalizedString(@"Maximum", nil),
[NSNumber numberWithFloat:0.5], NSLocalizedString(@"Average", nil),
@ -572,10 +573,40 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (IBAction)onEncryptedDevicesClick:(id)sender {
DevicesListView *view = VIEW(DevicesListView);
view.room = _chatRoom;
BOOL isOneToOne = linphone_chat_room_get_capabilities(_chatRoom) & LinphoneChatRoomCapabilitiesOneToOne;
NSString *message = NSLocalizedString(@"Instant messages are end-to-end encrypted in secured conversations. It is possible to upgrade the security level of a conversation by authenticating participants. To do so, call the contact and follow the authentification process.",nil);
[PhoneMainView.instance popToView:view.compositeViewDescription];
if (isOneToOne) {
bctbx_list_t *participants = linphone_chat_room_get_participants(_chatRoom);
LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL;
const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_chatRoom);
if (bctbx_list_size(linphone_participant_get_devices(firstParticipant)) == 1) {
if (securityDialog && securityDialog.notAskAgain) {
[LinphoneManager.instance doCall:addr];
} else {
securityDialog = [UIConfirmationDialog ShowWithMessage:message cancelMessage:NSLocalizedString(@"CANCELL", nil) confirmMessage:NSLocalizedString(@"CALL", nil) onCancelClick:^() {
} onConfirmationClick:^() {
[LinphoneManager.instance doCall:addr];
}];
securityDialog.authView.hidden = FALSE;
}
return;
}
}
if (securityDialog && securityDialog.notAskAgain) {
[self goToDeviceListView];
} else {
securityDialog = [UIConfirmationDialog ShowWithMessage:message cancelMessage:NSLocalizedString(@"CANCELL", nil) confirmMessage:NSLocalizedString(@"OK", nil) onCancelClick:^() {
} onConfirmationClick:^() {
DevicesListView *view = VIEW(DevicesListView);
view.room = _chatRoom;
[PhoneMainView.instance popToView:view.compositeViewDescription];
}];
securityDialog.authView.hidden = FALSE;
}
}
- (IBAction)onCallClick:(id)sender {
@ -937,6 +968,12 @@ void on_chat_room_conference_left(LinphoneChatRoom *cr, const LinphoneEventLog *
[view.tableController scrollToBottom:true];
}
- (void)goToDeviceListView {
DevicesListView *view = VIEW(DevicesListView);
view.room = _chatRoom;
[PhoneMainView.instance popToView:view.compositeViewDescription];
}
- (void)openFile:(NSString *) filePath
{
// Open the controller.

View file

@ -95,8 +95,7 @@ static UICompositeViewDescription *compositeDescription = nil;
{
if (!_isOneToOne) {
DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row];
return (entry->numberOfDevices + 1) * 56.0;
return entry->numberOfDevices > 1 ? (entry->numberOfDevices + 1) * 56.0 : 56.0;
}
return 56.0;
}
@ -129,8 +128,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[ContactDisplay setDisplayNameLabel:cell.addressLabel forAddress:linphone_participant_get_address(entry->participant)];
cell.devices = linphone_participant_get_devices(entry->participant);
UIImage *image = (entry->numberOfDevices != 0) ? [UIImage imageNamed:@"chevron_list_open"] : [UIImage imageNamed:@"chevron_list_close"];
[cell.dropMenuButton setImage:image forState:UIControlStateNormal];
[cell update:(entry->numberOfDevices != 0)];
return cell;
}

View file

@ -11,6 +11,8 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="UIConfirmationDialog">
<connections>
<outlet property="authButton" destination="lWW-wB-FMR" id="C7W-JM-WFQ"/>
<outlet property="authView" destination="CCn-Oz-I0M" id="fSM-6k-paN"/>
<outlet property="cancelButton" destination="B1K-CB-3of" id="KKi-Xc-ldA"/>
<outlet property="confirmationButton" destination="SbQ-re-fGQ" id="yiv-a9-o8E"/>
<outlet property="securityImage" destination="bbo-g3-bGy" id="qZa-li-yrl"/>
@ -36,7 +38,7 @@
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Are you sure you want to delete all your selection?" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" id="jLz-g1-cTe" userLabel="titleLabel">
<rect key="frame" x="-10" y="54" width="336" height="226"/>
<rect key="frame" x="-10" y="15" width="336" height="279"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="21"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -54,6 +56,28 @@
<action selector="onCancelClick:" destination="-1" eventType="touchUpInside" id="LvF-N2-56g"/>
</connections>
</button>
<view contentMode="scaleToFill" id="CCn-Oz-I0M" userLabel="authView">
<rect key="frame" x="61" y="273" width="240" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="lWW-wB-FMR" userLabel="authButton">
<rect key="frame" x="26" y="2" width="17" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<state key="normal" image="checkbox_unchecked.png"/>
<state key="selected" image="checkbox_checked.png"/>
<connections>
<action selector="onAuthClick:" destination="-1" eventType="touchUpInside" id="9A4-ZX-cXA"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Do not ask again" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="dQL-Sf-slc">
<rect key="frame" x="55" y="2" width="176" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="SbQ-re-fGQ" userLabel="confirmationButton" customClass="UIRoundBorderedButton">
<rect key="frame" x="169" y="308" width="143" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
@ -75,6 +99,8 @@
</view>
</objects>
<resources>
<image name="checkbox_checked.png" width="17" height="17"/>
<image name="checkbox_unchecked.png" width="17" height="17"/>
<image name="color_C.png" width="2" height="2"/>
<image name="color_F.png" width="2" height="2"/>
<image name="color_H.png" width="2" height="2"/>

View file

@ -35,8 +35,13 @@ typedef void (^UIConfirmationBlock)(void);
@property(weak, nonatomic) IBOutlet UIRoundBorderedButton *cancelButton;
@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
@property(weak, nonatomic) IBOutlet UIRoundBorderedButton *confirmationButton;
@property (weak, nonatomic) IBOutlet UIView *authView;
@property(weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIButton *authButton;
@property BOOL notAskAgain;
- (IBAction)onCancelClick:(id)sender;
- (IBAction)onConfirmationClick:(id)sender;
- (IBAction)onAuthClick:(id)sender;
- (void)dismiss;
@end

View file

@ -24,6 +24,7 @@
dialog->onCancelCb = onCancel;
dialog->onConfirmCb = onConfirm;
dialog.notAskAgain = FALSE;
if (cancel) {
[dialog.cancelButton setTitle:cancel forState:UIControlStateNormal];
@ -91,6 +92,12 @@
}
}
- (IBAction)onAuthClick:(id)sender {
_notAskAgain = !_notAskAgain;
UIImage *image = _notAskAgain ? [UIImage imageNamed:@"checkbox_checked.png"] : [UIImage imageNamed:@"checkbox_unchecked.png"];
[_authButton setImage:image forState:UIControlStateNormal];
}
- (void)dismiss {
[self onCancelClick:nil];
}

View file

@ -10,10 +10,11 @@
@interface UIDeviceCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *deviceLabel;
@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
@property (weak, nonatomic) IBOutlet UIButton *securityButton;
@property LinphoneParticipantDevice *device;
@property BOOL isOneToOne;
- (IBAction)onSecurityCallClick:(id)sender;
- (id)initWithIdentifier:(NSString *)identifier;
- (void)update;
@end

View file

@ -24,7 +24,7 @@
}
- (void)update {
[_securityImage setImage:[FastAddressBook imageForSecurityLevel:linphone_participant_device_get_security_level(_device)]];
[_securityButton setImage:[FastAddressBook imageForSecurityLevel:linphone_participant_device_get_security_level(_device)] forState:UIControlStateNormal];
_deviceLabel.text = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(linphone_participant_device_get_address(_device))];
if (_isOneToOne) {
@ -36,5 +36,12 @@
self.selectionStyle =UITableViewCellSelectionStyleNone;
}
- (IBAction)onSecurityCallClick:(id)sender {
const LinphoneAddress *addr = linphone_participant_device_get_address(_device);
if (addr)
[LinphoneManager.instance doCall:addr];
else
LOGE(@"CallKit : No call address");
}
@end

View file

@ -13,7 +13,7 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="UIDeviceCell">
<connections>
<outlet property="deviceLabel" destination="7tu-QT-9B2" id="HXh-Cw-5Lo"/>
<outlet property="securityImage" destination="W00-d7-5Mq" id="3DW-zg-aZT"/>
<outlet property="securityButton" destination="I16-aS-Ah2" id="rmi-B5-zMM"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
@ -25,10 +25,6 @@
<rect key="frame" x="0.0" y="55" width="375" height="1"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" fixedFrame="YES" image="security_1_indicator.png" translatesAutoresizingMaskIntoConstraints="NO" id="W00-d7-5Mq" userLabel="securityImage">
<rect key="frame" x="336" y="17" width="18" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" fixedFrame="YES" text="John Doe" lineBreakMode="tailTruncation" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7tu-QT-9B2" userLabel="deviceLabel">
<rect key="frame" x="69" y="16" width="220" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
@ -37,6 +33,14 @@
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="I16-aS-Ah2" userLabel="securityButton">
<rect key="frame" x="336" y="17" width="18" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<state key="normal" image="security_1_indicator.png"/>
<connections>
<action selector="onSecurityCallClick:" destination="-1" eventType="touchUpInside" id="yLI-cZ-jfY"/>
</connections>
</button>
</subviews>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>

View file

@ -13,8 +13,11 @@
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
@property (weak, nonatomic) IBOutlet UIButton *securityButton;
@property (weak, nonatomic) IBOutlet UITableView *devicesTable;
@property bctbx_list_t *devices;
- (IBAction)onSecurityCallClick:(id)sender;
- (id)initWithIdentifier:(NSString *)identifier;
- (void)update:(BOOL)listOpen;
@end

View file

@ -26,6 +26,24 @@
return self;
}
- (void)update:(BOOL)listOpen {
if (bctbx_list_size(_devices) == 1) {
_securityButton.hidden = FALSE;
_dropMenuButton.hidden = TRUE;
} else {
UIImage *image = listOpen ? [UIImage imageNamed:@"chevron_list_open"] : [UIImage imageNamed:@"chevron_list_close"];
[_dropMenuButton setImage:image forState:UIControlStateNormal];
}
}
- (IBAction)onSecurityCallClick:(id)sender {
LinphoneParticipantDevice *device = (LinphoneParticipantDevice *)bctbx_list_nth_data(_devices, 0);
const LinphoneAddress *addr = linphone_participant_device_get_address(device);
if (addr)
[LinphoneManager.instance doCall:addr];
else
LOGE(@"CallKit : No call address");
}
#pragma mark - TableView

View file

@ -16,6 +16,7 @@
<outlet property="avatarImage" destination="gUM-dT-1wZ" id="WPF-6b-5Hv"/>
<outlet property="devicesTable" destination="Bhw-SW-cbz" id="Fc6-BV-RrV"/>
<outlet property="dropMenuButton" destination="fqu-53-vFp" id="qwN-sh-50p"/>
<outlet property="securityButton" destination="exm-bi-aEL" id="Ht8-LX-ag7"/>
<outlet property="securityImage" destination="kEm-qC-OwR" id="SYs-Vr-JdZ"/>
</connections>
</placeholder>
@ -49,6 +50,14 @@
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<state key="normal" image="chevron_list_close.png"/>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="exm-bi-aEL" userLabel="securityButton">
<rect key="frame" x="336" y="17" width="18" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<state key="normal" image="security_1_indicator.png"/>
<connections>
<action selector="onSecurityCallClick:" destination="-1" eventType="touchUpInside" id="D1A-3d-K60"/>
</connections>
</button>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="Bhw-SW-cbz">
<rect key="frame" x="0.0" y="56" width="375" height="100"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>