Skip to content

Commit b42f93c

Browse files
committed
bug fix
1 parent 394dd31 commit b42f93c

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
33

44
android {
55
compileSdkVersion 30
6-
buildToolsVersion '30.0.0'
6+
buildToolsVersion '30.0.2'
77

88
defaultConfig {
99
applicationId "com.sw926.imagefileselector.example"
@@ -26,9 +26,9 @@ android {
2626

2727
dependencies {
2828
implementation fileTree(include: ['*.jar'], dir: 'libs')
29-
testImplementation 'junit:junit:4.13'
29+
testImplementation 'junit:junit:4.13.1'
3030
implementation project(':library')
31-
implementation 'androidx.appcompat:appcompat:1.1.0'
31+
implementation 'androidx.appcompat:appcompat:1.2.0'
3232
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3333
}
3434
repositories {

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.72'
4+
ext.kotlin_version = '1.4.20'
55
repositories {
66
jcenter()
77
google()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:4.0.1'
10+
classpath 'com.android.tools.build:gradle:4.1.1'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ POM_DEVELOPER_NAME=sunwei
2121
POM_LICENCE_URL=http\://www.apache.org/licenses/LICENSE-2.0.txt
2222
POM_DESCRIPTION=Android image file selector
2323
POM_LICENCE_NAME=The Apache Software License, Version 2.0
24-
VERSION_NAME=1.1.0-SNAPSHOT
25-
VERSION_CODE=22
24+
VERSION_NAME=1.1.2
25+
VERSION_CODE=24
2626
POM_SCM_DEV_CONNECTION=scm\:https\://github.com/sw926/ImageFileSelector.git
2727
POM_URL=https\://github.com/sw926/ImageFileSelector
2828
POM_SCM_CONNECTION=scm\:https\://github.com/sw926/ImageFileSelector.git
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Tue Dec 01 15:33:21 CST 2020
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

library/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
55

6+
<queries>
7+
<intent>
8+
<action android:name="android.media.action.IMAGE_CAPTURE" />
9+
</intent>
10+
</queries>
11+
612
<application>
13+
714
<provider
815
android:name=".GenericFileProvider"
916
android:authorities="${applicationId}.com.sw926.imagefileselector.provider"

library/src/main/java/com/sw926/imagefileselector/ImageCaptureHelper.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import android.net.Uri
1111
import android.os.Build
1212
import android.os.Bundle
1313
import android.provider.MediaStore
14+
import androidx.core.content.FileProvider
1415
import androidx.fragment.app.Fragment
1516
import com.sw926.imagefileselector.ErrorResult.*
1617
import java.io.File
@@ -125,16 +126,15 @@ class ImageCaptureHelper {
125126
}
126127

127128
private fun createIntent(context: Context): Intent {
129+
val file = File(context.getExternalFilesDir("app_share"), "capture.jpg")
128130
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
129131
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
130-
mOutputFile?.let {
131-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
132-
val cameraTempUri = CommonUtils.getFileUri(context, it)
133-
intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraTempUri)
134-
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1)
135-
} else {
136-
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mOutputFile))
137-
}
132+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
133+
val cameraTempUri = FileProvider.getUriForFile(context, "com.example.myapplication", file)
134+
intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraTempUri)
135+
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1)
136+
} else {
137+
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mOutputFile))
138138
}
139139
return intent
140140
}

library/src/main/java/com/sw926/imagefileselector/ImageCropper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,6 @@ class ImageCropper {
239239

240240
interface ImageCropperCallback {
241241
fun onError(result: CropperErrorResult?)
242-
fun onSuccess(outputFile: String?)
242+
fun onSuccess(outputFile: String)
243243
}
244244
}

0 commit comments

Comments
 (0)