rework contacts / checkboxes

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-08 13:24:38 +02:00
parent cd09fa61ca
commit 11e760d3b8
10 changed files with 93 additions and 115 deletions

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>

View file

@ -9,8 +9,6 @@
<connections>
<outlet property="addButton" destination="6" id="91"/>
<outlet property="allButton" destination="4" id="27"/>
<outlet property="backButton" destination="87" id="90"/>
<outlet property="deleteButton" destination="aJI-VJ-xN6" id="nXJ-rR-zmW"/>
<outlet property="linphoneButton" destination="5" id="31"/>
<outlet property="searchBar" destination="5jE-oF-d45" id="xfS-xo-2Bm"/>
<outlet property="tableController" destination="TJG-JZ-YRR" id="0lt-gC-EOm"/>
@ -35,19 +33,6 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="42"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</imageView>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="87" userLabel="backButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="0.0" width="75" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Back"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="back.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="color_E.png"/>
<connections>
<action selector="onBackClick:" destination="-1" eventType="touchUpInside" id="89"/>
</connections>
</button>
<view contentMode="scaleToFill" id="93" userLabel="switchView">
<rect key="frame" x="0.0" y="0.0" width="150" height="46"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
@ -92,17 +77,59 @@
</button>
</subviews>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="vXX-dG-OTJ" userLabel="listEditButton" customClass="UIIconButton">
<rect key="frame" x="225" y="0.0" width="75" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Add contact"/>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="MZP-cb-ntf" userLabel="cancelButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="1" width="75" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Delete all"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="cancel_edit.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" backgroundImage="color_E.png"/>
<connections>
<action selector="onCancelClick:" destination="TJG-JZ-YRR" eventType="touchUpInside" id="1nW-5f-kbI"/>
<action selector="onEditionChangeClick:" destination="-1" eventType="touchUpInside" id="PL4-Js-Xvg"/>
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="tFB-Vf-lUX" userLabel="deleteButton" customClass="UIIconButton">
<rect key="frame" x="300" y="1" width="75" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Delete all"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="delete.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" backgroundImage="color_E.png"/>
<connections>
<action selector="onDeleteClick:" destination="-1" eventType="touchUpInside" id="VJS-p2-Jsp"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="DZc-zR-1Q7" userLabel="editButton" customClass="UIIconButton">
<rect key="frame" x="225" y="1" width="75" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Edit"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="edit_list.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="color_E.png"/>
<state key="selected" backgroundImage="color_E.png"/>
<connections>
<action selector="onEditClick:" destination="-1" eventType="touchUpInside" id="SYP-yf-EhC"/>
<action selector="onEditClick:" destination="TJG-JZ-YRR" eventType="touchUpInside" id="CKU-6b-3F2"/>
<action selector="onEditionChangeClick:" destination="-1" eventType="touchUpInside" id="uvi-82-4ka"/>
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="5lZ-u7-Yex" userLabel="toggleSelectionButton" customClass="UIIconButton">
<rect key="frame" x="225" y="0.0" width="75" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Edit"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="select_all.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" image="deselect_all.png"/>
<connections>
<action selector="onSelectionToggle:" destination="TJG-JZ-YRR" eventType="touchUpInside" id="YcH-HT-zyi"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="6" userLabel="addButton" customClass="UIIconButton">
@ -118,19 +145,6 @@
<action selector="onAddContactClick:" destination="-1" eventType="touchUpInside" id="86"/>
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="aJI-VJ-xN6" userLabel="deleteButton" customClass="UIIconButton">
<rect key="frame" x="300" y="0.0" width="75" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Add contact"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="delete.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="color_E.png"/>
<connections>
<action selector="onDeleteClick:" destination="-1" eventType="touchUpInside" id="XEW-2B-Q5j"/>
</connections>
</button>
</subviews>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" allowsSelectionDuringEditing="YES" allowsMultipleSelectionDuringEditing="YES" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="zOo-FS-W6l" userLabel="tableView">
@ -162,14 +176,17 @@
</view>
<tableViewController id="TJG-JZ-YRR" userLabel="tableController" customClass="ContactsListTableView">
<connections>
<outlet property="deleteButton" destination="aJI-VJ-xN6" id="aDS-tk-vAO"/>
<outlet property="cancelButton" destination="MZP-cb-ntf" id="4Hf-l6-Qyp"/>
<outlet property="deleteButton" destination="tFB-Vf-lUX" id="dF5-uF-nhK"/>
<outlet property="editButton" destination="DZc-zR-1Q7" id="TkL-MM-OFA"/>
<outlet property="toggleSelectionButton" destination="5lZ-u7-Yex" id="C99-nu-2wJ"/>
<outlet property="view" destination="zOo-FS-W6l" id="cM7-Da-i7e"/>
</connections>
<point key="canvasLocation" x="510" y="206"/>
</tableViewController>
</objects>
<resources>
<image name="back.png" width="24" height="21"/>
<image name="cancel_edit.png" width="29" height="29"/>
<image name="color_E.png" width="1" height="1"/>
<image name="color_F.png" width="1" height="1"/>
<image name="contact_add.png" width="34" height="29"/>
@ -178,7 +195,9 @@
<image name="contacts_sip_default.png" width="38" height="29"/>
<image name="contacts_sip_selected.png" width="38" height="29"/>
<image name="delete.png" width="21" height="27"/>
<image name="deselect_all.png" width="26" height="26"/>
<image name="edit_list.png" width="29" height="28"/>
<image name="select_all.png" width="26" height="26"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>

View file

@ -73,10 +73,10 @@
<state key="selected" backgroundImage="color_E.png"/>
<connections>
<action selector="onCancelClick:" destination="18" eventType="touchUpInside" id="DAX-W6-l0H"/>
<action selector="onCancelClick:" destination="-1" eventType="touchUpInside" id="vIn-o6-Ui0"/>
<action selector="onEditionChangeClick:" destination="-1" eventType="touchUpInside" id="WQf-rB-DUt"/>
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="nhN-oH-LQ9" userLabel="toggleSelectionButton" customClass="UIIconButton">
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" reversesTitleShadowWhenHighlighted="YES" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="nhN-oH-LQ9" userLabel="toggleSelectionButton" customClass="UIIconButton">
<rect key="frame" x="225" y="0.0" width="75" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Edit"/>
@ -114,7 +114,7 @@
<state key="selected" backgroundImage="color_E.png"/>
<connections>
<action selector="onEditClick:" destination="18" eventType="touchUpInside" id="5Ft-HW-cVh"/>
<action selector="onEditClick:" destination="-1" eventType="touchUpInside" id="7uo-X1-sO5"/>
<action selector="onEditionChangeClick:" destination="-1" eventType="touchUpInside" id="9gC-6R-w0j"/>
</connections>
</button>
</subviews>

View file

@ -603,21 +603,10 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSe
}
if (dest != nil) {
NSString *displayName = [FastAddressBook getContactDisplayName:contact];
if ([ContactSelection getSelectionMode] != ContactSelectionModeMessage) {
// Go to dialer view
DialerView *view = VIEW(DialerView);
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
[view call:dest displayName:displayName];
} else {
// Go to Chat room view
[PhoneMainView.instance popToView:ChatsListView.compositeViewDescription];
// Then push ChatRoom
ChatConversationView *view = VIEW(ChatConversationView);
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE];
LinphoneChatRoom *room =
linphone_core_get_chat_room_from_uri([LinphoneManager getLc], [dest UTF8String]);
[view setChatRoom:room];
}
// Go to dialer view
DialerView *view = VIEW(DialerView);
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
[view call:dest displayName:displayName];
}
} else {
NSString *key = nil;

View file

@ -24,12 +24,7 @@
#import "ContactsListTableView.h"
#import "UIIconButton.h"
typedef enum _ContactSelectionMode {
ContactSelectionModeNone,
ContactSelectionModeEdit,
ContactSelectionModePhone,
ContactSelectionModeMessage
} ContactSelectionMode;
typedef enum _ContactSelectionMode { ContactSelectionModeNone, ContactSelectionModeEdit } ContactSelectionMode;
@interface ContactSelection : NSObject <UISearchBarDelegate> {
}
@ -83,7 +78,6 @@ typedef enum _ContactSelectionMode {
@property(strong, nonatomic) IBOutlet UIView *topBar;
@property(nonatomic, strong) IBOutlet UIButton *allButton;
@property(nonatomic, strong) IBOutlet UIButton *linphoneButton;
@property(nonatomic, strong) IBOutlet UIButton *backButton;
@property(nonatomic, strong) IBOutlet UIButton *addButton;
@property(strong, nonatomic) IBOutlet UISearchBar *searchBar;
@property(weak, nonatomic) IBOutlet UIIconButton *deleteButton;
@ -91,8 +85,7 @@ typedef enum _ContactSelectionMode {
- (IBAction)onAllClick:(id)event;
- (IBAction)onLinphoneClick:(id)event;
- (IBAction)onAddContactClick:(id)event;
- (IBAction)onBackClick:(id)event;
- (IBAction)onEditClick:(id)sender;
- (IBAction)onDeleteClick:(id)sender;
- (IBAction)onEditionChangeClick:(id)sender;
@end

View file

@ -80,7 +80,6 @@ static NSString *sNameOrEmailFilter;
@synthesize tableController;
@synthesize allButton;
@synthesize linphoneButton;
@synthesize backButton;
@synthesize addButton;
@synthesize topBar;
@ -184,17 +183,8 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)refreshButtons {
switch ([ContactSelection getSelectionMode]) {
case ContactSelectionModePhone:
case ContactSelectionModeMessage:
[addButton setHidden:TRUE];
[backButton setHidden:FALSE];
break;
default:
[addButton setHidden:FALSE];
[backButton setHidden:TRUE];
break;
}
[addButton setHidden:FALSE];
if ([ContactSelection getSipFilter]) {
allButton.selected = FALSE;
linphoneButton.selected = TRUE;
@ -230,26 +220,22 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
- (IBAction)onBackClick:(id)event {
[PhoneMainView.instance popCurrentView];
}
- (IBAction)onEditClick:(id)sender {
[tableController setEditing:!tableController.isEditing animated:TRUE];
_deleteButton.hidden = !tableController.isEditing;
addButton.hidden = !_deleteButton.hidden;
}
- (IBAction)onDeleteClick:(id)sender {
NSString *msg =
[NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d contacts?", nil),
tableController.selectedItems.count];
[UIConfirmationDialog ShowWithMessage:msg
onCancelClick:nil
onConfirmationClick:^() {
[tableController removeSelection];
[tableController loadData];
}];
onCancelClick:^() {
[self onEditionChangeClick:nil];
}
onConfirmationClick:^() {
[tableController removeSelection];
[tableController loadData];
}];
}
- (IBAction)onEditionChangeClick:(id)sender {
allButton.hidden = linphoneButton.hidden = addButton.hidden = self.tableController.isEditing;
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
@ -315,8 +301,4 @@ static UICompositeViewDescription *compositeDescription = nil;
[searchBar resignFirstResponder];
}
- (void)viewDidUnload {
[self setTopBar:nil];
[super viewDidUnload];
}
@end

View file

@ -34,7 +34,6 @@
- (IBAction)onAllClick:(id)event;
- (IBAction)onMissedClick:(id)event;
- (IBAction)onDeleteClick:(id)event;
- (IBAction)onEditClick:(id)sender;
- (IBAction)onCancelClick:(id)sender;
- (IBAction)onEditionChangeClick:(id)sender;
@end

View file

@ -59,7 +59,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[_tableController setEditing:FALSE animated:FALSE];
}
[self changeView:History_All];
[self updateTopBar];
[self onEditionChangeClick:nil];
// Reset missed call
linphone_core_reset_missed_calls_count([LinphoneManager getLc]);
@ -95,31 +95,23 @@ static UICompositeViewDescription *compositeDescription = nil;
[self changeView:History_Missed];
}
- (void)updateTopBar {
_allButton.hidden = _missedButton.hidden = self.tableController.isEditing;
}
- (IBAction)onDeleteClick:(id)event {
NSString *msg =
[NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d history?", nil),
_tableController.selectedItems.count];
[UIConfirmationDialog ShowWithMessage:msg
onCancelClick:^() {
[self updateTopBar];
[self onEditionChangeClick:nil];
}
onConfirmationClick:^() {
[_tableController removeSelection];
[_tableController loadData];
[self updateTopBar];
[self onEditionChangeClick:nil];
}];
}
- (IBAction)onEditClick:(id)sender {
[self updateTopBar];
}
- (IBAction)onCancelClick:(id)sender {
[self updateTopBar];
- (IBAction)onEditionChangeClick:(id)sender {
_allButton.hidden = _missedButton.hidden = self.tableController.isEditing;
}
@end

View file

@ -47,6 +47,7 @@
cell.accessoryType = (cell.accessoryType == UITableViewCellAccessoryCheckmark) ? UITableViewCellAccessoryNone
: UITableViewCellAccessoryCheckmark;
[self accessoryForCell:cell atPath:indexPath];
_toggleSelectionButton.selected = (_selectedItems.count == 0);
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView
@ -82,7 +83,6 @@
cell.accessoryType = UITableViewCellAccessoryNone;
}
_deleteButton.enabled = (_selectedItems.count != 0);
_editButton.enabled = [self tableView:self.tableView numberOfRowsInSection:0] != 0;
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
@ -90,6 +90,7 @@
_editButton.hidden = editing;
_deleteButton.hidden = _cancelButton.hidden = _toggleSelectionButton.hidden = !editing;
_toggleSelectionButton.selected = NO;
// when switching editing mode, we must reload all cells to remove/add checkboxes
[self loadData];
@ -98,6 +99,9 @@
- (void)loadData {
[_selectedItems removeAllObjects];
[self.tableView reloadData];
_editButton.enabled = ([self numberOfSectionsInTableView:self.tableView] > 0 &&
[self tableView:self.tableView numberOfRowsInSection:0] != 0);
}
- (void)removeSelection {
@ -116,12 +120,13 @@
- (void)onSelectionToggle:(id)sender {
[_selectedItems removeAllObjects];
UIButton *button = (UIButton *)sender;
button.selected = !button.selected; // TODO: why do we need that?
for (int i = 0; i < [self numberOfSectionsInTableView:self.tableView]; i++) {
for (int j = 0; j < [self tableView:self.tableView numberOfRowsInSection:i]; j++) {
NSIndexPath *idx = [NSIndexPath indexPathForRow:j inSection:i];
UITableViewCell *cell = [self tableView:self.tableView cellForRowAtIndexPath:idx];
cell.accessoryType = (button.state == UIControlStateSelected) ? UITableViewRowAnimationNone
: UITableViewCellAccessoryCheckmark;
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:idx];
cell.accessoryType = button.selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
[self accessoryForCell:cell atPath:idx];
}
}