Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions OpenDocumentReader/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

@UIApplicationMain
@main
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
Expand Down Expand Up @@ -50,8 +50,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ app: UIApplication, open inputURL: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
guard let documentBrowserViewController = window?.rootViewController as? DocumentBrowserViewController else {
fatalError("documentBrowserViewController is null")
CrashManager.shared.log("root view controller is not a DocumentBrowserViewController")

return false
}

Expand All @@ -66,8 +66,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
try FileManager.default.moveItem(at: inputURL, to: destinationUrl)
} catch {
CrashManager.shared.log(error)
fatalError("copying from Inbox failed")


return false
}
} else {
Expand Down
18 changes: 3 additions & 15 deletions OpenDocumentReader/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,8 @@

import Foundation

class Constants {
static let start = "Start"
static let skip = "Skip"
static let next = "Next"
static let onboarding_header_1 = "Open and read your ODF file on the go!"
static let onboarding_header_2 = "Found a typo in your document? Now supports modification!"
static let onboarding_header_3 = "Read your documents from within other apps"
static let onboarding_subheader_1 = "OpenDocument Reader allows you to view documents that are stored in OpenDocument format (.odt, .ods, .odp and .odg). These files are usually created using LibreOffice or OpenOffice. This app allows to open such files on your mobile device too, so you can read them on the go."
static let onboarding_subheader_2 = "OpenDocument Reader not only allows to read documents on your mobile device, but also supports modifying them too. Typos are fixed in a breeze, even on the train!"
static let onboarding_subheader_3 = "OpenDocument Reader supports a huge range of other apps to open documents from. A colleague sent a presentation via Gmail? Click the attachment and this app is going to open right away!"
static let onboarding_image_1 = "onboard1"
static let onboarding_image_2 = "onboard2"
static let onboarding_image_3 = "onboard3"
enum Constants {
static let onboardingImages = ["onboard1", "onboard2", "onboard3"]

static let key_was_intro_watched = "wasIntroWatched"
static let configurationFull = "Full"
static let configurationLite = "Lite"
}
33 changes: 15 additions & 18 deletions OpenDocumentReader/ContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,29 @@ class ContentViewController: UIViewController {
pageControl.pageIndicatorTintColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
}

switch index {
case 0:
pageButton.setTitle(Constants.next, for: .normal)
case 1:
pageButton.setTitle(Constants.next, for: .normal)
case 2:
pageButton.setTitle(Constants.start, for: .normal)
default:
break
}
let isLastPage = index == Constants.onboardingImages.count - 1
// only en.lproj carries these keys so far, and a missing key resolves to
// the key itself rather than to the development language. The explicit
// value keeps the other 16 localizations on the English wording the
// button hardcoded before instead of showing "intro_next".
pageButton.setTitle(
isLastPage
? NSLocalizedString("intro_start", value: "Start", comment: "onboarding button on the last page")
: NSLocalizedString("intro_next", value: "Next", comment: "onboarding button advancing to the next page"),
for: .normal)
Comment thread
andiwand marked this conversation as resolved.

headerLabel.text = header
subHeaderLabel.text = subHeader
imageView.image = UIImage(named: imageFile)
pageControl.currentPage = index
pageControl.numberOfPages = 3
pageControl.numberOfPages = Constants.onboardingImages.count
}


@IBAction func pageButtonPressed(_ sender: Any) {
switch index {
case 0,1:
let pageVC = parent as! PageViewController
pageVC.nextVC(atIndex: index)
case 0, 1:
(parent as? PageViewController)?.nextVC(atIndex: index)
case 2:
dismissViewController()
default:
Expand All @@ -68,10 +67,8 @@ class ContentViewController: UIViewController {
}

func dismissViewController() {
let userDefaults = UserDefaults.standard
userDefaults.setValue(true, forKey: Constants.key_was_intro_watched)
userDefaults.synchronize()

UserDefaults.standard.set(true, forKey: Constants.key_was_intro_watched)

dismiss(animated: true, completion: nil)
}

Expand Down
33 changes: 28 additions & 5 deletions OpenDocumentReader/CoreWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,37 @@

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

extern NSErrorDomain const CoreWrapperErrorDomain;

typedef NS_ERROR_ENUM(CoreWrapperErrorDomain, CoreWrapperError) {
/// odrcore threw something we have no specific handling for.
CoreWrapperErrorUnknown = 1,
/// The document is encrypted and the supplied password did not open it.
CoreWrapperErrorWrongPassword = 2,
/// Not a document odrcore can translate. PDFs land here on purpose.
CoreWrapperErrorUnsupportedFileType = 3,
};

@interface CoreWrapper : NSObject

@property NSArray *pageNames;
@property NSArray *pagePaths;
@property NSNumber *errorCode;
@property (nonatomic, copy, readonly) NSArray<NSString *> *pageNames;
@property (nonatomic, copy, readonly) NSArray<NSString *> *pagePaths;

- (BOOL)translate:(NSString *)inputPath
cache:(NSString *)cachePath
into:(NSString *)outputPath
with:(nullable NSString *)password
editable:(BOOL)editable
error:(NSError **)error;

- (BOOL)backTranslate:(NSString *)diff
into:(NSString *)outputPath
error:(NSError **)error;

- (bool)translate:(NSString *)inputPath cache:(NSString *)cachePath into:(NSString *)outputPath with:(NSString *)password editable:(bool)editable;
- (bool)backTranslate:(NSString *)diff into:(NSString *)outputPath;
@end

NS_ASSUME_NONNULL_END

#endif /* CoreWrapper_h */
Loading
Loading