mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
[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:
parent
207b5e294d
commit
d7269e2fd2
|
@ -565,7 +565,7 @@
|
||||||
);
|
);
|
||||||
PREBINDING = NO;
|
PREBINDING = NO;
|
||||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "6B49E4AA-03F0-4CBB-80B6-5987C7E23569";
|
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "6B49E4AA-03F0-4CBB-80B6-5987C7E23569";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos4.2;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#import "ArchiveController.h"
|
#import "ArchiveController.h"
|
||||||
#import "Database.h"
|
#import "Database.h"
|
||||||
#import "Scan.h"
|
#import "Scan.h"
|
||||||
#import "ResultParser.h"
|
#import "UniversalResultParser.h"
|
||||||
#import "ParsedResult.h"
|
#import "ParsedResult.h"
|
||||||
#import "ScanViewController.h"
|
#import "ScanViewController.h"
|
||||||
#import "ScanCell.h"
|
#import "ScanCell.h"
|
||||||
|
@ -128,7 +128,8 @@
|
||||||
self.scans = [NSMutableArray arrayWithArray:[[Database sharedDatabase] scans]];
|
self.scans = [NSMutableArray arrayWithArray:[[Database sharedDatabase] scans]];
|
||||||
self.results = [NSMutableArray arrayWithCapacity:self.scans.count];
|
self.results = [NSMutableArray arrayWithCapacity:self.scans.count];
|
||||||
for (Scan *scan in scans) {
|
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.scans = [NSMutableArray arrayWithArray:[[Database sharedDatabase] scans]];
|
||||||
self.results = [NSMutableArray arrayWithCapacity:self.scans.count];
|
self.results = [NSMutableArray arrayWithCapacity:self.scans.count];
|
||||||
for (Scan *scan in scans) {
|
for (Scan *scan in scans) {
|
||||||
[results addObject:[ResultParser parsedResultForString:scan.text]];
|
[results addObject:[UniversalResultParser parsedResultForString:scan.text]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#import "Scan.h"
|
#import "Scan.h"
|
||||||
#import "ParsedResult.h"
|
#import "ParsedResult.h"
|
||||||
#import "ResultParser.h"
|
#import "ResultParser.h"
|
||||||
|
#import "UniversalResultParser.h"
|
||||||
|
|
||||||
static NSDateFormatter *_makeDateFormatter(NSDateFormatterStyle dateStyle,
|
static NSDateFormatter *_makeDateFormatter(NSDateFormatterStyle dateStyle,
|
||||||
NSDateFormatterStyle timeStyle) {
|
NSDateFormatterStyle timeStyle) {
|
||||||
|
@ -146,7 +147,7 @@ static NSString *_timeString(NSDate *date) {
|
||||||
[scan release];
|
[scan release];
|
||||||
scan = newScan;
|
scan = newScan;
|
||||||
[result release];
|
[result release];
|
||||||
result = [[ResultParser parsedResultForString:[scan text]] retain];
|
result = [[UniversalResultParser parsedResultForString:[scan text]] retain];
|
||||||
|
|
||||||
imageView.image = [result icon];
|
imageView.image = [result icon];
|
||||||
textView.text = [result stringForDisplay];
|
textView.text = [result stringForDisplay];
|
||||||
|
|
|
@ -16,13 +16,11 @@
|
||||||
|
|
||||||
|
|
||||||
@interface ZXMainViewController : UIViewController <ZXingDelegate,UIActionSheetDelegate,ModalViewControllerDelegate> {
|
@interface ZXMainViewController : UIViewController <ZXingDelegate,UIActionSheetDelegate,ModalViewControllerDelegate> {
|
||||||
UniversalResultParser *resultParser;
|
|
||||||
NSArray *actions;
|
NSArray *actions;
|
||||||
ParsedResult *result;
|
ParsedResult *result;
|
||||||
IBOutlet UITextView *resultView;
|
IBOutlet UITextView *resultView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic,retain) UniversalResultParser *resultParser;
|
|
||||||
@property (nonatomic,assign) NSArray *actions;
|
@property (nonatomic,assign) NSArray *actions;
|
||||||
@property (nonatomic,assign) ParsedResult *result;
|
@property (nonatomic,assign) ParsedResult *result;
|
||||||
@property (nonatomic,retain) IBOutlet UITextView *resultView;
|
@property (nonatomic,retain) IBOutlet UITextView *resultView;
|
||||||
|
@ -34,6 +32,8 @@
|
||||||
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result;
|
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result;
|
||||||
- (void)zxingControllerDidCancel:(ZXingWidgetController*)controller;
|
- (void)zxingControllerDidCancel:(ZXingWidgetController*)controller;
|
||||||
- (void)performResultAction;
|
- (void)performResultAction;
|
||||||
|
- (void)setResultViewWithText:(NSString*)theResult;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#import "Database.h"
|
#import "Database.h"
|
||||||
|
|
||||||
@implementation ZXMainViewController
|
@implementation ZXMainViewController
|
||||||
@synthesize resultParser;
|
//@synthesize resultParser;
|
||||||
@synthesize actions;
|
@synthesize actions;
|
||||||
@synthesize result;
|
@synthesize result;
|
||||||
@synthesize resultView;
|
@synthesize resultView;
|
||||||
|
@ -35,13 +35,12 @@
|
||||||
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
||||||
- (void)viewDidLoad {
|
- (void)viewDidLoad {
|
||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
UniversalResultParser *parser = [[UniversalResultParser alloc] initWithDefaultParsers];
|
//UniversalResultParser *parser = [[UniversalResultParser alloc] initWithDefaultParsers];
|
||||||
self.resultParser = parser;
|
//self.resultParser = parser;
|
||||||
[parser release];
|
// [parser release];
|
||||||
NSString *lastResult = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastScan"];
|
NSString *rawLatestResult = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastScan"];
|
||||||
if (!lastResult) lastResult = NSLocalizedString(@"MainViewLatestResultDefault",@"Last result will appear here once you have scanned a barcode at least once");
|
if (!rawLatestResult) rawLatestResult = NSLocalizedString(@"MainViewLatestResultDefault",@"Last result will appear here once you have scanned a barcode at least once");
|
||||||
self.resultView.text = (NSString*)[[NSUserDefaults standardUserDefaults] objectForKey:@"lastScan"];
|
[self setResultViewWithText:rawLatestResult];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,10 +81,7 @@
|
||||||
|
|
||||||
- (IBAction)info:(id)sender {
|
- (IBAction)info:(id)sender {
|
||||||
MessageViewController *aboutController =
|
MessageViewController *aboutController =
|
||||||
[[MessageViewController alloc] initWithMessageFilename:@"About"
|
[[MessageViewController alloc] initWithMessageFilename:@"About"];
|
||||||
/* target:self
|
|
||||||
onSuccess:@selector(messageReady:)
|
|
||||||
onFailure:@selector(messageFailed:)*/];
|
|
||||||
aboutController.delegate = self;
|
aboutController.delegate = self;
|
||||||
[self presentModalViewController:aboutController animated:YES];
|
[self presentModalViewController:aboutController animated:YES];
|
||||||
[aboutController release];
|
[aboutController release];
|
||||||
|
@ -119,25 +115,30 @@
|
||||||
|
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
[resultParser release];
|
|
||||||
[resultView release];
|
[resultView release];
|
||||||
actions = nil;
|
actions = nil;
|
||||||
result = nil;
|
result = nil;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)setResultViewWithText:(NSString*)theResult {
|
||||||
|
ParsedResult *parsedResult = [[UniversalResultParser parsedResultForString:theResult] retain];
|
||||||
|
NSString *displayString = [parsedResult stringForDisplay];
|
||||||
|
self.resultView.text = displayString;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark ZXingDelegateMethods
|
#pragma mark ZXingDelegateMethods
|
||||||
|
|
||||||
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)resultString {
|
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)resultString {
|
||||||
[self dismissModalViewControllerAnimated:YES];
|
[self dismissModalViewControllerAnimated:YES];
|
||||||
ParsedResult *theResult = [self.resultParser resultForString:resultString];
|
ParsedResult *theResult = [UniversalResultParser parsedResultForString:resultString];
|
||||||
self.result = [theResult retain];
|
self.result = [theResult retain];
|
||||||
self.actions = [self.result.actions retain];
|
self.actions = [self.result.actions retain];
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
NSLog(@"result has %d actions", actions ? 0 : actions.count);
|
NSLog(@"result has %d actions", actions ? 0 : actions.count);
|
||||||
#endif
|
#endif
|
||||||
self.resultView.text = resultString;
|
[self setResultViewWithText:resultString];
|
||||||
[[Database sharedDatabase] addScanWithText:resultString];
|
[[Database sharedDatabase] addScanWithText:resultString];
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:resultString forKey:@"lastScan"];
|
[[NSUserDefaults standardUserDefaults] setObject:resultString forKey:@"lastScan"];
|
||||||
[self performResultAction];
|
[self performResultAction];
|
||||||
|
|
Loading…
Reference in a new issue