Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {

defaultConfig {
applicationId = "com.dot.gallery"
minSdk = 30
minSdk = 26
targetSdk = 36
versionCode = 32006
versionName = "3.2.0"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<uses-permission android:name="android.permission.INTERNET"/>

<!-- Remove unwanted permissions from being added -->
<uses-permission android:name="android.permission.INTERNET" tools:node="remove"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>

<!-- Required to access media for SDK < 33 -->
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/kotlin/com/dot/gallery/core/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ object Constants {
*/
const val DEFAULT_TOP_BAR_ANIMATION_DURATION = 500

private val PERMISSION_COMMON = listOf(
Manifest.permission.ACCESS_MEDIA_LOCATION
)
private val PERMISSION_COMMON = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
listOf(
Manifest.permission.ACCESS_MEDIA_LOCATION
)
} else {
emptyList()
}

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
private val PERMISSION_T = PERMISSION_COMMON.toMutableList().apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.dot.gallery.feature_node.data.data_source.mediastore

import android.net.Uri
import android.os.Build
import android.provider.MediaStore
import androidx.core.net.toUri
import com.dot.gallery.core.util.eq
import com.dot.gallery.core.util.or

object MediaQuery {
val MediaStoreFileUri: Uri = MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL)
val MediaStoreFileUri: Uri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL)
} else {
MediaStore.Files.getContentUri("external")
}
val MediaProjection = arrayOf(
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.DATA,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import android.content.Intent
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.MediaStore
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.IntentSenderRequest
import androidx.core.app.ActivityOptionsCompat
import androidx.core.content.contentValuesOf
import androidx.datastore.preferences.core.Preferences
import androidx.work.WorkManager
import com.dot.gallery.core.Resource
Expand Down Expand Up @@ -200,45 +202,65 @@ class MediaRepositoryImpl(
mediaList: List<T>,
favorite: Boolean
) {
val intentSender = MediaStore.createFavoriteRequest(
contentResolver,
mediaList.map { it.getUri() },
favorite
).intentSender
val senderRequest: IntentSenderRequest = IntentSenderRequest.Builder(intentSender)
.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION, 0)
.build()
result.launch(senderRequest)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val intentSender = MediaStore.createFavoriteRequest(
contentResolver,
mediaList.map { it.getUri() },
favorite
).intentSender
val senderRequest: IntentSenderRequest = IntentSenderRequest.Builder(intentSender)
.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION, 0)
.build()
result.launch(senderRequest)
} else {
mediaList.forEach { media ->
val contentValues = contentValuesOf(
MediaStore.MediaColumns.IS_FAVORITE to if (favorite) 1 else 0
)
contentResolver.update(media.getUri(), contentValues, null, null)
}
}
}

override suspend fun <T : Media> trashMedia(
result: ActivityResultLauncher<IntentSenderRequest>,
mediaList: List<T>,
trash: Boolean
) {
val intentSender = MediaStore.createTrashRequest(
contentResolver,
mediaList.map { it.getUri() },
trash
).intentSender
val senderRequest: IntentSenderRequest = IntentSenderRequest.Builder(intentSender)
.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION, 0)
.build()
result.launch(senderRequest, ActivityOptionsCompat.makeTaskLaunchBehind())

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val intentSender = MediaStore.createTrashRequest(
contentResolver,
mediaList.map { it.getUri() },
trash
).intentSender
val senderRequest: IntentSenderRequest = IntentSenderRequest.Builder(intentSender)
.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION, 0)
.build()
result.launch(senderRequest, ActivityOptionsCompat.makeTaskLaunchBehind())
} else {
// Trash under A11
}
}

override suspend fun <T : Media> deleteMedia(
result: ActivityResultLauncher<IntentSenderRequest>,
mediaList: List<T>
) {
val intentSender =
MediaStore.createDeleteRequest(

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val intentSender = MediaStore.createDeleteRequest(
contentResolver,
mediaList.map { it.getUri() }).intentSender
val senderRequest: IntentSenderRequest = IntentSenderRequest.Builder(intentSender)
.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION, 0)
.build()
result.launch(senderRequest)
val senderRequest: IntentSenderRequest = IntentSenderRequest.Builder(intentSender)
.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION, 0)
.build()
result.launch(senderRequest)
} else {
mediaList.forEach { media ->
contentResolver.delete(media.getUri(), null, null)
}
}
}

override suspend fun <T : Media> copyMedia(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ fun SetupScreen(
}
val appName = "${stringResource(id = R.string.app_name)} v${BuildConfig.VERSION_NAME}"
LaunchedEffect(permissionGranted) {

println("tetsinggg: $permissionGranted")

if (permissionGranted) {
onPermissionGranted()
} else if (!firstLaunch) Toast.makeText(context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import java.util.UUID
import kotlin.math.log10
import kotlin.math.min
import kotlin.math.pow
import androidx.core.net.toUri

@Suppress("NOTHING_TO_INLINE")
inline fun String.sentenceCase(): String = lowercase().replaceFirstChar { it.uppercase() }
Expand Down Expand Up @@ -58,7 +59,6 @@ fun File.formattedFileSize(context: Context): String {
}

class FileUtils(var context: Context) {
@SuppressLint("NewApi")
fun getPath(uri: Uri): String? {
val selection: String?
val selectionArgs: Array<String>?
Expand Down Expand Up @@ -104,7 +104,7 @@ class FileUtils(var context: Context) {
for (contentUriPrefix in contentUriPrefixesToTry) {
return try {
val contentUri = ContentUris.withAppendedId(
Uri.parse(contentUriPrefix),
contentUriPrefix.toUri(),
id.toLong()
)
getDataColumn(context, contentUri, null, null)
Expand Down
2 changes: 1 addition & 1 deletion libs/cropper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
compileSdk = 34

defaultConfig {
minSdk = 30
minSdk = 26
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion libs/gesture/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
compileSdk = 34

defaultConfig {
minSdk = 30
minSdk = 26
}

buildTypes {
Expand Down