Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sw926 committed Dec 9, 2020
1 parent 394dd31 commit b42f93c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'

android {
compileSdkVersion 30
buildToolsVersion '30.0.0'
buildToolsVersion '30.0.2'

defaultConfig {
applicationId "com.sw926.imagefileselector.example"
Expand All @@ -26,9 +26,9 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.1'
implementation project(':library')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.72'
ext.kotlin_version = '1.4.20'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ POM_DEVELOPER_NAME=sunwei
POM_LICENCE_URL=http\://www.apache.org/licenses/LICENSE-2.0.txt
POM_DESCRIPTION=Android image file selector
POM_LICENCE_NAME=The Apache Software License, Version 2.0
VERSION_NAME=1.1.0-SNAPSHOT
VERSION_CODE=22
VERSION_NAME=1.1.2
VERSION_CODE=24
POM_SCM_DEV_CONNECTION=scm\:https\://github.com/sw926/ImageFileSelector.git
POM_URL=https\://github.com/sw926/ImageFileSelector
POM_SCM_CONNECTION=scm\:https\://github.com/sw926/ImageFileSelector.git
Expand Down
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Tue Dec 01 15:33:21 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
7 changes: 7 additions & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@

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

<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>

<application>

<provider
android:name=".GenericFileProvider"
android:authorities="${applicationId}.com.sw926.imagefileselector.provider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.MediaStore
import androidx.core.content.FileProvider
import androidx.fragment.app.Fragment
import com.sw926.imagefileselector.ErrorResult.*
import java.io.File
Expand Down Expand Up @@ -125,16 +126,15 @@ class ImageCaptureHelper {
}

private fun createIntent(context: Context): Intent {
val file = File(context.getExternalFilesDir("app_share"), "capture.jpg")
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
mOutputFile?.let {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val cameraTempUri = CommonUtils.getFileUri(context, it)
intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraTempUri)
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1)
} else {
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mOutputFile))
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val cameraTempUri = FileProvider.getUriForFile(context, "com.example.myapplication", file)
intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraTempUri)
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1)
} else {
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mOutputFile))
}
return intent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@ class ImageCropper {

interface ImageCropperCallback {
fun onError(result: CropperErrorResult?)
fun onSuccess(outputFile: String?)
fun onSuccess(outputFile: String)
}
}

0 comments on commit b42f93c

Please sign in to comment.