diff --git a/Classes/Base.lproj/ContactsViewController.xib b/Classes/Base.lproj/ContactsViewController.xib
index 0936796a0..d16430f4d 100644
--- a/Classes/Base.lproj/ContactsViewController.xib
+++ b/Classes/Base.lproj/ContactsViewController.xib
@@ -11,8 +11,7 @@
-
-
+
@@ -113,32 +112,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Classes/ContactsViewController.h b/Classes/ContactsViewController.h
index c21948896..c580d82bf 100644
--- a/Classes/ContactsViewController.h
+++ b/Classes/ContactsViewController.h
@@ -18,6 +18,7 @@
*/
#import
+#import
#import "UICompositeViewController.h"
#import "ContactsTableViewController.h"
@@ -44,11 +45,14 @@ typedef enum _ContactSelectionMode {
@end
-@interface ContactsViewController : UIViewController {
+@interface ContactsViewController : UIViewController {
+ BOOL use_systemView;
}
@property (nonatomic, retain) IBOutlet ContactsTableViewController* tableController;
@property (nonatomic, retain) IBOutlet UITableView *tableView;
+@property (nonatomic, retain) IBOutlet UINavigationController* sysViewController;
+@property (retain, nonatomic) IBOutlet UIView *toolBar;
@property (nonatomic, retain) IBOutlet UIButton* allButton;
@property (nonatomic, retain) IBOutlet UIButton* linphoneButton;
@property (nonatomic, retain) IBOutlet UIButton *backButton;
diff --git a/Classes/ContactsViewController.m b/Classes/ContactsViewController.m
index d3b54c122..b188f9b0c 100644
--- a/Classes/ContactsViewController.m
+++ b/Classes/ContactsViewController.m
@@ -76,10 +76,13 @@ static BOOL sEmailFilter = FALSE;
@synthesize tableController;
@synthesize tableView;
+@synthesize sysViewController;
+
@synthesize allButton;
@synthesize linphoneButton;
@synthesize backButton;
@synthesize addButton;
+@synthesize toolBar;
typedef enum _HistoryView {
History_All,
@@ -130,25 +133,43 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
- if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
- [tableController viewWillDisappear:animated];
- }
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
- [tableController viewWillAppear:animated];
- }
- [self update];
+ BOOL use_system = [[LinphoneManager instance] lpConfigBoolForKey:@"use_system_contacts"];
+ if( use_system && !self.sysViewController){// use system contacts
+ ABPeoplePickerNavigationController* picker = [[ABPeoplePickerNavigationController alloc] init];
+ picker.peoplePickerDelegate = self;
+ picker.view.frame = self.view.frame;
+
+ [self.view addSubview:picker.view];
+
+ self.sysViewController = picker;
+
+ } else if( !use_system && !self.tableController ){
+
+ CGRect subViewFrame= self.view.frame;
+ // let the toolBar be visible
+ subViewFrame.origin.y += self.toolBar.frame.size.height;
+
+ self.tableController = [[ContactsTableViewController alloc] init];
+ self.tableView = [[UITableView alloc] init];
+
+ self.tableController.view = self.tableView;
+ self.tableView.frame = subViewFrame;
+
+ self.tableView.dataSource = self.tableController;
+ self.tableView.delegate = self.tableController;
+
+ [self.view addSubview:tableView];
+ [self update];
+ }
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
- if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
- [tableController viewDidAppear:animated];
- }
if(![FastAddressBook isAuthorized]) {
UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Address book",nil)
message:NSLocalizedString(@"You must authorize the application to have access to address book.\n"
@@ -164,9 +185,6 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
- if ([[UIDevice currentDevice].systemVersion doubleValue] < 5.0) {
- [tableController viewDidDisappear:animated];
- }
}
- (void)viewDidLoad {
@@ -205,10 +223,10 @@ static UICompositeViewDescription *compositeDescription = nil;
} else {
allButton.selected = FALSE;
}
-
+
if(view == History_Linphone) {
[ContactSelection setSipFilter:[LinphoneManager instance].contactFilter];
- [ContactSelection setEmailFilter:FALSE];
+ [ContactSelection setEmailFilter:FALSE];
[tableController loadData];
linphoneButton.selected = TRUE;
} else {
@@ -265,4 +283,42 @@ static UICompositeViewDescription *compositeDescription = nil;
[[PhoneMainView instance] popCurrentView];
}
+
+#pragma mark - ABPeoplePickerDelegate
+
+-(void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
+{
+ [[PhoneMainView instance] popCurrentView];
+ return;
+}
+
+- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
+ shouldContinueAfterSelectingPerson:(ABRecordRef)person {
+ return true;
+
+}
+
+- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
+ shouldContinueAfterSelectingPerson:(ABRecordRef)person
+ property:(ABPropertyID)property
+ identifier:(ABMultiValueIdentifier)identifier {
+
+ CFTypeRef multiValue = ABRecordCopyValue(person, property);
+ CFIndex valueIdx = ABMultiValueGetIndexForIdentifier(multiValue,identifier);
+ NSString *phoneNumber = (NSString *)ABMultiValueCopyValueAtIndex(multiValue, valueIdx);
+ // Go to dialer view
+ DialerViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[DialerViewController compositeViewDescription]], DialerViewController);
+ if(controller != nil) {
+ [controller call:phoneNumber displayName:(NSString*)ABRecordCopyCompositeName(person)];
+ }
+ [phoneNumber release];
+ CFRelease(multiValue);
+ return false;
+}
+
+
+- (void)viewDidUnload {
+[self setToolBar:nil];
+[super viewDidUnload];
+}
@end
diff --git a/Resources/linphonerc b/Resources/linphonerc
index 992f3b19c..ee656d368 100644
--- a/Resources/linphonerc
+++ b/Resources/linphonerc
@@ -26,6 +26,7 @@ upload_bw=380
rotation_preference=auto
animations_preference=1
edge_opt_preference=0
+use_system_contacts=0
[default_values]
reg_expires=600
\ No newline at end of file
diff --git a/Resources/linphonerc~ipad b/Resources/linphonerc~ipad
index cf9188553..a0164663f 100644
--- a/Resources/linphonerc~ipad
+++ b/Resources/linphonerc~ipad
@@ -26,6 +26,7 @@ upload_bw=512
rotation_preference=auto
animations_preference=1
edge_opt_preference=0
+use_system_contacts=0
[default_values]
reg_expires=600