From 4b5c1491d0c9929c29fb9bd847da3690776c99fa Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 19 Nov 2017 15:19:36 +0000 Subject: [PATCH] iOS: various fixes --- .../ios/Joplin.xcodeproj/project.pbxproj | 20 +++++++++++ ReactNativeClient/ios/Joplin/Info.plist | 34 +++++++++---------- .../ios/Joplin/Joplin.entitlements | 20 +++++++++++ .../lib/components/note-body-viewer.js | 10 ++++-- .../lib/components/screen-header.js | 2 +- .../lib/components/screens/note.js | 17 +++++++--- 6 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 ReactNativeClient/ios/Joplin/Joplin.entitlements diff --git a/ReactNativeClient/ios/Joplin.xcodeproj/project.pbxproj b/ReactNativeClient/ios/Joplin.xcodeproj/project.pbxproj index d87363aa0..3e52e2378 100644 --- a/ReactNativeClient/ios/Joplin.xcodeproj/project.pbxproj +++ b/ReactNativeClient/ios/Joplin.xcodeproj/project.pbxproj @@ -382,6 +382,7 @@ 2D02E4901E0B4A5D006451C7 /* Joplin-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Joplin-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 381C047F2739439CB3E6452A /* libRNVectorIcons.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNVectorIcons.a; sourceTree = ""; }; 3FFC0F5EFDC54862B1F998DD /* Foundation.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Foundation.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Foundation.ttf"; sourceTree = ""; }; + 4DA7F7A61FC1196F00353191 /* Joplin.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Joplin.entitlements; path = Joplin/Joplin.entitlements; sourceTree = ""; }; 508DD20D1EA341CA8F730F22 /* libRCTImageResizer.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTImageResizer.a; sourceTree = ""; }; 51BCEC3BC28046C8BB19531F /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf"; sourceTree = ""; }; 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; @@ -557,6 +558,7 @@ 13B07FAE1A68108700A75B9A /* Joplin */ = { isa = PBXGroup; children = ( + 4DA7F7A61FC1196F00353191 /* Joplin.entitlements */, 008F07F21AC5B25A0029DE68 /* main.jsbundle */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.m */, @@ -846,6 +848,12 @@ }; 13B07F861A680F5B00A75B9A = { DevelopmentTeam = A9BXAFS6CT; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.iCloud = { + enabled = 1; + }; + }; }; 2D02E47A1E0B4A5D006451C7 = { CreatedOnToolsVersion = 8.2.1; @@ -1454,6 +1462,9 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = Joplin/Joplin.entitlements; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEAD_CODE_STRIPPING = NO; DEVELOPMENT_TEAM = A9BXAFS6CT; @@ -1473,7 +1484,10 @@ "-ObjC", "-lc++", ); + PRODUCT_BUNDLE_IDENTIFIER = net.cozic.joplin; PRODUCT_NAME = Joplin; + PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -1482,6 +1496,9 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = Joplin/Joplin.entitlements; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = A9BXAFS6CT; HEADER_SEARCH_PATHS = ( @@ -1500,7 +1517,10 @@ "-ObjC", "-lc++", ); + PRODUCT_BUNDLE_IDENTIFIER = net.cozic.joplin; PRODUCT_NAME = Joplin; + PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; diff --git a/ReactNativeClient/ios/Joplin/Info.plist b/ReactNativeClient/ios/Joplin/Info.plist index a973da938..4c388e221 100644 --- a/ReactNativeClient/ios/Joplin/Info.plist +++ b/ReactNativeClient/ios/Joplin/Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -24,22 +24,6 @@ 1 LSRequiresIPhoneOS - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - NSLocationWhenInUseUsageDescription - NSAppTransportSecurity NSExceptionDomains @@ -51,6 +35,8 @@ + NSLocationWhenInUseUsageDescription + UIAppFonts Entypo.ttf @@ -65,5 +51,19 @@ SimpleLineIcons.ttf Zocial.ttf + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + diff --git a/ReactNativeClient/ios/Joplin/Joplin.entitlements b/ReactNativeClient/ios/Joplin/Joplin.entitlements new file mode 100644 index 000000000..367dc1be8 --- /dev/null +++ b/ReactNativeClient/ios/Joplin/Joplin.entitlements @@ -0,0 +1,20 @@ + + + + + com.apple.developer.icloud-container-identifiers + + iCloud.$(CFBundleIdentifier) + + com.apple.developer.icloud-services + + CloudDocuments + + com.apple.developer.ubiquity-container-identifiers + + iCloud.$(CFBundleIdentifier) + + com.apple.developer.ubiquity-kvstore-identifier + $(TeamIdentifierPrefix)$(CFBundleIdentifier) + + diff --git a/ReactNativeClient/lib/components/note-body-viewer.js b/ReactNativeClient/lib/components/note-body-viewer.js index 656cf0408..b93eb00e4 100644 --- a/ReactNativeClient/lib/components/note-body-viewer.js +++ b/ReactNativeClient/lib/components/note-body-viewer.js @@ -1,5 +1,5 @@ const React = require('react'); const Component = React.Component; -const { WebView, View, Linking } = require('react-native'); +const { Platform, WebView, View, Linking } = require('react-native'); const { globalStyle } = require('lib/components/global-style.js'); const { Resource } = require('lib/models/resource.js'); const { reg } = require('lib/registry.js'); @@ -52,11 +52,17 @@ class NoteBodyViewer extends Component { const html = this.mdToHtml_.render(note ? note.body : '', this.props.webViewStyle, mdOptions); let webViewStyle = {} - webViewStyle.opacity = this.state.webViewLoaded ? 1 : 0.01; + // On iOS, the onLoadEnd() event is never fired so always + // display the webview (don't do the little trick + // to avoid the white flash). + if (Platform.OS !== 'ios') { + webViewStyle.opacity = this.state.webViewLoaded ? 1 : 0.01; + } return ( this.onLoadEnd()} diff --git a/ReactNativeClient/lib/components/screen-header.js b/ReactNativeClient/lib/components/screen-header.js index 17b71724a..82448d2b6 100644 --- a/ReactNativeClient/lib/components/screen-header.js +++ b/ReactNativeClient/lib/components/screen-header.js @@ -41,7 +41,7 @@ class ScreenHeaderComponent extends Component { alignItems: 'center', shadowColor: '#000000', elevation: 5, - paddingTop: Platform.OS === 'ios' ? 10 : 0, // Extra padding for iOS because the top icons are there + paddingTop: Platform.OS === 'ios' ? 15 : 0, // Extra padding for iOS because the top icons are there }, divider: { borderBottomWidth: 1, diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index 359323861..e4498cc50 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -1,5 +1,5 @@ const React = require('react'); const Component = React.Component; -const { Keyboard, BackHandler, View, Button, TextInput, WebView, Text, StyleSheet, Linking, Image } = require('react-native'); +const { Platform, Keyboard, BackHandler, View, Button, TextInput, WebView, Text, StyleSheet, Linking, Image } = require('react-native'); const { connect } = require('react-redux'); const { uuid } = require('lib/uuid.js'); const { Log } = require('lib/log.js'); @@ -45,6 +45,9 @@ class NoteScreenComponent extends BaseScreenComponent { titleTextInputHeight: 20, }; + // iOS doesn't support multiline text fields properly so disable it + this.enableMultilineTitle_ = Platform.OS !== 'ios'; + this.saveButtonHasBeenShown_ = false; this.styles_ = {}; @@ -185,7 +188,7 @@ class NoteScreenComponent extends BaseScreenComponent { async pickDocument() { return new Promise((resolve, reject) => { - DocumentPicker.show({ filetype: [DocumentPickerUtil.images()] }, (error,res) => { + DocumentPicker.show({ filetype: [DocumentPickerUtil.allFiles()] }, (error,res) => { if (error) { // Also returns an error if the user doesn't pick a file // so just resolve with null. @@ -314,6 +317,8 @@ class NoteScreenComponent extends BaseScreenComponent { } titleTextInput_contentSizeChange(event) { + if (!this.enableMultilineTitle_) return; + let height = event.nativeEvent.contentSize.height; this.setState({ titleTextInputHeight: height }); } @@ -399,14 +404,18 @@ class NoteScreenComponent extends BaseScreenComponent { backgroundColor: theme.backgroundColor, fontWeight: 'bold', fontSize: theme.fontSize, + paddingTop: 10, // Added for iOS (Not needed for Android??) + paddingBottom: 10, // Added for iOS (Not needed for Android??) }; - titleTextInputStyle.height = this.state.titleTextInputHeight; + if (this.enableMultilineTitle_) titleTextInputStyle.height = this.state.titleTextInputHeight; let checkboxStyle = { color: theme.color, paddingRight: 10, paddingLeft: theme.marginLeft, + paddingTop: 10, // Added for iOS (Not needed for Android??) + paddingBottom: 10, // Added for iOS (Not needed for Android??) } const titleComp = ( @@ -415,7 +424,7 @@ class NoteScreenComponent extends BaseScreenComponent { this.titleTextInput_contentSizeChange(event)} autoFocus={isNew} - multiline={true} + multiline={this.enableMultilineTitle_} underlineColorAndroid="#ffffff00" autoCapitalize="sentences" style={titleTextInputStyle}