Merge branch 'master' of github.com:laurent22/joplin

pull/3358/head
Laurent Cozic 2020-06-08 09:02:04 +01:00
commit b749bb60fc
5 changed files with 43 additions and 36 deletions

View File

@ -28,7 +28,7 @@ Linux | <a href='https://github.com/laurent22/joplin/releases/download/
Operating System | Download | Alt. Download
-----------------|----------|----------------
Android | <a href='https://play.google.com/store/apps/details?id=net.cozic.joplin&utm_source=GitHub&utm_campaign=README&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'><img alt='Get it on Google Play' height="40px" src='https://joplinapp.org/images/BadgeAndroid.png'/></a> | or download the APK file: [64-bit](https://github.com/laurent22/joplin-android/releases/download/android-v1.0.330/joplin-v1.0.330.apk) [32-bit](https://github.com/laurent22/joplin-android/releases/download/android-v1.0.330/joplin-v1.0.330-32bit.apk)
Android | <a href='https://play.google.com/store/apps/details?id=net.cozic.joplin&utm_source=GitHub&utm_campaign=README&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'><img alt='Get it on Google Play' height="40px" src='https://joplinapp.org/images/BadgeAndroid.png'/></a> | or download the APK file: [64-bit](https://github.com/laurent22/joplin-android/releases/download/android-v1.0.331/joplin-v1.0.331.apk) [32-bit](https://github.com/laurent22/joplin-android/releases/download/android-v1.0.331/joplin-v1.0.331-32bit.apk)
iOS | <a href='https://itunes.apple.com/us/app/joplin/id1315599797'><img alt='Get it on the App Store' height="40px" src='https://joplinapp.org/images/BadgeIOS.png'/></a> | -
## Terminal application

View File

@ -120,8 +120,8 @@ android {
applicationId "net.cozic.joplin"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2097566
versionName "1.0.330"
versionCode 2097567
versionName "1.0.331"
ndk {
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}

View File

@ -1,9 +1,19 @@
const { PermissionsAndroid } = require('react-native');
const { Platform, PermissionsAndroid } = require('react-native');
type rationale = {
title: string,
message: string,
buttonPositive: string,
buttonNegative?: string
buttonNeutral?: string
}
export default async (permissions: string, rationale?: rationale) => {
if (Platform.OS !== 'android') return true;
export default async (permissions: string) => {
let result = await PermissionsAndroid.check(permissions);
if (result !== PermissionsAndroid.RESULTS.GRANTED) {
result = await PermissionsAndroid.request(permissions);
result = await PermissionsAndroid.request(permissions, rationale);
}
return result === PermissionsAndroid.RESULTS.GRANTED;
};

View File

@ -1,8 +1,6 @@
import { PermissionsAndroid } from 'react-native';
import Slider from '@react-native-community/slider';
const React = require('react');
const { Platform, TouchableOpacity, Linking, View, Switch, StyleSheet, Text, Button, ScrollView, TextInput, Alert } = require('react-native');
const { Platform, TouchableOpacity, Linking, View, Switch, StyleSheet, Text, Button, ScrollView, TextInput, Alert, PermissionsAndroid } = require('react-native');
const { connect } = require('react-redux');
const { ScreenHeader } = require('lib/components/screen-header.js');
const { _ } = require('lib/locale.js');
@ -20,6 +18,7 @@ const { time } = require('lib/time-utils');
const { shim } = require('lib/shim');
const SearchEngine = require('lib/services/SearchEngine');
const RNFS = require('react-native-fs');
const checkPermissions = require('lib/checkPermissions.js').default;
class ConfigScreenComponent extends BaseScreenComponent {
static navigationOptions() {
@ -101,28 +100,30 @@ class ConfigScreenComponent extends BaseScreenComponent {
const exportPath = this.state.profileExportPath;
const resourcePath = `${exportPath}/resources`;
try {
{
const copyFiles = async (source, dest) => {
await shim.fsDriver().mkdir(dest);
const files = await shim.fsDriver().readDirStats(source);
for (const file of files) {
const source_ = `${source}/${file.path}`;
const dest_ = `${dest}/${file.path}`;
if (!file.isDirectory()) {
reg.logger().info(`Copying profile: ${source_} => ${dest_}`);
await shim.fsDriver().copy(source_, dest_);
} else {
await copyFiles(source_, dest_);
}
}
};
await copyFiles(dbPath, exportPath);
await copyFiles(Setting.value('resourceDir'), resourcePath);
const hasPermissions = await checkPermissions(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
if (!hasPermissions) {
throw new Error('Permission denied');
}
const copyFiles = async (source, dest) => {
await shim.fsDriver().mkdir(dest);
const files = await shim.fsDriver().readDirStats(source);
for (const file of files) {
const source_ = `${source}/${file.path}`;
const dest_ = `${dest}/${file.path}`;
if (!file.isDirectory()) {
reg.logger().info(`Copying profile: ${source_} => ${dest_}`);
await shim.fsDriver().copy(source_, dest_);
} else {
await copyFiles(source_, dest_);
}
}
};
await copyFiles(dbPath, exportPath);
await copyFiles(Setting.value('resourceDir'), resourcePath);
alert('Profile has been exported!');
} catch (error) {
alert(`Could not export files: ${error.message}`);
@ -141,16 +142,11 @@ class ConfigScreenComponent extends BaseScreenComponent {
// Not implemented yet
return true;
}
const hasPermission = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
if (hasPermission) {
return true;
}
const requestResult = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, {
return await checkPermissions(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, {
title: _('Information'),
message: _('In order to use file system synchronisation your permission to write to external storage is required.'),
buttonPositive: _('OK'),
});
return requestResult === PermissionsAndroid.RESULTS.GRANTED;
}
UNSAFE_componentWillMount() {

View File

@ -846,8 +846,9 @@ class NoteScreenComponent extends BaseScreenComponent {
async folderPickerOptions_valueChanged(itemValue) {
const note = this.state.note;
const isProvisionalNote = this.props.provisionalNoteIds.includes(note.id);
if (!note.id) {
if (isProvisionalNote) {
await this.saveNoteButton_press(itemValue);
} else {
await Note.moveToFolder(note.id, itemValue);