Showing
31 changed files
with
769 additions
and
9 deletions
| ... | @@ -14,6 +14,9 @@ | ... | @@ -14,6 +14,9 @@ |
| 14 | 1E108A9428A3F9280008B8E7 /* pf_square_sans_pro_extra_black.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A8F28A3F9280008B8E7 /* pf_square_sans_pro_extra_black.ttf */; }; | 14 | 1E108A9428A3F9280008B8E7 /* pf_square_sans_pro_extra_black.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A8F28A3F9280008B8E7 /* pf_square_sans_pro_extra_black.ttf */; }; |
| 15 | 1E108A9528A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9028A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf */; }; | 15 | 1E108A9528A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9028A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf */; }; |
| 16 | 1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */; }; | 16 | 1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */; }; |
| 17 | + 1E1489752AB48D6400D332BE /* TelematicsMainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E1489742AB48D6400D332BE /* TelematicsMainViewController.swift */; }; | ||
| 18 | + 1E1489772AB49EA300D332BE /* TelematicsHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E1489762AB49EA300D332BE /* TelematicsHistoryViewController.swift */; }; | ||
| 19 | + 1E1489792AB49EC600D332BE /* TelematicsHistoryAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E1489782AB49EC600D332BE /* TelematicsHistoryAnalysisViewController.swift */; }; | ||
| 17 | 1E151F1829DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */; }; | 20 | 1E151F1829DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */; }; |
| 18 | 1E151F1A29DAE4D500951FA0 /* ActiveCodeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */; }; | 21 | 1E151F1A29DAE4D500951FA0 /* ActiveCodeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */; }; |
| 19 | 1E15B9A229DDCF02000A408D /* MarketSharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */; }; | 22 | 1E15B9A229DDCF02000A408D /* MarketSharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */; }; |
| ... | @@ -199,6 +202,9 @@ | ... | @@ -199,6 +202,9 @@ |
| 199 | 1E108A9028A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_bold_italic.ttf; sourceTree = "<group>"; }; | 202 | 1E108A9028A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_bold_italic.ttf; sourceTree = "<group>"; }; |
| 200 | 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_bold.ttf; sourceTree = "<group>"; }; | 203 | 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_bold.ttf; sourceTree = "<group>"; }; |
| 201 | 1E108A9728A3FA9B0008B8E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; | 204 | 1E108A9728A3FA9B0008B8E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; |
| 205 | + 1E1489742AB48D6400D332BE /* TelematicsMainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TelematicsMainViewController.swift; sourceTree = "<group>"; }; | ||
| 206 | + 1E1489762AB49EA300D332BE /* TelematicsHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TelematicsHistoryViewController.swift; sourceTree = "<group>"; }; | ||
| 207 | + 1E1489782AB49EC600D332BE /* TelematicsHistoryAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TelematicsHistoryAnalysisViewController.swift; sourceTree = "<group>"; }; | ||
| 202 | 1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponsTableViewCell.swift; sourceTree = "<group>"; }; | 208 | 1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponsTableViewCell.swift; sourceTree = "<group>"; }; |
| 203 | 1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveCodeTableViewCell.swift; sourceTree = "<group>"; }; | 209 | 1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveCodeTableViewCell.swift; sourceTree = "<group>"; }; |
| 204 | 1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketSharingHistoryViewController.swift; sourceTree = "<group>"; }; | 210 | 1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketSharingHistoryViewController.swift; sourceTree = "<group>"; }; |
| ... | @@ -537,6 +543,9 @@ | ... | @@ -537,6 +543,9 @@ |
| 537 | 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */, | 543 | 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */, |
| 538 | 1EB5F4C728536FD60016F36E /* StepsViewController.swift */, | 544 | 1EB5F4C728536FD60016F36E /* StepsViewController.swift */, |
| 539 | 1EF228472AA73E48009DF715 /* TelematicsViewController.swift */, | 545 | 1EF228472AA73E48009DF715 /* TelematicsViewController.swift */, |
| 546 | + 1E1489742AB48D6400D332BE /* TelematicsMainViewController.swift */, | ||
| 547 | + 1E1489762AB49EA300D332BE /* TelematicsHistoryViewController.swift */, | ||
| 548 | + 1E1489782AB49EC600D332BE /* TelematicsHistoryAnalysisViewController.swift */, | ||
| 540 | E6A77860282933E40045BBA8 /* MyApi.h */, | 549 | E6A77860282933E40045BBA8 /* MyApi.h */, |
| 541 | E6A778DC282933E60045BBA8 /* MyApi.m */, | 550 | E6A778DC282933E60045BBA8 /* MyApi.m */, |
| 542 | E6A77862282933E50045BBA8 /* MyEmptyClass.swift */, | 551 | E6A77862282933E50045BBA8 /* MyEmptyClass.swift */, |
| ... | @@ -962,6 +971,7 @@ | ... | @@ -962,6 +971,7 @@ |
| 962 | A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */, | 971 | A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */, |
| 963 | E6A77901282933E60045BBA8 /* WLBaseItem.m in Sources */, | 972 | E6A77901282933E60045BBA8 /* WLBaseItem.m in Sources */, |
| 964 | 1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */, | 973 | 1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */, |
| 974 | + 1E1489792AB49EC600D332BE /* TelematicsHistoryAnalysisViewController.swift in Sources */, | ||
| 965 | 1E479FB329DD948B00C38193 /* WalletBadgesTableViewCell.swift in Sources */, | 975 | 1E479FB329DD948B00C38193 /* WalletBadgesTableViewCell.swift in Sources */, |
| 966 | 1E151F1829DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift in Sources */, | 976 | 1E151F1829DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift in Sources */, |
| 967 | E6A778F0282933E60045BBA8 /* WLNativeAdsCollectionMode.m in Sources */, | 977 | E6A778F0282933E60045BBA8 /* WLNativeAdsCollectionMode.m in Sources */, |
| ... | @@ -1021,6 +1031,7 @@ | ... | @@ -1021,6 +1031,7 @@ |
| 1021 | E6A77A36282BB4CB0045BBA8 /* MakeItAPresentViewController.swift in Sources */, | 1031 | E6A77A36282BB4CB0045BBA8 /* MakeItAPresentViewController.swift in Sources */, |
| 1022 | E6A77947282933E70045BBA8 /* FMDatabaseQueue.m in Sources */, | 1032 | E6A77947282933E70045BBA8 /* FMDatabaseQueue.m in Sources */, |
| 1023 | E6A77922282933E60045BBA8 /* NSData+SSToolkitAdditions.m in Sources */, | 1033 | E6A77922282933E60045BBA8 /* NSData+SSToolkitAdditions.m in Sources */, |
| 1034 | + 1E1489752AB48D6400D332BE /* TelematicsMainViewController.swift in Sources */, | ||
| 1024 | 1EA771AC290977CA0030924C /* CopyableLabel.swift in Sources */, | 1035 | 1EA771AC290977CA0030924C /* CopyableLabel.swift in Sources */, |
| 1025 | 1EB236AB28816B680063777A /* ShareViewController.swift in Sources */, | 1036 | 1EB236AB28816B680063777A /* ShareViewController.swift in Sources */, |
| 1026 | 1EF228482AA73E48009DF715 /* TelematicsViewController.swift in Sources */, | 1037 | 1EF228482AA73E48009DF715 /* TelematicsViewController.swift in Sources */, |
| ... | @@ -1047,6 +1058,7 @@ | ... | @@ -1047,6 +1058,7 @@ |
| 1047 | A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */, | 1058 | A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */, |
| 1048 | E6A7792A282933E70045BBA8 /* AFNetworkActivityIndicatorManager.m in Sources */, | 1059 | E6A7792A282933E70045BBA8 /* AFNetworkActivityIndicatorManager.m in Sources */, |
| 1049 | E6A77914282933E60045BBA8 /* WLUserManager.m in Sources */, | 1060 | E6A77914282933E60045BBA8 /* WLUserManager.m in Sources */, |
| 1061 | + 1E1489772AB49EA300D332BE /* TelematicsHistoryViewController.swift in Sources */, | ||
| 1050 | 1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */, | 1062 | 1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */, |
| 1051 | E6A7794F282933E70045BBA8 /* FMDatabasePool.m in Sources */, | 1063 | E6A7794F282933E70045BBA8 /* FMDatabasePool.m in Sources */, |
| 1052 | 1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */, | 1064 | 1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */, | ... | ... |
No preview for this file type
| ... | @@ -300,7 +300,6 @@ | ... | @@ -300,7 +300,6 @@ |
| 300 | <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | 300 | <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> |
| 301 | </state> | 301 | </state> |
| 302 | <connections> | 302 | <connections> |
| 303 | - <action selector="redeemButtomAction:" destination="CDt-eI-msA" eventType="touchUpInside" id="ZgM-FV-cPH"/> | ||
| 304 | <action selector="tripButtonTapped:" destination="CkE-e6-QAc" eventType="touchUpInside" id="hmd-Ue-s8Z"/> | 303 | <action selector="tripButtonTapped:" destination="CkE-e6-QAc" eventType="touchUpInside" id="hmd-Ue-s8Z"/> |
| 305 | </connections> | 304 | </connections> |
| 306 | </button> | 305 | </button> |
| ... | @@ -392,7 +391,52 @@ | ... | @@ -392,7 +391,52 @@ |
| 392 | </viewController> | 391 | </viewController> |
| 393 | <placeholder placeholderIdentifier="IBFirstResponder" id="MGA-l3-4Jz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> | 392 | <placeholder placeholderIdentifier="IBFirstResponder" id="MGA-l3-4Jz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> |
| 394 | </objects> | 393 | </objects> |
| 395 | - <point key="canvasLocation" x="138" y="1545"/> | 394 | + <point key="canvasLocation" x="116" y="2238"/> |
| 395 | + </scene> | ||
| 396 | + <!--Telematics Main View Controller--> | ||
| 397 | + <scene sceneID="BFY-HZ-rDp"> | ||
| 398 | + <objects> | ||
| 399 | + <viewController storyboardIdentifier="TelematicsMainViewController" id="rLq-1b-nGI" customClass="TelematicsMainViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController"> | ||
| 400 | + <view key="view" contentMode="scaleToFill" id="x7s-zd-bAg"> | ||
| 401 | + <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> | ||
| 402 | + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| 403 | + <viewLayoutGuide key="safeArea" id="LMR-ha-1z2"/> | ||
| 404 | + <color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
| 405 | + </view> | ||
| 406 | + </viewController> | ||
| 407 | + <placeholder placeholderIdentifier="IBFirstResponder" id="aRH-Fl-OPs" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> | ||
| 408 | + </objects> | ||
| 409 | + <point key="canvasLocation" x="867" y="2238"/> | ||
| 410 | + </scene> | ||
| 411 | + <!--Telematics History View Controller--> | ||
| 412 | + <scene sceneID="ax9-8b-0Xf"> | ||
| 413 | + <objects> | ||
| 414 | + <viewController storyboardIdentifier="TelematicsHistoryViewController" id="niq-m0-9T8" customClass="TelematicsHistoryViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController"> | ||
| 415 | + <view key="view" contentMode="scaleToFill" id="Ijr-jl-PS2"> | ||
| 416 | + <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> | ||
| 417 | + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| 418 | + <viewLayoutGuide key="safeArea" id="4r4-t4-51H"/> | ||
| 419 | + <color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
| 420 | + </view> | ||
| 421 | + </viewController> | ||
| 422 | + <placeholder placeholderIdentifier="IBFirstResponder" id="fXf-uN-H7T" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> | ||
| 423 | + </objects> | ||
| 424 | + <point key="canvasLocation" x="1612" y="2238"/> | ||
| 425 | + </scene> | ||
| 426 | + <!--Telematics History Analysis View Controller--> | ||
| 427 | + <scene sceneID="tnC-G4-NTO"> | ||
| 428 | + <objects> | ||
| 429 | + <viewController storyboardIdentifier="TelematicsHistoryAnalysisViewController" id="3e7-Qu-SLH" customClass="TelematicsHistoryAnalysisViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController"> | ||
| 430 | + <view key="view" contentMode="scaleToFill" id="dBw-ap-NHM"> | ||
| 431 | + <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> | ||
| 432 | + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| 433 | + <viewLayoutGuide key="safeArea" id="xmW-KJ-2ba"/> | ||
| 434 | + <color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
| 435 | + </view> | ||
| 436 | + </viewController> | ||
| 437 | + <placeholder placeholderIdentifier="IBFirstResponder" id="HvF-nf-rXv" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> | ||
| 438 | + </objects> | ||
| 439 | + <point key="canvasLocation" x="2341" y="2238"/> | ||
| 396 | </scene> | 440 | </scene> |
| 397 | <!--Details View Controller--> | 441 | <!--Details View Controller--> |
| 398 | <scene sceneID="TPv-Bl-CUP"> | 442 | <scene sceneID="TPv-Bl-CUP"> |
| ... | @@ -2532,7 +2576,7 @@ | ... | @@ -2532,7 +2576,7 @@ |
| 2532 | <rect key="frame" x="0.0" y="947.5" width="414" height="44"/> | 2576 | <rect key="frame" x="0.0" y="947.5" width="414" height="44"/> |
| 2533 | <autoresizingMask key="autoresizingMask"/> | 2577 | <autoresizingMask key="autoresizingMask"/> |
| 2534 | <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="TeS-tP-Ilh" id="FFV-uA-HHA"> | 2578 | <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="TeS-tP-Ilh" id="FFV-uA-HHA"> |
| 2535 | - <rect key="frame" x="0.0" y="0.0" width="600" height="44"/> | 2579 | + <rect key="frame" x="0.0" y="0.0" width="414" height="44"/> |
| 2536 | <autoresizingMask key="autoresizingMask"/> | 2580 | <autoresizingMask key="autoresizingMask"/> |
| 2537 | <subviews> | 2581 | <subviews> |
| 2538 | <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AV7-t1-eK0"> | 2582 | <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="AV7-t1-eK0"> |
| ... | @@ -2759,7 +2803,7 @@ | ... | @@ -2759,7 +2803,7 @@ |
| 2759 | <rect key="frame" x="0.0" y="991.5" width="414" height="404"/> | 2803 | <rect key="frame" x="0.0" y="991.5" width="414" height="404"/> |
| 2760 | <autoresizingMask key="autoresizingMask"/> | 2804 | <autoresizingMask key="autoresizingMask"/> |
| 2761 | <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="fgI-zL-RPZ" id="gNB-PU-R1J"> | 2805 | <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="fgI-zL-RPZ" id="gNB-PU-R1J"> |
| 2762 | - <rect key="frame" x="0.0" y="0.0" width="600" height="404"/> | 2806 | + <rect key="frame" x="0.0" y="0.0" width="414" height="404"/> |
| 2763 | <autoresizingMask key="autoresizingMask"/> | 2807 | <autoresizingMask key="autoresizingMask"/> |
| 2764 | <subviews> | 2808 | <subviews> |
| 2765 | <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IZz-Fy-5Iv"> | 2809 | <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IZz-Fy-5Iv"> | ... | ... |
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "filename" : "cosmote_insurance_logo.png", | ||
| 5 | + "idiom" : "universal", | ||
| 6 | + "scale" : "1x" | ||
| 7 | + }, | ||
| 8 | + { | ||
| 9 | + "filename" : "cosmote_insurance_logo 1.png", | ||
| 10 | + "idiom" : "universal", | ||
| 11 | + "scale" : "2x" | ||
| 12 | + }, | ||
| 13 | + { | ||
| 14 | + "filename" : "cosmote_insurance_logo 2.png", | ||
| 15 | + "idiom" : "universal", | ||
| 16 | + "scale" : "3x" | ||
| 17 | + } | ||
| 18 | + ], | ||
| 19 | + "info" : { | ||
| 20 | + "author" : "xcode", | ||
| 21 | + "version" : 1 | ||
| 22 | + } | ||
| 23 | +} |
12 KB
12 KB
12 KB
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "filename" : "tel_driving_percentage.png", | ||
| 5 | + "idiom" : "universal", | ||
| 6 | + "scale" : "1x" | ||
| 7 | + }, | ||
| 8 | + { | ||
| 9 | + "filename" : "tel_driving_percentage 1.png", | ||
| 10 | + "idiom" : "universal", | ||
| 11 | + "scale" : "2x" | ||
| 12 | + }, | ||
| 13 | + { | ||
| 14 | + "filename" : "tel_driving_percentage 2.png", | ||
| 15 | + "idiom" : "universal", | ||
| 16 | + "scale" : "3x" | ||
| 17 | + } | ||
| 18 | + ], | ||
| 19 | + "info" : { | ||
| 20 | + "author" : "xcode", | ||
| 21 | + "version" : 1 | ||
| 22 | + } | ||
| 23 | +} |
9.26 KB
9.26 KB
9.26 KB
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/tel_driving_rating.imageset/Contents.json
0 → 100644
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "filename" : "tel_driving_rating.png", | ||
| 5 | + "idiom" : "universal", | ||
| 6 | + "scale" : "1x" | ||
| 7 | + }, | ||
| 8 | + { | ||
| 9 | + "filename" : "tel_driving_rating 1.png", | ||
| 10 | + "idiom" : "universal", | ||
| 11 | + "scale" : "2x" | ||
| 12 | + }, | ||
| 13 | + { | ||
| 14 | + "filename" : "tel_driving_rating 2.png", | ||
| 15 | + "idiom" : "universal", | ||
| 16 | + "scale" : "3x" | ||
| 17 | + } | ||
| 18 | + ], | ||
| 19 | + "info" : { | ||
| 20 | + "author" : "xcode", | ||
| 21 | + "version" : 1 | ||
| 22 | + } | ||
| 23 | +} |
4.25 KB
4.25 KB
4.25 KB
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/tel_history_bg.imageset/Contents.json
0 → 100644
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "filename" : "tel_history_bg.png", | ||
| 5 | + "idiom" : "universal", | ||
| 6 | + "scale" : "1x" | ||
| 7 | + }, | ||
| 8 | + { | ||
| 9 | + "filename" : "tel_history_bg 1.png", | ||
| 10 | + "idiom" : "universal", | ||
| 11 | + "scale" : "2x" | ||
| 12 | + }, | ||
| 13 | + { | ||
| 14 | + "filename" : "tel_history_bg 2.png", | ||
| 15 | + "idiom" : "universal", | ||
| 16 | + "scale" : "3x" | ||
| 17 | + } | ||
| 18 | + ], | ||
| 19 | + "info" : { | ||
| 20 | + "author" : "xcode", | ||
| 21 | + "version" : 1 | ||
| 22 | + } | ||
| 23 | +} |
171 KB
171 KB
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/tel_history_bg.imageset/tel_history_bg.png
0 → 100644
171 KB
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/tel_thumbs_down_gray.imageset/Contents.json
0 → 100644
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "filename" : "tel_thumbs_down_gray.png", | ||
| 5 | + "idiom" : "universal", | ||
| 6 | + "scale" : "1x" | ||
| 7 | + }, | ||
| 8 | + { | ||
| 9 | + "filename" : "tel_thumbs_down_gray 1.png", | ||
| 10 | + "idiom" : "universal", | ||
| 11 | + "scale" : "2x" | ||
| 12 | + }, | ||
| 13 | + { | ||
| 14 | + "filename" : "tel_thumbs_down_gray 2.png", | ||
| 15 | + "idiom" : "universal", | ||
| 16 | + "scale" : "3x" | ||
| 17 | + } | ||
| 18 | + ], | ||
| 19 | + "info" : { | ||
| 20 | + "author" : "xcode", | ||
| 21 | + "version" : 1 | ||
| 22 | + } | ||
| 23 | +} |
3.47 KB
3.47 KB
3.47 KB
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/tel_thumbs_up_gray.imageset/Contents.json
0 → 100644
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "filename" : "tel_thumbs_up_gray.png", | ||
| 5 | + "idiom" : "universal", | ||
| 6 | + "scale" : "1x" | ||
| 7 | + }, | ||
| 8 | + { | ||
| 9 | + "filename" : "tel_thumbs_up_gray 1.png", | ||
| 10 | + "idiom" : "universal", | ||
| 11 | + "scale" : "2x" | ||
| 12 | + }, | ||
| 13 | + { | ||
| 14 | + "filename" : "tel_thumbs_up_gray 2.png", | ||
| 15 | + "idiom" : "universal", | ||
| 16 | + "scale" : "3x" | ||
| 17 | + } | ||
| 18 | + ], | ||
| 19 | + "info" : { | ||
| 20 | + "author" : "xcode", | ||
| 21 | + "version" : 1 | ||
| 22 | + } | ||
| 23 | +} |
3.49 KB
3.49 KB
3.49 KB
| 1 | +// | ||
| 2 | +// TelematicsHistoryAnalysisViewController.swift | ||
| 3 | +// SwiftWarplyFramework | ||
| 4 | +// | ||
| 5 | +// Created by Manos Chorianopoulos on 15/9/23. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import UIKit | ||
| 9 | + | ||
| 10 | +@objc public class TelematicsHistoryAnalysisViewController: UIViewController { | ||
| 11 | + | ||
| 12 | + public override func viewDidLoad() { | ||
| 13 | + super.viewDidLoad() | ||
| 14 | + | ||
| 15 | + // Do any additional setup after loading the view. | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + /* | ||
| 20 | + // MARK: - Navigation | ||
| 21 | + | ||
| 22 | + // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| 23 | + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
| 24 | + // Get the new view controller using segue.destination. | ||
| 25 | + // Pass the selected object to the new view controller. | ||
| 26 | + } | ||
| 27 | + */ | ||
| 28 | + | ||
| 29 | +} |
| 1 | +// | ||
| 2 | +// TelematicsHistoryViewController.swift | ||
| 3 | +// SwiftWarplyFramework | ||
| 4 | +// | ||
| 5 | +// Created by Manos Chorianopoulos on 15/9/23. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import UIKit | ||
| 9 | + | ||
| 10 | +@objc public class TelematicsHistoryViewController: UIViewController { | ||
| 11 | + | ||
| 12 | + public override func viewDidLoad() { | ||
| 13 | + super.viewDidLoad() | ||
| 14 | + | ||
| 15 | + // Do any additional setup after loading the view. | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + /* | ||
| 20 | + // MARK: - Navigation | ||
| 21 | + | ||
| 22 | + // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| 23 | + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
| 24 | + // Get the new view controller using segue.destination. | ||
| 25 | + // Pass the selected object to the new view controller. | ||
| 26 | + } | ||
| 27 | + */ | ||
| 28 | + | ||
| 29 | +} |
| 1 | +// | ||
| 2 | +// TelematicsMainViewController.swift | ||
| 3 | +// SwiftWarplyFramework | ||
| 4 | +// | ||
| 5 | +// Created by Manos Chorianopoulos on 15/9/23. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import UIKit | ||
| 9 | +import CoreLocation | ||
| 10 | +import CoreMotion | ||
| 11 | + | ||
| 12 | +@objc public class TelematicsMainViewController: UIViewController, CLLocationManagerDelegate, UITextFieldDelegate { | ||
| 13 | + | ||
| 14 | + // MARK: Constants and Properties | ||
| 15 | + | ||
| 16 | + private var mIsTripStarted = false | ||
| 17 | + private var hasLocationPermissions = false | ||
| 18 | + private var isFirstLoad = true | ||
| 19 | + private var mAccelerationTimestamps = [[String: Any]]() | ||
| 20 | + private var locationManager: CLLocationManager! | ||
| 21 | + private var motionManager: CMMotionManager! | ||
| 22 | + private var lastUpdate: TimeInterval = 0 | ||
| 23 | + private var lastX: Double = 0.0 | ||
| 24 | + private var lastY: Double = 0.0 | ||
| 25 | + private var lastZ: Double = 0.0 | ||
| 26 | + private var velocity: Double = 0.0 | ||
| 27 | + private var mAcceleration: Double = 0.0 | ||
| 28 | + private let ALPHA: Double = 0.8 // Filter factor | ||
| 29 | + private let STOP_THRESHOLD: Double = 8.0 // Stop threshold in m/s² | ||
| 30 | + private let RECORDS_INTERVAL: Int = 5000 | ||
| 31 | + private var mLatitude: Double = 0.0 | ||
| 32 | + private var mLongitude: Double = 0.0 | ||
| 33 | + private var mSpeed: Double = 0.0 | ||
| 34 | + private let EARTH_RADIUS: Double = 6371000.0 | ||
| 35 | + private let LOCATION_UPDATE_INTERVAL: Double = 1000.0 | ||
| 36 | + private var mStartTimestamp: String = "" | ||
| 37 | + private var mStopTimestamp: String = "" | ||
| 38 | + private var orientationCount: Int = 0 | ||
| 39 | + private var touchCount: Int = 0 | ||
| 40 | + var oldOrientationIsLandscape: Bool = true | ||
| 41 | + private var timerTel: DispatchSourceTimer? | ||
| 42 | + private var recordsSaved: Int = 0 | ||
| 43 | + | ||
| 44 | + // MARK: Outlets | ||
| 45 | + | ||
| 46 | + @IBOutlet private weak var tripButton: UIButton! | ||
| 47 | +// @IBOutlet private weak var sensorDataLabel: UILabel! | ||
| 48 | +// @IBOutlet private weak var velocityLabel: UILabel! | ||
| 49 | +// @IBOutlet private weak var accelerationLabel: UILabel! | ||
| 50 | +// @IBOutlet private weak var avgVelocityLabel: UILabel! | ||
| 51 | +// @IBOutlet private weak var recordsSavedLabel: UILabel! | ||
| 52 | +// @IBOutlet private weak var orientationCountLabel: UILabel! | ||
| 53 | +// @IBOutlet private weak var touchCountLabel: UILabel! | ||
| 54 | +// @IBOutlet private weak var accelerationLimitTextField: UITextField! | ||
| 55 | +// @IBOutlet private weak var sampleTimeTextField: UITextField! | ||
| 56 | + | ||
| 57 | + public override func viewDidLoad() { | ||
| 58 | + super.viewDidLoad() | ||
| 59 | + | ||
| 60 | + self.hidesBottomBarWhenPushed = true | ||
| 61 | + | ||
| 62 | +// self.setupToHideKeyboardOnTapOnView() | ||
| 63 | + | ||
| 64 | + setBackButton() | ||
| 65 | + setNavigationTitle("Safe Driving") | ||
| 66 | + | ||
| 67 | + locationManager = CLLocationManager() | ||
| 68 | + motionManager = CMMotionManager() | ||
| 69 | + locationManager.delegate = self | ||
| 70 | +// accelerationLimitTextField.delegate = self | ||
| 71 | +// sampleTimeTextField.delegate = self | ||
| 72 | + | ||
| 73 | + hasLocationPermissions = authorizationStatusIsGranted(status: CLLocationManager.authorizationStatus()) | ||
| 74 | + | ||
| 75 | +// orientationCountLabel.text = "0" | ||
| 76 | +// touchCountLabel.text = "0" | ||
| 77 | +// recordsSavedLabel.text = "0" | ||
| 78 | + | ||
| 79 | + tripButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 17) | ||
| 80 | + tripButton.setTitle("Start Trip", for: .normal) | ||
| 81 | + tripButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal) | ||
| 82 | + tripButton.layer.cornerRadius = 15.0 | ||
| 83 | + tripButton.frame = CGRect(x: 0.0, y: 0.0, width: tripButton.intrinsicContentSize.width, height: 50) | ||
| 84 | + tripButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25) | ||
| 85 | + tripButton.backgroundColor = .clear | ||
| 86 | + tripButton.layer.borderWidth = 2 | ||
| 87 | + tripButton.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor | ||
| 88 | + | ||
| 89 | + setupOrientationChangeDetection() | ||
| 90 | + | ||
| 91 | + let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.didTapView(sender:))) | ||
| 92 | +// tapGesture.cancelsTouchesInView = false | ||
| 93 | + self.view.addGestureRecognizer(tapGesture) | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public override func viewWillAppear(_ animated: Bool) { | ||
| 97 | + super.viewWillAppear(animated) | ||
| 98 | + | ||
| 99 | + swiftApi().logTrackersEvent("screen", "TelematicsScreen") | ||
| 100 | + | ||
| 101 | + self.navigationController?.hideHairline() | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public override func viewWillDisappear(_ animated: Bool) { | ||
| 105 | + super.viewWillDisappear(animated) | ||
| 106 | + | ||
| 107 | + if (self.mIsTripStarted == true) { | ||
| 108 | + self.stopTrip() | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + deinit { | ||
| 113 | + NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil) | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + // MARK: Actions | ||
| 117 | + | ||
| 118 | + @IBAction private func tripButtonTapped(_ sender: UIButton) { | ||
| 119 | + if (mIsTripStarted == true) { | ||
| 120 | + // Stop trip | ||
| 121 | + stopTrip() | ||
| 122 | + | ||
| 123 | + } else { | ||
| 124 | + // Start trip | ||
| 125 | +// if let limitText = accelerationLimitTextField.text, limitText.isEmpty { | ||
| 126 | +// // Handle empty limit field | ||
| 127 | +// return | ||
| 128 | +// } | ||
| 129 | + | ||
| 130 | + // Disable UI elements | ||
| 131 | +// accelerationLimitTextField.isEnabled = false | ||
| 132 | +// sampleTimeTextField.isEnabled = false | ||
| 133 | + | ||
| 134 | + // Start location and sensor updates | ||
| 135 | + requestLocationUpdates() | ||
| 136 | +// registerSensor() | ||
| 137 | + | ||
| 138 | + mIsTripStarted = true | ||
| 139 | +// orientationCountLabel.text = "0" | ||
| 140 | +// touchCountLabel.text = "0" | ||
| 141 | + tripButton.setTitle("Stop Trip", for: .normal) | ||
| 142 | + mStartTimestamp = String(Int(Date().timeIntervalSince1970 * 1000)) // time in milliseconds since January 1, 1970 | ||
| 143 | + initializeOrientation() | ||
| 144 | + startTimer() | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + | ||
| 149 | + private func stopTrip() { | ||
| 150 | + mIsTripStarted = false | ||
| 151 | + stopTimer() | ||
| 152 | + unregisterSensor() | ||
| 153 | + stopLocationUpdates() | ||
| 154 | + tripButton.setTitle("Start Trip", for: .normal) | ||
| 155 | + | ||
| 156 | + mStopTimestamp = String(Int(Date().timeIntervalSince1970 * 1000)) // time in milliseconds since January 1, 1970 | ||
| 157 | + initViews() | ||
| 158 | + | ||
| 159 | + // Disable UI elements | ||
| 160 | +// accelerationLimitTextField.isEnabled = true | ||
| 161 | +// sampleTimeTextField.isEnabled = true | ||
| 162 | + | ||
| 163 | + saveAccelerationDataToFile() | ||
| 164 | + | ||
| 165 | + orientationCount = 0 | ||
| 166 | + touchCount = 0 | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + private func saveAccelerationDataToFile() { | ||
| 170 | + var jsonArray = [[String: Any]]() | ||
| 171 | + for var jsonObject in mAccelerationTimestamps { | ||
| 172 | + if let parent = jsonObject.keys.first, var jobj = jsonObject[parent] as? [String: Any] { | ||
| 173 | + jobj["stop_time"] = mStopTimestamp | ||
| 174 | + jsonObject[parent] = jobj | ||
| 175 | + } | ||
| 176 | + jsonArray.append(jsonObject) | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + mAccelerationTimestamps = jsonArray | ||
| 180 | + | ||
| 181 | + // print("=== mAccelerationTimestamps: ",mAccelerationTimestamps) | ||
| 182 | + | ||
| 183 | + sendAccelerationDataToServer(jsonArray) | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + func sendAccelerationDataToServer(_ jsonArray: [[String: Any]]) { | ||
| 187 | + if (mAccelerationTimestamps.isEmpty) { | ||
| 188 | + return | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + swiftApi().sendAccelerationDataAsync(accelerationTimestamps: mAccelerationTimestamps, sendAccelerationDataSuccessCallback, failureCallback: {errorCode in }) | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + func sendAccelerationDataSuccessCallback (_ response: swiftApi.GenericResponseModel?) -> Void { | ||
| 195 | + if (response != nil) { | ||
| 196 | + DispatchQueue.main.async { | ||
| 197 | + if (response?.getStatus == 1) { | ||
| 198 | + self.recordsSaved += 1; | ||
| 199 | +// self.recordsSavedLabel.text = String(self.recordsSaved) | ||
| 200 | + | ||
| 201 | + } else { | ||
| 202 | + print("=== sendAccelerationDataAsync error ===") | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + } else { | ||
| 206 | + print("=== sendAccelerationDataAsync error ===") | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + private func initializeOrientation() { | ||
| 211 | + if #available(iOS 13.0, *) { | ||
| 212 | + if let newOrientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation { | ||
| 213 | + oldOrientationIsLandscape = newOrientation.isLandscape | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + } else { | ||
| 217 | + let newOrientation = UIDevice.current.orientation | ||
| 218 | + oldOrientationIsLandscape = newOrientation.isLandscape | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + // MARK: Sensor and Location Handling | ||
| 223 | + | ||
| 224 | + private func registerSensor() { | ||
| 225 | + // Register sensor for accelerometer data | ||
| 226 | + if motionManager.isAccelerometerAvailable { | ||
| 227 | + motionManager.accelerometerUpdateInterval = 0.1 | ||
| 228 | + motionManager.startAccelerometerUpdates(to: .main) { (data, error) in | ||
| 229 | + if let accelerationData = data { | ||
| 230 | + self.processAccelerometerData(accelerationData) | ||
| 231 | + } | ||
| 232 | + } | ||
| 233 | + } | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + private func unregisterSensor() { | ||
| 237 | + motionManager.stopAccelerometerUpdates() | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + private func processAccelerometerData(_ accelerationData: CMAccelerometerData) { | ||
| 241 | + // print("=== accelerationData: ",accelerationData) | ||
| 242 | + | ||
| 243 | +// sensorDataLabel.text = "\(accelerationData.acceleration.x), \(accelerationData.acceleration.y), \(accelerationData.acceleration.z)" | ||
| 244 | + | ||
| 245 | + // timeIntervalSince1970 is the number of seconds since January, 1st, 1970, 12:00 am (mid night) | ||
| 246 | + let currentTime = Date().timeIntervalSince1970 | ||
| 247 | + let timeDifference = currentTime - lastUpdate | ||
| 248 | + lastUpdate = currentTime | ||
| 249 | + | ||
| 250 | + let time = timeDifference | ||
| 251 | + | ||
| 252 | + // Apply low-pass filter | ||
| 253 | + let filteredX = ALPHA * lastX + (1 - ALPHA) * accelerationData.acceleration.x | ||
| 254 | + let filteredY = ALPHA * lastY + (1 - ALPHA) * accelerationData.acceleration.y | ||
| 255 | + let filteredZ = ALPHA * lastZ + (1 - ALPHA) * accelerationData.acceleration.z | ||
| 256 | + | ||
| 257 | + // Calculate acceleration in m/s² using filtered values | ||
| 258 | + let accelerationX = (filteredX - lastX) / time | ||
| 259 | + let accelerationY = (filteredY - lastY) / time | ||
| 260 | + let accelerationZ = (filteredZ - lastZ) / time | ||
| 261 | + | ||
| 262 | + // Calculate total acceleration | ||
| 263 | + let acceleration = sqrt(pow(accelerationX, 2) + pow(accelerationY, 2) + pow(accelerationZ, 2)) | ||
| 264 | + // TODO: CHECK mayby this is correct | ||
| 265 | +// accelerationLabel.text = String(format: "%.1f m/s^2", acceleration) | ||
| 266 | + | ||
| 267 | + // print("=== acceleration: ",acceleration) | ||
| 268 | + | ||
| 269 | + // If acceleration is below the stop threshold, assume we are in a stop | ||
| 270 | +// if acceleration < STOP_THRESHOLD { | ||
| 271 | +// velocity = 0 | ||
| 272 | +// } else { | ||
| 273 | + // Update velocity | ||
| 274 | + velocity = acceleration * time | ||
| 275 | +// } | ||
| 276 | + | ||
| 277 | + // print("=== velocity: ",velocity) | ||
| 278 | + | ||
| 279 | + // Convert velocity to km/h | ||
| 280 | + mAcceleration = velocity // Convert to km/h | ||
| 281 | +// mAcceleration = velocity * 3.6 // Convert to km/h | ||
| 282 | +// velocityLabel.text = String(format: "%.1f m/s^2", velocity) | ||
| 283 | +// avgVelocityLabel.text = String(format: "%.1f km/h", velocity) | ||
| 284 | +// accelerationLabel.text = String(format: "%.1f m/s^2", velocity) | ||
| 285 | + // Update last values | ||
| 286 | + lastX = filteredX | ||
| 287 | + lastY = filteredY | ||
| 288 | + lastZ = filteredZ | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + private func requestLocationUpdates() { | ||
| 292 | + if CLLocationManager.locationServicesEnabled() { | ||
| 293 | + locationManager.desiredAccuracy = kCLLocationAccuracyBest | ||
| 294 | +// locationManager.requestLocation() | ||
| 295 | + | ||
| 296 | + if (!locationServicesIsEnabled()) { | ||
| 297 | + onLocationServicesIsDisabled(); | ||
| 298 | + } | ||
| 299 | + else if (authorizationStatusIsDenied(status: CLLocationManager.authorizationStatus())) { | ||
| 300 | + onAuthorizationStatusIsDenied(); | ||
| 301 | + } | ||
| 302 | + else if (authorizationStatusNeedRequest(status: CLLocationManager.authorizationStatus())) { | ||
| 303 | + onAuthorizationStatusNeedRequest(); | ||
| 304 | + } | ||
| 305 | + else if (authorizationStatusIsGranted(status: CLLocationManager.authorizationStatus())) { | ||
| 306 | + onAuthorizationStatusIsGranted(); | ||
| 307 | + } | ||
| 308 | + } | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + private func stopLocationUpdates() { | ||
| 312 | + locationManager.stopUpdatingLocation() | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + // MARK: Helper Methods | ||
| 316 | + | ||
| 317 | + private func initViews() { | ||
| 318 | +// velocityLabel.text = "0.0 m/s^2" | ||
| 319 | +// accelerationLabel.text = "0.0 m/s^2" | ||
| 320 | +// avgVelocityLabel.text = "0.0 km/h" | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + private func calculateSpeed(lat1: Double, lon1: Double, lat2: Double, lon2: Double, timeDifferenceInSeconds: Double) -> Double { | ||
| 324 | + let distance = calculateDistance(lat1: lat1, lon1: lon1, lat2: lat2, lon2: lon2) | ||
| 325 | + return (distance / timeDifferenceInSeconds) * 3.6 // Convert to km/h | ||
| 326 | + } | ||
| 327 | + | ||
| 328 | + private func calculateDistance(lat1: Double, lon1: Double, lat2: Double, lon2: Double) -> Double { | ||
| 329 | + let x = (lon2 - lon1).toRadians() * cos(((lat1 + lat2) / 2).toRadians()) | ||
| 330 | + let y = (lat2 - lat1).toRadians() | ||
| 331 | + return sqrt(x * x + y * y) * EARTH_RADIUS | ||
| 332 | + } | ||
| 333 | + | ||
| 334 | + // Orientation Observer | ||
| 335 | + func setupOrientationChangeDetection() { | ||
| 336 | + NotificationCenter.default.addObserver(self, selector: #selector(orientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil) | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + @objc func orientationDidChange() { | ||
| 340 | + if mIsTripStarted { | ||
| 341 | + if #available(iOS 13.0, *) { | ||
| 342 | + if let newOrientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation { | ||
| 343 | + if ((newOrientation.isLandscape || newOrientation.isPortrait) && (newOrientation.isLandscape != oldOrientationIsLandscape)) { | ||
| 344 | + orientationCount += 1 | ||
| 345 | +// orientationCountLabel.text = String(orientationCount) | ||
| 346 | + oldOrientationIsLandscape = !oldOrientationIsLandscape | ||
| 347 | + } | ||
| 348 | + } | ||
| 349 | + | ||
| 350 | + } else { | ||
| 351 | + let newOrientation = UIDevice.current.orientation | ||
| 352 | + if ((newOrientation.isLandscape || newOrientation.isPortrait) && (newOrientation.isLandscape != oldOrientationIsLandscape)) { | ||
| 353 | + orientationCount += 1 | ||
| 354 | +// orientationCountLabel.text = String(orientationCount) | ||
| 355 | + oldOrientationIsLandscape = !oldOrientationIsLandscape | ||
| 356 | + } | ||
| 357 | + } | ||
| 358 | + } | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + // MARK: TapGestureRecognizer callback | ||
| 362 | + @objc func didTapView(sender: UITapGestureRecognizer) { | ||
| 363 | + self.view.endEditing(true); | ||
| 364 | + | ||
| 365 | + if (mIsTripStarted == true) { | ||
| 366 | + touchCount += 1; | ||
| 367 | +// touchCountLabel.text = String(touchCount); | ||
| 368 | + } | ||
| 369 | + } | ||
| 370 | + | ||
| 371 | + // MARK: Timer | ||
| 372 | + func startTimer() { | ||
| 373 | +// let timeInterval = Int(sampleTimeTextField.text ?? String(RECORDS_INTERVAL)) ?? RECORDS_INTERVAL | ||
| 374 | + let timeInterval = 2000 | ||
| 375 | + let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".telematics.timer") | ||
| 376 | + timerTel = DispatchSource.makeTimerSource(queue: queue) | ||
| 377 | + timerTel!.schedule(deadline: .now(), repeating: .milliseconds(timeInterval)) | ||
| 378 | + timerTel!.setEventHandler { [weak self] in | ||
| 379 | + // do whatever stuff you want on the background queue here here | ||
| 380 | + | ||
| 381 | + DispatchQueue.main.async { | ||
| 382 | + // update your model objects and/or UI here | ||
| 383 | + | ||
| 384 | + var jsonObject = [String: Any]() | ||
| 385 | + var jsonObjectData = [String: Any]() | ||
| 386 | + | ||
| 387 | + let timestamp = String(Int(Date().timeIntervalSince1970 * 1000)) | ||
| 388 | + | ||
| 389 | + jsonObjectData["acceleration"] = self?.mAcceleration | ||
| 390 | + jsonObjectData["speed"] = self?.mSpeed | ||
| 391 | + jsonObjectData["orientation_count"] = self?.orientationCount | ||
| 392 | + jsonObjectData["touch_count"] = self?.touchCount | ||
| 393 | + jsonObjectData["timestamp"] = timestamp | ||
| 394 | + jsonObjectData["start_time"] = self?.mStartTimestamp | ||
| 395 | + jsonObjectData["stop_time"] = self?.mStopTimestamp | ||
| 396 | + jsonObjectData["latitude"] = self?.mLatitude | ||
| 397 | + jsonObjectData["longitude"] = self?.mLongitude | ||
| 398 | + jsonObjectData["limit"] = self?.getCutOffLimit() | ||
| 399 | +// jsonObjectData["samples"] = Int(self?.sampleTimeTextField.text ?? String(self?.RECORDS_INTERVAL ?? 5000)) ?? self?.RECORDS_INTERVAL ?? 5000 | ||
| 400 | + jsonObjectData["samples"] = 2000 | ||
| 401 | + | ||
| 402 | + jsonObject[timestamp] = jsonObjectData | ||
| 403 | + | ||
| 404 | +// let valid = JSONSerialization.isValidJSONObject(jsonObject) | ||
| 405 | +// print("=== valid JSON: ", valid) | ||
| 406 | + | ||
| 407 | + self?.mAccelerationTimestamps.append(jsonObject) | ||
| 408 | + | ||
| 409 | + // print("=== self?.mAccelerationTimestamps: ", self?.mAccelerationTimestamps) | ||
| 410 | + } | ||
| 411 | + } | ||
| 412 | + timerTel!.resume() | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + func stopTimer() { | ||
| 416 | + timerTel?.cancel() | ||
| 417 | + timerTel = nil | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + func getCutOffLimit() -> String { | ||
| 421 | +// if let limitText = accelerationLimitTextField.text, !limitText.isEmpty, let limitValue = Double(limitText) { | ||
| 422 | + let limitValue = 50.0 | ||
| 423 | + if limitValue > mAcceleration { | ||
| 424 | + return "red" | ||
| 425 | + } else { | ||
| 426 | + return "green" | ||
| 427 | + } | ||
| 428 | +// } | ||
| 429 | +// | ||
| 430 | +// return "" | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + // MARK: Location Permissions | ||
| 434 | + func locationServicesIsEnabled() -> Bool { | ||
| 435 | + return (CLLocationManager.locationServicesEnabled()) ? true : false; | ||
| 436 | + } | ||
| 437 | + | ||
| 438 | + func authorizationStatusNeedRequest(status: CLAuthorizationStatus) -> Bool { | ||
| 439 | + return (status == .notDetermined) ? true : false; | ||
| 440 | + } | ||
| 441 | + | ||
| 442 | + func authorizationStatusIsGranted(status: CLAuthorizationStatus) -> Bool { | ||
| 443 | + return (status == .authorizedAlways || status == .authorizedWhenInUse) ? true : false; | ||
| 444 | + } | ||
| 445 | + | ||
| 446 | + func authorizationStatusIsDenied(status: CLAuthorizationStatus) -> Bool { | ||
| 447 | + return (status == .restricted || status == .denied) ? true : false; | ||
| 448 | + } | ||
| 449 | + | ||
| 450 | + func onLocationServicesIsDisabled() { | ||
| 451 | + locationManager.requestWhenInUseAuthorization(); | ||
| 452 | + } | ||
| 453 | + | ||
| 454 | + func onAuthorizationStatusNeedRequest() { | ||
| 455 | + locationManager.requestWhenInUseAuthorization(); | ||
| 456 | + } | ||
| 457 | + | ||
| 458 | + func onAuthorizationStatusIsGranted() { | ||
| 459 | + // print("=== onAuthorizationStatusIsGranted === ") | ||
| 460 | + locationManager.startUpdatingLocation(); | ||
| 461 | +// registerSensor() | ||
| 462 | + if (!isFirstLoad || (isFirstLoad && !hasLocationPermissions)) { | ||
| 463 | + registerSensor() | ||
| 464 | + } | ||
| 465 | + hasLocationPermissions = true | ||
| 466 | + isFirstLoad = false | ||
| 467 | + } | ||
| 468 | + | ||
| 469 | + func onAuthorizationStatusIsDenied() { | ||
| 470 | + | ||
| 471 | + } | ||
| 472 | + | ||
| 473 | + public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { | ||
| 474 | + // print("=== locationManager didChangeAuthorization: ",status) | ||
| 475 | + | ||
| 476 | + if (authorizationStatusIsDenied(status: status)) { | ||
| 477 | + onAuthorizationStatusIsDenied(); | ||
| 478 | + } | ||
| 479 | + else if (authorizationStatusIsGranted(status: status)) { | ||
| 480 | + onAuthorizationStatusIsGranted(); | ||
| 481 | + } | ||
| 482 | + } | ||
| 483 | + | ||
| 484 | + public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { | ||
| 485 | + if let location = locations.last { | ||
| 486 | + // print("=== locationManager didUpdateLocations latitude: ",location.coordinate.latitude) | ||
| 487 | + // print("=== locationManager didUpdateLocations longitude: ",location.coordinate.longitude) | ||
| 488 | + | ||
| 489 | + if mLatitude != 0 && mLongitude != 0 { | ||
| 490 | + mSpeed = calculateSpeed(lat1: mLatitude, lon1: mLongitude, lat2: location.coordinate.latitude, lon2: location.coordinate.longitude, timeDifferenceInSeconds: LOCATION_UPDATE_INTERVAL / 1000) | ||
| 491 | +// avgVelocityLabel.text = String(format: "%.1f", floor(mSpeed)) + " km/h" | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + mLatitude = location.coordinate.latitude | ||
| 495 | + mLongitude = location.coordinate.longitude | ||
| 496 | + } | ||
| 497 | + } | ||
| 498 | + | ||
| 499 | + public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { | ||
| 500 | + print("=== locationManager didFailWithError: ", error) | ||
| 501 | + } | ||
| 502 | +} | ||
| 503 | + | ||
| 504 | +extension Double { | ||
| 505 | + func toRadians() -> Double { | ||
| 506 | + return self * .pi / 180.0 | ||
| 507 | + } | ||
| 508 | +} |
| ... | @@ -498,8 +498,8 @@ import CoreMotion | ... | @@ -498,8 +498,8 @@ import CoreMotion |
| 498 | } | 498 | } |
| 499 | } | 499 | } |
| 500 | 500 | ||
| 501 | -extension Double { | 501 | +//extension Double { |
| 502 | - func toRadians() -> Double { | 502 | +// func toRadians() -> Double { |
| 503 | - return self * .pi / 180.0 | 503 | +// return self * .pi / 180.0 |
| 504 | - } | 504 | +// } |
| 505 | -} | 505 | +//} | ... | ... |
-
Please register or login to post a comment