Skip to content

Commit

Permalink
chore: Update version number to 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aldrichanyline committed Aug 29, 2023
1 parent 97486ea commit 52828ec
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 54 deletions.
20 changes: 10 additions & 10 deletions Anyline Tire Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Begin PBXBuildFile section */
802B90F6296D80EB0017919D /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 802B90F5296D80EB0017919D /* Alamofire */; };
8C92B7A42A6FC8BA0068EBF5 /* AnylineTireTreadSdk in Frameworks */ = {isa = PBXBuildFile; productRef = 8C92B7A32A6FC8BA0068EBF5 /* AnylineTireTreadSdk */; };
A0BEEBA62A6FFF7800E27276 /* AnylineTireTreadSdk in Frameworks */ = {isa = PBXBuildFile; productRef = A0BEEBA52A6FFF7800E27276 /* AnylineTireTreadSdk */; };
A0D1F2412A6181BD00A6146B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43E3FA4296573C400F1D384 /* SceneDelegate.swift */; };
A0D1F2422A6181BD00A6146B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43E3FA2296573C400F1D384 /* AppDelegate.swift */; };
A0D1F2432A6181D600A6146B /* UserDefaultsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4B9B46E299A46DE00C1CF81 /* UserDefaultsManager.swift */; };
Expand Down Expand Up @@ -162,7 +162,7 @@
buildActionMask = 2147483647;
files = (
D4B53701298002C5009CAB53 /* KeychainSwift in Frameworks */,
8C92B7A42A6FC8BA0068EBF5 /* AnylineTireTreadSdk in Frameworks */,
A0BEEBA62A6FFF7800E27276 /* AnylineTireTreadSdk in Frameworks */,
D43E3FFB2966E86200F1D384 /* SnapKit in Frameworks */,
802B90F6296D80EB0017919D /* Alamofire in Frameworks */,
);
Expand Down Expand Up @@ -205,7 +205,7 @@
path = ViewModel;
sourceTree = "<group>";
};
8C92B7A22A6FC8BA0068EBF5 /* Frameworks */ = {
A0BEEBA42A6FFF7800E27276 /* Frameworks */ = {
isa = PBXGroup;
children = (
);
Expand Down Expand Up @@ -328,7 +328,7 @@
children = (
D43E3FA1296573C400F1D384 /* Anyline Tire Demo */,
D43E3FA0296573C400F1D384 /* Products */,
8C92B7A22A6FC8BA0068EBF5 /* Frameworks */,
A0BEEBA42A6FFF7800E27276 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -604,7 +604,7 @@
D43E3FFA2966E86200F1D384 /* SnapKit */,
802B90F5296D80EB0017919D /* Alamofire */,
D4B53700298002C5009CAB53 /* KeychainSwift */,
8C92B7A32A6FC8BA0068EBF5 /* AnylineTireTreadSdk */,
A0BEEBA52A6FFF7800E27276 /* AnylineTireTreadSdk */,
);
productName = "Anyline Tire Demo";
productReference = D43E3F9F296573C400F1D384 /* Anyline Tire Demo.app */;
Expand Down Expand Up @@ -888,13 +888,13 @@
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIRequiresFullScreen = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationLandscapeRight;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.anyline.showcase.tiretread;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -923,13 +923,13 @@
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIRequiresFullScreen = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationLandscapeRight;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.anyline.showcase.tiretread;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -1006,7 +1006,7 @@
package = 802B90F4296D80EB0017919D /* XCRemoteSwiftPackageReference "Alamofire" */;
productName = Alamofire;
};
8C92B7A32A6FC8BA0068EBF5 /* AnylineTireTreadSdk */ = {
A0BEEBA52A6FFF7800E27276 /* AnylineTireTreadSdk */ = {
isa = XCSwiftPackageProductDependency;
package = A07622DF2A696B5400250387 /* XCRemoteSwiftPackageReference "anyline-tiretread-spm-module" */;
productName = AnylineTireTreadSdk;
Expand Down
4 changes: 2 additions & 2 deletions Anyline Tire Demo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>UIAppFonts</key>
<array>
<string>ProximaNova-Bold.otf</string>
Expand All @@ -25,7 +27,5 @@
</array>
</dict>
</dict>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ private extension FeedbackViewController {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
feedbackView.measurementUUIDLabel.text = "Scan ID: \(self.uuid)"

let label = feedbackView.measurementUUIDLabel

// add tap-to-copy-to-clipboard
label.isUserInteractionEnabled = true
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(labelTapped))
tapGesture.numberOfTapsRequired = 1
label.addGestureRecognizer(tapGesture)
}

@objc func labelTapped() {
if feedbackView.measurementUUIDLabel.text != nil {
// Copy the label's text to the clipboard
let uuid = self.uuid
UIPasteboard.general.string = uuid
feedbackView.measurementUUIDLabel.text = "\(uuid) Copied!"
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { [weak self] in
self?.feedbackView.measurementUUIDLabel.text = "Scan ID: \(uuid)"
}
}
}

func addSubviews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ private extension FeedbackView {
self.addSubview(buttonsView)
self.addSubview(feedbackLabel)
self.addSubview(contentVStackView)
self.addSubview(measurementUUIDLabel)

self.contentVStackView.addArrangedSubview(tireDepthsView)
self.contentVStackView.addArrangedSubview(feedbackTextField)
self.contentVStackView.addArrangedSubview(measurementUUIDLabel)
}

func setupLayout() {
Expand All @@ -96,6 +97,11 @@ private extension FeedbackView {
make.width.equalTo(440)
make.height.equalTo(90)
}

self.measurementUUIDLabel.snp.makeConstraints { make in
make.top.equalTo(20)
make.trailing.equalTo(-20)
}

self.contentVStackView.snp.makeConstraints { make in
make.trailing.equalTo(buttonsView.safeAreaLayoutGuide.snp.leading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class LoadingViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
configureView()
configureUUIDLabel()
addSubviews()
setupLayout()
setDelegates()
Expand All @@ -54,6 +55,28 @@ private extension LoadingViewController {
func configureView() {
view.backgroundColor = ColorStruct.snowWhite
}

func configureUUIDLabel() {
let label = self.customView.customView.measurementUUIDLabel

// add tap-to-copy-to-clipboard
label.isUserInteractionEnabled = true
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(labelTapped))
tapGesture.numberOfTapsRequired = 1
label.addGestureRecognizer(tapGesture)
}

@objc func labelTapped() {
if let _ = self.customView.customView.measurementUUIDLabel.text {
// Copy the label's text to the clipboard
let uuid = self.uuid
UIPasteboard.general.string = uuid
self.customView.customView.measurementUUIDLabel.text = "\(uuid) Copied!"
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { [weak self] in
self?.customView.customView.measurementUUIDLabel.text = "Scan ID: \(uuid)"
}
}
}

func addSubviews() {
self.view.addSubview(topView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LoadingViewModel {

// MARK: - Actions
func startDataProcessing() {
DispatchQueue.global().asyncAfter(deadline: .now() + 10) { [weak self] in
DispatchQueue.global().asyncAfter(deadline: .now() + 0.5) { [weak self] in
self?.fetchTreadDepthResult()
}
}
Expand Down Expand Up @@ -73,15 +73,8 @@ private extension LoadingViewModel {
self.loadingViewModelDelegate?.displayError()
}
case .processing, .waitingforimages:
if processingAttempts < 10 {
DispatchQueue.global().asyncAfter(deadline: .now() + 3) { [weak self] in
self?.processingAttempts += 1
self?.fetchTreadDepthResult()
}
} else {
DispatchQueue.main.async {
self.loadingViewModelDelegate?.displayError()
}
DispatchQueue.global().asyncAfter(deadline: .now() + 0.5) { [weak self] in
self?.fetchTreadDepthResult()
}
default:
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,28 @@ private extension ResultViewController {

func configureView() {
self.view.backgroundColor = ColorStruct.snowWhite

resultView.UUIDLabel.text = "Scan ID: \(self.uuid)"

let label = resultView.UUIDLabel

// add tap-to-copy-to-clipboard
label.isUserInteractionEnabled = true
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(labelTapped))
tapGesture.numberOfTapsRequired = 1
label.addGestureRecognizer(tapGesture)
}

@objc func labelTapped() {
if resultView.UUIDLabel.text != nil {
// Copy the label's text to the clipboard
let uuid = self.uuid
UIPasteboard.general.string = uuid
resultView.UUIDLabel.text = "\(uuid) Copied!"
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { [weak self] in
self?.resultView.UUIDLabel.text = "Scan ID: \(uuid)"
}
}
}

func addSubviews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class ResultView: UIView {
let view = TireTreadMeasurementView()
return view
}()

lazy var UUIDLabel: ATDTextLabel = {
let label = ATDTextLabel(text: "Scan ID: {UUID}")
label.font = FontStruct.proximaNovaRegular12
return label
}()

// MARK: - Private Properties

Expand Down Expand Up @@ -44,7 +50,7 @@ private extension ResultView {
func addSubviews() {
self.addSubview(buttonsView)
self.addSubview(tireTreadMeasurementView)

self.addSubview(UUIDLabel)
}

func setupLayout() {
Expand All @@ -57,6 +63,11 @@ private extension ResultView {
make.leading.top.bottom.equalToSuperview()
make.trailing.equalTo(buttonsView.snp.leading)
}

self.UUIDLabel.snp.makeConstraints { make in
make.bottom.equalTo(0)
make.trailing.equalTo(-20)
}
}

func setDelegates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,26 +252,43 @@ private extension ScanViewController {
}

// Function to start the beeping sound
func startBeeping(distanceInCm: Double) {
func startBeeping(distanceInCm: Double, distanceStatus: DistanceStatus) {
// Cancel any existing timer
beepingTimer?.invalidate()

// Calculate the interval for the timer based on the distance
let roundedDistance = Int(distanceInCm)
var interval: Double
var playerToUse: AVAudioPlayer?

if roundedDistance < 16 {
interval = 500 * (distanceInCm / 16)
switch distanceStatus {
case .close:
interval = 1000
playerToUse = self.highBeepAudioPlayer
} else if roundedDistance > 22 {
interval = max(500 + (distanceInCm - 22) * (0 - 500) / (40 - 22), 0)
case .far:
interval = 1000
playerToUse = self.lowBeepAudioPlayer
} else {
// Distance is in the optimal range - no need to beep
return
case .tooClose:
interval = 500
playerToUse = self.highBeepAudioPlayer
case .tooFar:
interval = 500
playerToUse = self.lowBeepAudioPlayer
default: return
}

// another way of calculating interval (older method)
// let roundedDistance = Int(distanceInCm)
// if roundedDistance < 16 {
// interval = 500 * (distanceInCm / 16)
// playerToUse = self.highBeepAudioPlayer
// } else if roundedDistance > 22 {
// interval = max(500 + (distanceInCm - 22) * (0 - 500) / (40 - 22), 0)
// playerToUse = self.lowBeepAudioPlayer
// } else {
// // Distance is in the optimal range - no need to beep
// return
// }

// Create a new timer
beepingTimer = Timer.scheduledTimer(withTimeInterval: interval / 1000, repeats: true) { _ in
DispatchQueue.global(qos: .userInitiated).async {
Expand All @@ -285,7 +302,7 @@ private extension ScanViewController {
}
}


func setupHapticEngine() {
do {
engine = try CHHapticEngine()
Expand Down Expand Up @@ -381,13 +398,14 @@ extension ScanViewController: ErrorViewControllerDelegate {
extension ScanViewController: TireTreadScanViewCallback {

func onScanAbort(uuid: String?) {

print("scan aborted for uuid: \(uuid ?? "")")
self.navigationController?.popViewController(animated: true)
}

func onUploadAborted(uuid: String?) {

print("upload aborted for uuid: \(uuid ?? "")")
self.navigationController?.popViewController(animated: true)
}


func onFocusFound(uuid: String?) {
self.playFocusSound()
Expand Down Expand Up @@ -419,6 +437,9 @@ extension ScanViewController: TireTreadScanViewCallback {

func onScanStop(uuid: String?) {
print("Native iOS: Scan stopped for uuid: \(uuid ?? "unknown")")
distanceLabel.isHidden = true
stopBeeping()
stopAudioPlayers()
}

/// Called when the distance has changed.
Expand All @@ -434,7 +455,7 @@ extension ScanViewController: TireTreadScanViewCallback {
func onDistanceChanged(uuid: String?, previousStatus: DistanceStatus, newStatus: DistanceStatus, previousDistance: Float, newDistance: Float) {
if Int(newDistance) != Int(previousDistance) {
let distanceInCentimeters = UserDefaultsManager.shared.imperialSystem ? (newDistance * 2.54) : (newDistance / 10.0)
startBeeping(distanceInCm: Double(distanceInCentimeters))
startBeeping(distanceInCm: Double(distanceInCentimeters), distanceStatus: newStatus)
DispatchQueue.main.async { [weak self] in
self?.updateUI(status: newStatus, distance: Int(UserDefaultsManager.shared.imperialSystem ? newDistance : distanceInCentimeters))
}
Expand Down
Loading

0 comments on commit 52828ec

Please sign in to comment.