diff --git a/iphone/Barcodes/Barcodes.xcodeproj/project.pbxproj b/iphone/Barcodes/Barcodes.xcodeproj/project.pbxproj index 905ad23ee..d6dea7234 100755 --- a/iphone/Barcodes/Barcodes.xcodeproj/project.pbxproj +++ b/iphone/Barcodes/Barcodes.xcodeproj/project.pbxproj @@ -33,6 +33,24 @@ 1FB432881290295C002D63E8 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4327F1290295C002D63E8 /* MainWindow.xib */; }; 1FB432891290295C002D63E8 /* Message.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1FB432811290295C002D63E8 /* Message.xib */; }; 1FB4352E12904F56002D63E8 /* MessageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FB4352D12904F56002D63E8 /* MessageViewController.m */; }; + 1FB4365712918DA9002D63E8 /* ArchiveController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FB4365412918DA9002D63E8 /* ArchiveController.m */; }; + 1FB4365812918DA9002D63E8 /* Database.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FB4365612918DA9002D63E8 /* Database.m */; }; + 1FB4366512918E90002D63E8 /* business-card.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4365A12918E90002D63E8 /* business-card.png */; }; + 1FB4366612918E90002D63E8 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4365B12918E90002D63E8 /* Default.png */; }; + 1FB4366712918E90002D63E8 /* email.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4365C12918E90002D63E8 /* email.png */; }; + 1FB4366812918E90002D63E8 /* filmroll-2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4365D12918E90002D63E8 /* filmroll-2.png */; }; + 1FB4366912918E90002D63E8 /* link1.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4365E12918E90002D63E8 /* link1.png */; }; + 1FB4366A12918E90002D63E8 /* link2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4365F12918E90002D63E8 /* link2.png */; }; + 1FB4366B12918E90002D63E8 /* map-pin.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4366012918E90002D63E8 /* map-pin.png */; }; + 1FB4366C12918E90002D63E8 /* phone.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4366112918E90002D63E8 /* phone.png */; }; + 1FB4366D12918E90002D63E8 /* photolib.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4366212918E90002D63E8 /* photolib.png */; }; + 1FB4366E12918E90002D63E8 /* sms.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4366312918E90002D63E8 /* sms.png */; }; + 1FB4366F12918E90002D63E8 /* text.png in Resources */ = {isa = PBXBuildFile; fileRef = 1FB4366412918E90002D63E8 /* text.png */; }; + 1FB4367512918F63002D63E8 /* Scan.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FB4367412918F63002D63E8 /* Scan.m */; }; + 1FB4367D12918FAF002D63E8 /* ScanCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FB4367C12918FAF002D63E8 /* ScanCell.m */; }; + 1FB4369612918FF0002D63E8 /* ScanViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FB4369512918FF0002D63E8 /* ScanViewController.m */; }; + 1FB4369A12919014002D63E8 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FB4369912919014002D63E8 /* libsqlite3.dylib */; }; + 1FB436DF129194E7002D63E8 /* scans.db in Resources */ = {isa = PBXBuildFile; fileRef = 1FB436DE129194E7002D63E8 /* scans.db */; }; 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; /* End PBXBuildFile section */ @@ -98,6 +116,29 @@ 1FB4329712902973002D63E8 /* sv */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = sv; path = sv.lproj/Message.xib; sourceTree = ""; }; 1FB4352C12904F56002D63E8 /* MessageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageViewController.h; sourceTree = ""; }; 1FB4352D12904F56002D63E8 /* MessageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageViewController.m; sourceTree = ""; }; + 1FB4365312918DA9002D63E8 /* ArchiveController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArchiveController.h; sourceTree = ""; }; + 1FB4365412918DA9002D63E8 /* ArchiveController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ArchiveController.m; sourceTree = ""; }; + 1FB4365512918DA9002D63E8 /* Database.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Database.h; sourceTree = ""; }; + 1FB4365612918DA9002D63E8 /* Database.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Database.m; sourceTree = ""; }; + 1FB4365A12918E90002D63E8 /* business-card.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "business-card.png"; path = "images/business-card.png"; sourceTree = ""; }; + 1FB4365B12918E90002D63E8 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = images/Default.png; sourceTree = ""; }; + 1FB4365C12918E90002D63E8 /* email.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = email.png; path = images/email.png; sourceTree = ""; }; + 1FB4365D12918E90002D63E8 /* filmroll-2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "filmroll-2.png"; path = "images/filmroll-2.png"; sourceTree = ""; }; + 1FB4365E12918E90002D63E8 /* link1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = link1.png; path = images/link1.png; sourceTree = ""; }; + 1FB4365F12918E90002D63E8 /* link2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = link2.png; path = images/link2.png; sourceTree = ""; }; + 1FB4366012918E90002D63E8 /* map-pin.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "map-pin.png"; path = "images/map-pin.png"; sourceTree = ""; }; + 1FB4366112918E90002D63E8 /* phone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = phone.png; path = images/phone.png; sourceTree = ""; }; + 1FB4366212918E90002D63E8 /* photolib.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = photolib.png; path = images/photolib.png; sourceTree = ""; }; + 1FB4366312918E90002D63E8 /* sms.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = sms.png; path = images/sms.png; sourceTree = ""; }; + 1FB4366412918E90002D63E8 /* text.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = text.png; path = images/text.png; sourceTree = ""; }; + 1FB4367312918F63002D63E8 /* Scan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scan.h; sourceTree = ""; }; + 1FB4367412918F63002D63E8 /* Scan.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Scan.m; sourceTree = ""; }; + 1FB4367B12918FAF002D63E8 /* ScanCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScanCell.h; sourceTree = ""; }; + 1FB4367C12918FAF002D63E8 /* ScanCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScanCell.m; sourceTree = ""; }; + 1FB4369412918FF0002D63E8 /* ScanViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScanViewController.h; sourceTree = ""; }; + 1FB4369512918FF0002D63E8 /* ScanViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScanViewController.m; sourceTree = ""; }; + 1FB4369912919014002D63E8 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; + 1FB436DE129194E7002D63E8 /* scans.db */ = {isa = PBXFileReference; lastKnownFileType = file; path = scans.db; sourceTree = ""; }; 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; 29B97316FDCFA39411CA2CEA /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; @@ -121,6 +162,7 @@ 1FB43100129008B9002D63E8 /* CoreMedia.framework in Frameworks */, 1FB431AB12901D7D002D63E8 /* AddressBook.framework in Frameworks */, 1FB431B112901D8C002D63E8 /* AddressBookUI.framework in Frameworks */, + 1FB4369A12919014002D63E8 /* libsqlite3.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -130,6 +172,16 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + 1FB4369412918FF0002D63E8 /* ScanViewController.h */, + 1FB4369512918FF0002D63E8 /* ScanViewController.m */, + 1FB4367B12918FAF002D63E8 /* ScanCell.h */, + 1FB4367C12918FAF002D63E8 /* ScanCell.m */, + 1FB4367312918F63002D63E8 /* Scan.h */, + 1FB4367412918F63002D63E8 /* Scan.m */, + 1FB4365312918DA9002D63E8 /* ArchiveController.h */, + 1FB4365412918DA9002D63E8 /* ArchiveController.m */, + 1FB4365512918DA9002D63E8 /* Database.h */, + 1FB4365612918DA9002D63E8 /* Database.m */, 1FB4352C12904F56002D63E8 /* MessageViewController.h */, 1FB4352D12904F56002D63E8 /* MessageViewController.m */, 1D3623240D0F684500981E51 /* BarcodesAppDelegate.h */, @@ -168,6 +220,17 @@ 1FB4302D128FFF46002D63E8 /* images */ = { isa = PBXGroup; children = ( + 1FB4365A12918E90002D63E8 /* business-card.png */, + 1FB4365B12918E90002D63E8 /* Default.png */, + 1FB4365C12918E90002D63E8 /* email.png */, + 1FB4365D12918E90002D63E8 /* filmroll-2.png */, + 1FB4365E12918E90002D63E8 /* link1.png */, + 1FB4365F12918E90002D63E8 /* link2.png */, + 1FB4366012918E90002D63E8 /* map-pin.png */, + 1FB4366112918E90002D63E8 /* phone.png */, + 1FB4366212918E90002D63E8 /* photolib.png */, + 1FB4366312918E90002D63E8 /* sms.png */, + 1FB4366412918E90002D63E8 /* text.png */, 1FB4303A129000B4002D63E8 /* ZxingLarge.png */, 1FB4302E128FFF56002D63E8 /* icon.png */, 1FB4302F128FFF56002D63E8 /* icon@2x.png */, @@ -200,6 +263,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 1FB436DE129194E7002D63E8 /* scans.db */, 1FB432751290295C002D63E8 /* About.html */, 1FB432771290295C002D63E8 /* DecoderView.xib */, 1FB432791290295C002D63E8 /* Hints.html */, @@ -228,6 +292,7 @@ 1FB430FF129008B9002D63E8 /* CoreMedia.framework */, 1FB431AA12901D7D002D63E8 /* AddressBook.framework */, 1FB431B012901D8C002D63E8 /* AddressBookUI.framework */, + 1FB4369912919014002D63E8 /* libsqlite3.dylib */, ); name = Frameworks; sourceTree = ""; @@ -314,6 +379,18 @@ 1FB432871290295C002D63E8 /* Localizable.strings in Resources */, 1FB432881290295C002D63E8 /* MainWindow.xib in Resources */, 1FB432891290295C002D63E8 /* Message.xib in Resources */, + 1FB4366512918E90002D63E8 /* business-card.png in Resources */, + 1FB4366612918E90002D63E8 /* Default.png in Resources */, + 1FB4366712918E90002D63E8 /* email.png in Resources */, + 1FB4366812918E90002D63E8 /* filmroll-2.png in Resources */, + 1FB4366912918E90002D63E8 /* link1.png in Resources */, + 1FB4366A12918E90002D63E8 /* link2.png in Resources */, + 1FB4366B12918E90002D63E8 /* map-pin.png in Resources */, + 1FB4366C12918E90002D63E8 /* phone.png in Resources */, + 1FB4366D12918E90002D63E8 /* photolib.png in Resources */, + 1FB4366E12918E90002D63E8 /* sms.png in Resources */, + 1FB4366F12918E90002D63E8 /* text.png in Resources */, + 1FB436DF129194E7002D63E8 /* scans.db in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -328,6 +405,11 @@ 1D3623260D0F684500981E51 /* BarcodesAppDelegate.m in Sources */, 1FB430371290002C002D63E8 /* ZXMainViewController.mm in Sources */, 1FB4352E12904F56002D63E8 /* MessageViewController.m in Sources */, + 1FB4365712918DA9002D63E8 /* ArchiveController.m in Sources */, + 1FB4365812918DA9002D63E8 /* Database.m in Sources */, + 1FB4367512918F63002D63E8 /* Scan.m in Sources */, + 1FB4367D12918FAF002D63E8 /* ScanCell.m in Sources */, + 1FB4369612918FF0002D63E8 /* ScanViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iphone/Barcodes/Classes/ArchiveController.h b/iphone/Barcodes/Classes/ArchiveController.h new file mode 100644 index 000000000..c8ee5e5df --- /dev/null +++ b/iphone/Barcodes/Classes/ArchiveController.h @@ -0,0 +1,41 @@ +// +// ArchiveController.h +// UIShowcase +// +// Created by Christian Brunschen on 29/05/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +//@class DecoderViewController; + +@interface ArchiveController : UITableViewController { + NSMutableArray *scans; + NSMutableArray *results; +// DecoderViewController *decoderViewController; + NSDateFormatter *dateFormatter; +} + +@property (nonatomic, retain) NSMutableArray *scans; +@property (nonatomic, retain) NSMutableArray *results; +//@property (nonatomic, retain) DecoderViewController *decoderViewController; +@property (nonatomic, retain) NSDateFormatter *dateFormatter; + +- (NSInteger)scanIndexForRow:(NSInteger)row; +- (id)init; + +@end diff --git a/iphone/Barcodes/Classes/ArchiveController.m b/iphone/Barcodes/Classes/ArchiveController.m new file mode 100644 index 000000000..eafab1ccd --- /dev/null +++ b/iphone/Barcodes/Classes/ArchiveController.m @@ -0,0 +1,160 @@ +// +// ArchiveController.m +// UIShowcase +// +// Created by Christian Brunschen on 29/05/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "ArchiveController.h" +#import "Database.h" +#import "Scan.h" +#import "ResultParser.h" +#import "ParsedResult.h" +//#import "DecoderViewController.h" +#import "ScanViewController.h" +#import "ScanCell.h" + +@implementation ArchiveController + +@synthesize scans; +@synthesize results; +//@synthesize decoderViewController; +@synthesize dateFormatter; + +- (id)init { + if ((self = [super initWithStyle:UITableViewStylePlain])) { + scans = [[NSMutableArray alloc] init]; + results = [[NSMutableArray alloc] init]; + dateFormatter = [[NSDateFormatter alloc] init]; + } + return self; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return [scans count]; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 44.0; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + static NSString *ScanIdentifier = @"ScanIdentifier"; + + ScanCell *cell = (ScanCell *)[tableView dequeueReusableCellWithIdentifier:ScanIdentifier]; + if (cell == nil) { + cell = [[[ScanCell alloc] initWithFrame:CGRectZero reuseIdentifier:ScanIdentifier] autorelease]; + } + + // Configure the cell + int idx = [self scanIndexForRow:indexPath.row]; + Scan *scan = [scans objectAtIndex:idx]; + [cell setScan:scan]; + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + //[decoderViewController showScan:[scans objectAtIndex:[self scanIndexForRow:indexPath.row]]]; + int idx = [self scanIndexForRow:indexPath.row]; + Scan *scan = [scans objectAtIndex:idx]; + ParsedResult *result = [results objectAtIndex:idx]; + ScanViewController *scanViewController = [[ScanViewController alloc] initWithResult:result forScan:scan]; + [self.navigationController pushViewController:scanViewController animated:YES]; + [scanViewController release]; +} + +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + int idx = [self scanIndexForRow:indexPath.row]; + Scan *scan = [self.scans objectAtIndex:idx]; + // delete the scan from the database ... + [[Database sharedDatabase] deleteScan:scan]; + // ... delete the scan from our in-memory cache of the database ... + [scans removeObjectAtIndex:idx]; + // ... delete the corresponding result from our in-memory cache ... + [results removeObjectAtIndex:idx]; + // ... and remove the row from the table view. + [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + // [tableView reloadData]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // no insertions! + } +} + +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + return YES; +} + +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} + +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + return NO; +} + + +- (void)dealloc { + [scans release]; + [results release]; + //[decoderViewController release]; + [dateFormatter release]; + [super dealloc]; +} + + +- (void)viewDidLoad { + [super viewDidLoad]; + self.title = NSLocalizedString(@"ScanArchiveTitle", @"Scan Archive"); + self.navigationItem.rightBarButtonItem = [self editButtonItem]; +} + + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + self.scans = [NSMutableArray arrayWithArray:[[Database sharedDatabase] scans]]; + self.results = [NSMutableArray arrayWithCapacity:self.scans.count]; + for (Scan *scan in scans) { + [results addObject:[ResultParser parsedResultForString:scan.text]]; + } +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +} + +- (void)viewWillDisappear:(BOOL)animated { + self.scans = nil; + self.results = nil; +} + +- (void)viewDidDisappear:(BOOL)animated { +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +- (NSInteger)scanIndexForRow:(NSInteger)row { + return scans.count - 1 - row; +} + +@end + diff --git a/iphone/Barcodes/Classes/Database.h b/iphone/Barcodes/Classes/Database.h new file mode 100644 index 000000000..38ec771dc --- /dev/null +++ b/iphone/Barcodes/Classes/Database.h @@ -0,0 +1,41 @@ +// +// Database.h +// ZXing +// +// Created by Christian Brunschen on 29/05/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import +#import + +@class Scan; + +@interface Database : NSObject { + sqlite3 *connection; + int nextScanIdent; +} + +@property sqlite3 *connection; +@property int nextScanIdent; + ++ (id)sharedDatabase; + +- (void)addScanWithText:(NSString *)text; +- (NSArray *)scans; +- (void)deleteScan:(Scan *)scan; + +@end diff --git a/iphone/Barcodes/Classes/Database.m b/iphone/Barcodes/Classes/Database.m new file mode 100644 index 000000000..cd4897c63 --- /dev/null +++ b/iphone/Barcodes/Classes/Database.m @@ -0,0 +1,115 @@ +// +// Database.m +// ZXing +// +// Created by Christian Brunschen on 29/05/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "Database.h" +#import "Scan.h" + +@implementation Database + +static sqlite3_stmt *maxIdStatement; +static sqlite3_stmt *selectAllStatement; +static sqlite3_stmt *insertStatement; +static sqlite3_stmt *deleteStatement; + +@synthesize connection; +@synthesize nextScanIdent; + +static Database *sharedDatabase = nil; + ++ (id)sharedDatabase { + if (!sharedDatabase) { + sharedDatabase = [[self alloc] init]; + + BOOL success; + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSError *error; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"scans.db"]; + success = [fileManager fileExistsAtPath:writableDBPath]; + if (!success) { + // The writable database does not exist, so copy the default to the appropriate location. + NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"scans.db"]; + success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error]; + if (!success) { + NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]); + } + } + + sqlite3 *connection; + sqlite3_open([writableDBPath UTF8String], &connection); + sharedDatabase.connection = connection; + + static const char *maxIdSql = "SELECT MAX(id) FROM SCAN"; + sqlite3_prepare_v2(connection, maxIdSql, -1, &maxIdStatement, NULL); + + static const char *selectAllSql = "SELECT id, text, stamp FROM SCAN ORDER BY id"; + sqlite3_prepare_v2(connection, selectAllSql, -1, &selectAllStatement, NULL); + + static const char *insertSql = + "INSERT INTO SCAN (id, text, stamp) VALUES (?, ?, ?)"; + sqlite3_prepare_v2(connection, insertSql, -1, &insertStatement, NULL); + + static const char *deleteSql = "DELETE FROM SCAN WHERE id = ?"; + sqlite3_prepare_v2(connection, deleteSql, -1, &deleteStatement, NULL); + + if (SQLITE_ROW == sqlite3_step(maxIdStatement)) { + int maxId = sqlite3_column_int(maxIdStatement, 0); + sharedDatabase.nextScanIdent = maxId + 1; + sqlite3_reset(maxIdStatement); + } else { + NSLog(@"failed to read max ID from database\n"); + } + + } + return sharedDatabase; +} + +- (void)addScanWithText:(NSString *)text { + sqlite3_bind_int(insertStatement, 1, nextScanIdent++); + sqlite3_bind_text(insertStatement, 2, [text UTF8String], -1, SQLITE_TRANSIENT); + sqlite3_bind_double(insertStatement, 3, [[NSDate date] timeIntervalSince1970]); + sqlite3_step(insertStatement); + sqlite3_reset(insertStatement); +} + +- (NSArray *)scans { + NSMutableArray *scans = [NSMutableArray array]; + while (SQLITE_ROW == sqlite3_step(selectAllStatement)) { + int ident = sqlite3_column_int(selectAllStatement, 0); + NSString *text = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectAllStatement, 1)]; + NSDate *stamp = [NSDate dateWithTimeIntervalSince1970:sqlite3_column_double(selectAllStatement, 2)]; + Scan *scan = [[Scan alloc] initWithIdent:ident text:text stamp:stamp]; + [scans addObject:scan]; + [scan release]; + } + sqlite3_reset(selectAllStatement); + return scans; +} + +- (void)deleteScan:(Scan *)scan { + sqlite3_bind_int(deleteStatement, 1, [scan ident]); + sqlite3_step(deleteStatement); + sqlite3_reset(deleteStatement); +} + + +@end diff --git a/iphone/Barcodes/Classes/Scan.h b/iphone/Barcodes/Classes/Scan.h new file mode 100644 index 000000000..b96d9c95a --- /dev/null +++ b/iphone/Barcodes/Classes/Scan.h @@ -0,0 +1,37 @@ +// +// Scan.h +// ZXing +// +// Created by Christian Brunschen on 29/05/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + + +@interface Scan : NSObject { + NSInteger ident; + NSString *text; + NSDate *stamp; +} + +@property NSInteger ident; +@property (nonatomic, copy) NSString *text; +@property (nonatomic, retain) NSDate *stamp; + +- (id)initWithIdent:(int)i text:(NSString *)t stamp:(NSDate *)s; + +@end diff --git a/iphone/Barcodes/Classes/Scan.m b/iphone/Barcodes/Classes/Scan.m new file mode 100644 index 000000000..6d7b29bf4 --- /dev/null +++ b/iphone/Barcodes/Classes/Scan.m @@ -0,0 +1,40 @@ +// +// Scan.m +// ZXing +// +// Created by Christian Brunschen on 29/05/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "Scan.h" + + +@implementation Scan + +@synthesize ident; +@synthesize text; +@synthesize stamp; + +- (id)initWithIdent:(int)i text:(NSString *)t stamp:(NSDate *)s { + if ((self = [super init]) != nil) { + self.ident = i; + self.text = t; + self.stamp = s; + } + return self; +} + +@end diff --git a/iphone/Barcodes/Classes/ScanCell.h b/iphone/Barcodes/Classes/ScanCell.h new file mode 100644 index 000000000..0860c446c --- /dev/null +++ b/iphone/Barcodes/Classes/ScanCell.h @@ -0,0 +1,42 @@ +// +// ScanCell.h +// ZXing +// +// Created by Christian Brunschen on 30/06/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +@class Scan; +@class ParsedResult; + +@interface ScanCell : UITableViewCell { + Scan *scan; + ParsedResult *result; + UIImageView *imageView; + UILabel *textView; + UILabel *dateView; + UILabel *timeView; +} + +@property (nonatomic, retain) Scan *scan; +@property (nonatomic, retain) UIImageView *imageView; +@property (nonatomic, retain) UILabel *textView; +@property (nonatomic, retain) UILabel *dateView; +@property (nonatomic, retain) UILabel *timeView; + +@end diff --git a/iphone/Barcodes/Classes/ScanCell.m b/iphone/Barcodes/Classes/ScanCell.m new file mode 100644 index 000000000..33eac8690 --- /dev/null +++ b/iphone/Barcodes/Classes/ScanCell.m @@ -0,0 +1,175 @@ +// +// ScanCell.m +// ZXing +// +// Created by Christian Brunschen on 30/06/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "ScanCell.h" +#import "Scan.h" +#import "ParsedResult.h" +#import "ResultParser.h" + +static NSDateFormatter *_makeDateFormatter(NSDateFormatterStyle dateStyle, + NSDateFormatterStyle timeStyle) { + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateStyle:dateStyle]; + [dateFormatter setTimeStyle:timeStyle]; + return dateFormatter; +} + +static NSString *_dateString(NSDate *date) { + static NSDateFormatter *dateFormatter = nil; + if (!dateFormatter) { + dateFormatter = + _makeDateFormatter(NSDateFormatterShortStyle, NSDateFormatterNoStyle); + } + return [dateFormatter stringFromDate:date]; +} + +static NSString *_timeString(NSDate *date) { + static NSDateFormatter *timeFormatter = nil; + if (!timeFormatter) { + timeFormatter = + + _makeDateFormatter(NSDateFormatterNoStyle, NSDateFormatterShortStyle); + } + return [timeFormatter stringFromDate:date]; +} + +#define VIEW_PADDING 2.0 +#define IMAGE_SIZE 40.0 +#define EDITING_INSET 10.0 +#define CONTENT_HEIGHT (IMAGE_SIZE + 2.0 * VIEW_PADDING) +#define DATE_TIME_WIDTH 50.0 + +@implementation ScanCell + +@synthesize imageView; +@synthesize textView; +@synthesize dateView; +@synthesize timeView; + + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { + if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { + imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; + imageView.contentMode = UIViewContentModeCenter; + [self.contentView addSubview:imageView]; + + textView = [[UILabel alloc] initWithFrame:CGRectZero]; + textView.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; + textView.textAlignment = UITextAlignmentLeft; + textView.textColor = [UIColor blackColor]; + [self.contentView addSubview:textView]; + + dateView = [[UILabel alloc] initWithFrame:CGRectZero]; + dateView.font = [UIFont systemFontOfSize:(2 * [UIFont systemFontSize]) / 3]; + dateView.textAlignment = UITextAlignmentRight; + dateView.textColor = [UIColor grayColor]; + [self.contentView addSubview:dateView]; + + timeView = [[UILabel alloc] initWithFrame:CGRectZero]; + timeView.font = [UIFont systemFontOfSize:(2 * [UIFont systemFontSize]) / 3]; + timeView.textAlignment = UITextAlignmentRight; + timeView.textColor = [UIColor grayColor]; + [self.contentView addSubview:timeView]; + } + return self; +} + +- (CGRect) _imageViewFrame { + CGRect frame = CGRectMake(VIEW_PADDING, VIEW_PADDING, IMAGE_SIZE, IMAGE_SIZE); + if (self.editing) { + frame.origin.x += EDITING_INSET; + } + return frame; +} + +- (CGRect) _textViewFrame { + CGRect frame = CGRectMake(2 * VIEW_PADDING + IMAGE_SIZE, VIEW_PADDING, self.contentView.bounds.size.width - IMAGE_SIZE - DATE_TIME_WIDTH - 3 * VIEW_PADDING, CONTENT_HEIGHT - 2 * VIEW_PADDING); + if (self.editing) { + frame.origin.x += EDITING_INSET; + frame.size.width += DATE_TIME_WIDTH + VIEW_PADDING - EDITING_INSET; + } + return frame; +} + +- (CGRect) _timeViewFrame { + float x = CGRectGetMaxX(self.contentView.bounds) - DATE_TIME_WIDTH - VIEW_PADDING; + CGRect frame = CGRectMake(x, VIEW_PADDING, DATE_TIME_WIDTH, (CONTENT_HEIGHT - 2 * VIEW_PADDING) / 2); + return frame; +} + +- (CGRect) _dateViewFrame { + float x = CGRectGetMaxX(self.contentView.bounds) - DATE_TIME_WIDTH - VIEW_PADDING; + CGRect frame = CGRectMake(x, (CONTENT_HEIGHT - 2 * VIEW_PADDING) / 2, DATE_TIME_WIDTH, (CONTENT_HEIGHT - 2 * VIEW_PADDING) / 2); + return frame; +} + + +- (void)layoutSubviews { + [super layoutSubviews]; + + [imageView setFrame:[self _imageViewFrame]]; + [textView setFrame:[self _textViewFrame]]; + [dateView setFrame:[self _dateViewFrame]]; + [timeView setFrame:[self _timeViewFrame]]; + if (self.editing) { + dateView.alpha = 0.0; + timeView.alpha = 0.0; + } else { + dateView.alpha = 1.0; + timeView.alpha = 1.0; + } +} + + + +- (void)setScan:(Scan *)newScan { + if (newScan != scan) { + [newScan retain]; + [scan release]; + scan = newScan; + [result release]; + result = [[ResultParser parsedResultForString:[scan text]] retain]; + + imageView.image = [result icon]; + textView.text = [result stringForDisplay]; + + NSDate *date = [scan stamp]; + dateView.text = _dateString(date); + timeView.text = _timeString(date); + } +} + +- (Scan *)scan { + return scan; +} + +- (void)dealloc { + [imageView release]; + [textView release]; + [dateView release]; + [timeView release]; + [scan release]; + [result release]; + [super dealloc]; +} + + +@end diff --git a/iphone/Barcodes/Classes/ScanViewController.h b/iphone/Barcodes/Classes/ScanViewController.h new file mode 100644 index 000000000..7a8eaafe4 --- /dev/null +++ b/iphone/Barcodes/Classes/ScanViewController.h @@ -0,0 +1,39 @@ +// +// ScanViewController.h +// ZXing +// +// Created by Christian Brunschen on 24/06/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import +#import "Scan.h" +#import "ParsedResult.h" + +@interface ScanViewController : UITableViewController { + IBOutlet ParsedResult *result; + IBOutlet Scan *scan; + UIFont *bodyFont; + NSDateFormatter *dateFormatter; +} + +@property (nonatomic, retain) ParsedResult *result; +@property (nonatomic, retain) Scan *scan; +@property (nonatomic, retain) NSDateFormatter *dateFormatter; + +- (id)initWithResult:(ParsedResult *)r forScan:(Scan *)s; + +@end diff --git a/iphone/Barcodes/Classes/ScanViewController.m b/iphone/Barcodes/Classes/ScanViewController.m new file mode 100644 index 000000000..ee40cc92d --- /dev/null +++ b/iphone/Barcodes/Classes/ScanViewController.m @@ -0,0 +1,255 @@ +// +// ScanViewController.m +// ZXing +// +// Created by Christian Brunschen on 24/06/2008. +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "ScanViewController.h" +#import "ResultAction.h" + + +#define TEXT_VIEW_TAG 0x17 +#define DATETIME_VIEW_TAG 0x18 +#define BUTTON_LABEL_TAG 0x19 +#define TITLE_HEIGHT 44 +#define BODY_HEIGHT 88 + +@implementation ScanViewController + +@synthesize result; +@synthesize scan; +@synthesize dateFormatter; + +#define FONT_NAME @"TimesNewRomanPSMT" +#define FONT_SIZE 16 + +- (id)initWithResult:(ParsedResult *)r forScan:(Scan *)s { + if ((self = [super initWithStyle:UITableViewStyleGrouped])) { + self.result = r; + self.scan = s; + self.title = NSLocalizedString(@"ScanViewController title", @"Scan"); + dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateStyle:NSDateFormatterLongStyle]; + [dateFormatter setTimeStyle:NSDateFormatterLongStyle]; + bodyFont = [[UIFont fontWithName:FONT_NAME size:FONT_SIZE] retain]; + } + return self; +} + + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return [[result actions] count] ? 2 : 1; +} + + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + switch (section) { + case 0: + return 3; + case 1: + return [[result actions] count]; + default: + return 0; + } +} + +- (UITableViewCell *)cellWithIdentifier:(NSString *)identifier inTableView:(UITableView *)tableView { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:identifier] autorelease]; + } + return cell; +} + +- (UITableViewCell *)titleCellInTableView:(UITableView *)tableView { + static NSString *TitleIdentifier = @"ScanViewTitleIdentifier"; + return [self cellWithIdentifier:TitleIdentifier inTableView:tableView]; +} + +- (UITableViewCell *)datetimeCellInTableView:(UITableView *)tableView { + static NSString *DatetimeIdentifier = @"ScanViewDatetimeIdentifier"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DatetimeIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 34) reuseIdentifier:DatetimeIdentifier] autorelease]; + UILabel *label = [cell textLabel]; + label.font = [UIFont systemFontOfSize:[UIFont systemFontSize] * 2.0 / 3.0]; + label.textColor = [UIColor grayColor]; + label.textAlignment = UITextAlignmentCenter; + } + return cell; +} + +- (UITableViewCell *)bodyCellInTableView:(UITableView *)tableView { + static NSString *BodyIdentifier = @"ScanViewBodyIdentifier"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:BodyIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, BODY_HEIGHT) reuseIdentifier:BodyIdentifier] autorelease]; + UITextView *textView = [[UITextView alloc] initWithFrame:CGRectInset(cell.contentView.bounds, 6, 6)]; + textView.font = bodyFont; + [textView setTag:TEXT_VIEW_TAG]; + textView.editable = NO; + [textView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; + [cell.contentView addSubview:textView]; + [textView release]; + } + return cell; +} + +- (UITableViewCell *)buttonCellInTableView:(UITableView *)tableView { + static NSString *ButtonIdentifier = @"ScanViewButtonIdentifier"; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ButtonIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 44) reuseIdentifier:ButtonIdentifier] autorelease]; + UILabel *label = [[UILabel alloc] initWithFrame:CGRectInset(cell.contentView.bounds, 6, 6)]; + label.font = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]]; + [label setTag:BUTTON_LABEL_TAG]; + label.lineBreakMode = UILineBreakModeMiddleTruncation; + label.textColor = [UIColor grayColor]; + label.textAlignment = UITextAlignmentCenter; + [label setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; + [cell.contentView addSubview:label]; + [label release]; + } + return cell; +} + +#define TEXT_VIEW_HEIGHT 330.0 + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + if (indexPath.section == 0) { + if (indexPath.row == 0) { + return TITLE_HEIGHT; + } else if (indexPath.row == 1) { + CGSize size = [[result stringForDisplay] sizeWithFont:bodyFont constrainedToSize:CGSizeMake(280.0, TEXT_VIEW_HEIGHT) lineBreakMode:UILineBreakModeWordWrap]; +#ifdef DEBUG + NSLog(@"text size = %f", size.height); +#endif + return fminf(TEXT_VIEW_HEIGHT, fmaxf(44, size.height + 24)); + } else if (indexPath.row == 2) { + return 24.0; + } + } + return tableView.rowHeight; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell; + + if (indexPath.section == 0) { + if (indexPath.row == 0) { + cell = [self titleCellInTableView:tableView]; + UIImageView *imageView = cell.imageView; + imageView.image = [result icon]; + UILabel *textLabel = cell.textLabel; + textLabel.text = [[result class] typeName]; + } else if (indexPath.row == 1) { + cell = [self bodyCellInTableView:tableView]; + UITextView *textView = (UITextView *)[cell viewWithTag:TEXT_VIEW_TAG]; + textView.text = [result stringForDisplay]; + } else if (indexPath.row == 2) { + cell = [self datetimeCellInTableView:tableView]; + UILabel *textLabel = cell.textLabel; + textLabel.text = [dateFormatter stringFromDate:[scan stamp]]; + } + } else if (indexPath.section == 1) { + cell = [self buttonCellInTableView:tableView]; + ResultAction *action = [[result actions] objectAtIndex:indexPath.row]; + UILabel *label = (UILabel *)[cell viewWithTag:BUTTON_LABEL_TAG]; + label.text = [action title]; + } + + return cell; +} + +- (void)performAction:(ResultAction *)action { + [action performActionWithController:self shouldConfirm:NO]; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (indexPath.section == 1) { + ResultAction *action = [[result actions] objectAtIndex:indexPath.row]; + [self performSelector:@selector(performAction:) withObject:action afterDelay:0.0]; + } +} + +/* +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + + if (editingStyle == UITableViewCellEditingStyleDelete) { + } + if (editingStyle == UITableViewCellEditingStyleInsert) { + } +} +*/ + +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + return NO; +} + +/* +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + return NO; +} + +- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (indexPath.section != 1) { + return nil; + } + return indexPath; +} + + +- (void)dealloc { + [result release]; + [scan release]; + [bodyFont release]; + [dateFormatter release]; + [super dealloc]; +} + + +- (void)viewDidLoad { + [super viewDidLoad]; +} + + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +} + +- (void)viewWillDisappear:(BOOL)animated { +} + +- (void)viewDidDisappear:(BOOL)animated { +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + + +@end + diff --git a/iphone/Barcodes/Classes/ZXMainViewController.h b/iphone/Barcodes/Classes/ZXMainViewController.h index cf948a345..5caac0c7a 100644 --- a/iphone/Barcodes/Classes/ZXMainViewController.h +++ b/iphone/Barcodes/Classes/ZXMainViewController.h @@ -26,6 +26,7 @@ - (IBAction)scan:(id)sender; - (IBAction)info:(id)sender; +- (IBAction)showArchive:(id)sender; - (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result; - (void)zxingControllerDidCancel:(ZXingWidgetController*)controller; diff --git a/iphone/Barcodes/Classes/ZXMainViewController.mm b/iphone/Barcodes/Classes/ZXMainViewController.mm index 3c2a5f408..cb2f911ea 100644 --- a/iphone/Barcodes/Classes/ZXMainViewController.mm +++ b/iphone/Barcodes/Classes/ZXMainViewController.mm @@ -11,6 +11,8 @@ #import #import #import +#import "ArchiveController.h" +#import "Database.h" @implementation ZXMainViewController @synthesize resultParser; @@ -84,6 +86,14 @@ [aboutController release]; } +- (IBAction)showArchive:(id)sender { + ArchiveController *archiveController = [[ArchiveController alloc] init]; + UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:archiveController]; + [self presentModalViewController:navController animated:YES]; + [navController release]; + [archiveController release]; +} + - (void)messageViewControllerWantsToBeDispissed:(MessageViewController *)controller { [self dismissModalViewControllerAnimated:YES]; } @@ -120,6 +130,7 @@ #ifdef DEBUG NSLog(@"result has %d actions", actions ? 0 : actions.count); #endif + [[Database sharedDatabase] addScanWithText:resultString]; [self performResultAction]; } diff --git a/iphone/Barcodes/Classes/ZXMainViewController.xib b/iphone/Barcodes/Classes/ZXMainViewController.xib index eb37f1fc6..43a5b8523 100644 --- a/iphone/Barcodes/Classes/ZXMainViewController.xib +++ b/iphone/Barcodes/Classes/ZXMainViewController.xib @@ -107,6 +107,25 @@ MC41AA + + + 292 + {{96, 412}, {128, 28}} + + NO + IBCocoaTouchFramework + 0 + 0 + + 1 + Archives + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 292 @@ -166,6 +185,15 @@ 9 + + + showArchive: + + + 7 + + 14 + @@ -182,9 +210,10 @@ YES - - + + + @@ -205,8 +234,13 @@ - 5 - + 8 + + + + + 10 + @@ -215,8 +249,8 @@ - 8 - + 5 + @@ -229,6 +263,8 @@ -2.CustomClassName 1.IBEditorWindowLastContentRect 1.IBPluginDependency + 10.IBPluginDependency + 10.IBViewBoundsToFrameTransform 4.IBPluginDependency 4.IBViewBoundsToFrameTransform 5.IBPluginDependency @@ -242,19 +278,23 @@ YES ZXMainViewController UIResponder - {{184, 249}, {320, 480}} + {{298, 248}, {320, 480}} com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + AULAAABDzgAAA + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin P4AAAL+AAABCoAAAwzYAAA com.apple.InterfaceBuilder.IBCocoaTouchPlugin - P4AAAL+AAABCzAAAwgAAAA + AUKIAABB8AAAA com.apple.InterfaceBuilder.IBCocoaTouchPlugin - P4AAAL+AAABC+AAAw5CAAA + AULAAABDcAAAA com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -278,7 +318,7 @@ - 9 + 14 @@ -292,11 +332,13 @@ YES info: scan: + showArchive: YES id id + id @@ -305,6 +347,7 @@ YES info: scan: + showArchive: YES @@ -316,6 +359,10 @@ scan: id + + showArchive: + id + diff --git a/iphone/Barcodes/images/Default.png b/iphone/Barcodes/images/Default.png new file mode 100644 index 000000000..11cc0db55 Binary files /dev/null and b/iphone/Barcodes/images/Default.png differ diff --git a/iphone/Barcodes/images/Default@2x.png b/iphone/Barcodes/images/Default@2x.png new file mode 100644 index 000000000..f782ed9ae Binary files /dev/null and b/iphone/Barcodes/images/Default@2x.png differ diff --git a/iphone/Barcodes/images/business-card.png b/iphone/Barcodes/images/business-card.png new file mode 100644 index 000000000..1cf65fcbf Binary files /dev/null and b/iphone/Barcodes/images/business-card.png differ diff --git a/iphone/Barcodes/images/email.png b/iphone/Barcodes/images/email.png new file mode 100644 index 000000000..5043c64d8 Binary files /dev/null and b/iphone/Barcodes/images/email.png differ diff --git a/iphone/Barcodes/images/filmroll-2.png b/iphone/Barcodes/images/filmroll-2.png new file mode 100644 index 000000000..e44f47a98 Binary files /dev/null and b/iphone/Barcodes/images/filmroll-2.png differ diff --git a/iphone/Barcodes/images/link1.png b/iphone/Barcodes/images/link1.png new file mode 100644 index 000000000..2759a3512 Binary files /dev/null and b/iphone/Barcodes/images/link1.png differ diff --git a/iphone/Barcodes/images/link2.png b/iphone/Barcodes/images/link2.png new file mode 100644 index 000000000..0c3463f70 Binary files /dev/null and b/iphone/Barcodes/images/link2.png differ diff --git a/iphone/Barcodes/images/map-pin.png b/iphone/Barcodes/images/map-pin.png new file mode 100644 index 000000000..7cf2b8207 Binary files /dev/null and b/iphone/Barcodes/images/map-pin.png differ diff --git a/iphone/Barcodes/images/phone.png b/iphone/Barcodes/images/phone.png new file mode 100644 index 000000000..b473d8fb0 Binary files /dev/null and b/iphone/Barcodes/images/phone.png differ diff --git a/iphone/Barcodes/images/photolib.png b/iphone/Barcodes/images/photolib.png new file mode 100644 index 000000000..6f330c5cb Binary files /dev/null and b/iphone/Barcodes/images/photolib.png differ diff --git a/iphone/Barcodes/images/sms.png b/iphone/Barcodes/images/sms.png new file mode 100644 index 000000000..0850635a0 Binary files /dev/null and b/iphone/Barcodes/images/sms.png differ diff --git a/iphone/Barcodes/images/text.png b/iphone/Barcodes/images/text.png new file mode 100644 index 000000000..ff9a8b7cc Binary files /dev/null and b/iphone/Barcodes/images/text.png differ diff --git a/iphone/Barcodes/scans.db b/iphone/Barcodes/scans.db new file mode 100644 index 000000000..c3563f9f6 Binary files /dev/null and b/iphone/Barcodes/scans.db differ