1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Fixed geolocation bug and improved saving of notes and folders

This commit is contained in:
Laurent Cozic 2017-07-16 11:17:40 +01:00
parent e2d426a986
commit cd6d8ce284
9 changed files with 56 additions and 54 deletions

View File

@ -7,7 +7,7 @@
"url": "https://github.com/laurent22/joplin" "url": "https://github.com/laurent22/joplin"
}, },
"url": "git://github.com/laurent22/joplin.git", "url": "git://github.com/laurent22/joplin.git",
"version": "0.8.42", "version": "0.8.43",
"bin": { "bin": {
"joplin": "./main_launcher.js" "joplin": "./main_launcher.js"
}, },

View File

@ -90,8 +90,8 @@ android {
applicationId "net.cozic.joplin" applicationId "net.cozic.joplin"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 22 targetSdkVersion 22
versionCode 14 versionCode 16
versionName "0.9.1" versionName "0.9.3"
ndk { ndk {
abiFilters "armeabi-v7a", "x86" abiFilters "armeabi-v7a", "x86"
} }

View File

@ -7,7 +7,7 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> --> <!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
<!-- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> --> <!-- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> -->
<!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/> <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>
<uses-sdk <uses-sdk

View File

@ -42,9 +42,23 @@ let styleObject = {
fontWeight: 'bold', fontWeight: 'bold',
flex: 1, flex: 1,
}, },
saveButton: {
flex: 1,
backgroundColor: "#0482E3",
paddingLeft: 15,
paddingRight: 15,
marginRight: 10,
},
saveButtonText: {
textAlignVertical: 'center',
color: "#ffffff",
fontWeight: 'bold',
flex: 1,
},
}; };
styleObject.backButtonDisabled = Object.assign({}, styleObject.backButton, { backgroundColor: "#c6c6c6" }); styleObject.backButtonDisabled = Object.assign({}, styleObject.backButton, { backgroundColor: "#c6c6c6" });
styleObject.saveButtonDisabled = Object.assign({}, styleObject.saveButton, { backgroundColor: "#c6c6c6" });
const styles = StyleSheet.create(styleObject); const styles = StyleSheet.create(styleObject);
@ -100,6 +114,18 @@ class ScreenHeaderComponent extends Component {
); );
} }
function saveButton(styles, onPress, disabled, show) {
if (!show) return null;
return (
<TouchableOpacity onPress={onPress} disabled={disabled}>
<View style={disabled ? styles.saveButtonDisabled : styles.saveButton}>
<Text style={styles.saveButtonText}>Save</Text>
</View>
</TouchableOpacity>
);
}
let key = 0; let key = 0;
let menuOptionComponents = []; let menuOptionComponents = [];
for (let i = 0; i < this.props.menuOptions.length; i++) { for (let i = 0; i < this.props.menuOptions.length; i++) {
@ -130,6 +156,7 @@ class ScreenHeaderComponent extends Component {
<View style={{ flexDirection: 'row', paddingLeft: 10, paddingTop: 10, paddingBottom: 10, paddingRight: 0, backgroundColor: '#ffffff', alignItems: 'center' }} > <View style={{ flexDirection: 'row', paddingLeft: 10, paddingTop: 10, paddingBottom: 10, paddingRight: 0, backgroundColor: '#ffffff', alignItems: 'center' }} >
{ sideMenuButton(styles, () => this.sideMenuButton_press()) } { sideMenuButton(styles, () => this.sideMenuButton_press()) }
{ backButton(styles, () => this.backButton_press(), !this.props.historyCanGoBack) } { backButton(styles, () => this.backButton_press(), !this.props.historyCanGoBack) }
{ saveButton(styles, () => { if (this.props.onSaveButtonPress) this.props.onSaveButtonPress() }, this.props.saveButtonDisabled === true, this.props.showSaveButton === true) }
<Text style={{ flex:1, marginLeft: 10 }} >{title}</Text> <Text style={{ flex:1, marginLeft: 10 }} >{title}</Text>
<Menu onSelect={(value) => this.menu_select(value)}> <Menu onSelect={(value) => this.menu_select(value)}>
<MenuTrigger> <MenuTrigger>

View File

@ -83,31 +83,17 @@ class FolderScreenComponent extends BaseScreenComponent {
} }
render() { render() {
const renderActionButton = () => { let saveButtonDisabled = !this.isModified();
let buttons = [];
buttons.push({
title: _('Save'),
icon: 'md-checkmark',
onPress: () => {
this.saveFolderButton_press()
},
});
if (!this.isModified()) return <ActionButton style={{display:'none'}}/>;
let buttonIndex = this.state.mode == 'view' ? 0 : 1;
return <ActionButton multiStates={true} buttons={buttons} buttonIndex={0} />
}
const actionButtonComp = renderActionButton();
return ( return (
<View style={this.styles().screen}> <View style={this.styles().screen}>
<ScreenHeader navState={this.props.navigation.state} /> <ScreenHeader
navState={this.props.navigation.state}
showSaveButton={true}
saveButtonDisabled={saveButtonDisabled}
onSaveButtonPress={() => this.saveFolderButton_press()}
/>
<TextInput autoFocus={true} value={this.state.folder.title} onChangeText={(text) => this.title_changeText(text)} /> <TextInput autoFocus={true} value={this.state.folder.title} onChangeText={(text) => this.title_changeText(text)} />
{ actionButtonComp }
<dialogs.DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/> <dialogs.DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
</View> </View>
); );

View File

@ -271,13 +271,8 @@ class NoteScreenComponent extends BaseScreenComponent {
); );
} }
let title = null; let headerTitle = ''
let noteHeaderTitle = note && note.title ? note.title : _('New note'); if (folder) headerTitle = folder.title;
if (folder) {
title = folder.title + ' > ' + noteHeaderTitle;
} else {
title = noteHeaderTitle;
}
const renderActionButton = () => { const renderActionButton = () => {
let buttons = []; let buttons = [];
@ -290,27 +285,26 @@ class NoteScreenComponent extends BaseScreenComponent {
}, },
}); });
buttons.push({ if (this.state.mode == 'edit') return <ActionButton style={{display:'none'}}/>;
title: _('Save'),
icon: 'md-checkmark',
onPress: () => {
this.saveNoteButton_press();
return false;
},
});
if (this.state.mode == 'edit' && !this.isModified()) return <ActionButton style={{display:'none'}}/>; return <ActionButton multiStates={true} buttons={buttons} buttonIndex={0} />
let buttonIndex = this.state.mode == 'view' ? 0 : 1;
return <ActionButton multiStates={true} buttons={buttons} buttonIndex={buttonIndex} />
} }
const actionButtonComp = renderActionButton(); const actionButtonComp = renderActionButton();
let showSaveButton = this.state.mode == 'edit';
let saveButtonDisabled = !this.isModified();
return ( return (
<View style={this.styles().screen}> <View style={this.styles().screen}>
<ScreenHeader navState={this.props.navigation.state} menuOptions={this.menuOptions()} title={title} /> <ScreenHeader
title={headerTitle}
navState={this.props.navigation.state}
menuOptions={this.menuOptions()}
showSaveButton={showSaveButton}
saveButtonDisabled={saveButtonDisabled}
onSaveButtonPress={() => this.saveNoteButton_press()}
/>
<View style={{ flexDirection: 'row' }}> <View style={{ flexDirection: 'row' }}>
{ isTodo && <Checkbox checked={!!Number(note.todo_completed)} onChange={(checked) => { this.todoCheckbox_change(checked) }} /> }<TextInput style={{flex:1}} value={note.title} onChangeText={(text) => this.title_changeText(text)} /> { isTodo && <Checkbox checked={!!Number(note.todo_completed)} onChange={(checked) => { this.todoCheckbox_change(checked) }} /> }<TextInput style={{flex:1}} value={note.title} onChangeText={(text) => this.title_changeText(text)} />
</View> </View>

View File

@ -16,11 +16,6 @@ class GeolocationReact {
} }
static currentPosition(options = null) { static currentPosition(options = null) {
if (typeof navigator === 'undefined') {
// TODO
return Promise.resolve(this.currentPosition_testResponse());
}
if (!options) options = {}; if (!options) options = {};
if (!('enableHighAccuracy' in options)) options.enableHighAccuracy = true; if (!('enableHighAccuracy' in options)) options.enableHighAccuracy = true;
if (!('timeout' in options)) options.timeout = 10000; if (!('timeout' in options)) options.timeout = 10000;

View File

@ -50,7 +50,7 @@ class Synchronizer {
if (report.createLocal) lines.push(_('Created local items: %d.', report.createLocal)); if (report.createLocal) lines.push(_('Created local items: %d.', report.createLocal));
if (report.updateLocal) lines.push(_('Updated local items: %d.', report.updateLocal)); if (report.updateLocal) lines.push(_('Updated local items: %d.', report.updateLocal));
if (report.createRemote) lines.push(_('Created remote items: %d.', report.createRemote)); if (report.createRemote) lines.push(_('Created remote items: %d.', report.createRemote));
if (report.updatedRemote) lines.push(_('Updated remote items: %d.', report.updatedRemote)); if (report.updateRemote) lines.push(_('Updated remote items: %d.', report.updateRemote));
if (report.deleteLocal) lines.push(_('Deleted local items: %d.', report.deleteLocal)); if (report.deleteLocal) lines.push(_('Deleted local items: %d.', report.deleteLocal));
if (report.deleteRemote) lines.push(_('Deleted remote items: %d.', report.deleteRemote)); if (report.deleteRemote) lines.push(_('Deleted remote items: %d.', report.deleteRemote));
if (report.state) lines.push(_('State: %s.', report.state.replace(/_/g, ' '))); if (report.state) lines.push(_('State: %s.', report.state.replace(/_/g, ' ')));
@ -76,7 +76,7 @@ class Synchronizer {
if (remote) { if (remote) {
let s = []; let s = [];
s.push(remote.id); s.push(remote.id ? remote.id : remote.path);
if ('title' in remote) s.push('"' + remote.title + '"'); if ('title' in remote) s.push('"' + remote.title + '"');
line.push('(Remote ' + s.join(', ') + ')'); line.push('(Remote ' + s.join(', ') + ')');
} }

View File

@ -283,7 +283,7 @@ async function initialize(dispatch, backButtonHandler) {
dbLogger.addTarget('database', { database: logDatabase, source: 'm' }); dbLogger.addTarget('database', { database: logDatabase, source: 'm' });
if (Setting.value('env') == 'dev') dbLogger.addTarget('console'); if (Setting.value('env') == 'dev') dbLogger.addTarget('console');
if (Setting.value('env') == 'dev') { if (Setting.value('env') == 'dev') {
dbLogger.setLevel(Logger.LEVEL_DEBUG); // Set to LEVEL_DEBUG for full SQL queries dbLogger.setLevel(Logger.LEVEL_INFO); // Set to LEVEL_DEBUG for full SQL queries
} else { } else {
dbLogger.setLevel(Logger.LEVEL_INFO); dbLogger.setLevel(Logger.LEVEL_INFO);
} }