mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
[iphone/barcodes] added possibility to trigger action of last result on splash screen. Default screen is now aligned with current splash screen UI
git-svn-id: https://zxing.googlecode.com/svn/trunk@1671 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
e8bafc49f9
commit
fac01a6f45
|
@ -564,7 +564,7 @@
|
|||
../../cpp/core/src,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "6B49E4AA-03F0-4CBB-80B6-5987C7E23569";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "A74F7EF8-F2D5-4961-891C-BB2D09877990";
|
||||
SDKROOT = iphoneos4.2;
|
||||
};
|
||||
name = Debug;
|
||||
|
|
|
@ -13,21 +13,25 @@
|
|||
|
||||
@class UniversalResultParser;
|
||||
@class ParsedResult;
|
||||
@class ResultAction;
|
||||
|
||||
|
||||
@interface ZXMainViewController : UIViewController <ZXingDelegate,UIActionSheetDelegate,ModalViewControllerDelegate> {
|
||||
NSArray *actions;
|
||||
ParsedResult *result;
|
||||
IBOutlet UITextView *resultView;
|
||||
IBOutlet UIButton *lastActionButton;
|
||||
}
|
||||
|
||||
@property (nonatomic,assign) NSArray *actions;
|
||||
@property (nonatomic,assign) ParsedResult *result;
|
||||
@property (nonatomic,retain) IBOutlet UITextView *resultView;
|
||||
@property (nonatomic,retain) IBOutlet UIButton *lastActionButton;
|
||||
|
||||
- (IBAction)scan:(id)sender;
|
||||
- (IBAction)info:(id)sender;
|
||||
- (IBAction)showArchive:(id)sender;
|
||||
- (IBAction)lastResultAction:(id)sender;
|
||||
|
||||
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result;
|
||||
- (void)zxingControllerDidCancel:(ZXingWidgetController*)controller;
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#import "Database.h"
|
||||
|
||||
@implementation ZXMainViewController
|
||||
//@synthesize resultParser;
|
||||
@synthesize actions;
|
||||
@synthesize result;
|
||||
@synthesize resultView;
|
||||
@synthesize lastActionButton;
|
||||
|
||||
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
|
||||
/*
|
||||
|
@ -35,12 +35,10 @@
|
|||
// 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 *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];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,7 +51,6 @@
|
|||
*/
|
||||
|
||||
- (IBAction)scan:(id)sender {
|
||||
|
||||
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
|
||||
QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
|
||||
NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil];
|
||||
|
@ -96,49 +93,73 @@
|
|||
[archiveController release];
|
||||
}
|
||||
|
||||
- (IBAction)lastResultAction:(id)sender {
|
||||
[self performResultAction];
|
||||
}
|
||||
|
||||
|
||||
- (void)performAction:(ResultAction *)action {
|
||||
[action performActionWithController:self shouldConfirm:NO];
|
||||
}
|
||||
|
||||
- (void)modalViewControllerWantsToBeDismissed:(UIViewController *)controller {
|
||||
[self dismissModalViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
// Releases the view if it doesn't have a superview.
|
||||
[super didReceiveMemoryWarning];
|
||||
|
||||
// Release any cached data, images, etc. that aren't in use.
|
||||
// Releases the view if it doesn't have a superview.
|
||||
[super didReceiveMemoryWarning];
|
||||
// Release any cached data, images, etc. that aren't in use.
|
||||
}
|
||||
|
||||
- (void)viewDidUnload {
|
||||
[super viewDidUnload];
|
||||
// Release any retained subviews of the main view.
|
||||
// e.g. self.myOutlet = nil;
|
||||
[super viewDidUnload];
|
||||
// Release any retained subviews of the main view.
|
||||
// e.g. self.myOutlet = nil;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc {
|
||||
[resultView release];
|
||||
[lastActionButton 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;
|
||||
self.resultView.text = displayString;
|
||||
self.result = [parsedResult retain];
|
||||
self.actions = [[parsedResult actions] retain];
|
||||
NSString *buttonTitle;
|
||||
if ([self.actions count] == 1) {
|
||||
ResultAction *theAction = [self.actions objectAtIndex:0];
|
||||
buttonTitle = [theAction title];
|
||||
lastActionButton.userInteractionEnabled = YES;
|
||||
} else if ([self.actions count] == 0) {
|
||||
lastActionButton.userInteractionEnabled = NO;
|
||||
buttonTitle = @"No Actions";
|
||||
} else {
|
||||
|
||||
lastActionButton.userInteractionEnabled = YES;
|
||||
buttonTitle = @"Actions ...";
|
||||
}
|
||||
[lastActionButton setTitle:buttonTitle forState: UIControlStateNormal];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark ZXingDelegateMethods
|
||||
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)resultString {
|
||||
[self dismissModalViewControllerAnimated:YES];
|
||||
ParsedResult *theResult = [UniversalResultParser parsedResultForString:resultString];
|
||||
self.result = [theResult retain];
|
||||
self.actions = [self.result.actions retain];
|
||||
//ParsedResult *theResult = [UniversalResultParser parsedResultForString:resultString];
|
||||
//self.result = [theResult retain];
|
||||
//self.actions = [self.result.actions retain];
|
||||
[self setResultViewWithText:resultString];
|
||||
#ifdef DEBUG
|
||||
NSLog(@"result has %d actions", actions ? 0 : actions.count);
|
||||
#endif
|
||||
[self setResultViewWithText:resultString];
|
||||
[[Database sharedDatabase] addScanWithText:resultString];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:resultString forKey:@"lastScan"];
|
||||
[self performResultAction];
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
<object class="IBUIImageView" id="466572544">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{4, 258}, {311, 152}}</string>
|
||||
<string key="NSFrame">{{4, 254}, {311, 152}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
|
@ -151,7 +151,7 @@
|
|||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<string key="IBUIText">Latest result :</string>
|
||||
<object class="NSFont" key="IBUIFont">
|
||||
<object class="NSFont" key="IBUIFont" id="192988789">
|
||||
<string key="NSName">Helvetica-Bold</string>
|
||||
<double key="NSSize">14</double>
|
||||
<int key="NSfFlags">16</int>
|
||||
|
@ -198,6 +198,24 @@
|
|||
<reference key="IBUINormalTitleColor" ref="642293943"/>
|
||||
<reference key="IBUINormalTitleShadowColor" ref="931878472"/>
|
||||
</object>
|
||||
<object class="IBUIButton" id="1000912642">
|
||||
<reference key="NSNextResponder" ref="191373211"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{146, 265}, {154, 27}}</string>
|
||||
<reference key="NSSuperview" ref="191373211"/>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<int key="IBUIContentHorizontalAlignment">0</int>
|
||||
<int key="IBUIContentVerticalAlignment">0</int>
|
||||
<reference key="IBUIFont" ref="192988789"/>
|
||||
<int key="IBUIButtonType">1</int>
|
||||
<reference key="IBUIHighlightedTitleColor" ref="85817449"/>
|
||||
<object class="NSColor" key="IBUINormalTitleColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
<bytes key="NSRGB">MC4wOTgwMzkyMTcyOSAwLjA5ODAzOTIxNzI5IDAuMDk4MDM5MjE3MjkAA</bytes>
|
||||
</object>
|
||||
<reference key="IBUINormalTitleShadowColor" ref="931878472"/>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{320, 460}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
|
@ -255,6 +273,23 @@
|
|||
</object>
|
||||
<int key="connectionID">16</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchEventConnection" key="connection">
|
||||
<string key="label">lastResultAction:</string>
|
||||
<reference key="source" ref="1000912642"/>
|
||||
<reference key="destination" ref="372490531"/>
|
||||
<int key="IBEventType">7</int>
|
||||
</object>
|
||||
<int key="connectionID">22</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">lastActionButton</string>
|
||||
<reference key="source" ref="372490531"/>
|
||||
<reference key="destination" ref="1000912642"/>
|
||||
</object>
|
||||
<int key="connectionID">23</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
|
@ -272,12 +307,13 @@
|
|||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="171320148"/>
|
||||
<reference ref="38308048"/>
|
||||
<reference ref="466572544"/>
|
||||
<reference ref="132134303"/>
|
||||
<reference ref="1000547791"/>
|
||||
<reference ref="1005126370"/>
|
||||
<reference ref="912006692"/>
|
||||
<reference ref="865902498"/>
|
||||
<reference ref="466572544"/>
|
||||
<reference ref="1000912642"/>
|
||||
</object>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
|
@ -332,6 +368,11 @@
|
|||
<reference key="object" ref="912006692"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">21</int>
|
||||
<reference key="object" ref="1000912642"/>
|
||||
<reference key="parent" ref="191373211"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
|
@ -351,6 +392,8 @@
|
|||
<string>19.IBViewBoundsToFrameTransform</string>
|
||||
<string>20.IBPluginDependency</string>
|
||||
<string>20.IBViewBoundsToFrameTransform</string>
|
||||
<string>21.IBPluginDependency</string>
|
||||
<string>21.IBViewBoundsToFrameTransform</string>
|
||||
<string>5.IBPluginDependency</string>
|
||||
<string>5.IBViewBoundsToFrameTransform</string>
|
||||
<string>6.IBPluginDependency</string>
|
||||
|
@ -362,7 +405,7 @@
|
|||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>ZXMainViewController</string>
|
||||
<string>UIResponder</string>
|
||||
<string>{{298, 248}, {320, 480}}</string>
|
||||
<string>{{468, 276}, {320, 480}}</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<object class="NSAffineTransform">
|
||||
|
@ -375,13 +418,17 @@
|
|||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<object class="NSAffineTransform">
|
||||
<bytes key="NSTransformStruct">P4AAAL+AAABAoAAAw9UAAA</bytes>
|
||||
<bytes key="NSTransformStruct">P4AAAL+AAABAgAAAw8wAAA</bytes>
|
||||
</object>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<object class="NSAffineTransform">
|
||||
<bytes key="NSTransformStruct">P4AAAL+AAABDSQAAwsYAAA</bytes>
|
||||
</object>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<object class="NSAffineTransform">
|
||||
<bytes key="NSTransformStruct">P4AAAL+AAABDDQAAw46AAA</bytes>
|
||||
</object>
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<object class="NSAffineTransform">
|
||||
<bytes key="NSTransformStruct">P4AAAL+AAABCiAAAwiQAAA</bytes>
|
||||
</object>
|
||||
|
@ -411,7 +458,7 @@
|
|||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">20</int>
|
||||
<int key="maxID">23</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
@ -424,6 +471,7 @@
|
|||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>info:</string>
|
||||
<string>lastResultAction:</string>
|
||||
<string>scan:</string>
|
||||
<string>showArchive:</string>
|
||||
</object>
|
||||
|
@ -432,6 +480,7 @@
|
|||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||
|
@ -439,6 +488,7 @@
|
|||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>info:</string>
|
||||
<string>lastResultAction:</string>
|
||||
<string>scan:</string>
|
||||
<string>showArchive:</string>
|
||||
</object>
|
||||
|
@ -448,6 +498,10 @@
|
|||
<string key="name">info:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">lastResultAction:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">scan:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
|
@ -459,14 +513,35 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<string key="NS.key.0">resultView</string>
|
||||
<string key="NS.object.0">UITextView</string>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>lastActionButton</string>
|
||||
<string>resultView</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>UIButton</string>
|
||||
<string>UITextView</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<string key="NS.key.0">resultView</string>
|
||||
<object class="IBToOneOutletInfo" key="NS.object.0">
|
||||
<string key="name">resultView</string>
|
||||
<string key="candidateClassName">UITextView</string>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>lastActionButton</string>
|
||||
<string>resultView</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">lastActionButton</string>
|
||||
<string key="candidateClassName">UIButton</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">resultView</string>
|
||||
<string key="candidateClassName">UITextView</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 58 KiB |
Loading…
Reference in a new issue