Skip to content

Commit 3312be0

Browse files
fix: Behavior for API below 26 (#4)
* chore: Match compile/target SDK to original lib * chore: minSdk to minimum required by consumers OutSystems requires 28, Capacitor requires 24, none requires 23. * fix: Fallback for API level below 26
1 parent 72b5a5d commit 3312be0

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ apply plugin: "jacoco"
1818

1919
android {
2020
namespace "io.ionic.libs.ioncameralib"
21-
compileSdk 35
21+
compileSdk 36
2222

2323
defaultConfig {
24-
minSdk 23
25-
targetSdk 35
24+
minSdk 24
25+
targetSdk 36
2626
versionCode 1
2727
versionName "1.0"
2828

src/main/kotlin/io/ionic/libs/ioncameralib/helper/IONCAMRFileHelper.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import android.content.Intent
2424
import android.database.Cursor
2525
import android.graphics.Bitmap
2626
import android.net.Uri
27+
import android.os.Build
2728
import android.os.Environment
2829
import android.provider.DocumentsContract
2930
import android.provider.MediaStore
@@ -400,8 +401,18 @@ class IONCAMRFileHelper: IONCAMRFileHelperInterface {
400401
}
401402

402403
override fun getFileCreationDate(file: File): String {
403-
val attr = Files.readAttributes(file.toPath(), BasicFileAttributes::class.java)
404-
return attr.creationTime().toString()
404+
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
405+
try {
406+
val attr = Files.readAttributes(file.toPath(), BasicFileAttributes::class.java)
407+
attr.creationTime().toString()
408+
} catch (e: Exception) {
409+
Log.e(LOG_TAG, "Error getting file creation time", e)
410+
Date(file.lastModified()).toString()
411+
}
412+
} else {
413+
// Fallback API below API level 26
414+
Date(file.lastModified()).toString()
415+
}
405416
}
406417

407418
override fun storeFileNameInPrefs(fileName: String, context: Context) {

0 commit comments

Comments
 (0)