Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi image picker #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/controllers/phone/cameraGallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ function openComponent(e) {
saveToGallery();
break;
case 'openFromGallery':
openFromGallery();
openFromGallery(false);
break;
case 'openFromGalleryMulti':
openFromGallery(true);
break;
default:
logger.log('Ti.Media', 'Unknown action selected: ' + action);
Expand Down Expand Up @@ -106,17 +109,22 @@ function saveToGallery() {
});
}

function openFromGallery() {
function openFromGallery(allowMultiple) {
require('/permissions').checkCameraPermission(success => {
if (!success) {
alert('No permissions!');
return;
}

Ti.Media.openPhotoGallery({
allowMultiple: allowMultiple,
success: (e) => {
logger.log('Ti.Media', 'Image open successfully!');
processImage(e.media);
if (e.images) {
processImage(e.images[0].media);
} else {
processImage(e.media);
}
},
error: ({ error }) => {
logger.log('Ti.Media', 'Error opening image: ' + error);
Expand Down
3 changes: 2 additions & 1 deletion app/views/phone/cameraGallery.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
</ListSection>
<ListSection headerTitle="Gallery">
<!-- Disable on Windows, TIMOB-25282, TIMOB-25281-->
<ListItem title="Save to Gallery" itemId="saveToGallery" platform="!windows"/>
<ListItem title="Save to Gallery" itemId="saveToGallery"/>
<ListItem title="Open from Gallery" itemId="openFromGallery" />
<ListItem title="Open from Gallery (multi images)" itemId="openFromGalleryMulti" />
</ListSection>
</ListView>
</Window>
Expand Down