-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Abhilash S T P
authored and
Abhilash S T P
committed
Apr 14, 2014
1 parent
3f351e6
commit e96cf0c
Showing
312 changed files
with
82,640 additions
and
18 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// CameraViewController.h | ||
// Tesseract BizScanner | ||
// | ||
// Created by Abhilash S T P on 3/31/14. | ||
// Copyright (c) 2014 Abhilash S T P. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface CameraViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// CameraViewController.m | ||
// Tesseract BizScanner | ||
// | ||
// Created by Abhilash S T P on 3/31/14. | ||
// Copyright (c) 2014 Abhilash S T P. All rights reserved. | ||
// | ||
|
||
#import "CameraViewController.h" | ||
|
||
@interface CameraViewController () | ||
|
||
@end | ||
|
||
@implementation CameraViewController | ||
|
||
- (void)viewWillAppear:(BOOL)animated | ||
{ | ||
self.tabBarController.selectedIndex = 1; | ||
} | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view. | ||
|
||
[self openCamera]; | ||
} | ||
|
||
- (void)openCamera | ||
{ | ||
NSLog(@"Boom Camera Opened!"); | ||
UIImagePickerController *imgPicker = [UIImagePickerController new]; | ||
imgPicker.delegate = self; | ||
|
||
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) | ||
{ | ||
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera; | ||
[self presentViewController:imgPicker animated:YES completion:nil]; | ||
} | ||
} | ||
|
||
- (void)didReceiveMemoryWarning | ||
{ | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
/* | ||
#pragma mark - Navigation | ||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | ||
{ | ||
// Get the new view controller using [segue destinationViewController]. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// ContactsViewController.h | ||
// Tesseract BizScanner | ||
// | ||
// Created by Abhilash S T P on 4/7/14. | ||
// Copyright (c) 2014 Abhilash S T P. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
@import AddressBook; | ||
@import AddressBookUI; | ||
@interface ContactsViewController : UIViewController | ||
- (IBAction)saveNewContact:(id)sender; | ||
- (IBAction)cancelContact:(id)sender; | ||
- (ABRecordRef)newContact:(NSMutableArray *)contactData; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
// | ||
// ContactsViewController.m | ||
// Tesseract BizScanner | ||
// | ||
// Created by Abhilash S T P on 4/7/14. | ||
// Copyright (c) 2014 Abhilash S T P. All rights reserved. | ||
// | ||
|
||
#import "ContactsViewController.h" | ||
|
||
@interface ContactsViewController () | ||
|
||
@end | ||
|
||
@implementation ContactsViewController | ||
|
||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil | ||
{ | ||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | ||
if (self) { | ||
// Custom initialization | ||
} | ||
return self; | ||
} | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view. | ||
|
||
} | ||
|
||
- (void)didReceiveMemoryWarning | ||
{ | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
/* | ||
#pragma mark - Navigation | ||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | ||
{ | ||
// Get the new view controller using [segue destinationViewController]. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
- (ABRecordRef)newContact:(NSMutableArray *)contactData | ||
{ | ||
CFErrorRef error = nil; | ||
ABAddressBookRef iPhoneAddressBook = ABAddressBookCreateWithOptions(nil, &error); | ||
|
||
ABRecordRef newPerson = ABPersonCreate(); | ||
ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType); | ||
NSRegularExpression *regularExpression = nil; | ||
NSTextCheckingResult *match = nil; | ||
for(int i=0;i<contactData.count;i++) | ||
{ | ||
|
||
switch (i) { | ||
case 0: | ||
{ | ||
NSLog(@"%@",contactData[i]); | ||
NSArray *names = [contactData[i] componentsSeparatedByString:@" "]; | ||
ABRecordSetValue(newPerson, kABPersonFirstNameProperty,(__bridge CFStringRef)names[0], &error); | ||
ABRecordSetValue(newPerson, kABPersonLastNameProperty,(__bridge CFStringRef)names[1], &error); | ||
break; | ||
} | ||
case 1: | ||
{ | ||
NSLog(@"%@",contactData[i]); | ||
regularExpression = [NSRegularExpression regularExpressionWithPattern:@"[(\\d)]+[ ]+[\\d-]+" options:NSRegularExpressionCaseInsensitive error:NULL]; | ||
match = [regularExpression firstMatchInString:contactData[i] options:0 range:NSMakeRange(0, [contactData[i] length])]; | ||
NSString *phoneNumber = [contactData[i] substringWithRange:[match rangeAtIndex:0]]; | ||
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, (__bridge CFTypeRef)(phoneNumber),kABWorkLabel,NULL); | ||
break; | ||
} | ||
case 2: | ||
{ | ||
NSLog(@"%@",contactData[i]); | ||
regularExpression = [NSRegularExpression regularExpressionWithPattern:@"[(\\d)]+[ ]+[\\d-]+" options:NSRegularExpressionCaseInsensitive error:NULL]; | ||
|
||
match = [regularExpression firstMatchInString:contactData[i] options:0 range:NSMakeRange(0, [contactData[i] length])]; | ||
NSString *faxNumber = [contactData[i] substringWithRange:[match rangeAtIndex:0]]; | ||
|
||
ABMultiValueAddValueAndLabel(phoneNumberMultiValue, (__bridge CFTypeRef)(faxNumber), kABPersonPhoneWorkFAXLabel, NULL); | ||
break; | ||
} | ||
case 3: | ||
{ | ||
NSLog(@"%@",contactData[i]); | ||
regularExpression = [NSRegularExpression regularExpressionWithPattern:@"[a-zA-Z]+_[a-zA-Z]+@[a-z]+.[a-z]{3}" options:NSRegularExpressionCaseInsensitive error:NULL]; | ||
|
||
match = [regularExpression firstMatchInString:contactData[i] options:0 range:NSMakeRange(0, [contactData[i] length])]; | ||
NSString *email = [contactData[i] substringWithRange:[match rangeAtIndex:0]]; | ||
ABMutableMultiValueRef emailMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType); | ||
ABMultiValueAddValueAndLabel(emailMultiValue, (__bridge CFTypeRef)(email), kABWorkLabel, NULL); | ||
ABRecordSetValue(newPerson, kABPersonEmailProperty,emailMultiValue, &error); | ||
break; | ||
} | ||
case 4: | ||
{ | ||
NSLog(@"%@",contactData[i]); | ||
regularExpression = [NSRegularExpression regularExpressionWithPattern:@"[([w]{3})+.[a-zA-Z]+.[a-z]{3}" options:NSRegularExpressionCaseInsensitive error:NULL]; | ||
|
||
match = [regularExpression firstMatchInString:contactData[i] options:0 range:NSMakeRange(0, [contactData[i] length])]; | ||
NSString *url = [contactData[i] substringWithRange:[match rangeAtIndex:0]]; | ||
ABMutableMultiValueRef urlMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType); | ||
ABMultiValueAddValueAndLabel(urlMultiValue, (__bridge CFTypeRef)(url), kABPersonHomePageLabel, NULL); | ||
ABRecordSetValue(newPerson, kABPersonURLProperty,urlMultiValue, &error); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
|
||
} | ||
|
||
// else if([addressFields rangeOfString:@"Phone" options:NSCaseInsensitiveSearch].location != NSNotFound) | ||
// { | ||
// NSLog(@"%@",addressFields); | ||
// NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:@"[(\\d)]+[ ]+[\\d-]+" options:NSRegularExpressionCaseInsensitive error:NULL]; | ||
// | ||
// NSTextCheckingResult *match = [regularExpression firstMatchInString:addressFields options:0 range:NSMakeRange(0, [addressFields length])]; | ||
// NSString *phoneNumber = [addressFields substringWithRange:[match rangeAtIndex:0]]; | ||
// | ||
// | ||
// ABMultiValueAddValueAndLabel(phoneNumberMultiValue, (__bridge CFTypeRef)(phoneNumber), kABPersonPhoneMobileLabel, NULL); | ||
// | ||
// } | ||
// else if ([addressFields rangeOfString:@"Fax" options:NSCaseInsensitiveSearch].location != NSNotFound) | ||
// { | ||
// NSLog(@"%@",addressFields); | ||
// NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:@"[(\\d)]+[ ]+[\\d-]+" options:NSRegularExpressionCaseInsensitive error:NULL]; | ||
// | ||
// NSTextCheckingResult *match = [regularExpression firstMatchInString:addressFields options:0 range:NSMakeRange(0, [addressFields length])]; | ||
// NSString *faxNumber = [addressFields substringWithRange:[match rangeAtIndex:0]]; | ||
// | ||
// ABMultiValueAddValueAndLabel(phoneNumberMultiValue, (__bridge CFTypeRef)(faxNumber), kABPersonPhoneWorkFAXLabel, NULL); | ||
// | ||
// } | ||
// else if ([addressFields rangeOfString:@"@" options:NSCaseInsensitiveSearch].location != NSNotFound) | ||
// { | ||
// NSLog(@"%@",addressFields); | ||
// NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:@"[a-zA-Z]+_[a-zA-Z]+@[a-z]+.[a-z]{3}" options:NSRegularExpressionCaseInsensitive error:NULL]; | ||
// | ||
// NSTextCheckingResult *match = [regularExpression firstMatchInString:addressFields options:0 range:NSMakeRange(0, [addressFields length])]; | ||
// NSString *email = [addressFields substringWithRange:[match rangeAtIndex:0]]; | ||
// ABMutableMultiValueRef emailMultiValue = ABMultiValueCreateMutable(kABMultiStringPropertyType); | ||
// ABMultiValueAddValueAndLabel(emailMultiValue, (__bridge CFTypeRef)(email), kABWorkLabel, NULL); | ||
// ABRecordSetValue(newPerson, kABPersonEmailProperty,emailMultiValue, &error); | ||
// } | ||
//} | ||
|
||
ABRecordSetValue(newPerson, kABPersonPhoneProperty,phoneNumberMultiValue, &error); | ||
|
||
//ABRecordSetValue(newPerson, kABPersonFirstNameProperty,(__bridge CFStringRef)name, &error); | ||
//ABRecordSetValue(newPerson, kABPersonLastNameProperty, people.lastname, &error); | ||
//ABAddressBookAddRecord(iPhoneAddressBook, newPerson, &error); | ||
|
||
|
||
//CFRelease(newPerson); | ||
CFRelease(iPhoneAddressBook); | ||
|
||
return newPerson; | ||
|
||
} | ||
- (IBAction)saveNewContact:(id)sender { | ||
NSLog(@"boom"); | ||
CFErrorRef error = nil; | ||
ABAddressBookRef iPhoneAddressBook = ABAddressBookCreateWithOptions(nil, &error); | ||
if (nil == iPhoneAddressBook) { | ||
NSLog(@"error: %@", error); | ||
return; | ||
} | ||
ABAuthorizationStatus stat = ABAddressBookGetAuthorizationStatus(); | ||
if (stat==kABAuthorizationStatusDenied || | ||
stat==kABAuthorizationStatusRestricted) { | ||
NSLog(@"%@", @"no access"); | ||
return; | ||
} | ||
|
||
ABRecordRef newPerson = ABPersonCreate(); | ||
|
||
ABRecordSetValue(newPerson, kABPersonFirstNameProperty, CFSTR("Boom"), &error); | ||
//ABRecordSetValue(newPerson, kABPersonLastNameProperty, people.lastname, &error); | ||
ABAddressBookAddRecord(iPhoneAddressBook, newPerson, &error); | ||
|
||
ABAddressBookSave(iPhoneAddressBook, &error); | ||
CFRelease(newPerson); | ||
CFRelease(iPhoneAddressBook); | ||
if (error != NULL) | ||
{ | ||
CFStringRef errorDesc = CFErrorCopyDescription(error); | ||
NSLog(@"Contact not saved: %@", errorDesc); | ||
CFRelease(errorDesc); | ||
} | ||
} | ||
|
||
- (IBAction)cancelContact:(id)sender { | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// DetailSettingsViewController.h | ||
// Tesseract BizScanner | ||
// | ||
// Created by Abhilash S T P on 4/4/14. | ||
// Copyright (c) 2014 Abhilash S T P. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface DetailSettingsViewController : UIViewController | ||
@property (weak, nonatomic) IBOutlet UITextView *detailSettingsText; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// DetailSettingsViewController.m | ||
// Tesseract BizScanner | ||
// | ||
// Created by Abhilash S T P on 4/4/14. | ||
// Copyright (c) 2014 Abhilash S T P. All rights reserved. | ||
// | ||
|
||
#import "DetailSettingsViewController.h" | ||
|
||
@interface DetailSettingsViewController () | ||
|
||
@end | ||
|
||
@implementation DetailSettingsViewController | ||
|
||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil | ||
{ | ||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | ||
if (self) { | ||
// Custom initialization | ||
} | ||
return self; | ||
} | ||
|
||
- (void)viewWillAppear:(BOOL)animated | ||
{ | ||
self.detailSettingsText.text = @"Tesseract Scanner"; | ||
|
||
} | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view. | ||
} | ||
|
||
- (void)didReceiveMemoryWarning | ||
{ | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
/* | ||
#pragma mark - Navigation | ||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | ||
{ | ||
// Get the new view controller using [segue destinationViewController]. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
|
||
@end |
Oops, something went wrong.