Skip to content

Commit

Permalink
add video pick option to setup
Browse files Browse the repository at this point in the history
default setup is image by default
  • Loading branch information
molaeiali committed Apr 15, 2018
1 parent 9d99da1 commit 2114b5f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected void customize(PickSetup setup) {
setup.setSystemDialog(getBool(R.string.key_system_dialog));

//setup.setWidth(800).setHeight(700);

//setup.setVideo(true);

if (getBool(R.string.key_colored_icons)) {
setup.setGalleryIcon(R.mipmap.gallery_colored);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class PickSetup implements Serializable {

private boolean systemDialog;

private boolean video;

private boolean isCameraToPictures;

@OrientationMode
Expand Down Expand Up @@ -281,6 +283,14 @@ public PickSetup setIconGravityInt(int iconGravity) {
return this;
}

public boolean isVideo() {
return video;
}

public PickSetup setVideo(boolean video){
this.video = video;
return this;
}

public PickSetup() {
setTitle("Choose")
Expand All @@ -298,7 +308,8 @@ public PickSetup() {
.setCameraIcon(R.drawable.camera)
.setSystemDialog(false)
.setCameraToPictures(true)
.setGalleryIcon(R.drawable.gallery);
.setGalleryIcon(R.drawable.gallery)
.setVideo(false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public abstract class PickImageBaseDialog extends DialogFragment implements IPic

private Boolean validProviders = null;

private IPickResult onPickResult;
private IPickClick onClick;
private IPickCancel onPickCancel;
private IPickResult onPickResult;
private IPickClick onClick;
private IPickCancel onPickCancel;


@Nullable
Expand Down Expand Up @@ -158,9 +158,8 @@ private void onBindViewListeners() {

private View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View view)
{
if (view.getId() == R.id.cancel) {
public void onClick(View view) {
if (view.getId() == R.id.cancel) {
onPickCancel.onCancelClick();
dismiss();
} else {
Expand Down Expand Up @@ -269,11 +268,10 @@ protected PickImageBaseDialog setOnClick(IPickClick onClick) {
}


protected PickImageBaseDialog setOnPickCancel(IPickCancel onPickCancel)
{
this.onPickCancel = onPickCancel;
return this;
}
protected PickImageBaseDialog setOnPickCancel(IPickCancel onPickCancel) {
this.onPickCancel = onPickCancel;
return this;
}


protected AsyncImageResult getAsyncResult() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public boolean isCamerasAvailable() {

private Intent getCameraIntent() {
if (cameraIntent == null) {
cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (setup.isVideo()) {
cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
} else {
cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
}
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraUriForProvider());

applyProviderPermission();
Expand Down Expand Up @@ -149,7 +153,11 @@ private Uri cameraUriForProvider() {
private Intent getGalleryIntent() {
if (galleryIntent == null) {
galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
galleryIntent.setType(activity.getString(R.string.image_content_type));
if (setup.isVideo()) {
galleryIntent.setType(activity.getString(R.string.video_content_type));
} else {
galleryIntent.setType(activity.getString(R.string.image_content_type));
}
}

return galleryIntent;
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/consts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<string name="provider_package">.com.vansuita.pickimage.provider</string>
<string name="image_file_name">current</string>
<string name="image_content_type">image/*</string>
<string name="video_content_type">video/*</string>
</resources>

0 comments on commit 2114b5f

Please sign in to comment.