Remove unnecessary SDK version checks

With minSdk=35 all Build.VERSION.SDK_INT checks for API levels below
35 are always true. Remove all version branching in HapticFeedback
(API 29/31 checks) and PhotoSaver (API 29 checks). Keep only the
modern API calls and drop @Suppress("DEPRECATION") annotations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ole-Morten Duesund 2026-02-27 15:25:16 +01:00
commit c7fa8f16be
2 changed files with 19 additions and 55 deletions

View file

@ -16,6 +16,7 @@ import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
/**
* Result of a photo save operation.
*/
@ -52,11 +53,8 @@ class PhotoSaver(private val context: Context) {
put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis() / 1000)
put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
put(MediaStore.Images.Media.RELATIVE_PATH, "${Environment.DIRECTORY_PICTURES}/TiltShift")
put(MediaStore.Images.Media.IS_PENDING, 1)
}
put(MediaStore.Images.Media.RELATIVE_PATH, "${Environment.DIRECTORY_PICTURES}/TiltShift")
put(MediaStore.Images.Media.IS_PENDING, 1)
}
// Insert into MediaStore
@ -74,12 +72,10 @@ class PhotoSaver(private val context: Context) {
// Write EXIF data
writeExifToUri(uri, orientation, location)
// Mark as complete (API 29+)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
contentValues.clear()
contentValues.put(MediaStore.Images.Media.IS_PENDING, 0)
contentResolver.update(uri, contentValues, null, null)
}
// Mark as complete
contentValues.clear()
contentValues.put(MediaStore.Images.Media.IS_PENDING, 0)
contentResolver.update(uri, contentValues, null, null)
// Get the file path for display
val path = getPathFromUri(uri)