Skip to content

Commit

Permalink
Merge pull request #51 from opendocument-app/development
Browse files Browse the repository at this point in the history
1.14
  • Loading branch information
TomTasche authored Apr 5, 2020
2 parents 7c30841 + b411f53 commit 4961e40
Show file tree
Hide file tree
Showing 27 changed files with 1,577 additions and 1,079 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ios_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install pods
run: pod install
- name: Run build.sh
run: bash build.sh
run: bash build-simulator.sh
- name: Build
run: |
xcodebuild clean build -workspace OpenDocumentReader.xcworkspace -scheme "${scheme}" -destination "${destination}" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.12.4)

option (ODR_TEST "" OFF)
set(ODR_TEST OFF)

add_subdirectory(OpenDocument.core)
2 changes: 1 addition & 1 deletion OpenDocument.core
1,383 changes: 341 additions & 1,042 deletions OpenDocumentReader.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions OpenDocumentReader/CoreWrapper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

#import "CoreWrapper.h"

#include "TranslationHelper.h"
#include "TranslationConfig.h"
#include "FileMeta.h"
#include "odr/OpenDocumentReader.h"
#include "odr/Config.h"
#include "odr/Meta.h"

@implementation CoreWrapper {
odr::TranslationHelper translator;
odr::OpenDocumentReader translator;
bool initialized;
}

Expand All @@ -25,15 +25,15 @@ - (bool)translate:(NSString *)inputPath into:(NSString *)outputPath at:(NSNumber
_errorCode = 0;

if (!initialized) {
bool opened = translator.openOpenDocument([inputPath cStringUsingEncoding:NSUTF8StringEncoding]);
bool opened = translator.open([inputPath cStringUsingEncoding:NSUTF8StringEncoding]);
if (!opened) {
_errorCode = @(-1);
return false;
}

const auto meta = translator.getMeta();

bool decrypted = !meta->encrypted;
bool decrypted = !meta.encrypted;
if (password != nil) {
decrypted = translator.decrypt([password cStringUsingEncoding:NSUTF8StringEncoding]);
}
Expand All @@ -44,10 +44,10 @@ - (bool)translate:(NSString *)inputPath into:(NSString *)outputPath at:(NSNumber
}

NSMutableArray *pageNames = [[NSMutableArray alloc] init];
if (meta->type == odr::FileType::OPENDOCUMENT_TEXT) {
if (meta.type == odr::FileType::OPENDOCUMENT_TEXT) {
[pageNames addObject:@"Text document"];
} else {
for (auto page = meta->entries.begin(); page != meta->entries.end(); page++) {
for (auto page = meta.entries.begin(); page != meta.entries.end(); page++) {
auto pageName = page->name;

[pageNames addObject:[NSString stringWithCString:pageName.c_str() encoding:[NSString defaultCStringEncoding]]];
Expand All @@ -58,7 +58,7 @@ - (bool)translate:(NSString *)inputPath into:(NSString *)outputPath at:(NSNumber
initialized = true;
}

odr::TranslationConfig config = {};
odr::Config config = {};
config.editable = editable;
config.entryOffset = page.intValue;
config.entryCount = 1;
Expand Down
6 changes: 3 additions & 3 deletions OpenDocumentReader/DocumentBrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class DocumentBrowserViewController: UIDocumentBrowserViewController, UIDocument

func documentBrowser(_ controller: UIDocumentBrowserViewController, failedToImportDocumentAt documentURL: URL, error: Error?) {
let alert = UIAlertController(
title: "Unable to Import Document",
message: "An error occurred while trying to import a document: \(error?.localizedDescription ?? "No Description")",
title: "",
message: NSLocalizedString("alert_error_generic", comment: ""),
preferredStyle: .alert)

let action = UIAlertAction(
title: "OK",
title: NSLocalizedString("ok", comment: ""),
style: .cancel,
handler: nil)

Expand Down
30 changes: 15 additions & 15 deletions OpenDocumentReader/DocumentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ class DocumentViewController: UIViewController, DocumentDelegate {
}

if doc.edit {
let alert = UIAlertController(title: "You have unsaved changes", message: "Save them now?", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "No", style: .destructive, handler: { (_) in
let alert = UIAlertController(title: NSLocalizedString("alert_unsaved_changes", comment: ""), message: NSLocalizedString("alert_save_now", comment: ""), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("no", comment: ""), style: .destructive, handler: { (_) in
Analytics.logEvent("alert_unsaved_changes_no", parameters: nil)

self.discardChanges()
self.closeCurrentDocument()
}))
alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: { (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("yes", comment: ""), style: .default, handler: { (_) in
Analytics.logEvent("alert_unsaved_changes_yes", parameters: nil)

self.saveContent()
Expand Down Expand Up @@ -152,31 +152,31 @@ class DocumentViewController: UIViewController, DocumentDelegate {
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

if (document?.isOdf ?? false && !(document?.edit ?? false)) {
alert.addAction(UIAlertAction(title: "Edit (EXPERIMENTAL)", style: .default, handler: { (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("menu_edit", comment: ""), style: .default, handler: { (_) in
self.editDocument()
}))
}

if document?.edit ?? false {
alert.addAction(UIAlertAction(title: "Save", style: .default, handler: { (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("menu_save", comment: ""), style: .default, handler: { (_) in
self.saveContent()
}))

alert.addAction(UIAlertAction(title: "Discard changes", style: .default, handler: { (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("menu_discard_changes", comment: ""), style: .default, handler: { (_) in
self.discardChanges()
}))
}

alert.addAction(UIAlertAction(title: "Fullscreen", style: .default, handler: { (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("menu_fullscreen", comment: ""), style: .default, handler: { (_) in
self.toggleFullscreen()
}))
alert.addAction(UIAlertAction(title: "Print", style: .default, handler: { (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("menu_cloud_print", comment: ""), style: .default, handler: { (_) in
self.printDocument()
}))
alert.addAction(UIAlertAction(title: "Help!?", style: .default, handler: { (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("menu_help", comment: ""), style: .default, handler: { (_) in
self.showWebsite()
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
alert.addAction(UIAlertAction(title: NSLocalizedString("cancel", comment: ""), style: .cancel, handler: nil))

alert.popoverPresentationController?.sourceView = menuButton.value(forKey: "view") as? UIView
self.present(alert, animated: true, completion: nil)
Expand Down Expand Up @@ -207,10 +207,10 @@ class DocumentViewController: UIViewController, DocumentDelegate {
let message: String
let color: UIColor
if success {
message = "Successfully saved"
message = NSLocalizedString("alert_document_saved", comment: "")
color = .green
} else {
message = "Error while saving"
message = NSLocalizedString("alert_error_save_failed", comment: "")
color = .red
}

Expand Down Expand Up @@ -280,14 +280,14 @@ class DocumentViewController: UIViewController, DocumentDelegate {
})
}

let alert = UIAlertController(title: "Document encrypted", message: "Please enter the password to decrypt this document", preferredStyle: .alert)
let alert = UIAlertController(title: NSLocalizedString("alert_error_password_protected", comment: ""), message: NSLocalizedString("alert_enter_password", comment: ""), preferredStyle: .alert)
alert.addTextField { (textField) in
textField.text = ""
}
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { [] (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("cancel", comment: ""), style: .cancel, handler: { [] (_) in
self.returnToDocuments("nil" as Any)
}))
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { [weak alert] (_) in
alert.addAction(UIAlertAction(title: NSLocalizedString("ok", comment: ""), style: .default, handler: { [weak alert] (_) in
let textField = alert?.textFields![0]

self.document?.password = textField!.text!
Expand Down
12 changes: 6 additions & 6 deletions OpenDocumentReader/PageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class PageViewController: UIPageViewController {

let contentViewController = "contentViewController"

var headersArray = [Constants.onboarding_header_1,
Constants.onboarding_header_2,
Constants.onboarding_header_3]
var subHeadersArray = [Constants.onboarding_subheader_1,
Constants.onboarding_subheader_2,
Constants.onboarding_subheader_3]
var headersArray = [NSLocalizedString("intro_title_1", comment: ""),
NSLocalizedString("intro_title_2", comment: ""),
NSLocalizedString("intro_title_3", comment: ""),]
var subHeadersArray = [NSLocalizedString("intro_description_1", comment: ""),
NSLocalizedString("intro_description_2", comment: ""),
NSLocalizedString("intro_description_3", comment: ""),]
var imagesArray = [Constants.onboarding_image_1,
Constants.onboarding_image_2,
Constants.onboarding_image_3]
Expand Down
74 changes: 74 additions & 0 deletions OpenDocumentReader/ca.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* */
"alert_error_generic" = "Hi ha hagut un problema. No s'ha pogut obrir el fitxer.";

/* */
"ok" = "OK";

/* */
"no_description" = "No Description";

/* */
"alert_unsaved_changes" = "You have unsaved changes";

/* */
"alert_save_now" = "Save them now?";

/* */
"yes" = "Yes";

/* */
"no" = "No";

/* */
"menu_edit" = "Edit document";

/* */
"menu_save" = "Save";

/* */
"menu_discard_changes" = "Discard changes";

/* */
"menu_fullscreen" = "Mode de pantalla completa";

/* */
"menu_cloud_print" = "Google Cloud Print";

/* */
"menu_help" = "Help!?";

/* */
"cancel" = "Cancel";

/* */
"alert_document_saved" = "Document saved";

/* */
"alert_error_save_failed" = "File could not be saved. Please contact [email protected]";

/* */
"alert_error_password_protected" = "El document està protegit per contrasenya";

/* */
"alert_enter_password" = "Please enter the password to decrypt this document";

/* */
"intro_title_1" = "Open and read your ODF file on the go!";

/* */
"intro_title_2" = "Found a typo in your document? Now supports modification!";

/* */
"intro_title_3" = "Read your documents from within other apps";

/* */
"intro_description_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.";

/* */
"intro_description_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!";

/* */
"intro_description_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!";



74 changes: 74 additions & 0 deletions OpenDocumentReader/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* */
"alert_error_generic" = "Něco se pokazilo. Nelze otevřít soubor.";

/* */
"ok" = "OK";

/* */
"no_description" = "No Description";

/* */
"alert_unsaved_changes" = "You have unsaved changes";

/* */
"alert_save_now" = "Save them now?";

/* */
"yes" = "Yes";

/* */
"no" = "No";

/* */
"menu_edit" = "Upravit dokument";

/* */
"menu_save" = "Uložit";

/* */
"menu_discard_changes" = "Discard changes";

/* */
"menu_fullscreen" = "Celá obrazovka";

/* */
"menu_cloud_print" = "Google Cloud Print";

/* */
"menu_help" = "Help!?";

/* */
"cancel" = "Cancel";

/* */
"alert_document_saved" = "Document saved";

/* */
"alert_error_save_failed" = "File could not be saved. Please contact [email protected]";

/* */
"alert_error_password_protected" = "Dokument je chráněn heslem";

/* */
"alert_enter_password" = "Please enter the password to decrypt this document";

/* */
"intro_title_1" = "Open and read your ODF file on the go!";

/* */
"intro_title_2" = "Found a typo in your document? Now supports modification!";

/* */
"intro_title_3" = "Read your documents from within other apps";

/* */
"intro_description_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.";

/* */
"intro_description_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!";

/* */
"intro_description_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!";



Loading

0 comments on commit 4961e40

Please sign in to comment.