mirror of
https://github.com/laurent22/joplin.git
synced 2025-04-23 11:52:59 +02:00
Mobile: Resolves #1015: (Re-)added support for selecting image from camera roll
This commit is contained in:
parent
7d0def30f0
commit
d08aaffe41
@ -161,7 +161,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.attachPhoto_onPress = this.attachPhoto_onPress.bind(this);
|
this.takePhoto_onPress = this.takePhoto_onPress.bind(this);
|
||||||
this.cameraView_onPhoto = this.cameraView_onPhoto.bind(this);
|
this.cameraView_onPhoto = this.cameraView_onPhoto.bind(this);
|
||||||
this.cameraView_onCancel = this.cameraView_onCancel.bind(this);
|
this.cameraView_onCancel = this.cameraView_onCancel.bind(this);
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
|
|
||||||
showImagePicker(options) {
|
showImagePicker(options) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ImagePicker.showImagePicker(options, (response) => {
|
ImagePicker.launchImageLibrary(options, (response) => {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -380,7 +380,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
let resource = Resource.new();
|
let resource = Resource.new();
|
||||||
resource.id = uuid.create();
|
resource.id = uuid.create();
|
||||||
resource.mime = mimeType;
|
resource.mime = mimeType;
|
||||||
resource.title = pickerResponse.fileName ? pickerResponse.fileName : _('Untitled');
|
resource.title = pickerResponse.fileName ? pickerResponse.fileName : '';
|
||||||
resource.file_extension = safeFileExtension(fileExtension(pickerResponse.fileName ? pickerResponse.fileName : localFilePath));
|
resource.file_extension = safeFileExtension(fileExtension(pickerResponse.fileName ? pickerResponse.fileName : localFilePath));
|
||||||
|
|
||||||
if (!resource.mime) resource.mime = 'application/octet-stream';
|
if (!resource.mime) resource.mime = 'application/octet-stream';
|
||||||
@ -419,15 +419,12 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
this.setState({ note: newNote });
|
this.setState({ note: newNote });
|
||||||
}
|
}
|
||||||
|
|
||||||
async attachImage_onPress() {
|
async attachPhoto_onPress() {
|
||||||
const options = {
|
const response = await this.showImagePicker({ mediaType: 'photo' });
|
||||||
mediaType: 'photo',
|
|
||||||
};
|
|
||||||
const response = await this.showImagePicker(options);
|
|
||||||
await this.attachFile(response, 'image');
|
await this.attachFile(response, 'image');
|
||||||
}
|
}
|
||||||
|
|
||||||
attachPhoto_onPress() {
|
takePhoto_onPress() {
|
||||||
this.setState({ showCamera: true });
|
this.setState({ showCamera: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,6 +527,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
let canAttachPicture = true;
|
let canAttachPicture = true;
|
||||||
if (Platform.OS === 'android' && Platform.Version < 21) canAttachPicture = false;
|
if (Platform.OS === 'android' && Platform.Version < 21) canAttachPicture = false;
|
||||||
if (canAttachPicture) {
|
if (canAttachPicture) {
|
||||||
|
output.push({ title: _('Take photo'), onPress: () => { this.takePhoto_onPress(); } });
|
||||||
output.push({ title: _('Attach photo'), onPress: () => { this.attachPhoto_onPress(); } });
|
output.push({ title: _('Attach photo'), onPress: () => { this.attachPhoto_onPress(); } });
|
||||||
output.push({ title: _('Attach any file'), onPress: () => { this.attachFile_onPress(); } });
|
output.push({ title: _('Attach any file'), onPress: () => { this.attachFile_onPress(); } });
|
||||||
output.push({ isDivider: true });
|
output.push({ isDivider: true });
|
||||||
@ -583,9 +581,6 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
return <CameraView theme={this.props.theme} style={{flex:1}} onPhoto={this.cameraView_onPhoto} onCancel={this.cameraView_onCancel}/>
|
return <CameraView theme={this.props.theme} style={{flex:1}} onPhoto={this.cameraView_onPhoto} onCancel={this.cameraView_onCancel}/>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let bodyComponent = null;
|
let bodyComponent = null;
|
||||||
if (this.state.mode == 'view') {
|
if (this.state.mode == 'view') {
|
||||||
const onCheckboxChange = (newBody) => {
|
const onCheckboxChange = (newBody) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user