Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhilash S T P authored and Abhilash S T P committed Apr 14, 2014
1 parent 3f351e6 commit e96cf0c
Show file tree
Hide file tree
Showing 312 changed files with 82,640 additions and 18 deletions.
523 changes: 523 additions & 0 deletions Tesseract BizScanner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file added Tesseract BizScanner/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tesseract BizScanner/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tesseract BizScanner/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tesseract BizScanner/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tesseract BizScanner/5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tesseract BizScanner/6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tesseract BizScanner/7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tesseract BizScanner/8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Tesseract BizScanner/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//

#import <UIKit/UIKit.h>

#import "TesseractSettingsModel.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property TesseractSettingsModel *settingsModel;
@end
1 change: 1 addition & 0 deletions Tesseract BizScanner/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.settingsModel = [[TesseractSettingsModel alloc]init];
return YES;
}

Expand Down
438 changes: 428 additions & 10 deletions Tesseract BizScanner/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Tesseract BizScanner/CameraViewController.h
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
60 changes: 60 additions & 0 deletions Tesseract BizScanner/CameraViewController.m
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
16 changes: 16 additions & 0 deletions Tesseract BizScanner/ContactsViewController.h
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
203 changes: 203 additions & 0 deletions Tesseract BizScanner/ContactsViewController.m
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
14 changes: 14 additions & 0 deletions Tesseract BizScanner/DetailSettingsViewController.h
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
55 changes: 55 additions & 0 deletions Tesseract BizScanner/DetailSettingsViewController.m
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
Loading

0 comments on commit e96cf0c

Please sign in to comment.