Skip to content

Commit

Permalink
Added samles code
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Chernikov committed Jul 29, 2016
1 parent 7db38ce commit 5576849
Show file tree
Hide file tree
Showing 92 changed files with 5,669 additions and 0 deletions.
549 changes: 549 additions & 0 deletions Barcode Demo/Mobile Barcode Demo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B208E25F1CEF3BEB0053F137"
BuildableName = "Mobile Barcode Demo.app"
BlueprintName = "Mobile Barcode Demo"
ReferencedContainer = "container:Mobile Barcode Demo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B208E25F1CEF3BEB0053F137"
BuildableName = "Mobile Barcode Demo.app"
BlueprintName = "Mobile Barcode Demo"
ReferencedContainer = "container:Mobile Barcode Demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B208E25F1CEF3BEB0053F137"
BuildableName = "Mobile Barcode Demo.app"
BlueprintName = "Mobile Barcode Demo"
ReferencedContainer = "container:Mobile Barcode Demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B208E25F1CEF3BEB0053F137"
BuildableName = "Mobile Barcode Demo.app"
BlueprintName = "Mobile Barcode Demo"
ReferencedContainer = "container:Mobile Barcode Demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
123 changes: 123 additions & 0 deletions Barcode Demo/Mobile Barcode Demo/AboutCell.swift
@@ -0,0 +1,123 @@
//
// AboutCell.swift
// Mobile Capture Demo
//
// Created by Michael Chernikov on 23/06/16.
// Copyright © 2016 Atalasoft, a Kofax Company. All rights reserved.
//

import UIKit

class AboutCell: UITableViewCell {

@IBOutlet var versionLabel: UILabel!
@IBOutlet var appNameLabel: UILabel!
@IBOutlet var text1Label: UITextView!
@IBOutlet var text2Label: UITextView!
@IBOutlet var emailLabel: UITextView!

var linkTapGestureRecognizer: UITapGestureRecognizer!

func makeLink(text: NSMutableAttributedString, linkText: String, linkUrl: String) {

let linkRange = (text.string as NSString).rangeOfString(linkText)
text.addAttribute(NSLinkAttributeName, value: linkUrl, range: linkRange)
}

func setupAboutData() {

if linkTapGestureRecognizer == nil {
linkTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleLinkTapGestureRecognizer))
linkTapGestureRecognizer.cancelsTouchesInView = false
linkTapGestureRecognizer.delaysTouchesBegan = false
linkTapGestureRecognizer.delaysTouchesEnded = false
addGestureRecognizer(linkTapGestureRecognizer)
}

let appVersion = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"];
if let ver = appVersion {
versionLabel.text = "Version \(ver)"
}

appNameLabel.text = "Atalasoft MobileImage Barcode SDK app"

let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.Justified

let text1 = NSMutableAttributedString(string: "This app is for app developers to see what they can build with the Atalasoft MobileImage barcode SDK for iOS/Xcode. The technology can recognize one or many barcodes on the screen. This app is not for consumers looking to check store prices.", attributes: [
NSParagraphStyleAttributeName: paragraphStyle,
NSBaselineOffsetAttributeName: NSNumber(float: 0)
])
text1Label.attributedText = text1;

let text2 = NSMutableAttributedString(string: "To build your own document capture, processing, or viewing app - visit Atalasoft and grab a 30-day evaluation copy for yourself. We'll provide the tools and the support you need to get started!", attributes: [
NSParagraphStyleAttributeName: paragraphStyle,
NSBaselineOffsetAttributeName: NSNumber(float: 0)
])

makeLink(text2, linkText: "Atalasoft", linkUrl: "http://hubs.ly/H03pzS80")
text2Label.attributedText = text2


let email = NSMutableAttributedString(string: "sales@atalasoft.com")
let emailUrl = "sales@atalasoft.com"

makeLink(email, linkText: emailUrl, linkUrl: "mailto:sales@atalasoft.com")
emailLabel.attributedText = email
}

func handleLinkTapGestureRecognizer(tapRecognizer: UITapGestureRecognizer) {

let view = tapRecognizer.view
let location = tapRecognizer.locationInView(view)

var linkStr = ""

if CGRectContainsPoint(text2Label.frame, location) {
linkStr = getLinkOnText(tapRecognizer.locationInView(text2Label), textView: text2Label)
} else if CGRectContainsPoint(emailLabel.frame, location) {
linkStr = getLinkOnText(tapRecognizer.locationInView(emailLabel), textView: emailLabel)
}

if !linkStr.isEmpty {
let url: NSURL! = NSURL(string: linkStr)
UIApplication.sharedApplication().openURL(url)
}
}

func getLinkOnText(location: CGPoint, textView: UITextView) -> String {

var textPosition1 = textView.closestPositionToPoint(location)
var textPosition2:UITextPosition?
if let _ = textPosition1 {
textPosition2 = textView.positionFromPosition(textPosition1!, offset: 1)
if let _ = textPosition2 {
textPosition1 = textView.positionFromPosition(textPosition1!, offset: -1)
textPosition2 = textView.positionFromPosition(textPosition1!, offset: 1)
} else {
return ""
}
}

let range = textView.textRangeFromPosition(textPosition1!, toPosition: textPosition2!)
let startOffset = textView.offsetFromPosition(textView.beginningOfDocument, toPosition: range!.start)
let endOffset = textView.offsetFromPosition(textView.beginningOfDocument, toPosition: range!.end)
let offsetRange = NSMakeRange(startOffset, endOffset - startOffset)
if offsetRange.location == NSNotFound || offsetRange.length == 0 {
return ""
}

if NSMaxRange(offsetRange) > textView.attributedText.length {
return ""
}

let attributedSubstring = textView.attributedText .attributedSubstringFromRange(offsetRange)
let link = attributedSubstring.attribute(NSLinkAttributeName, atIndex: 0, effectiveRange: nil)

if let linkStr = link {
return linkStr as! String
}

return ""
}
}
43 changes: 43 additions & 0 deletions Barcode Demo/Mobile Barcode Demo/AboutViewController.swift
@@ -0,0 +1,43 @@
//
// AboutViewController.swift
// Mobile Barcode Demo
//
// Created by Michael Chernikov on 27/05/16.
// Copyright © 2016 Atalasoft, a Kofax Company. All rights reserved.
//

import UIKit

class AboutViewController: UITableViewController {

static let cellIdentifier = "AboutCell"

override func viewDidLoad() {
super.viewDidLoad()

tableView.estimatedRowHeight = 100.0;
tableView.rowHeight = UITableViewAutomaticDimension;

tableView.setNeedsLayout()
tableView.layoutIfNeeded()
}

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: AboutCell! = tableView.dequeueReusableCellWithIdentifier(AboutViewController.cellIdentifier) as! AboutCell!

cell.setupAboutData()

cell.selectionStyle = .None

return cell
}

}
47 changes: 47 additions & 0 deletions Barcode Demo/Mobile Barcode Demo/AppDelegate.swift
@@ -0,0 +1,47 @@
//
// AppDelegate.swift
// Mobile Barcode Demo
//
// Created by Michael Chernikov on 20/05/16.
// Copyright © 2016 Atalasoft, a Kofax Company. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
return true
}

func applicationWillResignActive(application: UIApplication) {
}

func applicationDidEnterBackground(application: UIApplication) {
}

func applicationWillEnterForeground(application: UIApplication) {
}

func applicationDidBecomeActive(application: UIApplication) {
Settings.validateLimitation()
if Settings.ExceedLimitation {
let alert = UIAlertController(title: "Error", message: "You have reached your monthly usage limit.", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default) { action -> Void in })

if let wnd = window {
wnd.rootViewController?.presentViewController(alert, animated: true, completion: nil)
}
}
}

func applicationWillTerminate(application: UIApplication) {
}


}

@@ -0,0 +1,40 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "barcodeAppIcon-120.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "barcodeAppIcon-180.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5576849

Please sign in to comment.