From f38b9076809abf1cfafc8815b1f5f7685617036e Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Thu, 27 Dec 2018 22:49:19 +0100 Subject: [PATCH] Mobile: Fixes #1057: Fix missing title field issue in Android --- ReactNativeClient/android/app/build.gradle | 4 +- .../lib/components/note-body-viewer.js | 2 + .../lib/components/screens/note.js | 22 ++++++++++ ReactNativeClient/lib/joplin-database.js | 3 +- ReactNativeClient/package-lock.json | 43 ++++++++----------- 5 files changed, 45 insertions(+), 29 deletions(-) diff --git a/ReactNativeClient/android/app/build.gradle b/ReactNativeClient/android/app/build.gradle index 44ad066c0..9198998dc 100644 --- a/ReactNativeClient/android/app/build.gradle +++ b/ReactNativeClient/android/app/build.gradle @@ -90,8 +90,8 @@ android { applicationId "net.cozic.joplin" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 2097437 - versionName "1.0.201" + versionCode 2097459 + versionName "1.0.223" ndk { abiFilters "armeabi-v7a", "x86" } diff --git a/ReactNativeClient/lib/components/note-body-viewer.js b/ReactNativeClient/lib/components/note-body-viewer.js index 5a74783cd..9a597d916 100644 --- a/ReactNativeClient/lib/components/note-body-viewer.js +++ b/ReactNativeClient/lib/components/note-body-viewer.js @@ -37,6 +37,8 @@ class NoteBodyViewer extends Component { if (!this.isMounted_) return; this.setState({ webViewLoaded: true }); }, 100); + + if (this.props.onLoadEnd) this.props.onLoadEnd(); } shouldComponentUpdate(nextProps, nextState) { diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index 115595aa1..b9382e29f 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -63,6 +63,15 @@ class NoteScreenComponent extends BaseScreenComponent { noteTagDialogShown: false, fromShare: false, showCamera: false, + + // HACK: For reasons I can't explain, when the WebView is present, the TextInput initially does not display (It's just a white rectangle with + // no visible text). It will only appear when tapping it or doing certain action like selecting text on the webview. The bug started to + // appear one day and did not go away - reverting to an old RN version did not help, undoing all + // the commits till a working version did not help. The bug also does not happen in the simulator which makes it hard to fix. + // Eventually, a way that "worked" is to add a 1px margin on top of the text input just after the webview has loaded, then removing this + // margin. This forces RN to update the text input and to display it. Maybe that hack can be removed once RN is upgraded. + // See https://github.com/laurent22/joplin/issues/1057 + HACK_webviewLoadingState: 0, }; // iOS doesn't support multiline text fields properly so disable it @@ -602,6 +611,14 @@ class NoteScreenComponent extends BaseScreenComponent { note={note} highlightedKeywords={keywords} onCheckboxChange={(newBody) => { onCheckboxChange(newBody) }} + onLoadEnd={() => { + setTimeout(() => { + this.setState({ HACK_webviewLoadingState: this.state.HACK_webviewLoadingState + 1 }); + setTimeout(() => { + this.setState({ HACK_webviewLoadingState: this.state.HACK_webviewLoadingState + 1 }); + }, 50); + }, 50); + }} /> } else { const focusBody = !isNew && !!note.title; @@ -649,6 +666,7 @@ class NoteScreenComponent extends BaseScreenComponent { let titleTextInputStyle = { flex: 1, + marginTop: 0, paddingLeft: 0, color: theme.color, backgroundColor: theme.backgroundColor, @@ -668,6 +686,10 @@ class NoteScreenComponent extends BaseScreenComponent { paddingBottom: 10, // Added for iOS (Not needed for Android??) } + if (this.state.HACK_webviewLoadingState === 1) { + titleTextInputStyle.marginTop = 1; + } + const dueDate = isTodo && note.todo_due ? new Date(note.todo_due) : null; const titleComp = ( diff --git a/ReactNativeClient/lib/joplin-database.js b/ReactNativeClient/lib/joplin-database.js index 17f92efdf..660d2987e 100644 --- a/ReactNativeClient/lib/joplin-database.js +++ b/ReactNativeClient/lib/joplin-database.js @@ -261,7 +261,8 @@ class JoplinDatabase extends Database { // default value and thus might cause problems. In that case, the default value // must be set in the synchronizer too. - const existingDatabaseVersions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; + // Note: v16 and v17 don't do anything. They were used to debug an issue. + const existingDatabaseVersions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]; let currentVersionIndex = existingDatabaseVersions.indexOf(fromVersion); diff --git a/ReactNativeClient/package-lock.json b/ReactNativeClient/package-lock.json index 79d2e5829..e29ca890d 100644 --- a/ReactNativeClient/package-lock.json +++ b/ReactNativeClient/package-lock.json @@ -1016,7 +1016,7 @@ }, "ansi-colors": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", "requires": { "ansi-wrap": "^0.1.0" @@ -2832,14 +2832,14 @@ "dependencies": { "kind-of": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", "integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=" } } }, "external-editor": { "version": "2.2.0", - "resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", "requires": { "chardet": "^0.4.0", @@ -3112,13 +3112,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3131,13 +3129,11 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", @@ -3244,8 +3240,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -3255,7 +3250,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3268,7 +3262,6 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3368,8 +3361,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -3484,7 +3476,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3808,7 +3799,7 @@ }, "http-errors": { "version": "1.6.3", - "resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", "requires": { "depd": "~1.1.2", @@ -4924,7 +4915,7 @@ }, "jsonfile": { "version": "2.4.0", - "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "requires": { "graceful-fs": "^4.1.6" @@ -5997,7 +5988,7 @@ }, "opn": { "version": "3.0.3", - "resolved": "http://registry.npmjs.org/opn/-/opn-3.0.3.tgz", + "resolved": "https://registry.npmjs.org/opn/-/opn-3.0.3.tgz", "integrity": "sha1-ttmec5n3jWXDuq/+8fsojpuFJDo=", "requires": { "object-assign": "^4.0.1" @@ -6172,7 +6163,7 @@ }, "pegjs": { "version": "0.10.0", - "resolved": "http://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", + "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", "integrity": "sha1-z4uvrm7d/0tafvsYUmnqr0YQ3b0=" }, "performance-now": { @@ -6286,7 +6277,7 @@ }, "pretty-format": { "version": "4.3.1", - "resolved": "http://registry.npmjs.org/pretty-format/-/pretty-format-4.3.1.tgz", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-4.3.1.tgz", "integrity": "sha1-UwvlxCs8BbNkFKeipDN6qArNDo0=" }, "private": { @@ -7266,7 +7257,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -8411,7 +8402,7 @@ "dependencies": { "rimraf": { "version": "2.2.8", - "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=" } } @@ -8437,7 +8428,7 @@ }, "through": { "version": "2.3.8", - "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { @@ -9048,7 +9039,7 @@ "dependencies": { "sax": { "version": "1.1.6", - "resolved": "http://registry.npmjs.org/sax/-/sax-1.1.6.tgz", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.1.6.tgz", "integrity": "sha1-XWFr6KXmB9VOEUr65Vt+ry/MMkA=" } }