Tables: fix deletion

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-26 14:25:46 +01:00
parent 66d06cd76d
commit 54625e3c4c
11 changed files with 76 additions and 41 deletions

View file

@ -181,6 +181,14 @@
</view>
</subviews>
</view>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No conversation." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="p7C-WH-uR1" userLabel="emptyTableLabel">
<rect key="frame" x="0.0" y="0.0" width="375" height="453"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" id="14" userLabel="messageView">
<rect key="frame" x="0.0" y="453" width="375" height="66"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>

View file

@ -128,6 +128,14 @@
<outlet property="delegate" destination="4" id="12"/>
</connections>
</tableView>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No conversation." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="MSn-PY-yf1" userLabel="emptyTableLabel">
<rect key="frame" x="0.0" y="42" width="375" height="517"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
</subviews>
@ -141,6 +149,7 @@
<outlet property="cancelButton" destination="KhE-c3-2Zj" id="0BM-Q1-ZaR"/>
<outlet property="deleteButton" destination="Rxo-0W-iqY" id="vsb-dD-1zl"/>
<outlet property="editButton" destination="qem-Y1-v78" id="Ba4-I1-fI5"/>
<outlet property="emptyView" destination="MSn-PY-yf1" id="C72-01-4pD"/>
<outlet property="toggleSelectionButton" destination="uqG-2T-VOa" id="ytx-bj-7Qr"/>
<outlet property="view" destination="6" id="13"/>
</connections>

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="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
@ -179,6 +179,14 @@
<outlet property="delegate" destination="TJG-JZ-YRR" id="V1N-gI-U4J"/>
</connections>
</tableView>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No contacts." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="JR3-k7-gVP" userLabel="emptyTableLabel">
<rect key="frame" x="0.0" y="42" width="375" height="519"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
</subviews>
@ -191,6 +199,7 @@
<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="emptyView" destination="JR3-k7-gVP" id="3vV-F3-Eit"/>
<outlet property="toggleSelectionButton" destination="5lZ-u7-Yex" id="C99-nu-2wJ"/>
<outlet property="view" destination="zOo-FS-W6l" id="cM7-Da-i7e"/>
</connections>
@ -200,9 +209,9 @@
<resources>
<image name="cancel_edit_default.png" width="29" height="29"/>
<image name="cancel_edit_disabled.png" width="29" height="29"/>
<image name="color_A.png" width="1" height="1"/>
<image name="color_E.png" width="1" height="1"/>
<image name="color_F.png" width="1" height="1"/>
<image name="color_A.png" width="2" height="2"/>
<image name="color_E.png" width="2" height="2"/>
<image name="color_F.png" width="2" height="2"/>
<image name="contact_add_default.png" width="34" height="29"/>
<image name="contact_add_disabled.png" width="34" height="29"/>
<image name="contacts_all_default.png" width="32" height="27"/>

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="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
@ -144,6 +144,14 @@
<outlet property="delegate" destination="18" id="24"/>
</connections>
</tableView>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No history." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="xtr-Fp-60Z" userLabel="emptyTableLabel">
<rect key="frame" x="0.0" y="40" width="375" height="519"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
@ -158,6 +166,7 @@
<outlet property="cancelButton" destination="00K-MU-NUc" id="KSi-MC-Usk"/>
<outlet property="deleteButton" destination="35" id="n8o-lE-u1t"/>
<outlet property="editButton" destination="6" id="Sgc-Z3-NeQ"/>
<outlet property="emptyView" destination="xtr-Fp-60Z" id="hgd-7A-cLI"/>
<outlet property="toggleSelectionButton" destination="nhN-oH-LQ9" id="77r-l0-3Yi"/>
<outlet property="view" destination="17" id="25"/>
</connections>
@ -167,9 +176,9 @@
<resources>
<image name="cancel_edit_default.png" width="29" height="29"/>
<image name="cancel_edit_disabled.png" width="29" height="29"/>
<image name="color_A.png" width="1" height="1"/>
<image name="color_E.png" width="1" height="1"/>
<image name="color_F.png" width="1" height="1"/>
<image name="color_A.png" width="2" height="2"/>
<image name="color_E.png" width="2" height="2"/>
<image name="color_F.png" width="2" height="2"/>
<image name="delete_default.png" width="21" height="27"/>
<image name="delete_disabled.png" width="21" height="27"/>
<image name="deselect_all_default.png" width="26" height="26"/>

View file

@ -20,7 +20,7 @@
#import <UIKit/UIKit.h>
#include "linphone/linphonecore.h"
#import "UICheckBoxTVTableViewController.h"
#import "UICheckBoxTableViewController.h"
@protocol ChatConversationDelegate <NSObject>
@ -29,7 +29,7 @@
@end
@interface ChatConversationTableView : UICheckBoxTVTableViewController {
@interface ChatConversationTableView : UICheckBoxTableViewController {
@private
LinphoneChatRoom *chatRoom;
MSList *messageList;

View file

@ -19,9 +19,9 @@
#import <UIKit/UIKit.h>
#include "linphone/linphonecore.h"
#include "UICheckBoxTVTableViewController.h"
#include "UICheckBoxTableViewController.h"
@interface ChatsListTableView : UICheckBoxTVTableViewController
@interface ChatsListTableView : UICheckBoxTableViewController
- (void)loadData;
@end

View file

@ -20,11 +20,11 @@
#import <UIKit/UIKit.h>
#import <AddressBook/AddressBook.h>
#import "UICheckBoxTVTableViewController.h"
#import "UICheckBoxTableViewController.h"
#import "OrderedDictionary.h"
@interface ContactsListTableView : UICheckBoxTVTableViewController {
@interface ContactsListTableView : UICheckBoxTableViewController {
@private
OrderedDictionary *addressBookMap;
NSMutableDictionary *avatarMap;

View file

@ -19,9 +19,9 @@
#import <UIKit/UIKit.h>
#import "UICheckBoxTVTableViewController.h"
#import "UICheckBoxTableViewController.h"
@interface HistoryListTableView : UICheckBoxTVTableViewController {
@interface HistoryListTableView : UICheckBoxTableViewController {
}
@property(nonatomic, assign) BOOL missedFilter;

View file

@ -10,13 +10,14 @@
#import <UIKit/UIKit.h>
@interface UICheckBoxTVTableViewController : UITableViewController
@interface UICheckBoxTableViewController : UITableViewController
@property(nonatomic, readonly) NSMutableArray *selectedItems;
@property(weak, nonatomic) IBOutlet UIButton *deleteButton;
@property(weak, nonatomic) IBOutlet UIButton *editButton;
@property(weak, nonatomic) IBOutlet UIButton *cancelButton;
@property(weak, nonatomic) IBOutlet UIButton *toggleSelectionButton;
@property(weak, nonatomic) IBOutlet UIView *emptyView;
- (void)loadData;
- (void)accessoryForCell:(UITableViewCell *)cell atPath:(NSIndexPath *)indexPath;

View file

@ -17,10 +17,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "UICheckBoxTVTableViewController.h"
#import "UICheckBoxTableViewController.h"
#import "Utils.h"
@implementation UICheckBoxTVTableViewController
@implementation UICheckBoxTableViewController
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
@ -38,15 +38,17 @@
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
_editButton.enabled = (([self numberOfSectionsInTableView:self.tableView] > 0) &&
([self tableView:self.tableView numberOfRowsInSection:0] != 0));
_emptyView.hidden = _editButton.enabled = ([self totalNumberOfItems] != 0);
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:NO];
cell.accessoryType = (cell.accessoryType == UITableViewCellAccessoryCheckmark) ? UITableViewCellAccessoryNone
: UITableViewCellAccessoryCheckmark;
if ([_selectedItems containsObject:indexPath]) {
[_selectedItems removeObject:indexPath];
} else {
[_selectedItems addObject:indexPath];
}
[self accessoryForCell:cell atPath:indexPath];
_toggleSelectionButton.selected = (_selectedItems.count == [self totalNumberOfItems]);
}
@ -57,11 +59,9 @@
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if ([self isEditing]) {
UIImage *image = nil;
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
[_selectedItems addObject:indexPath];
if ([_selectedItems containsObject:indexPath]) {
image = [UIImage imageNamed:@"checkbox_checked.png"];
} else if (cell.accessoryType == UITableViewCellAccessoryNone) {
[_selectedItems removeObject:indexPath];
} else {
image = [UIImage imageNamed:@"checkbox_unchecked.png"];
}
UIButton *checkBoxButton = [UIButton buttonWithType:UIButtonTypeCustom];
@ -93,8 +93,7 @@
[_selectedItems removeAllObjects];
[self.tableView reloadData];
_editButton.enabled = ([self numberOfSectionsInTableView:self.tableView] > 0 &&
[self tableView:self.tableView numberOfRowsInSection:0] != 0);
_editButton.enabled = _emptyView.hidden = ([self totalNumberOfItems] > 0);
}
- (void)removeSelection {
@ -118,12 +117,12 @@
_toggleSelectionButton.selected = !_toggleSelectionButton.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 cellForRowAtIndexPath:idx];
cell.accessoryType =
_toggleSelectionButton.selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
[self accessoryForCell:cell atPath:idx];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
if (_toggleSelectionButton.selected) {
[_selectedItems addObject:indexPath];
}
[self accessoryForCell:cell atPath:indexPath];
}
}
}

View file

@ -89,7 +89,7 @@
6334DDFB1BBAC99400631900 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D32B6E2E15A5C0AC0033019F /* libsqlite3.dylib */; };
6334DDFC1BBAC99B00631900 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 152F22351B15E889008C0621 /* libxml2.dylib */; };
6334DDFD1BBAC9A200631900 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F0B026F21AA710AF00FF49F7 /* libiconv.dylib */; };
6334DE001BBAD5AA00631900 /* UICheckBoxTVTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6334DDFF1BBAD5AA00631900 /* UICheckBoxTVTableViewController.m */; };
6334DE001BBAD5AA00631900 /* UICheckBoxTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6334DDFF1BBAD5AA00631900 /* UICheckBoxTableViewController.m */; };
633671611BCBAAD200BFCBDE /* ChatConversationCreateView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6336715F1BCBAAD200BFCBDE /* ChatConversationCreateView.m */; };
633756391B67BAF400E21BAD /* SideMenuTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 633756381B67BAF400E21BAD /* SideMenuTableView.m */; };
633756451B67D2B200E21BAD /* SideMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = 633756431B67D2B100E21BAD /* SideMenuView.m */; };
@ -741,8 +741,8 @@
6313482F1B6F7B6600C6BDCB /* UIRoundBorderedButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIRoundBorderedButton.m; sourceTree = "<group>"; };
631348311B6FA53300C6BDCB /* rootca.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = rootca.pem; path = "liblinphone-sdk/apple-darwin/share/linphone/rootca.pem"; sourceTree = SOURCE_ROOT; };
63158FAC1B468E0E00969917 /* ImageOptim.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = ImageOptim.sh; path = Tools/ImageOptim.sh; sourceTree = "<group>"; };
6334DDFE1BBAD5AA00631900 /* UICheckBoxTVTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICheckBoxTVTableViewController.h; sourceTree = "<group>"; };
6334DDFF1BBAD5AA00631900 /* UICheckBoxTVTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICheckBoxTVTableViewController.m; sourceTree = "<group>"; };
6334DDFE1BBAD5AA00631900 /* UICheckBoxTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICheckBoxTableViewController.h; sourceTree = "<group>"; };
6334DDFF1BBAD5AA00631900 /* UICheckBoxTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICheckBoxTableViewController.m; sourceTree = "<group>"; };
6336715E1BCBAAD200BFCBDE /* ChatConversationCreateView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatConversationCreateView.h; sourceTree = "<group>"; };
6336715F1BCBAAD200BFCBDE /* ChatConversationCreateView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatConversationCreateView.m; sourceTree = "<group>"; };
633756371B67BAF400E21BAD /* SideMenuTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SideMenuTableView.h; sourceTree = "<group>"; };
@ -1567,8 +1567,8 @@
63B8D69F1BCBF43100C12B09 /* UIChatCreateCell.h */,
63B8D6A01BCBF43100C12B09 /* UIChatCreateCell.m */,
63B8D6A11BCBF43100C12B09 /* UIChatCreateCell.xib */,
6334DDFE1BBAD5AA00631900 /* UICheckBoxTVTableViewController.h */,
6334DDFF1BBAD5AA00631900 /* UICheckBoxTVTableViewController.m */,
6334DDFE1BBAD5AA00631900 /* UICheckBoxTableViewController.h */,
6334DDFF1BBAD5AA00631900 /* UICheckBoxTableViewController.m */,
D31B4B1E159876C0002E6C72 /* UICompositeView.h */,
D31B4B1F159876C0002E6C72 /* UICompositeView.m */,
639CEB051A1DF4EB004DE38F /* UICompositeView.xib */,
@ -2881,7 +2881,7 @@
D3807FC515C28940005BE9BC /* DCRoundSwitchToggleLayer.m in Sources */,
D3807FE815C2894A005BE9BC /* IASKAppSettingsViewController.m in Sources */,
D3807FEA15C2894A005BE9BC /* IASKAppSettingsWebViewController.m in Sources */,
6334DE001BBAD5AA00631900 /* UICheckBoxTVTableViewController.m in Sources */,
6334DE001BBAD5AA00631900 /* UICheckBoxTableViewController.m in Sources */,
D3807FEC15C2894A005BE9BC /* IASKSpecifierValuesViewController.m in Sources */,
D3807FEE15C2894A005BE9BC /* IASKSettingsReader.m in Sources */,
D3807FF015C2894A005BE9BC /* IASKSettingsStore.m in Sources */,