Skip to content
This repository has been archived by the owner on May 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #29 from alhazmy13/develop
Browse files Browse the repository at this point in the history
* Fix issue #26 
* request camera permission only with camera mode
  • Loading branch information
alhazmy13 authored May 17, 2017
2 parents 8a88901 + 45cd678 commit ebe0303
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 73 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ In order to receive the path of videos, you will need to override `onActivityRes
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == VideoPicker.VIDEO_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
List<String> mPaths = (List<String>) data.getSerializableExtra(ImagePicker.EXTRA_VIDEO_PATH);
List<String> mPaths = (List<String>) data.getSerializableExtra(VideoPicker.EXTRA_VIDEO_PATH);
//Your Code
}
}
Expand Down
17 changes: 9 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
apply from: '../deps.gradle'
//apply from: '../deps.gradle'

android {
compileSdkVersion versions.TARGET_SDK_VERSION
buildToolsVersion versions.BUILD_TOOLS_VERSION
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
minSdkVersion versions.MIN_SDK_VERSION
targetSdkVersion versions.TARGET_SDK_VERSION
minSdkVersion 14
targetSdkVersion 25
applicationId 'net.alhazmy13.mediapicker'
versionCode 1
versionName "1.0"
Expand All @@ -21,12 +21,13 @@ android {
lintOptions {
abortOnError false
}
buildToolsVersion '25.0.2'
}

dependencies {
compile "com.android.support:appcompat-v7:25.2.0"
compile "com.android.support:design:25.2.0"
compile "com.android.support:support-v13:25.2.0"
compile "com.android.support:appcompat-v7:25.3.1"
compile "com.android.support:design:25.3.1"
compile "com.android.support:support-v13:25.3.1"
compile project(':libary')
compile project(':rxjava')
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void onClick(View v) {
private void pickImage() {
new ImagePickerHelper(
new ImagePicker.Builder(getActivity())
.mode(ImagePicker.Mode.CAMERA_AND_GALLERY)
.mode(ImagePicker.Mode.CAMERA)
.allowMultipleImages(true)
.compressLevel(ImagePicker.ComperesLevel.MEDIUM)
.directory(ImagePicker.Directory.DEFAULT)
.extension(ImagePicker.Extension.PNG)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.alhazmy13.mediapickerexample;

import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
Expand All @@ -18,6 +19,8 @@

import rx.Subscriber;

import static android.app.Activity.RESULT_OK;

/**
* Created by alhazmy13 on 3/13/17.
*/
Expand Down Expand Up @@ -54,51 +57,33 @@ private void init(View view) {
view.findViewById(R.id.bt_pick).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pickImage();
pickVideo();
}
});
}


private void pickImage() {
new VideoPickerHelper(
new VideoPicker.Builder(getActivity())
.directory(VideoPicker.Directory.DEFAULT)
.mode(VideoPicker.Mode.CAMERA_AND_GALLERY)
.extension(VideoPicker.Extension.MP4)
private void pickVideo() {
new VideoPicker.Builder(getActivity())
.mode(VideoPicker.Mode.CAMERA_AND_GALLERY)
.directory(VideoPicker.Directory.DEFAULT)
.extension(VideoPicker.Extension.MP4)
.enableDebuggingMode(true)
.build();
}

).getObservable().subscribe(new Subscriber<List<String>>() {
@Override
public void onCompleted() {
Log.d(TAG, "onCompleted() called");
}
//
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

@Override
public void onError(Throwable e) {
Log.d(TAG, "onError() called with: e = [" + e + "]");
}
if (requestCode == VideoPicker.VIDEO_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
mPath = (List<String>) data.getSerializableExtra(VideoPicker.EXTRA_VIDEO_PATH);

@Override
public void onNext(List<String> paths) {
Log.d(TAG, "onNext() called with: strings = [" + paths + "]");
mPath = paths;
loadVideo();
}
});
loadVideo();
}
}

// //
// @Override
// public void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
//
// if (requestCode == VideoPicker.VIDEO_PICKER_REQUEST_CODE && resultCode == RESULT_OK) {
// mPath = (List<String>) data.getSerializableExtra(VideoPicker.EXTRA_VIDEO_PATH);
//
// loadImage();
// }
// }

private void loadVideo() {
if (mPath != null && mPath.size() > 0) {
Log.d(TAG, "loadImage: " + mPath.size());
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Sep 10 18:48:55 AST 2016
#Tue May 16 01:28:00 AST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
35 changes: 18 additions & 17 deletions libary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
apply from: '../deps.gradle'
//apply plugin: 'com.novoda.bintray-release'
//apply from: '../deps.gradle'

//./gradlew bintrayUpload
publish {
userOrg = 'alhazmy13'
groupId = 'net.alhazmy13.MediaPicker'
artifactId = 'libary'
uploadName = 'MediaPicker'
publishVersion = versions.LIBRARY_VERSION
desc = 'MediaPickerRx'
dryRun = false
website = 'https://github.com/alhzmy13/MediaPicker'
}
//publish {
// userOrg = 'alhazmy13'
// groupId = 'net.alhazmy13.MediaPicker'
// artifactId = 'libary'
// uploadName = 'MediaPicker'
// publishVersion = versions.LIBRARY_VERSION
// desc = 'MediaPickerRx'
// dryRun = false
// website = 'https://github.com/alhzmy13/MediaPicker'
//}

android {
compileSdkVersion versions.TARGET_SDK_VERSION
buildToolsVersion versions.BUILD_TOOLS_VERSION
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
minSdkVersion versions.MIN_SDK_VERSION
targetSdkVersion versions.TARGET_SDK_VERSION
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -36,9 +36,10 @@ android {
}

}
buildToolsVersion '25.0.2'
}


dependencies {
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:appcompat-v7:25.3.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void onCancel(DialogInterface dialogInterface) {
private void startActivityFromGallery() {
mImgConfig.isImgFromCamera = false;
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
// photoPickerIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, ImageTags.IntentCode.REQUEST_CODE_SELECT_PHOTO);
if (mImgConfig.debug)
Expand Down Expand Up @@ -231,8 +231,9 @@ private void pickImageWrapper() {
List<String> permissionsNeeded = new ArrayList<String>();

final List<String> permissionsList = new ArrayList<String>();
if (!addPermission(permissionsList, Manifest.permission.CAMERA))
permissionsNeeded.add(getString(R.string.media_picker_camera));
if(mImgConfig.mode == ImagePicker.Mode.CAMERA || mImgConfig.mode == ImagePicker.Mode.CAMERA_AND_GALLERY)
if (!addPermission(permissionsList, Manifest.permission.CAMERA))
permissionsNeeded.add(getString(R.string.media_picker_camera));
if (!addPermission(permissionsList, Manifest.permission.WRITE_EXTERNAL_STORAGE))
permissionsNeeded.add(getString(R.string.media_picker_read_Write_external_storage));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import net.alhazmy13.camerapicker.R;
import net.alhazmy13.mediapicker.FileProcessing;
import net.alhazmy13.mediapicker.Image.ImagePicker;
import net.alhazmy13.mediapicker.Utility;

import java.io.File;
Expand Down Expand Up @@ -233,7 +234,9 @@ private void pickImageWrapper() {
List<String> permissionsNeeded = new ArrayList<String>();

final List<String> permissionsList = new ArrayList<String>();
if (!addPermission(permissionsList, Manifest.permission.CAMERA))
if(mVideoConfig.mode == VideoPicker.Mode.CAMERA || mVideoConfig.mode == VideoPicker.Mode.CAMERA_AND_GALLERY)

if (!addPermission(permissionsList, Manifest.permission.CAMERA))
permissionsNeeded.add(getString(R.string.media_picker_camera));
if (!addPermission(permissionsList, Manifest.permission.WRITE_EXTERNAL_STORAGE))
permissionsNeeded.add(getString(R.string.media_picker_read_Write_external_storage));
Expand Down
11 changes: 6 additions & 5 deletions rxjava/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apply plugin: 'com.android.library'
apply from: '../deps.gradle'
//apply from: '../deps.gradle'
//apply plugin: 'com.novoda.bintray-release'

//./gradlew bintrayUpload
Expand All @@ -16,12 +16,12 @@ apply from: '../deps.gradle'
//}

android {
compileSdkVersion versions.TARGET_SDK_VERSION
buildToolsVersion versions.BUILD_TOOLS_VERSION
compileSdkVersion 25
buildToolsVersion '25.0.2'

defaultConfig {
minSdkVersion versions.MIN_SDK_VERSION
targetSdkVersion versions.TARGET_SDK_VERSION
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
Expand All @@ -31,6 +31,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '25.0.2'
}

dependencies {
Expand Down

0 comments on commit ebe0303

Please sign in to comment.