[iphone/barcodes] result is not shown in main view in a pretty way. It uses the same simple techniques than scanView for the archive

git-svn-id: https://zxing.googlecode.com/svn/trunk@1661 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
rpechayr 2010-11-17 19:38:08 +00:00
parent 207b5e294d
commit d7269e2fd2
5 changed files with 27 additions and 24 deletions

View file

@ -565,7 +565,7 @@
);
PREBINDING = NO;
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "6B49E4AA-03F0-4CBB-80B6-5987C7E23569";
SDKROOT = iphoneos;
SDKROOT = iphoneos4.2;
};
name = Debug;
};

View file

@ -22,7 +22,7 @@
#import "ArchiveController.h"
#import "Database.h"
#import "Scan.h"
#import "ResultParser.h"
#import "UniversalResultParser.h"
#import "ParsedResult.h"
#import "ScanViewController.h"
#import "ScanCell.h"
@ -128,7 +128,8 @@
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]];
ParsedResult *res = [UniversalResultParser parsedResultForString:scan.text];
[results addObject:res];
}
}
@ -142,7 +143,7 @@
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]];
[results addObject:[UniversalResultParser parsedResultForString:scan.text]];
}
}

View file

@ -23,6 +23,7 @@
#import "Scan.h"
#import "ParsedResult.h"
#import "ResultParser.h"
#import "UniversalResultParser.h"
static NSDateFormatter *_makeDateFormatter(NSDateFormatterStyle dateStyle,
NSDateFormatterStyle timeStyle) {
@ -146,7 +147,7 @@ static NSString *_timeString(NSDate *date) {
[scan release];
scan = newScan;
[result release];
result = [[ResultParser parsedResultForString:[scan text]] retain];
result = [[UniversalResultParser parsedResultForString:[scan text]] retain];
imageView.image = [result icon];
textView.text = [result stringForDisplay];

View file

@ -16,13 +16,11 @@
@interface ZXMainViewController : UIViewController <ZXingDelegate,UIActionSheetDelegate,ModalViewControllerDelegate> {
UniversalResultParser *resultParser;
NSArray *actions;
ParsedResult *result;
IBOutlet UITextView *resultView;
}
@property (nonatomic,retain) UniversalResultParser *resultParser;
@property (nonatomic,assign) NSArray *actions;
@property (nonatomic,assign) ParsedResult *result;
@property (nonatomic,retain) IBOutlet UITextView *resultView;
@ -34,6 +32,8 @@
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result;
- (void)zxingControllerDidCancel:(ZXingWidgetController*)controller;
- (void)performResultAction;
- (void)setResultViewWithText:(NSString*)theResult;
@end

View file

@ -15,7 +15,7 @@
#import "Database.h"
@implementation ZXMainViewController
@synthesize resultParser;
//@synthesize resultParser;
@synthesize actions;
@synthesize result;
@synthesize resultView;
@ -35,13 +35,12 @@
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
UniversalResultParser *parser = [[UniversalResultParser alloc] initWithDefaultParsers];
self.resultParser = parser;
[parser release];
NSString *lastResult = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastScan"];
if (!lastResult) lastResult = NSLocalizedString(@"MainViewLatestResultDefault",@"Last result will appear here once you have scanned a barcode at least once");
self.resultView.text = (NSString*)[[NSUserDefaults standardUserDefaults] objectForKey:@"lastScan"];
//UniversalResultParser *parser = [[UniversalResultParser alloc] initWithDefaultParsers];
//self.resultParser = parser;
// [parser release];
NSString *rawLatestResult = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastScan"];
if (!rawLatestResult) rawLatestResult = NSLocalizedString(@"MainViewLatestResultDefault",@"Last result will appear here once you have scanned a barcode at least once");
[self setResultViewWithText:rawLatestResult];
}
@ -82,10 +81,7 @@
- (IBAction)info:(id)sender {
MessageViewController *aboutController =
[[MessageViewController alloc] initWithMessageFilename:@"About"
/* target:self
onSuccess:@selector(messageReady:)
onFailure:@selector(messageFailed:)*/];
[[MessageViewController alloc] initWithMessageFilename:@"About"];
aboutController.delegate = self;
[self presentModalViewController:aboutController animated:YES];
[aboutController release];
@ -119,25 +115,30 @@
- (void)dealloc {
[resultParser release];
[resultView release];
actions = nil;
result = nil;
[super dealloc];
}
- (void)setResultViewWithText:(NSString*)theResult {
ParsedResult *parsedResult = [[UniversalResultParser parsedResultForString:theResult] retain];
NSString *displayString = [parsedResult stringForDisplay];
self.resultView.text = displayString;
}
#pragma mark -
#pragma mark ZXingDelegateMethods
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)resultString {
[self dismissModalViewControllerAnimated:YES];
ParsedResult *theResult = [self.resultParser resultForString:resultString];
ParsedResult *theResult = [UniversalResultParser parsedResultForString:resultString];
self.result = [theResult retain];
self.actions = [self.result.actions retain];
#ifdef DEBUG
NSLog(@"result has %d actions", actions ? 0 : actions.count);
#endif
self.resultView.text = resultString;
[self setResultViewWithText:resultString];
[[Database sharedDatabase] addScanWithText:resultString];
[[NSUserDefaults standardUserDefaults] setObject:resultString forKey:@"lastScan"];
[self performResultAction];