forked from mirrors/linphone-iphone
Improve filter & fix view change (same description)
This commit is contained in:
parent
d8438aa742
commit
4d42d182c1
10 changed files with 45 additions and 29 deletions
|
|
@ -102,6 +102,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (IBAction)onAddClick:(id)event {
|
||||
[ContactSelection setSelectionMode:ContactSelectionModeMessage];
|
||||
[ContactSelection setAddAddress:nil];
|
||||
[ContactSelection setSipFilter:TRUE];
|
||||
[[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] push:TRUE];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,8 @@
|
|||
OrderedDictionary* addressBookMap;
|
||||
|
||||
ABAddressBookRef addressBook;
|
||||
BOOL sipFilter;
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) BOOL sipFilter;
|
||||
- (void)loadData;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@
|
|||
|
||||
@implementation ContactsTableViewController
|
||||
|
||||
@synthesize sipFilter;
|
||||
|
||||
#pragma mark - Lifecycle Functions
|
||||
|
||||
- (void)initContactsTableViewController {
|
||||
|
|
@ -62,17 +60,9 @@
|
|||
}
|
||||
|
||||
|
||||
#pragma mark - Property Functions
|
||||
|
||||
- (void)setSipFilter:(BOOL)asipFilter {
|
||||
self->sipFilter = asipFilter;
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)reloadData {
|
||||
- (void)loadData {
|
||||
[LinphoneLogger logc:LinphoneLoggerLog format:"Load contact list"];
|
||||
@synchronized (addressBookMap) {
|
||||
|
||||
|
|
@ -82,7 +72,7 @@
|
|||
NSArray *lContacts = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
|
||||
for (id lPerson in lContacts) {
|
||||
BOOL add = true;
|
||||
if(sipFilter) {
|
||||
if([ContactSelection getSipFilter]) {
|
||||
add = false;
|
||||
ABMultiValueRef lMap = ABRecordCopyValue((ABRecordRef)lPerson, kABPersonInstantMessageProperty);
|
||||
for(int i = 0; i < ABMultiValueGetCount(lMap); ++i) {
|
||||
|
|
@ -91,6 +81,8 @@
|
|||
if(CFStringCompare((CFStringRef)@"SIP", CFDictionaryGetValue(lDict, @"service"), kCFCompareCaseInsensitive) == 0) {
|
||||
add = true;
|
||||
}
|
||||
} else {
|
||||
add = true;
|
||||
}
|
||||
CFRelease(lDict);
|
||||
}
|
||||
|
|
@ -141,7 +133,7 @@
|
|||
static void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef info, void *context) {
|
||||
ContactsTableViewController* controller = (ContactsTableViewController*)context;
|
||||
ABAddressBookRevert(addressBook);
|
||||
[controller reloadData];
|
||||
[controller loadData];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ typedef enum _ContactSelectionMode {
|
|||
+ (ContactSelectionMode)getSelectionMode;
|
||||
+ (void)setAddAddress:(NSString*)address;
|
||||
+ (NSString*)getAddAddress;
|
||||
+ (void)setSipFilter:(BOOL)enable;
|
||||
+ (BOOL)getSipFilter;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
static ContactSelectionMode sSelectionMode = ContactSelectionModeNone;
|
||||
static NSString* sAddAddress = nil;
|
||||
static BOOL sSipFilter = FALSE;
|
||||
|
||||
+ (void)setSelectionMode:(ContactSelectionMode)selectionMode {
|
||||
sSelectionMode = selectionMode;
|
||||
|
|
@ -50,6 +51,14 @@ static NSString* sAddAddress = nil;
|
|||
return sAddAddress;
|
||||
}
|
||||
|
||||
+ (void)setSipFilter:(BOOL)enable {
|
||||
sSipFilter = enable;
|
||||
}
|
||||
|
||||
+ (BOOL)getSipFilter {
|
||||
return sSipFilter;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation ContactsViewController
|
||||
|
|
@ -120,7 +129,6 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[tableController viewWillAppear:animated];
|
||||
}
|
||||
|
||||
[self changeView:History_All];
|
||||
[self update];
|
||||
}
|
||||
|
||||
|
|
@ -141,6 +149,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
[self changeView:History_All];
|
||||
|
||||
// Set selected+over background: IB lack !
|
||||
[linphoneButton setImage:[UIImage imageNamed:@"contacts_linphone_selected.png"]
|
||||
forState:(UIControlStateHighlighted | UIControlStateSelected)];
|
||||
|
|
@ -155,14 +165,16 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (void)changeView: (HistoryView) view {
|
||||
if(view == History_All) {
|
||||
[tableController setSipFilter:FALSE];
|
||||
[ContactSelection setSipFilter:FALSE];
|
||||
[tableController loadData];
|
||||
allButton.selected = TRUE;
|
||||
} else {
|
||||
allButton.selected = FALSE;
|
||||
}
|
||||
|
||||
if(view == History_Linphone) {
|
||||
[tableController setSipFilter:TRUE];
|
||||
[ContactSelection setSipFilter:TRUE];
|
||||
[tableController loadData];
|
||||
linphoneButton.selected = TRUE;
|
||||
} else {
|
||||
linphoneButton.selected = FALSE;
|
||||
|
|
@ -181,6 +193,14 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[backButton setHidden:TRUE];
|
||||
break;
|
||||
}
|
||||
if([ContactSelection getSipFilter]) {
|
||||
allButton.selected = FALSE;
|
||||
linphoneButton.selected = TRUE;
|
||||
} else {
|
||||
allButton.selected = TRUE;
|
||||
linphoneButton.selected = FALSE;
|
||||
}
|
||||
[tableController loadData];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
- (IBAction)onAddContactClick: (id) event {
|
||||
[ContactSelection setSelectionMode:ContactSelectionModeEdit];
|
||||
[ContactSelection setAddAddress:[addressField text]];
|
||||
[ContactSelection setSipFilter:FALSE];
|
||||
ContactsViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] push:TRUE], ContactsViewController);
|
||||
if(controller != nil) {
|
||||
|
||||
|
|
|
|||
|
|
@ -264,6 +264,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
- (IBAction)onAddContactClick:(id)event {
|
||||
[ContactSelection setSelectionMode:ContactSelectionModeEdit];
|
||||
[ContactSelection setAddAddress:[[addressButton titleLabel] text]];
|
||||
[ContactSelection setSipFilter:FALSE];
|
||||
ContactsViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] push:TRUE], ContactsViewController);
|
||||
if(controller != nil) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,9 +211,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if(oldViewDescription != nil && contentViewController != nil && oldViewDescription.content != currentViewDescription.content) {
|
||||
[UICompositeViewController removeSubView: contentViewController];
|
||||
}
|
||||
[UICompositeViewController removeSubView: contentViewController];
|
||||
if(oldViewDescription != nil && tabBarViewController != nil && oldViewDescription.tabBar != currentViewDescription.tabBar) {
|
||||
[UICompositeViewController removeSubView: tabBarViewController];
|
||||
}
|
||||
|
|
@ -311,9 +309,7 @@
|
|||
|
||||
// Change view
|
||||
if(description != nil) {
|
||||
if(oldViewDescription == nil || oldViewDescription.content != currentViewDescription.content) {
|
||||
[UICompositeViewController addSubView: contentViewController view:contentView];
|
||||
}
|
||||
[UICompositeViewController addSubView: contentViewController view:contentView];
|
||||
if(oldViewDescription == nil || oldViewDescription.tabBar != currentViewDescription.tabBar) {
|
||||
[UICompositeViewController addSubView: tabBarViewController view:tabBarView];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@
|
|||
- (IBAction)onContactsClick: (id) event {
|
||||
[ContactSelection setSelectionMode:ContactSelectionModeNone];
|
||||
[ContactSelection setAddAddress:nil];
|
||||
[ContactSelection setSipFilter:FALSE];
|
||||
[[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription]];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -334,17 +334,19 @@ static PhoneMainView* phoneMainViewInstance=nil;
|
|||
}
|
||||
|
||||
- (UIViewController*)changeCurrentView:(UICompositeViewDescription*)view push:(BOOL)push {
|
||||
BOOL force = push;
|
||||
if(!push) {
|
||||
force = [viewStack count] > 1;
|
||||
[viewStack removeAllObjects];
|
||||
}
|
||||
[viewStack addObject:view];
|
||||
return [self _changeCurrentView:view transition:nil];
|
||||
return [self _changeCurrentView:view transition:nil force:force];
|
||||
}
|
||||
|
||||
- (UIViewController*)_changeCurrentView:(UICompositeViewDescription*)view transition:(CATransition*)transition {
|
||||
- (UIViewController*)_changeCurrentView:(UICompositeViewDescription*)view transition:(CATransition*)transition force:(BOOL)force {
|
||||
[LinphoneLogger logc:LinphoneLoggerLog format:"PhoneMainView: change view %d", [view name]];
|
||||
|
||||
if(![view equal: currentView]) {
|
||||
if(force || ![view equal: currentView]) {
|
||||
if(transition == nil)
|
||||
transition = [PhoneMainView getTransition:currentView new:view];
|
||||
[mainViewController setViewTransition:transition];
|
||||
|
|
@ -362,7 +364,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
|
|||
while([viewStack count] > 1 && ![[viewStack lastObject] equal:view]) {
|
||||
[viewStack removeLastObject];
|
||||
}
|
||||
[self _changeCurrentView:[viewStack lastObject] transition:[PhoneMainView getBackwardTransition]];
|
||||
[self _changeCurrentView:[viewStack lastObject] transition:[PhoneMainView getBackwardTransition] force:TRUE];
|
||||
}
|
||||
|
||||
- (UICompositeViewDescription *)firstView {
|
||||
|
|
@ -377,7 +379,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
|
|||
[LinphoneLogger logc:LinphoneLoggerLog format:"PhoneMainView: Pop view"];
|
||||
if([viewStack count] > 0) {
|
||||
[viewStack removeLastObject];
|
||||
[self _changeCurrentView:[viewStack lastObject] transition:[PhoneMainView getBackwardTransition]];
|
||||
[self _changeCurrentView:[viewStack lastObject] transition:[PhoneMainView getBackwardTransition] force:TRUE];
|
||||
return [mainViewController getCurrentViewController];
|
||||
}
|
||||
return nil;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue