0.4.2 - Fixed issue with photo upload streams

This commit is contained in:
2025-08-17 00:57:48 -06:00
parent 15a5e217a5
commit c07186a7df
2 changed files with 27 additions and 35 deletions

View File

@@ -14,8 +14,8 @@ android {
applicationId = "com.atridad.openclimb"
minSdk = 31
targetSdk = 35
versionCode = 8
versionName = "0.4.1"
versionCode = 9
versionName = "0.4.2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

View File

@@ -35,18 +35,11 @@ object ImageUtils {
*/
fun saveImageFromUri(context: Context, imageUri: Uri): String? {
return try {
val inputStream = context.contentResolver.openInputStream(imageUri)
inputStream?.use { input ->
// Decode with options to get EXIF data
val options = BitmapFactory.Options().apply {
inJustDecodeBounds = true
}
input.reset()
BitmapFactory.decodeStream(input, null, options)
// Decode bitmap from a fresh stream to avoid mark/reset dependency
val originalBitmap = context.contentResolver.openInputStream(imageUri)?.use { input ->
BitmapFactory.decodeStream(input)
} ?: return null
// Reset stream and decode with proper orientation
input.reset()
val originalBitmap = BitmapFactory.decodeStream(input)
val orientedBitmap = correctImageOrientation(context, imageUri, originalBitmap)
val compressedBitmap = compressImage(orientedBitmap)
@@ -68,7 +61,6 @@ object ImageUtils {
// Return relative path
"$IMAGES_DIR/$filename"
}
} catch (e: Exception) {
e.printStackTrace()
null