diff --git a/ReactNativeClient/android/app/build.gradle b/ReactNativeClient/android/app/build.gradle index d63fda8e6..5cea267a6 100644 --- a/ReactNativeClient/android/app/build.gradle +++ b/ReactNativeClient/android/app/build.gradle @@ -90,8 +90,8 @@ android { applicationId "net.cozic.joplin" minSdkVersion 16 targetSdkVersion 22 - versionCode 31 - versionName "0.9.18" + versionCode 32 + versionName "0.9.19" ndk { abiFilters "armeabi-v7a", "x86" } diff --git a/ReactNativeClient/debug_log.sh b/ReactNativeClient/debug_log.sh new file mode 100644 index 000000000..7ab2f2c52 --- /dev/null +++ b/ReactNativeClient/debug_log.sh @@ -0,0 +1,2 @@ +#!/bin/bash +adb logcat *:S ReactNative:V ReactNativeJS:V \ No newline at end of file diff --git a/ReactNativeClient/lib/components/item-list.js b/ReactNativeClient/lib/components/item-list.js deleted file mode 100644 index f4018dcb0..000000000 --- a/ReactNativeClient/lib/components/item-list.js +++ /dev/null @@ -1,101 +0,0 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux' -import { ListView, Text, TouchableHighlight, Switch, View, StyleSheet } from 'react-native'; -import { Log } from 'lib/log.js'; -import { _ } from 'lib/locale.js'; -import { Checkbox } from 'lib/components/checkbox.js'; -import { NoteItem } from 'lib/components/note-item.js'; -import { reg } from 'lib/registry.js'; -import { Note } from 'lib/models/note.js'; -import { Setting } from 'lib/models/setting.js'; -import { time } from 'lib/time-utils.js'; -import { globalStyle } from 'lib/components/global-style.js'; - -const styles = StyleSheet.create({ - noItemMessage: { - paddingLeft: globalStyle.marginLeft, - paddingRight: globalStyle.marginRight, - paddingTop: globalStyle.marginTop, - paddingBottom: globalStyle.marginBottom - }, -}); - -class ItemListComponent extends Component { - - constructor() { - super(); - const ds = new ListView.DataSource({ - rowHasChanged: (r1, r2) => { return r1 !== r2; } - }); - this.state = { - dataSource: ds, - items: [], - selectedItemIds: [], - }; - } - - filterNotes(notes) { - const todoFilter = Setting.value('todoFilter'); - if (todoFilter == 'all') return notes; - - const now = time.unixMs(); - const maxInterval = 1000 * 60 * 60 * 24 * 2; - const notRecentTime = now - maxInterval; - - let output = []; - for (let i = 0; i < notes.length; i++) { - const note = notes[i]; - if (note.is_todo) { - if (todoFilter == 'recent' && note.updated_time < notRecentTime && !!note.todo_completed) continue; - if (todoFilter == 'nonCompleted' && !!note.todo_completed) continue; - } - output.push(note); - } - return output; - } - - componentWillMount() { - const newDataSource = this.state.dataSource.cloneWithRows(this.filterNotes(this.props.items)); - this.state = { dataSource: newDataSource }; - } - - componentWillReceiveProps(newProps) { - // https://stackoverflow.com/questions/38186114/react-native-redux-and-listview - this.setState({ - dataSource: this.state.dataSource.cloneWithRows(this.filterNotes(newProps.items)), - }); - } - - async todoCheckbox_change(itemId, checked) { - let note = await Note.load(itemId); - await Note.save({ id: note.id, todo_completed: checked ? time.unixMs() : 0 }); - reg.scheduleSync(); - } - - listView_itemLongPress(itemId) {} - listView_itemPress(itemId) {} - - render() { - // `enableEmptySections` is to fix this warning: https://github.com/FaridSafi/react-native-gifted-listview/issues/39 - - if (this.state.dataSource.getRowCount()) { - return ( - { - return this.listView_itemPress(note.id) } - onCheckboxChange={(note, checked) => this.todoCheckbox_change(note.id, checked) } - /> }} - enableEmptySections={true} - /> - ); - } else { - const noItemMessage = this.props.noItemMessage ? this.props.noItemMessage : ''; - return {noItemMessage}; - } - } -} - -export { ItemListComponent }; \ No newline at end of file diff --git a/ReactNativeClient/lib/components/note-list.js b/ReactNativeClient/lib/components/note-list.js index e13e93a94..3da7c66b9 100644 --- a/ReactNativeClient/lib/components/note-list.js +++ b/ReactNativeClient/lib/components/note-list.js @@ -1,11 +1,76 @@ import React, { Component } from 'react'; import { connect } from 'react-redux' -import { ListView, Text, TouchableHighlight } from 'react-native'; +import { ListView, Text, TouchableHighlight, Switch, View, StyleSheet } from 'react-native'; import { Log } from 'lib/log.js'; -import { ItemListComponent } from 'lib/components/item-list.js'; import { _ } from 'lib/locale.js'; +import { Checkbox } from 'lib/components/checkbox.js'; +import { NoteItem } from 'lib/components/note-item.js'; +import { reg } from 'lib/registry.js'; +import { Note } from 'lib/models/note.js'; +import { Setting } from 'lib/models/setting.js'; +import { time } from 'lib/time-utils.js'; +import { globalStyle } from 'lib/components/global-style.js'; -class NoteListComponent extends ItemListComponent { +const styles = StyleSheet.create({ + noItemMessage: { + paddingLeft: globalStyle.marginLeft, + paddingRight: globalStyle.marginRight, + paddingTop: globalStyle.marginTop, + paddingBottom: globalStyle.marginBottom + }, +}); + +class NoteListComponent extends Component { + + constructor() { + super(); + const ds = new ListView.DataSource({ + rowHasChanged: (r1, r2) => { return r1 !== r2; } + }); + this.state = { + dataSource: ds, + items: [], + selectedItemIds: [], + }; + } + + filterNotes(notes) { + const todoFilter = Setting.value('todoFilter'); + if (todoFilter == 'all') return notes; + + const now = time.unixMs(); + const maxInterval = 1000 * 60 * 60 * 24; + const notRecentTime = now - maxInterval; + + let output = []; + for (let i = 0; i < notes.length; i++) { + const note = notes[i]; + if (note.is_todo) { + if (todoFilter == 'recent' && note.updated_time < notRecentTime && !!note.todo_completed) continue; + if (todoFilter == 'nonCompleted' && !!note.todo_completed) continue; + } + output.push(note); + } + return output; + } + + componentWillMount() { + const newDataSource = this.state.dataSource.cloneWithRows(this.filterNotes(this.props.items)); + this.state = { dataSource: newDataSource }; + } + + componentWillReceiveProps(newProps) { + // https://stackoverflow.com/questions/38186114/react-native-redux-and-listview + this.setState({ + dataSource: this.state.dataSource.cloneWithRows(this.filterNotes(newProps.items)), + }); + } + + async todoCheckbox_change(itemId, checked) { + let note = await Note.load(itemId); + await Note.save({ id: note.id, todo_completed: checked ? time.unixMs() : 0 }); + reg.scheduleSync(); + } listView_itemPress(noteId) { this.props.dispatch({ @@ -15,6 +80,29 @@ class NoteListComponent extends ItemListComponent { }); } + listView_itemLongPress(itemId) {} + + render() { + // `enableEmptySections` is to fix this warning: https://github.com/FaridSafi/react-native-gifted-listview/issues/39 + + if (this.state.dataSource.getRowCount()) { + return ( + { + return this.listView_itemPress(note.id) } + onCheckboxChange={(note, checked) => this.todoCheckbox_change(note.id, checked) } + /> }} + enableEmptySections={true} + /> + ); + } else { + const noItemMessage = _('There are currently no notes. Create one by clicking on the (+) button.'); + return {noItemMessage}; + } + } } const NoteList = connect( diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index ebaa5c0c8..c9d47fc3e 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -112,11 +112,13 @@ class NoteScreenComponent extends BaseScreenComponent { note = await Note.load(this.props.noteId); } + const folder = Folder.byId(this.props.folders, note.parent_id); + this.setState({ lastSavedNote: Object.assign({}, note), note: note, mode: mode, - folder: await Folder.load(note.parent_id), + folder: folder, isLoading: false, }); @@ -439,7 +441,7 @@ class NoteScreenComponent extends BaseScreenComponent { let output = []; for (let i = 0; i < this.props.folders.length; i++) { let f = this.props.folders[i]; - output.push({ label: f.title + ' ' + f.id, value: f.id }); + output.push({ label: f.title, value: f.id }); } return output; } diff --git a/ReactNativeClient/lib/components/screens/notes.js b/ReactNativeClient/lib/components/screens/notes.js index c0122ffc8..eef205844 100644 --- a/ReactNativeClient/lib/components/screens/notes.js +++ b/ReactNativeClient/lib/components/screens/notes.js @@ -63,7 +63,7 @@ class NotesScreenComponent extends BaseScreenComponent { return ( - + { this.dialogbox = dialogbox }}/> diff --git a/ReactNativeClient/root.js b/ReactNativeClient/root.js index 9dfd161cd..1951988e9 100644 --- a/ReactNativeClient/root.js +++ b/ReactNativeClient/root.js @@ -16,7 +16,6 @@ import { BaseItem } from 'lib/models/base-item.js' import { BaseModel } from 'lib/base-model.js' import { JoplinDatabase } from 'lib/joplin-database.js' import { Database } from 'lib/database.js' -import { ItemList } from 'lib/components/item-list.js' import { NotesScreen } from 'lib/components/screens/notes.js' import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js' import { NoteScreen } from 'lib/components/screens/note.js' diff --git a/ReactNativeClient/start_server.sh b/ReactNativeClient/start_server.sh new file mode 100644 index 000000000..9bb7333d0 --- /dev/null +++ b/ReactNativeClient/start_server.sh @@ -0,0 +1,2 @@ +#!/bin/bash +npm start -- --reset-cache \ No newline at end of file