Skip to content

Commit 138c70a

Browse files
author
Thomas Taschauer
committed
add analytics, fix small UI bugs
1 parent 0679795 commit 138c70a

5 files changed

Lines changed: 34 additions & 6 deletions

File tree

OpenDocumentReader/Base.lproj/LaunchScreen.storyboard

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
99
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
1010
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1111
</dependencies>
@@ -15,11 +15,11 @@
1515
<objects>
1616
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
1717
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
18-
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
18+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1919
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2020
<subviews>
2121
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NIw-eq-wmR">
22-
<rect key="frame" x="48" y="141" width="318" height="146"/>
22+
<rect key="frame" x="29" y="141" width="318" height="146"/>
2323
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES"/>
2424
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
2525
<attributedString key="attributedText">
@@ -33,11 +33,11 @@
3333
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
3434
</textView>
3535
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6bP-eF-b7K">
36-
<rect key="frame" x="65" y="318" width="287" height="128"/>
36+
<rect key="frame" x="45" y="318" width="287" height="128"/>
3737
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES"/>
3838
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
3939
<attributedString key="attributedText">
40-
<fragment content="Choose a .odt-file to get started! Enjoy.">
40+
<fragment content="Choose a compatible file to get started!">
4141
<attributes>
4242
<font key="NSFont" size="14" name="ArialMT"/>
4343
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>

OpenDocumentReader/DocumentBrowserViewController.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import UIKit
9+
import FirebaseAnalytics
910

1011
class DocumentBrowserViewController: UIDocumentBrowserViewController, UIDocumentBrowserViewControllerDelegate {
1112

@@ -81,6 +82,10 @@ class DocumentBrowserViewController: UIDocumentBrowserViewController, UIDocument
8182

8283
documentViewController.document = doc
8384

85+
Analytics.logEvent(AnalyticsEventViewItem, parameters: [
86+
AnalyticsParameterItemName: documentURL.absoluteString
87+
])
88+
8489
doc.open { [weak self](success) in
8590
transitionController.loadingProgress = nil
8691

OpenDocumentReader/DocumentViewController.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import UIKit
99
import WebKit
1010
import ScrollableSegmentedControl
1111
import UIKit.UIPrinter
12+
import FirebaseAnalytics
1213

1314
// taken from: https://developer.apple.com/documentation/uikit/view_controllers/building_a_document_browser-based_app
1415
class DocumentViewController: UIViewController, DocumentDelegate {
@@ -39,6 +40,7 @@ class DocumentViewController: UIViewController, DocumentDelegate {
3940
@IBOutlet weak var toolbar: UIToolbar!
4041
@IBOutlet weak var toolbarDefaultHeight: NSLayoutConstraint!
4142
@IBOutlet weak var toolbarFullscreenHeight: NSLayoutConstraint!
43+
@IBOutlet weak var menuButton: UIBarButtonItem!
4244

4345
private var isFullscreen = false
4446

@@ -101,11 +103,25 @@ class DocumentViewController: UIViewController, DocumentDelegate {
101103
}
102104

103105
func showWebsite() {
106+
Analytics.logEvent("menu_help", parameters: nil)
107+
104108
UIApplication.shared.openURL(URL(string: "https://opendocument.app")!)
105109
}
106110

107111
func toggleFullscreen() {
108112
isFullscreen = !isFullscreen
113+
114+
let event: String
115+
if (isFullscreen) {
116+
event = "menu_fullscreen_enter"
117+
} else {
118+
event = "menu_fullscreen_leave"
119+
}
120+
Analytics.logEvent(event, parameters: nil)
121+
122+
let topInset = isFullscreen ? 0 : 8
123+
menuButton.imageInsets = UIEdgeInsets(top: CGFloat(topInset), left: 0, bottom: 0, right: 0)
124+
109125
setNeedsStatusBarAppearanceUpdate()
110126
}
111127

@@ -132,10 +148,13 @@ class DocumentViewController: UIViewController, DocumentDelegate {
132148
alert.addAction(UIAlertAction(title: "Help!?", style: .default, handler: { (_) in
133149
self.showWebsite()
134150
}))
151+
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
135152
self.present(alert, animated: true, completion: nil)
136153
}
137154

138155
func printDocument() {
156+
Analytics.logEvent("menu_print", parameters: nil)
157+
139158
let printController = UIPrintInteractionController.shared
140159
let printInfo : UIPrintInfo = UIPrintInfo(dictionary: nil)
141160

OpenDocumentReader/Main.storyboard

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
</constraints>
105105
</view>
106106
<connections>
107+
<outlet property="menuButton" destination="Vsd-IL-ujz" id="GoN-tp-egn"/>
107108
<outlet property="progressBar" destination="ePk-bQ-fV8" id="nz6-qw-ouf"/>
108109
<outlet property="segmentedControl" destination="sIx-zo-9kG" id="pCn-x0-Z01"/>
109110
<outlet property="toolbar" destination="N1x-QM-Qks" id="PLi-vF-UnF"/>

OpenDocumentReader/StoreReviewHelper.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88
import Foundation
99
import StoreKit
10+
import FirebaseAnalytics
1011

1112
// taken from: https://medium.com/@abhimuralidharan/asking-customers-for-ratings-and-reviews-from-inside-the-app-in-ios-d85f256dd4ef
1213
struct StoreReviewHelper {
@@ -46,6 +47,8 @@ struct StoreReviewHelper {
4647

4748
fileprivate func requestReview() {
4849
if #available(iOS 10.3, *) {
50+
Analytics.logEvent("rating_show", parameters: nil)
51+
4952
SKStoreReviewController.requestReview()
5053
} else {
5154
// Fallback on earlier versions

0 commit comments

Comments
 (0)