expo-media-library 18.2.0 → 18.3.0-canary-20250919-7a31b96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/medialibrary/next/MediaLibraryNextModule.kt +22 -12
- package/android/src/main/java/expo/modules/medialibrary/next/extensions/resolver/AlbumExtensions.kt +9 -0
- package/android/src/main/java/expo/modules/medialibrary/next/extensions/resolver/AssetExtensions.kt +2 -5
- package/android/src/main/java/expo/modules/medialibrary/next/objects/album/AlbumQuery.kt +22 -0
- package/android/src/main/java/expo/modules/medialibrary/next/objects/asset/delegates/AssetLegacyDelegate.kt +8 -3
- package/android/src/main/java/expo/modules/medialibrary/next/objects/asset/delegates/AssetModernDelegate.kt +8 -3
- package/android/src/main/java/expo/modules/medialibrary/next/objects/asset/factories/AssetLegacyFactory.kt +1 -1
- package/android/src/main/java/expo/modules/medialibrary/next/objects/query/MediaStoreQueryFormatter.kt +9 -3
- package/android/src/main/java/expo/modules/medialibrary/next/objects/query/Query.kt +0 -1
- package/android/src/main/java/expo/modules/medialibrary/next/objects/wrappers/MimeType.kt +10 -3
- package/android/src/main/java/expo/modules/medialibrary/next/objects/wrappers/RelativePath.kt +2 -1
- package/build/next/index.d.ts +10 -1
- package/build/next/index.d.ts.map +1 -1
- package/build/next/index.js +16 -2
- package/build/next/index.js.map +1 -1
- package/build/next/types/Album.d.ts +38 -17
- package/build/next/types/Album.d.ts.map +1 -1
- package/build/next/types/Album.js.map +1 -1
- package/build/next/types/Asset.d.ts +19 -24
- package/build/next/types/Asset.d.ts.map +1 -1
- package/build/next/types/Asset.js.map +1 -1
- package/build/next/types/Query.d.ts +1 -0
- package/build/next/types/Query.d.ts.map +1 -1
- package/build/next/types/Query.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/next/MediaLibraryNextModule.swift +10 -2
- package/ios/next/extensions/DateExtensions.swift +8 -0
- package/ios/next/objects/Query/PredicateBuilder.swift +1 -1
- package/ios/next/objects/asset/Asset.swift +2 -2
- package/ios/next/repository/AssetCollectionRepository.swift +12 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/{18.2.0/expo.modules.medialibrary-18.2.0-sources.jar → 18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar} +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/{18.2.0/expo.modules.medialibrary-18.2.0.module → 18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/{18.2.0/expo.modules.medialibrary-18.2.0.pom → 18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.3.0-canary-20250919-7a31b96/expo.modules.medialibrary-18.3.0-canary-20250919-7a31b96.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/maven-metadata.xml.sha512 +1 -1
- package/package.json +4 -5
- package/src/next/index.ts +19 -2
- package/src/next/types/Album.ts +39 -21
- package/src/next/types/Asset.ts +28 -18
- package/src/next/types/Query.ts +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.medialibrary/18.2.0/expo.modules.medialibrary-18.2.0.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,10 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
### 🎉 New features
|
|
8
8
|
|
|
9
|
+
- [next] Add `Album.get(title)` ([#39717](https://github.com/expo/expo/pull/39717) by [@Wenszel](https://github.com/Wenszel))
|
|
10
|
+
|
|
9
11
|
### 🐛 Bug fixes
|
|
10
12
|
|
|
13
|
+
- [next][android] Change default root directory to Pictures ([#39716](https://github.com/expo/expo/pull/39716) by [@Wenszel](https://github.com/Wenszel))
|
|
14
|
+
- [next] Fix `asset.getModificationTime` to return milliseconds ([#39715](https://github.com/expo/expo/pull/39715) by [@Wenszel](https://github.com/Wenszel))
|
|
15
|
+
|
|
11
16
|
### 💡 Others
|
|
12
17
|
|
|
18
|
+
- [next] Add documentation ([#39754](https://github.com/expo/expo/pull/39754) by [@Wenszel](https://github.com/Wenszel))
|
|
19
|
+
|
|
13
20
|
## 18.2.0 — 2025-09-16
|
|
14
21
|
|
|
15
22
|
### 🎉 New features
|
package/android/build.gradle
CHANGED
|
@@ -4,13 +4,13 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'host.exp.exponent'
|
|
7
|
-
version = '18.
|
|
7
|
+
version = '18.3.0-canary-20250919-7a31b96'
|
|
8
8
|
|
|
9
9
|
android {
|
|
10
10
|
namespace "expo.modules.medialibrary"
|
|
11
11
|
defaultConfig {
|
|
12
12
|
versionCode 37
|
|
13
|
-
versionName "18.
|
|
13
|
+
versionName "18.3.0-canary-20250919-7a31b96"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -11,6 +11,7 @@ import expo.modules.kotlin.modules.ModuleDefinition
|
|
|
11
11
|
import expo.modules.kotlin.types.Either
|
|
12
12
|
import expo.modules.kotlin.types.toKClass
|
|
13
13
|
import expo.modules.medialibrary.next.objects.album.Album
|
|
14
|
+
import expo.modules.medialibrary.next.objects.album.AlbumQuery
|
|
14
15
|
import expo.modules.medialibrary.next.objects.asset.Asset
|
|
15
16
|
import expo.modules.medialibrary.next.objects.album.factories.AlbumModernFactory
|
|
16
17
|
import expo.modules.medialibrary.next.objects.album.factories.AlbumLegacyFactory
|
|
@@ -38,6 +39,10 @@ class MediaLibraryNextModule : Module() {
|
|
|
38
39
|
MediaStorePermissionsDelegate(appContext)
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
private val albumQuery by lazy {
|
|
43
|
+
AlbumQuery(context)
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
private val albumFactory by lazy {
|
|
42
47
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
43
48
|
AlbumModernFactory(assetFactory, context)
|
|
@@ -164,29 +169,29 @@ class MediaLibraryNextModule : Module() {
|
|
|
164
169
|
self.album(album)
|
|
165
170
|
}
|
|
166
171
|
|
|
167
|
-
Function("eq") { self: Query, field: AssetField, value: Either<MediaType,
|
|
168
|
-
self.eq(field, MediaStoreQueryFormatter.parse(value))
|
|
172
|
+
Function("eq") { self: Query, field: AssetField, value: Either<MediaType, Long> ->
|
|
173
|
+
self.eq(field, MediaStoreQueryFormatter.parse(field, value))
|
|
169
174
|
}
|
|
170
175
|
|
|
171
|
-
Function("within") { self: Query, field: AssetField, values: List<Either<MediaType,
|
|
172
|
-
val stringValues = values.map { value -> MediaStoreQueryFormatter.parse(value) }
|
|
176
|
+
Function("within") { self: Query, field: AssetField, values: List<Either<MediaType, Long>> ->
|
|
177
|
+
val stringValues = values.map { value -> MediaStoreQueryFormatter.parse(field, value) }
|
|
173
178
|
self.within(field, stringValues)
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
Function("gt") { self: Query, field: AssetField, value:
|
|
177
|
-
self.gt(field, MediaStoreQueryFormatter.parse(value))
|
|
181
|
+
Function("gt") { self: Query, field: AssetField, value: Long ->
|
|
182
|
+
self.gt(field, MediaStoreQueryFormatter.parse(field, value))
|
|
178
183
|
}
|
|
179
184
|
|
|
180
|
-
Function("gte") { self: Query, field: AssetField, value:
|
|
181
|
-
self.gte(field, MediaStoreQueryFormatter.parse(value))
|
|
185
|
+
Function("gte") { self: Query, field: AssetField, value: Long ->
|
|
186
|
+
self.gte(field, MediaStoreQueryFormatter.parse(field, value))
|
|
182
187
|
}
|
|
183
188
|
|
|
184
|
-
Function("lt") { self: Query, field: AssetField, value:
|
|
185
|
-
self.lt(field, MediaStoreQueryFormatter.parse(value))
|
|
189
|
+
Function("lt") { self: Query, field: AssetField, value: Long ->
|
|
190
|
+
self.lt(field, MediaStoreQueryFormatter.parse(field, value))
|
|
186
191
|
}
|
|
187
192
|
|
|
188
|
-
Function("lte") { self: Query, field: AssetField, value:
|
|
189
|
-
self.lte(field, MediaStoreQueryFormatter.parse(value))
|
|
193
|
+
Function("lte") { self: Query, field: AssetField, value: Long ->
|
|
194
|
+
self.lte(field, MediaStoreQueryFormatter.parse(field, value))
|
|
190
195
|
}
|
|
191
196
|
|
|
192
197
|
Function("orderBy") { self: Query, sortDescriptorRef: Either<AssetField, SortDescriptor> ->
|
|
@@ -221,6 +226,11 @@ class MediaLibraryNextModule : Module() {
|
|
|
221
226
|
return@Coroutine albumFactory.createFromFilePaths(name, assetPaths)
|
|
222
227
|
}
|
|
223
228
|
|
|
229
|
+
AsyncFunction("getAlbum") Coroutine { title: String ->
|
|
230
|
+
systemPermissionsDelegate.requireSystemPermissions(false)
|
|
231
|
+
albumQuery.getAlbum(title)
|
|
232
|
+
}
|
|
233
|
+
|
|
224
234
|
AsyncFunction("deleteAlbums") Coroutine { albums: List<Album> ->
|
|
225
235
|
systemPermissionsDelegate.requireSystemPermissions(true)
|
|
226
236
|
albums.forEach { album -> album.delete() }
|
package/android/src/main/java/expo/modules/medialibrary/next/extensions/resolver/AlbumExtensions.kt
CHANGED
|
@@ -48,6 +48,15 @@ suspend fun ContentResolver.queryAlbumId(relativePath: RelativePath): String? =
|
|
|
48
48
|
arrayOf(relativePath.value)
|
|
49
49
|
)
|
|
50
50
|
|
|
51
|
+
suspend fun ContentResolver.queryAlbumId(name: String): String? =
|
|
52
|
+
queryOne(
|
|
53
|
+
EXTERNAL_CONTENT_URI,
|
|
54
|
+
MediaStore.Files.FileColumns.BUCKET_ID,
|
|
55
|
+
Cursor::getString,
|
|
56
|
+
"${MediaStore.MediaColumns.BUCKET_DISPLAY_NAME} = ?",
|
|
57
|
+
arrayOf(name)
|
|
58
|
+
)
|
|
59
|
+
|
|
51
60
|
suspend fun ContentResolver.queryAlbumAssetsContentUris(bucketId: String): List<Uri> =
|
|
52
61
|
withContext(Dispatchers.IO) {
|
|
53
62
|
val projection = arrayOf(
|
package/android/src/main/java/expo/modules/medialibrary/next/extensions/resolver/AssetExtensions.kt
CHANGED
|
@@ -17,8 +17,8 @@ import kotlinx.coroutines.withContext
|
|
|
17
17
|
suspend fun ContentResolver.queryAssetDisplayName(contentUri: Uri): String? =
|
|
18
18
|
queryOne(contentUri, MediaStore.MediaColumns.DISPLAY_NAME, Cursor::getString)
|
|
19
19
|
|
|
20
|
-
suspend fun ContentResolver.
|
|
21
|
-
queryOne(contentUri, MediaStore.
|
|
20
|
+
suspend fun ContentResolver.queryAssetCreationTime(contentUri: Uri): Long? =
|
|
21
|
+
queryOne(contentUri, MediaStore.Images.Media.DATE_TAKEN, Cursor::getLong)
|
|
22
22
|
|
|
23
23
|
suspend fun ContentResolver.queryAssetModificationTime(contentUri: Uri): Long? =
|
|
24
24
|
queryOne(contentUri, MediaStore.MediaColumns.DATE_MODIFIED, Cursor::getLong)
|
|
@@ -38,9 +38,6 @@ suspend fun ContentResolver.queryAssetPath(contentUri: Uri): String? =
|
|
|
38
38
|
suspend fun ContentResolver.queryAssetBucketId(contentUri: Uri): Int? =
|
|
39
39
|
queryOne(contentUri, MediaStore.MediaColumns.BUCKET_ID, Cursor::getInt)
|
|
40
40
|
|
|
41
|
-
suspend fun ContentResolver.queryAssetMediaType(contentUri: Uri): Int? =
|
|
42
|
-
queryOne(contentUri, MediaStore.Files.FileColumns.MEDIA_TYPE, Cursor::getInt)
|
|
43
|
-
|
|
44
41
|
suspend fun ContentResolver.insertPendingAsset(
|
|
45
42
|
displayName: String,
|
|
46
43
|
mimeType: MimeType,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package expo.modules.medialibrary.next.objects.album
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import expo.modules.medialibrary.next.exceptions.ContentResolverNotObtainedException
|
|
5
|
+
import expo.modules.medialibrary.next.extensions.getOrThrow
|
|
6
|
+
import expo.modules.medialibrary.next.extensions.resolver.queryAlbumId
|
|
7
|
+
import java.lang.ref.WeakReference
|
|
8
|
+
|
|
9
|
+
class AlbumQuery(context: Context) {
|
|
10
|
+
private val contextRef = WeakReference(context)
|
|
11
|
+
|
|
12
|
+
private val contentResolver
|
|
13
|
+
get() = contextRef
|
|
14
|
+
.getOrThrow()
|
|
15
|
+
.contentResolver ?: throw ContentResolverNotObtainedException()
|
|
16
|
+
|
|
17
|
+
suspend fun getAlbum(title: String): Album? {
|
|
18
|
+
val id = contentResolver.queryAlbumId(title)
|
|
19
|
+
?: return null
|
|
20
|
+
return Album(id, contextRef.getOrThrow())
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -19,7 +19,7 @@ import expo.modules.medialibrary.next.extensions.resolver.queryAssetHeight
|
|
|
19
19
|
import expo.modules.medialibrary.next.extensions.resolver.queryAssetModificationTime
|
|
20
20
|
import expo.modules.medialibrary.next.extensions.resolver.queryAssetPath
|
|
21
21
|
import expo.modules.medialibrary.next.extensions.resolver.queryAssetWidth
|
|
22
|
-
import expo.modules.medialibrary.next.extensions.resolver.
|
|
22
|
+
import expo.modules.medialibrary.next.extensions.resolver.queryAssetCreationTime
|
|
23
23
|
import expo.modules.medialibrary.next.extensions.safeCopy
|
|
24
24
|
import expo.modules.medialibrary.next.extensions.safeMove
|
|
25
25
|
import expo.modules.medialibrary.next.objects.wrappers.RelativePath
|
|
@@ -30,6 +30,8 @@ import kotlinx.coroutines.Dispatchers
|
|
|
30
30
|
import kotlinx.coroutines.withContext
|
|
31
31
|
import java.io.File
|
|
32
32
|
import java.lang.ref.WeakReference
|
|
33
|
+
import kotlin.time.DurationUnit
|
|
34
|
+
import kotlin.time.toDuration
|
|
33
35
|
|
|
34
36
|
@DeprecatedSinceApi(Build.VERSION_CODES.Q)
|
|
35
37
|
class AssetLegacyDelegate(contentUri: Uri, context: Context) : AssetDelegate {
|
|
@@ -50,7 +52,7 @@ class AssetLegacyDelegate(contentUri: Uri, context: Context) : AssetDelegate {
|
|
|
50
52
|
|
|
51
53
|
override suspend fun getCreationTime(): Long? {
|
|
52
54
|
return contentResolver
|
|
53
|
-
.
|
|
55
|
+
.queryAssetCreationTime(contentUri)
|
|
54
56
|
.takeIf { it != 0L }
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -98,7 +100,10 @@ class AssetLegacyDelegate(contentUri: Uri, context: Context) : AssetDelegate {
|
|
|
98
100
|
MediaType.fromContentUri(contentUri)
|
|
99
101
|
|
|
100
102
|
override suspend fun getModificationTime(): Long? =
|
|
101
|
-
contentResolver.queryAssetModificationTime(contentUri)
|
|
103
|
+
contentResolver.queryAssetModificationTime(contentUri)
|
|
104
|
+
?.takeIf { it != 0L }
|
|
105
|
+
?.toDuration(DurationUnit.SECONDS)
|
|
106
|
+
?.inWholeMilliseconds
|
|
102
107
|
|
|
103
108
|
override suspend fun getMimeType(): MimeType {
|
|
104
109
|
return contentResolver.getType(contentUri)?.let { MimeType(it) }
|
|
@@ -18,7 +18,7 @@ import expo.modules.medialibrary.next.extensions.resolver.queryAssetHeight
|
|
|
18
18
|
import expo.modules.medialibrary.next.extensions.resolver.queryAssetModificationTime
|
|
19
19
|
import expo.modules.medialibrary.next.extensions.resolver.queryAssetPath
|
|
20
20
|
import expo.modules.medialibrary.next.extensions.resolver.queryAssetWidth
|
|
21
|
-
import expo.modules.medialibrary.next.extensions.resolver.
|
|
21
|
+
import expo.modules.medialibrary.next.extensions.resolver.queryAssetCreationTime
|
|
22
22
|
import expo.modules.medialibrary.next.extensions.resolver.updateRelativePath
|
|
23
23
|
import expo.modules.medialibrary.next.objects.wrappers.RelativePath
|
|
24
24
|
import expo.modules.medialibrary.next.objects.asset.Asset
|
|
@@ -28,6 +28,8 @@ import kotlinx.coroutines.Dispatchers
|
|
|
28
28
|
import kotlinx.coroutines.withContext
|
|
29
29
|
import java.io.File
|
|
30
30
|
import java.lang.ref.WeakReference
|
|
31
|
+
import kotlin.time.DurationUnit
|
|
32
|
+
import kotlin.time.toDuration
|
|
31
33
|
|
|
32
34
|
@RequiresApi(Build.VERSION_CODES.Q)
|
|
33
35
|
class AssetModernDelegate(override val contentUri: Uri, context: Context) : AssetDelegate {
|
|
@@ -40,7 +42,7 @@ class AssetModernDelegate(override val contentUri: Uri, context: Context) : Asse
|
|
|
40
42
|
|
|
41
43
|
override suspend fun getCreationTime(): Long? {
|
|
42
44
|
return contentResolver
|
|
43
|
-
.
|
|
45
|
+
.queryAssetCreationTime(contentUri)
|
|
44
46
|
.takeIf { it != 0L }
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -88,7 +90,10 @@ class AssetModernDelegate(override val contentUri: Uri, context: Context) : Asse
|
|
|
88
90
|
MediaType.fromContentUri(contentUri)
|
|
89
91
|
|
|
90
92
|
override suspend fun getModificationTime(): Long? =
|
|
91
|
-
contentResolver.queryAssetModificationTime(contentUri)
|
|
93
|
+
contentResolver.queryAssetModificationTime(contentUri)
|
|
94
|
+
?.takeIf { it != 0L }
|
|
95
|
+
?.toDuration(DurationUnit.SECONDS)
|
|
96
|
+
?.inWholeMilliseconds
|
|
92
97
|
|
|
93
98
|
override suspend fun getUri(): Uri {
|
|
94
99
|
// e.g. storage/emulated/0/Android/data/expo/files/[ROOT_ALBUM]/[ALBUM_NAME]
|
|
@@ -35,7 +35,7 @@ class AssetLegacyFactory(context: Context) : AssetFactory {
|
|
|
35
35
|
val baseDir = if (relativePath != null) {
|
|
36
36
|
File(relativePath.toFilePath())
|
|
37
37
|
} else {
|
|
38
|
-
mimeType.
|
|
38
|
+
mimeType.externalStorageAssetDirectory()
|
|
39
39
|
}
|
|
40
40
|
baseDir.mkdirs()
|
|
41
41
|
|
|
@@ -3,18 +3,24 @@ package expo.modules.medialibrary.next.objects.query
|
|
|
3
3
|
import expo.modules.kotlin.apifeatures.EitherType
|
|
4
4
|
import expo.modules.kotlin.types.Either
|
|
5
5
|
import expo.modules.medialibrary.next.objects.wrappers.MediaType
|
|
6
|
+
import expo.modules.medialibrary.next.records.AssetField
|
|
7
|
+
import kotlin.time.DurationUnit
|
|
8
|
+
import kotlin.time.toDuration
|
|
6
9
|
|
|
7
10
|
@OptIn(EitherType::class)
|
|
8
11
|
class MediaStoreQueryFormatter {
|
|
9
12
|
companion object {
|
|
10
|
-
fun parse(value: Either<MediaType,
|
|
13
|
+
fun parse(field: AssetField, value: Either<MediaType, Long>): String {
|
|
11
14
|
if (value.`is`(MediaType::class)) {
|
|
12
15
|
return parse(value.get(MediaType::class))
|
|
13
16
|
}
|
|
14
|
-
return parse(value.get(
|
|
17
|
+
return parse(field, value.get(Long::class))
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
fun parse(value:
|
|
20
|
+
fun parse(field: AssetField, value: Long): String {
|
|
21
|
+
if (field == AssetField.MODIFICATION_TIME) {
|
|
22
|
+
return value.toDuration(DurationUnit.MILLISECONDS).inWholeSeconds.toString()
|
|
23
|
+
}
|
|
18
24
|
return value.toString()
|
|
19
25
|
}
|
|
20
26
|
|
|
@@ -32,7 +32,6 @@ class Query(context: Context) : SharedObject() {
|
|
|
32
32
|
private val args = mutableListOf<String>()
|
|
33
33
|
private val orderBy = mutableListOf<SortDescriptor>()
|
|
34
34
|
|
|
35
|
-
private var album: Album? = null
|
|
36
35
|
private var limit: Int? = null
|
|
37
36
|
private var offset: Int? = null
|
|
38
37
|
|
|
@@ -24,15 +24,22 @@ value class MimeType(val value: String?) {
|
|
|
24
24
|
fun isVideo(): Boolean = type == "video"
|
|
25
25
|
fun isAudio(): Boolean = type == "audio"
|
|
26
26
|
|
|
27
|
-
fun
|
|
27
|
+
fun assetRootDirectory(): String = when {
|
|
28
28
|
value == null -> Environment.DIRECTORY_DCIM
|
|
29
29
|
isImage() || isVideo() -> Environment.DIRECTORY_DCIM
|
|
30
30
|
isAudio() -> Environment.DIRECTORY_MUSIC
|
|
31
31
|
else -> Environment.DIRECTORY_DCIM
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
fun
|
|
35
|
-
Environment.
|
|
34
|
+
fun albumRootDirectory(): String = when {
|
|
35
|
+
value == null -> Environment.DIRECTORY_PICTURES
|
|
36
|
+
isImage() || isVideo() -> Environment.DIRECTORY_PICTURES
|
|
37
|
+
isAudio() -> Environment.DIRECTORY_MUSIC
|
|
38
|
+
else -> Environment.DIRECTORY_PICTURES
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fun externalStorageAssetDirectory(): File =
|
|
42
|
+
Environment.getExternalStoragePublicDirectory(assetRootDirectory())
|
|
36
43
|
|
|
37
44
|
fun mediaCollectionUri(): Uri = when {
|
|
38
45
|
value == null -> EXTERNAL_CONTENT_URI
|
package/android/src/main/java/expo/modules/medialibrary/next/objects/wrappers/RelativePath.kt
CHANGED
|
@@ -21,10 +21,11 @@ value class RelativePath(val value: String) {
|
|
|
21
21
|
|
|
22
22
|
companion object {
|
|
23
23
|
fun create(mimeType: MimeType, albumName: String? = null): RelativePath {
|
|
24
|
-
val rootDirectory = mimeType.rootDirectory()
|
|
25
24
|
if (albumName != null) {
|
|
25
|
+
val rootDirectory = mimeType.albumRootDirectory()
|
|
26
26
|
return RelativePath("$rootDirectory/$albumName/")
|
|
27
27
|
}
|
|
28
|
+
val rootDirectory = mimeType.assetRootDirectory()
|
|
28
29
|
return RelativePath("$rootDirectory/")
|
|
29
30
|
}
|
|
30
31
|
}
|
package/build/next/index.d.ts
CHANGED
|
@@ -11,7 +11,16 @@ export declare class Asset extends ExpoMediaLibraryNext.Asset {
|
|
|
11
11
|
export declare class Album extends ExpoMediaLibraryNext.Album {
|
|
12
12
|
static create(name: string, assetsRefs: string[] | Asset[], moveAssets?: boolean): Promise<Album>;
|
|
13
13
|
static delete(albums: Album[], deleteAssets?: boolean): Promise<void>;
|
|
14
|
-
static
|
|
14
|
+
static get(title: string): Promise<Album | null>;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Asks the user to grant permissions for accessing media in user's media library.
|
|
18
|
+
* @param writeOnly
|
|
19
|
+
* @param granularPermissions - A list of [`GranularPermission`](#granularpermission) values. This parameter has an
|
|
20
|
+
* effect only on Android 13 and newer. By default, `expo-media-library` will ask for all possible permissions.
|
|
21
|
+
*
|
|
22
|
+
* > When using granular permissions with a custom config plugin configuration, make sure that all the requested permissions are included in the plugin.
|
|
23
|
+
* @return A promise that fulfils with [`PermissionResponse`](#permissionresponse) object.
|
|
24
|
+
*/
|
|
16
25
|
export declare function requestPermissionsAsync(writeOnly?: boolean, granularPermissions?: GranularPermission[]): Promise<PermissionResponse>;
|
|
17
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAG5E,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,cAAc,0BAA0B,CAAC;AAEzC,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;CAAG;AAExD,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,mBAAmB,CAAC;AAG5E,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,cAAc,0BAA0B,CAAC;AAEzC,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;CAAG;AAExD,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IAEnD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAK9D,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C;AAED,qBAAa,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IAEnD,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAC9B,UAAU,GAAE,OAAc,GACzB,OAAO,CAAC,KAAK,CAAC;IAQjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5E,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAGjD;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,GAAE,OAAe,EAC1B,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,GACzC,OAAO,CAAC,kBAAkB,CAAC,CAQ7B"}
|
package/build/next/index.js
CHANGED
|
@@ -5,20 +5,24 @@ export * from './MediaLibraryNext.types';
|
|
|
5
5
|
export class Query extends ExpoMediaLibraryNext.Query {
|
|
6
6
|
}
|
|
7
7
|
export class Asset extends ExpoMediaLibraryNext.Asset {
|
|
8
|
+
// @hidden
|
|
8
9
|
static create(filePath, album) {
|
|
9
10
|
return ExpoMediaLibraryNext.createAsset(filePath, album);
|
|
10
11
|
}
|
|
12
|
+
// @hidden
|
|
11
13
|
static delete(assets) {
|
|
12
14
|
return ExpoMediaLibraryNext.deleteAssets(assets);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
export class Album extends ExpoMediaLibraryNext.Album {
|
|
18
|
+
// @hidden
|
|
16
19
|
static create(name, assetsRefs, moveAssets = true) {
|
|
17
20
|
if (Platform.OS === 'ios') {
|
|
18
21
|
return ExpoMediaLibraryNext.createAlbum(name, assetsRefs);
|
|
19
22
|
}
|
|
20
23
|
return ExpoMediaLibraryNext.createAlbum(name, assetsRefs, moveAssets);
|
|
21
24
|
}
|
|
25
|
+
// @hidden
|
|
22
26
|
static delete(albums, deleteAssets = false) {
|
|
23
27
|
if (Platform.OS === 'ios') {
|
|
24
28
|
return ExpoMediaLibraryNext.deleteAlbums(albums, deleteAssets);
|
|
@@ -27,10 +31,20 @@ export class Album extends ExpoMediaLibraryNext.Album {
|
|
|
27
31
|
return ExpoMediaLibraryNext.deleteAlbums(albums);
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
// @hidden
|
|
35
|
+
static get(title) {
|
|
36
|
+
return ExpoMediaLibraryNext.getAlbum(title);
|
|
32
37
|
}
|
|
33
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Asks the user to grant permissions for accessing media in user's media library.
|
|
41
|
+
* @param writeOnly
|
|
42
|
+
* @param granularPermissions - A list of [`GranularPermission`](#granularpermission) values. This parameter has an
|
|
43
|
+
* effect only on Android 13 and newer. By default, `expo-media-library` will ask for all possible permissions.
|
|
44
|
+
*
|
|
45
|
+
* > When using granular permissions with a custom config plugin configuration, make sure that all the requested permissions are included in the plugin.
|
|
46
|
+
* @return A promise that fulfils with [`PermissionResponse`](#permissionresponse) object.
|
|
47
|
+
*/
|
|
34
48
|
export async function requestPermissionsAsync(writeOnly = false, granularPermissions) {
|
|
35
49
|
if (!ExpoMediaLibraryNext.requestPermissionsAsync) {
|
|
36
50
|
throw new UnavailabilityError('MediaLibrary', 'requestPermissionsAsync');
|
package/build/next/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAG1D,cAAc,0BAA0B,CAAC;AAEzC,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;CAAG;AAExD,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,MAAM,CAAC,MAAM,CAAC,QAAgB,EAAE,KAAa;QAC3C,OAAO,oBAAoB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAG1D,cAAc,0BAA0B,CAAC;AAEzC,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;CAAG;AAExD,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,UAAU;IACV,MAAM,CAAC,MAAM,CAAC,QAAgB,EAAE,KAAa;QAC3C,OAAO,oBAAoB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED,UAAU;IACV,MAAM,CAAC,MAAM,CAAC,MAAe;QAC3B,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CACF;AAED,MAAM,OAAO,KAAM,SAAQ,oBAAoB,CAAC,KAAK;IACnD,UAAU;IACV,MAAM,CAAC,MAAM,CACX,IAAY,EACZ,UAA8B,EAC9B,aAAsB,IAAI;QAE1B,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,oBAAoB,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,oBAAoB,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACxE,CAAC;IAED,UAAU;IACV,MAAM,CAAC,MAAM,CAAC,MAAe,EAAE,eAAwB,KAAK;QAC1D,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,OAAO,oBAAoB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,UAAU;IACV,MAAM,CAAC,GAAG,CAAC,KAAa;QACtB,OAAO,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,YAAqB,KAAK,EAC1B,mBAA0C;IAE1C,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,EAAE,CAAC;QAClD,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,MAAM,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,MAAM,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { PermissionResponse, UnavailabilityError } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExpoMediaLibraryNext from './ExpoMediaLibraryNext';\nimport { GranularPermission } from './types/GranularPermission';\n\nexport * from './MediaLibraryNext.types';\n\nexport class Query extends ExpoMediaLibraryNext.Query {}\n\nexport class Asset extends ExpoMediaLibraryNext.Asset {\n // @hidden\n static create(filePath: string, album?: Album): Promise<Asset> {\n return ExpoMediaLibraryNext.createAsset(filePath, album);\n }\n\n // @hidden\n static delete(assets: Asset[]): Promise<void> {\n return ExpoMediaLibraryNext.deleteAssets(assets);\n }\n}\n\nexport class Album extends ExpoMediaLibraryNext.Album {\n // @hidden\n static create(\n name: string,\n assetsRefs: string[] | Asset[],\n moveAssets: boolean = true\n ): Promise<Album> {\n if (Platform.OS === 'ios') {\n return ExpoMediaLibraryNext.createAlbum(name, assetsRefs);\n }\n return ExpoMediaLibraryNext.createAlbum(name, assetsRefs, moveAssets);\n }\n\n // @hidden\n static delete(albums: Album[], deleteAssets: boolean = false): Promise<void> {\n if (Platform.OS === 'ios') {\n return ExpoMediaLibraryNext.deleteAlbums(albums, deleteAssets);\n } else {\n return ExpoMediaLibraryNext.deleteAlbums(albums);\n }\n }\n\n // @hidden\n static get(title: string): Promise<Album | null> {\n return ExpoMediaLibraryNext.getAlbum(title);\n }\n}\n\n/**\n * Asks the user to grant permissions for accessing media in user's media library.\n * @param writeOnly\n * @param granularPermissions - A list of [`GranularPermission`](#granularpermission) values. This parameter has an\n * effect only on Android 13 and newer. By default, `expo-media-library` will ask for all possible permissions.\n *\n * > When using granular permissions with a custom config plugin configuration, make sure that all the requested permissions are included in the plugin.\n * @return A promise that fulfils with [`PermissionResponse`](#permissionresponse) object.\n */\nexport async function requestPermissionsAsync(\n writeOnly: boolean = false,\n granularPermissions?: GranularPermission[]\n): Promise<PermissionResponse> {\n if (!ExpoMediaLibraryNext.requestPermissionsAsync) {\n throw new UnavailabilityError('MediaLibrary', 'requestPermissionsAsync');\n }\n if (Platform.OS === 'android') {\n return await ExpoMediaLibraryNext.requestPermissionsAsync(writeOnly, granularPermissions);\n }\n return await ExpoMediaLibraryNext.requestPermissionsAsync(writeOnly);\n}\n"]}
|
|
@@ -2,10 +2,9 @@ import { Asset } from './Asset';
|
|
|
2
2
|
/**
|
|
3
3
|
* Represents a media album (collection of assets) on the device.
|
|
4
4
|
*
|
|
5
|
-
* An
|
|
6
|
-
* Albums typically correspond to folders in the device’s gallery or media store.
|
|
7
|
-
*
|
|
5
|
+
* An {@link Album} groups together media assets (images, videos, or audio files).
|
|
8
6
|
* To create a new album, use {@link Album.create}.
|
|
7
|
+
* To fetch an existing album, use {@link Album.get}.
|
|
9
8
|
*/
|
|
10
9
|
export declare class Album {
|
|
11
10
|
/**
|
|
@@ -15,11 +14,11 @@ export declare class Album {
|
|
|
15
14
|
constructor(id: string);
|
|
16
15
|
/**
|
|
17
16
|
* Unique identifier of the album.
|
|
18
|
-
* Can be used to re-instantiate an
|
|
17
|
+
* Can be used to re-instantiate an {@link Album} later.
|
|
19
18
|
*/
|
|
20
19
|
id: string;
|
|
21
20
|
/**
|
|
22
|
-
* Retrieves all assets contained in
|
|
21
|
+
* Retrieves all assets contained in the album.
|
|
23
22
|
* @returns A promise resolving to an array of {@link Asset} objects.
|
|
24
23
|
*
|
|
25
24
|
* @example
|
|
@@ -31,6 +30,7 @@ export declare class Album {
|
|
|
31
30
|
getAssets(): Promise<Asset[]>;
|
|
32
31
|
/**
|
|
33
32
|
* Gets the display title (name) of the album.
|
|
33
|
+
* Note that album titles are not guaranteed to be unique.
|
|
34
34
|
* @returns A promise resolving to the album’s title string.
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
@@ -42,9 +42,10 @@ export declare class Album {
|
|
|
42
42
|
getTitle(): Promise<string>;
|
|
43
43
|
/**
|
|
44
44
|
* Permanently deletes the album from the device.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
45
|
+
* On Android, it deletes the album and all its assets.
|
|
46
|
+
* On iOS, it deletes the album but keeps the assets in the main library.
|
|
47
47
|
* @returns A promise that resolves once the deletion has completed.
|
|
48
|
+
* @throws An exception if the deletion fails or the album could not be found.
|
|
48
49
|
*
|
|
49
50
|
* @example
|
|
50
51
|
* ```ts
|
|
@@ -53,7 +54,7 @@ export declare class Album {
|
|
|
53
54
|
*/
|
|
54
55
|
delete(): Promise<void>;
|
|
55
56
|
/**
|
|
56
|
-
* Adds
|
|
57
|
+
* Adds an asset to the album.
|
|
57
58
|
* @param asset - The {@link Asset} to add.
|
|
58
59
|
* @returns A promise that resolves once the asset has been added.
|
|
59
60
|
*
|
|
@@ -65,12 +66,12 @@ export declare class Album {
|
|
|
65
66
|
*/
|
|
66
67
|
add(asset: Asset): Promise<void>;
|
|
67
68
|
/**
|
|
68
|
-
* Creates a new album with a given name and
|
|
69
|
-
*
|
|
69
|
+
* A static function. Creates a new album with a given name and assets.
|
|
70
|
+
* On Android, if assets are provided and `moveAssets` is true, the assets will be moved into the new album. If false or not supported, the assets will be copied.
|
|
70
71
|
*
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
72
|
+
* @param name - Name of the new album.
|
|
73
|
+
* @param assetsRefs - List of {@link Asset} objects or file paths (file:///...) to include.
|
|
74
|
+
* @param moveAssets - On Android, whether to move assets into the album.
|
|
74
75
|
* @returns A promise resolving to the created {@link Album}.
|
|
75
76
|
*
|
|
76
77
|
* @example
|
|
@@ -79,13 +80,33 @@ export declare class Album {
|
|
|
79
80
|
* console.log(await album.getTitle()); // "My Album"
|
|
80
81
|
* ```
|
|
81
82
|
*/
|
|
82
|
-
static create(
|
|
83
|
+
static create(name: string, assetsRefs: string[] | Asset[], moveAssets: boolean): Promise<Album>;
|
|
83
84
|
/**
|
|
84
|
-
* Deletes multiple albums at once.
|
|
85
|
+
* A static function. Deletes multiple albums at once.
|
|
85
86
|
* @param albums - An array of {@link Album} instances to delete.
|
|
86
|
-
* @param deleteAssets -
|
|
87
|
+
* @param deleteAssets - Whether to delete the assets in the albums as well.
|
|
87
88
|
* @returns A promise that resolves once the albums have been deleted.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const album = await Album.create("My Album", [asset]);
|
|
93
|
+
* await Album.delete([album]);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
static delete(albums: Album[], deleteAssets: boolean): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* A static function. Retrieves an album by its title.
|
|
99
|
+
* @param title - The title of the album to retrieve.
|
|
100
|
+
* @return A promise resolving to the {@link Album} if found, or `null` if not found.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const album = await Album.get("Camera");
|
|
105
|
+
* if (album) {
|
|
106
|
+
* console.log(await album.getTitle()); // "Camera"
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
88
109
|
*/
|
|
89
|
-
static
|
|
110
|
+
static get(title: string): Promise<Album | null>;
|
|
90
111
|
}
|
|
91
112
|
//# sourceMappingURL=Album.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Album.d.ts","sourceRoot":"","sources":["../../../src/next/types/Album.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC
|
|
1
|
+
{"version":3,"file":"Album.d.ts","sourceRoot":"","sources":["../../../src/next/types/Album.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB;;;OAGG;gBACS,EAAE,EAAE,MAAM;IAEtB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;;;;;OASG;IACH,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAE7B;;;;;;;;;;OAUG;IACH,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAE3B;;;;;;;;;;;OAWG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;IAEhG;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAEpE;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Album.js","sourceRoot":"","sources":["../../../src/next/types/Album.ts"],"names":[],"mappings":"","sourcesContent":["import { Asset } from './Asset';\n\n/**\n * Represents a media album (collection of assets) on the device.\n *\n * An
|
|
1
|
+
{"version":3,"file":"Album.js","sourceRoot":"","sources":["../../../src/next/types/Album.ts"],"names":[],"mappings":"","sourcesContent":["import { Asset } from './Asset';\n\n/**\n * Represents a media album (collection of assets) on the device.\n *\n * An {@link Album} groups together media assets (images, videos, or audio files).\n * To create a new album, use {@link Album.create}.\n * To fetch an existing album, use {@link Album.get}.\n */\nexport declare class Album {\n /**\n * Reinitialize an instance of an album with a given ID.\n * @param id - The unique identifier of the album.\n */\n constructor(id: string);\n\n /**\n * Unique identifier of the album.\n * Can be used to re-instantiate an {@link Album} later.\n */\n id: string;\n\n /**\n * Retrieves all assets contained in the album.\n * @returns A promise resolving to an array of {@link Asset} objects.\n *\n * @example\n * ```ts\n * const assets = await album.getAssets();\n * console.log(assets.length);\n * ```\n */\n getAssets(): Promise<Asset[]>;\n\n /**\n * Gets the display title (name) of the album.\n * Note that album titles are not guaranteed to be unique.\n * @returns A promise resolving to the album’s title string.\n *\n * @example\n * ```ts\n * const title = await album.getTitle();\n * console.log(title); // \"Camera\"\n * ```\n */\n getTitle(): Promise<string>;\n\n /**\n * Permanently deletes the album from the device.\n * On Android, it deletes the album and all its assets.\n * On iOS, it deletes the album but keeps the assets in the main library.\n * @returns A promise that resolves once the deletion has completed.\n * @throws An exception if the deletion fails or the album could not be found.\n *\n * @example\n * ```ts\n * await album.delete();\n * ```\n */\n delete(): Promise<void>;\n\n /**\n * Adds an asset to the album.\n * @param asset - The {@link Asset} to add.\n * @returns A promise that resolves once the asset has been added.\n *\n * @example\n * ```ts\n * const asset = await Asset.create(\"file:///path/to/photo.png\");\n * await album.add(asset);\n * ```\n */\n add(asset: Asset): Promise<void>;\n\n /**\n * A static function. Creates a new album with a given name and assets.\n * On Android, if assets are provided and `moveAssets` is true, the assets will be moved into the new album. If false or not supported, the assets will be copied.\n *\n * @param name - Name of the new album.\n * @param assetsRefs - List of {@link Asset} objects or file paths (file:///...) to include.\n * @param moveAssets - On Android, whether to move assets into the album.\n * @returns A promise resolving to the created {@link Album}.\n *\n * @example\n * ```ts\n * const album = await Album.create(\"My Album\", [asset]);\n * console.log(await album.getTitle()); // \"My Album\"\n * ```\n */\n static create(name: string, assetsRefs: string[] | Asset[], moveAssets: boolean): Promise<Album>;\n\n /**\n * A static function. Deletes multiple albums at once.\n * @param albums - An array of {@link Album} instances to delete.\n * @param deleteAssets - Whether to delete the assets in the albums as well.\n * @returns A promise that resolves once the albums have been deleted.\n *\n * @example\n * ```ts\n * const album = await Album.create(\"My Album\", [asset]);\n * await Album.delete([album]);\n * ```\n */\n static delete(albums: Album[], deleteAssets: boolean): Promise<void>;\n\n /**\n * A static function. Retrieves an album by its title.\n * @param title - The title of the album to retrieve.\n * @return A promise resolving to the {@link Album} if found, or `null` if not found.\n *\n * @example\n * ```ts\n * const album = await Album.get(\"Camera\");\n * if (album) {\n * console.log(await album.getTitle()); // \"Camera\"\n * }\n * ```\n */\n static get(title: string): Promise<Album | null>;\n}\n"]}
|