Skip to content

Fix Error : Pick Image CameraOnly on Android Q #262

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

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}
}

ext {
sdk = [
compileSdk: 28,
targetSdk : 28,
compileSdk: 29,
targetSdk : 29,
minSdk : 14
]
}
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 @@
#Mon May 20 03:29:47 EEST 2019
#Wed Mar 04 09:56:13 WIB 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
9 changes: 3 additions & 6 deletions imagepicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ artifacts {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation "com.github.bumptech.glide:glide:4.9.0"

implementation "androidx.recyclerview:recyclerview:1.0.0"
implementation "com.github.bumptech.glide:glide:4.10.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.appcompat:appcompat:1.1.0"

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Intent getCameraIntent(Context context) {
@Override
public Intent getCameraIntent(Context context, BaseConfig config) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imageFile = ImagePickerUtils.createImageFile(config.getImageDirectory());
File imageFile = ImagePickerUtils.createImageFile(config.getImageDirectory(), context);
if (imageFile != null) {
Context appContext = context.getApplicationContext();
String providerName = String.format(Locale.ENGLISH, "%s%s", appContext.getPackageName(), ".imagepicker.provider");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
Expand All @@ -27,12 +28,21 @@ public static boolean isStringEmpty(@Nullable String str) {
return str == null || str.length() == 0;
}

public static File createImageFile(ImagePickerSavePath savePath) {
private static File createFileInDirectory(ImagePickerSavePath savePath, Context context) {
// External sdcard location
final String path = savePath.getPath();
File mediaStorageDir = savePath.isFullPath()
? new File(path)
: new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), path);

File mediaStorageDir;
if (savePath.isFullPath()) {
mediaStorageDir = new File(path);
} else {
mediaStorageDir = new File(
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
? context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
: Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
, path
);
}

// Create the storage directory if it does not exist
if (!mediaStorageDir.exists()) {
Expand All @@ -42,6 +52,13 @@ public static File createImageFile(ImagePickerSavePath savePath) {
}
}

return mediaStorageDir;
}

public static File createImageFile(ImagePickerSavePath savePath, Context context) {
final File mediaStorageDir = createFileInDirectory(savePath, context);
if (mediaStorageDir == null) return null;

// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.getDefault()).format(new Date());
File result = new File(mediaStorageDir, "IMG_" + timeStamp + ".jpg");
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ repositories {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation "com.github.bumptech.glide:glide:4.9.0"
implementation "androidx.appcompat:appcompat:1.0.2"
implementation "com.github.bumptech.glide:glide:4.10.0"
implementation "androidx.appcompat:appcompat:1.1.0"

/* Development */
implementation project(':rximagepicker')
Expand Down