Skip to content

Commit

Permalink
Update 2.1.2 - Fixed #21 and #23
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Pinheiro committed Aug 24, 2021
1 parent 3a321e8 commit a1cdb80
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 15 deletions.
11 changes: 11 additions & 0 deletions on_audio_query/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [2.1.2] - [08.24.2021]
### Fixes
#### Android
- Fixed duplicate `media` from `[queryWithFilters]`.
- Fixed `crash` when calling `[queryWithFilters]`. - [Fixed #23](https://github.com/LucasPJS/on_audio_query/issues/23)
- Fixed `null` artwork returning from `[queryArtwork]` on Android 11/R. - [Fixed #21](https://github.com/LucasPJS/on_audio_query/issues/21)

### Documentation
- Updated `README` documentation.
- Updated `pubspec` documentation.

## [2.1.1] - [08.23.2021]
### Fixes
#### Android
Expand Down
2 changes: 1 addition & 1 deletion on_audio_query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ NOTE: Feel free to help with readme translations
Add the following code to your `pubspec.yaml`:
```yaml
dependencies:
on_audio_query: ^2.1.1
on_audio_query: ^2.1.2
```
### Request Permission:
Expand Down
2 changes: 1 addition & 1 deletion on_audio_query/README.pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ NOTE: Fique à vontade para ajudar nas traduções
Adicione o seguinte codigo para seu `pubspec.yaml`:
```yaml
dependencies:
on_audio_query: ^2.1.1
on_audio_query: ^2.1.2
```
#### Solicitar Permissões:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class OnArtworksQuery : ViewModel() {
artData = convertOrResize(bitmap = bitmap)!!
} catch (e: Exception) {
// Some problem can occur, we hide to not "flood" the terminal.
// Log.i("on_audio_error: ", e.toString())
// Log.i("on_audio_error: ", e.toString())
}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class OnWithFiltersQuery : ViewModel() {
resultWithFilter = loadWithFilters()
}

//
//Flutter UI will start, but, information still loading
result.success(resultWithFilter)
}
}
Expand Down Expand Up @@ -106,8 +106,6 @@ class OnWithFiltersQuery : ViewModel() {
//Get a extra information from audio, e.g: extension, uri, etc..
val tempExtraData = helper.loadSongExtraInfo(uri, tempData)
tempData.putAll(tempExtraData)

withFiltersList.add(tempData)
}

withFiltersList.add(tempData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.ContentResolver
import android.content.ContentUris
import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.provider.MediaStore
import java.io.File

Expand Down Expand Up @@ -46,7 +47,14 @@ class OnAudioHelper {
//This method will separate [String] from [Int]
fun loadAlbumItem(itemProperty: String, cursor: Cursor): Any? {
return when (itemProperty) {
"_id",
"_id" -> {
// The [album] id from Android >= 30/R is a [Long] instead of [Int].
if (Build.VERSION.SDK_INT >= 30) {
cursor.getLong(cursor.getColumnIndex(itemProperty))
} else {
cursor.getInt(cursor.getColumnIndex(itemProperty))
}
}
"album_id",
"numsongs" -> cursor.getInt(cursor.getColumnIndex(itemProperty))
else -> cursor.getString(cursor.getColumnIndex(itemProperty))
Expand Down Expand Up @@ -81,7 +89,9 @@ class OnAudioHelper {
}
}

fun loadFirstItem(uri: Uri, id: String, resolver: ContentResolver): String? {
// Ignore the [Data] deprecation because this plugin support older versions.
@Suppress("DEPRECATION")
fun loadFirstItem(uri: Uri, id: String, resolver: ContentResolver): String? {
val selection: String = if (uri == MediaStore.Audio.Media.EXTERNAL_CONTENT_URI) {
MediaStore.Audio.Media._ID + "=?"
} else {
Expand Down Expand Up @@ -109,13 +119,17 @@ class OnAudioHelper {
return data
}

fun chooseWithFilterType(uri: Uri, itemProperty: String, cursor: Cursor) {
when (uri) {
fun chooseWithFilterType(uri: Uri, itemProperty: String, cursor: Cursor): Any? {
return when (uri) {
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI -> loadSongItem(itemProperty, cursor)
MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI -> loadAlbumItem(itemProperty, cursor)
MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI -> loadPlaylistItem(itemProperty, cursor)
MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI -> loadPlaylistItem(
itemProperty,
cursor
)
MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI -> loadArtistItem(itemProperty, cursor)
MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI -> loadGenreItem(itemProperty, cursor)
else -> null
}
}
}
4 changes: 2 additions & 2 deletions on_audio_query/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _SongsState extends State<Songs> {
}

requestPermission() async {
// Web platform don't have permissions methods.
// Web platform don't support permissions methods.
if (!kIsWeb) {
bool permissionStatus = await audioQuery.permissionsStatus();
if (!permissionStatus) {
Expand All @@ -60,7 +60,7 @@ class _SongsState extends State<Songs> {
uriType: UriType.EXTERNAL,
),
builder: (context, item) {
// Load content
// Loading content
if (item.data == null) return CircularProgressIndicator();

// When you try "query" without asking for [READ] or [Library] permission
Expand Down
4 changes: 2 additions & 2 deletions on_audio_query/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: on_audio_query
description: Flutter Plugin used to query audios/songs infos [title, artist, album, etc..] from device storage.
version: 2.1.1
homepage: https://github.com/LucasPJS/on_audio_query
version: 2.1.2
homepage: https://github.com/LucasPJS/on_audio_query/tree/main/on_audio_query
# pub.dev: https://pub.dev/packages/on_audio_query
# ========
# author: Lucas Josino
Expand Down

0 comments on commit a1cdb80

Please sign in to comment.