diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..e32f32ffc --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [OxygenCobalt] diff --git a/.github/ISSUE_TEMPLATE/bug-crash-report.yml b/.github/ISSUE_TEMPLATE/bug-crash-report.yml index 652dba0b8..7b94b9916 100644 --- a/.github/ISSUE_TEMPLATE/bug-crash-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-crash-report.yml @@ -34,6 +34,7 @@ body: attributes: label: What android version do you use? options: + - Android 14 - Android 13 - Android 12L - Android 12 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ecfb63b5..49474667d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,33 @@ ## dev +## 3.3.0 + #### What's New - Added ability to rewind/skip tracks by swiping back/forward +- Added support for demo release type +- Added playlist importing/export from M3U files + +#### What's Improved +- Music loading will now fail when it hangs + +#### What's Changed +- Albums linked to an artist only as a collaborator are no longer included +in an artist's album count +- File name and parent path have been combined into "Path" in the Song Properties +view + +#### What's Fixed +- Fixed music loading failing on all huawei devices +- Fixed prior music loads not cancelling when reloading music in settings +- Fixed certain FLAC files failing to play on some devices +- Fixed music loading failing when duplicate tags with different casing was present + +#### Dev/Meta +- Revamped path management + + +## 3.2.1 #### What's Improved - Added support for native M4A multi-value tags based on duplicate atoms diff --git a/README.md b/README.md index 4c867895b..e57f93417 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@

Auxio

A simple, rational music player for android.

- - Latest Version + + Latest Version Releases diff --git a/app/build.gradle b/app/build.gradle index f6a0d3abc..999ea5e8c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,13 +16,13 @@ android { // it here so that binary stripping will work. // TODO: Eventually you might just want to start vendoring the FFMpeg extension so the // NDK use is unified - ndkVersion = "23.2.8568313" + ndkVersion = "25.2.9519653" namespace "org.oxycblt.auxio" defaultConfig { applicationId namespace - versionName "3.2.1" - versionCode 36 + versionName "3.3.0" + versionCode 37 minSdk 24 targetSdk 34 @@ -31,6 +31,7 @@ android { } compileOptions { + coreLibraryDesugaringEnabled true sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } @@ -87,8 +88,8 @@ dependencies { // General implementation "androidx.core:core-ktx:1.12.0" implementation "androidx.appcompat:appcompat:1.6.1" - implementation "androidx.activity:activity-ktx:1.8.0" - implementation "androidx.fragment:fragment-ktx:1.6.1" + implementation "androidx.activity:activity-ktx:1.8.2" + implementation "androidx.fragment:fragment-ktx:1.6.2" // Components // Deliberately kept on 1.2.1 to prevent a bug where the queue sheet will not collapse on @@ -111,13 +112,13 @@ dependencies { implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version" // Media - implementation "androidx.media:media:1.6.0" + implementation "androidx.media:media:1.7.0" // Preferences implementation "androidx.preference:preference-ktx:1.2.1" // Database - def room_version = '2.6.0-rc01' + def room_version = '2.6.1' implementation "androidx.room:room-runtime:$room_version" ksp "androidx.room:room-compiler:$room_version" implementation "androidx.room:room-ktx:$room_version" @@ -127,6 +128,7 @@ dependencies { // Exoplayer (Vendored) implementation project(":media-lib-exoplayer") implementation project(":media-lib-decoder-ffmpeg") + coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.4" // Image loading implementation 'io.coil-kt:coil-base:2.4.0' @@ -145,6 +147,9 @@ dependencies { // Logging implementation 'com.jakewharton.timber:timber:5.0.1' + // Speed dial + implementation "com.leinardi.android:speed-dial:3.3.0" + // Testing debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12' testImplementation "junit:junit:4.13.2" diff --git a/app/src/main/java/org/oxycblt/auxio/MainFragment.kt b/app/src/main/java/org/oxycblt/auxio/MainFragment.kt index ed1b47c7a..742018420 100644 --- a/app/src/main/java/org/oxycblt/auxio/MainFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/MainFragment.kt @@ -76,6 +76,7 @@ class MainFragment : private var sheetBackCallback: SheetBackPressedCallback? = null private var detailBackCallback: DetailBackPressedCallback? = null private var selectionBackCallback: SelectionBackPressedCallback? = null + private var speedDialBackCallback: SpeedDialBackPressedCallback? = null private var selectionNavigationListener: DialogAwareNavigationListener? = null private var lastInsets: WindowInsets? = null private var elevationNormal = 0f @@ -109,6 +110,8 @@ class MainFragment : DetailBackPressedCallback(detailModel).also { detailBackCallback = it } val selectionBackCallback = SelectionBackPressedCallback(listModel).also { selectionBackCallback = it } + val speedDialBackCallback = + SpeedDialBackPressedCallback(homeModel).also { speedDialBackCallback = it } selectionNavigationListener = DialogAwareNavigationListener(listModel::dropSelection) @@ -158,6 +161,7 @@ class MainFragment : collect(detailModel.toShow.flow, ::handleShow) collectImmediately(detailModel.editedPlaylist, detailBackCallback::invalidateEnabled) collectImmediately(homeModel.showOuter.flow, ::handleShowOuter) + collectImmediately(homeModel.speedDialOpen, speedDialBackCallback::invalidateEnabled) collectImmediately(listModel.selected, selectionBackCallback::invalidateEnabled) collectImmediately(playbackModel.song, ::updateSong) collectImmediately(playbackModel.openPanel.flow, ::handlePanel) @@ -181,6 +185,7 @@ class MainFragment : // navigation, navigation out of detail views, etc. We have to do this here in // onResume or otherwise the FragmentManager will have precedence. requireActivity().onBackPressedDispatcher.apply { + addCallback(viewLifecycleOwner, requireNotNull(speedDialBackCallback)) addCallback(viewLifecycleOwner, requireNotNull(selectionBackCallback)) addCallback(viewLifecycleOwner, requireNotNull(detailBackCallback)) addCallback(viewLifecycleOwner, requireNotNull(sheetBackCallback)) @@ -197,6 +202,7 @@ class MainFragment : override fun onDestroyBinding(binding: FragmentMainBinding) { super.onDestroyBinding(binding) + speedDialBackCallback = null sheetBackCallback = null detailBackCallback = null selectionBackCallback = null @@ -218,6 +224,13 @@ class MainFragment : binding.queueSheet.coordinatorLayoutBehavior as QueueBottomSheetBehavior? val playbackRatio = max(playbackSheetBehavior.calculateSlideOffset(), 0f) + if (playbackRatio > 0f && homeModel.speedDialOpen.value) { + // Stupid hack to prevent you from sliding the sheet up without closing the speed + // dial. Filtering out ACTION_MOVE events will cause back gestures to close the speed + // dial, which is super finicky behavior. + homeModel.setSpeedDialOpen(false) + } + val outPlaybackRatio = 1 - playbackRatio val halfOutRatio = min(playbackRatio * 2, 1f) val halfInPlaybackRatio = max(playbackRatio - 0.5f, 0f) * 2 @@ -493,4 +506,17 @@ class MainFragment : isEnabled = selection.isNotEmpty() } } + + private inner class SpeedDialBackPressedCallback(private val homeModel: HomeViewModel) : + OnBackPressedCallback(false) { + override fun handleOnBackPressed() { + if (homeModel.speedDialOpen.value) { + homeModel.setSpeedDialOpen(false) + } + } + + fun invalidateEnabled(open: Boolean) { + isEnabled = open + } + } } diff --git a/app/src/main/java/org/oxycblt/auxio/detail/AlbumDetailFragment.kt b/app/src/main/java/org/oxycblt/auxio/detail/AlbumDetailFragment.kt index 3fd4a6963..e041909cf 100644 --- a/app/src/main/java/org/oxycblt/auxio/detail/AlbumDetailFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/detail/AlbumDetailFragment.kt @@ -44,6 +44,7 @@ import org.oxycblt.auxio.music.Music import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.MusicViewModel import org.oxycblt.auxio.music.PlaylistDecision +import org.oxycblt.auxio.music.PlaylistMessage import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.music.info.Disc import org.oxycblt.auxio.playback.PlaybackDecision @@ -55,6 +56,7 @@ import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.navigateSafe import org.oxycblt.auxio.util.overrideOnOverflowMenuClick import org.oxycblt.auxio.util.setFullWidthLookup +import org.oxycblt.auxio.util.showToast import org.oxycblt.auxio.util.unlikelyToBeNull /** @@ -126,6 +128,7 @@ class AlbumDetailFragment : collect(listModel.menu.flow, ::handleMenu) collectImmediately(listModel.selected, ::updateSelection) collect(musicModel.playlistDecision.flow, ::handlePlaylistDecision) + collect(musicModel.playlistMessage.flow, ::handlePlaylistMessage) collectImmediately( playbackModel.song, playbackModel.parent, playbackModel.isPlaying, ::updatePlayback) collect(playbackModel.playbackDecision.flow, ::handlePlaybackDecision) @@ -273,12 +276,20 @@ class AlbumDetailFragment : decision.songs.map { it.uid }.toTypedArray()) } is PlaylistDecision.New, + is PlaylistDecision.Import, is PlaylistDecision.Rename, - is PlaylistDecision.Delete -> error("Unexpected playlist decision $decision") + is PlaylistDecision.Delete, + is PlaylistDecision.Export -> error("Unexpected playlist decision $decision") } findNavController().navigateSafe(directions) } + private fun handlePlaylistMessage(message: PlaylistMessage?) { + if (message == null) return + requireContext().showToast(message.stringRes) + musicModel.playlistMessage.consume() + } + private fun updatePlayback(song: Song?, parent: MusicParent?, isPlaying: Boolean) { albumListAdapter.setPlaying( song.takeIf { parent == detailModel.currentAlbum.value }, isPlaying) diff --git a/app/src/main/java/org/oxycblt/auxio/detail/ArtistDetailFragment.kt b/app/src/main/java/org/oxycblt/auxio/detail/ArtistDetailFragment.kt index b0bc09386..bdd5b04af 100644 --- a/app/src/main/java/org/oxycblt/auxio/detail/ArtistDetailFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/detail/ArtistDetailFragment.kt @@ -45,6 +45,7 @@ import org.oxycblt.auxio.music.Music import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.MusicViewModel import org.oxycblt.auxio.music.PlaylistDecision +import org.oxycblt.auxio.music.PlaylistMessage import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.playback.PlaybackDecision import org.oxycblt.auxio.playback.PlaybackViewModel @@ -54,6 +55,7 @@ import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.navigateSafe import org.oxycblt.auxio.util.overrideOnOverflowMenuClick import org.oxycblt.auxio.util.setFullWidthLookup +import org.oxycblt.auxio.util.showToast import org.oxycblt.auxio.util.unlikelyToBeNull /** @@ -128,6 +130,7 @@ class ArtistDetailFragment : collect(listModel.menu.flow, ::handleMenu) collectImmediately(listModel.selected, ::updateSelection) collect(musicModel.playlistDecision.flow, ::handlePlaylistDecision) + collect(musicModel.playlistMessage.flow, ::handlePlaylistMessage) collectImmediately( playbackModel.song, playbackModel.parent, playbackModel.isPlaying, ::updatePlayback) collect(playbackModel.playbackDecision.flow, ::handlePlaybackDecision) @@ -276,12 +279,20 @@ class ArtistDetailFragment : decision.songs.map { it.uid }.toTypedArray()) } is PlaylistDecision.New, + is PlaylistDecision.Import, is PlaylistDecision.Rename, + is PlaylistDecision.Export, is PlaylistDecision.Delete -> error("Unexpected playlist decision $decision") } findNavController().navigateSafe(directions) } + private fun handlePlaylistMessage(message: PlaylistMessage?) { + if (message == null) return + requireContext().showToast(message.stringRes) + musicModel.playlistMessage.consume() + } + private fun updatePlayback(song: Song?, parent: MusicParent?, isPlaying: Boolean) { val currentArtist = unlikelyToBeNull(detailModel.currentArtist.value) val playingItem = diff --git a/app/src/main/java/org/oxycblt/auxio/detail/DetailViewModel.kt b/app/src/main/java/org/oxycblt/auxio/detail/DetailViewModel.kt index 648424458..3613d96c6 100644 --- a/app/src/main/java/org/oxycblt/auxio/detail/DetailViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/detail/DetailViewModel.kt @@ -607,6 +607,7 @@ constructor( is ReleaseType.Soundtrack -> AlbumGrouping.SOUNDTRACKS is ReleaseType.Mix -> AlbumGrouping.DJMIXES is ReleaseType.Mixtape -> AlbumGrouping.MIXTAPES + is ReleaseType.Demo -> AlbumGrouping.DEMOS } } } @@ -709,6 +710,7 @@ constructor( SOUNDTRACKS(R.string.lbl_soundtracks), DJMIXES(R.string.lbl_mixes), MIXTAPES(R.string.lbl_mixtapes), + DEMOS(R.string.lbl_demos), APPEARANCES(R.string.lbl_appears_on), LIVE(R.string.lbl_live_group), REMIXES(R.string.lbl_remix_group), diff --git a/app/src/main/java/org/oxycblt/auxio/detail/GenreDetailFragment.kt b/app/src/main/java/org/oxycblt/auxio/detail/GenreDetailFragment.kt index 522ebbfa6..79ad38f23 100644 --- a/app/src/main/java/org/oxycblt/auxio/detail/GenreDetailFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/detail/GenreDetailFragment.kt @@ -45,6 +45,7 @@ import org.oxycblt.auxio.music.Music import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.MusicViewModel import org.oxycblt.auxio.music.PlaylistDecision +import org.oxycblt.auxio.music.PlaylistMessage import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.playback.PlaybackDecision import org.oxycblt.auxio.playback.PlaybackViewModel @@ -54,6 +55,7 @@ import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.navigateSafe import org.oxycblt.auxio.util.overrideOnOverflowMenuClick import org.oxycblt.auxio.util.setFullWidthLookup +import org.oxycblt.auxio.util.showToast import org.oxycblt.auxio.util.unlikelyToBeNull /** @@ -125,7 +127,8 @@ class GenreDetailFragment : collect(detailModel.toShow.flow, ::handleShow) collect(listModel.menu.flow, ::handleMenu) collectImmediately(listModel.selected, ::updateSelection) - collect(musicModel.playlistDecision.flow, ::handleDecision) + collect(musicModel.playlistDecision.flow, ::handlePlaylistDecision) + collect(musicModel.playlistMessage.flow, ::handlePlaylistMessage) collectImmediately( playbackModel.song, playbackModel.parent, playbackModel.isPlaying, ::updatePlayback) collect(playbackModel.playbackDecision.flow, ::handlePlaybackDecision) @@ -259,7 +262,7 @@ class GenreDetailFragment : } } - private fun handleDecision(decision: PlaylistDecision?) { + private fun handlePlaylistDecision(decision: PlaylistDecision?) { if (decision == null) return val directions = when (decision) { @@ -269,12 +272,20 @@ class GenreDetailFragment : decision.songs.map { it.uid }.toTypedArray()) } is PlaylistDecision.New, + is PlaylistDecision.Import, is PlaylistDecision.Rename, + is PlaylistDecision.Export, is PlaylistDecision.Delete -> error("Unexpected playlist decision $decision") } findNavController().navigateSafe(directions) } + private fun handlePlaylistMessage(message: PlaylistMessage?) { + if (message == null) return + requireContext().showToast(message.stringRes) + musicModel.playlistMessage.consume() + } + private fun updatePlayback(song: Song?, parent: MusicParent?, isPlaying: Boolean) { val currentGenre = unlikelyToBeNull(detailModel.currentGenre.value) val playingItem = diff --git a/app/src/main/java/org/oxycblt/auxio/detail/PlaylistDetailFragment.kt b/app/src/main/java/org/oxycblt/auxio/detail/PlaylistDetailFragment.kt index 540017724..5e02cd0a1 100644 --- a/app/src/main/java/org/oxycblt/auxio/detail/PlaylistDetailFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/detail/PlaylistDetailFragment.kt @@ -21,6 +21,8 @@ package org.oxycblt.auxio.detail import android.os.Bundle import android.view.LayoutInflater import android.view.MenuItem +import androidx.activity.result.ActivityResultLauncher +import androidx.activity.result.contract.ActivityResultContracts import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs @@ -47,16 +49,20 @@ import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.MusicViewModel import org.oxycblt.auxio.music.Playlist import org.oxycblt.auxio.music.PlaylistDecision +import org.oxycblt.auxio.music.PlaylistMessage import org.oxycblt.auxio.music.Song +import org.oxycblt.auxio.music.external.M3U import org.oxycblt.auxio.playback.PlaybackDecision import org.oxycblt.auxio.playback.PlaybackViewModel import org.oxycblt.auxio.ui.DialogAwareNavigationListener import org.oxycblt.auxio.util.collect import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.logD +import org.oxycblt.auxio.util.logW import org.oxycblt.auxio.util.navigateSafe import org.oxycblt.auxio.util.overrideOnOverflowMenuClick import org.oxycblt.auxio.util.setFullWidthLookup +import org.oxycblt.auxio.util.showToast import org.oxycblt.auxio.util.unlikelyToBeNull /** @@ -80,6 +86,8 @@ class PlaylistDetailFragment : private val playlistListAdapter = PlaylistDetailListAdapter(this) private var touchHelper: ItemTouchHelper? = null private var editNavigationListener: DialogAwareNavigationListener? = null + private var getContentLauncher: ActivityResultLauncher? = null + private var pendingImportTarget: Playlist? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -99,6 +107,17 @@ class PlaylistDetailFragment : editNavigationListener = DialogAwareNavigationListener(detailModel::dropPlaylistEdit) + getContentLauncher = + registerForActivityResult(ActivityResultContracts.GetContent()) { uri -> + if (uri == null) { + logW("No URI returned from file picker") + return@registerForActivityResult + } + + logD("Received playlist URI $uri") + musicModel.importPlaylist(uri, pendingImportTarget) + } + // --- UI SETUP --- binding.detailNormalToolbar.apply { setNavigationOnClickListener { findNavController().navigateUp() } @@ -142,7 +161,8 @@ class PlaylistDetailFragment : collect(detailModel.toShow.flow, ::handleShow) collect(listModel.menu.flow, ::handleMenu) collectImmediately(listModel.selected, ::updateSelection) - collect(musicModel.playlistDecision.flow, ::handleDecision) + collect(musicModel.playlistDecision.flow, ::handlePlaylistDecision) + collect(musicModel.playlistMessage.flow, ::handlePlaylistMessage) collectImmediately( playbackModel.song, playbackModel.parent, playbackModel.isPlaying, ::updatePlayback) collect(playbackModel.playbackDecision.flow, ::handlePlaybackDecision) @@ -316,13 +336,31 @@ class PlaylistDetailFragment : updateMultiToolbar() } - private fun handleDecision(decision: PlaylistDecision?) { + private fun handlePlaylistDecision(decision: PlaylistDecision?) { if (decision == null) return val directions = when (decision) { + is PlaylistDecision.Import -> { + logD("Importing playlist") + pendingImportTarget = decision.target + requireNotNull(getContentLauncher) { + "Content picker launcher was not available" + } + .launch(M3U.MIME_TYPE) + musicModel.playlistDecision.consume() + return + } is PlaylistDecision.Rename -> { logD("Renaming ${decision.playlist}") - PlaylistDetailFragmentDirections.renamePlaylist(decision.playlist.uid) + PlaylistDetailFragmentDirections.renamePlaylist( + decision.playlist.uid, + decision.template, + decision.applySongs.map { it.uid }.toTypedArray(), + decision.reason) + } + is PlaylistDecision.Export -> { + logD("Exporting ${decision.playlist}") + PlaylistDetailFragmentDirections.exportPlaylist(decision.playlist.uid) } is PlaylistDecision.Delete -> { logD("Deleting ${decision.playlist}") @@ -338,6 +376,12 @@ class PlaylistDetailFragment : findNavController().navigateSafe(directions) } + private fun handlePlaylistMessage(message: PlaylistMessage?) { + if (message == null) return + requireContext().showToast(message.stringRes) + musicModel.playlistMessage.consume() + } + private fun updatePlayback(song: Song?, parent: MusicParent?, isPlaying: Boolean) { // Prefer songs that are playing from this playlist. playlistListAdapter.setPlaying( diff --git a/app/src/main/java/org/oxycblt/auxio/detail/SongDetailDialog.kt b/app/src/main/java/org/oxycblt/auxio/detail/SongDetailDialog.kt index f43da103c..d7c682ce6 100644 --- a/app/src/main/java/org/oxycblt/auxio/detail/SongDetailDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/detail/SongDetailDialog.kt @@ -102,10 +102,7 @@ class SongDetailDialog : ViewBindingMaterialDialogFragment. - */ - -package org.oxycblt.auxio.home - -import android.content.Context -import android.util.AttributeSet -import androidx.annotation.DrawableRes -import androidx.annotation.StringRes -import com.google.android.material.R -import com.google.android.material.floatingactionbutton.FloatingActionButton -import org.oxycblt.auxio.util.logD - -/** - * An extension of [FloatingActionButton] that enables the ability to fade in and out between - * several states, as in the Material Design 3 specification. - * - * @author Alexander Capehart (OxygenCobalt) - */ -class FlipFloatingActionButton -@JvmOverloads -constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = R.attr.floatingActionButtonStyle -) : FloatingActionButton(context, attrs, defStyleAttr) { - private var pendingConfig: PendingConfig? = null - private var flipping = false - - override fun show() { - // Will already show eventually, need to do nothing. - if (flipping) { - logD("Already flipping, aborting show") - return - } - // Apply the new configuration possibly set in flipTo. This should occur even if - // a flip was canceled by a hide. - pendingConfig?.run { - logD("Applying pending configuration") - setImageResource(iconRes) - contentDescription = context.getString(contentDescriptionRes) - setOnClickListener(clickListener) - } - pendingConfig = null - logD("Beginning show") - super.show() - } - - override fun hide() { - if (flipping) { - logD("Hide was called, aborting flip") - } - // Not flipping anymore, disable the flag so that the FAB is not re-shown. - flipping = false - // Don't pass any kind of listener so that future flip operations will not be able - // to show the FAB again. - logD("Beginning hide") - super.hide() - } - - /** - * Flip to a new FAB state. - * - * @param iconRes The resource of the new FAB icon. - * @param contentDescriptionRes The resource of the new FAB content description. - */ - fun flipTo( - @DrawableRes iconRes: Int, - @StringRes contentDescriptionRes: Int, - clickListener: OnClickListener - ) { - // Avoid doing a flip if the given config is already being applied. - if (tag == iconRes) return - tag = iconRes - pendingConfig = PendingConfig(iconRes, contentDescriptionRes, clickListener) - - // Already hiding for whatever reason, apply the configuration when the FAB is shown again. - if (!isOrWillBeHidden) { - logD("Starting hide for flip") - flipping = true - // We will re-show the FAB later, assuming that there was not a prior flip operation. - super.hide(FlipVisibilityListener()) - } else { - logD("Already hiding, will apply config later") - } - } - - private data class PendingConfig( - @DrawableRes val iconRes: Int, - @StringRes val contentDescriptionRes: Int, - val clickListener: OnClickListener - ) - - private inner class FlipVisibilityListener : OnVisibilityChangedListener() { - override fun onHidden(fab: FloatingActionButton) { - if (!flipping) return - logD("Starting show for flip") - flipping = false - show() - } - } -} diff --git a/app/src/main/java/org/oxycblt/auxio/home/HomeFragment.kt b/app/src/main/java/org/oxycblt/auxio/home/HomeFragment.kt index 01558611d..be9d83007 100644 --- a/app/src/main/java/org/oxycblt/auxio/home/HomeFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/home/HomeFragment.kt @@ -21,6 +21,7 @@ package org.oxycblt.auxio.home import android.os.Bundle import android.view.LayoutInflater import android.view.MenuItem +import android.view.MotionEvent import android.view.View import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts @@ -36,10 +37,14 @@ import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.appbar.AppBarLayout +import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.transition.MaterialSharedAxis +import com.leinardi.android.speeddial.SpeedDialActionItem +import com.leinardi.android.speeddial.SpeedDialView import dagger.hilt.android.AndroidEntryPoint import java.lang.reflect.Field +import java.lang.reflect.Method import kotlin.math.abs import org.oxycblt.auxio.BuildConfig import org.oxycblt.auxio.R @@ -64,16 +69,22 @@ import org.oxycblt.auxio.music.MusicViewModel import org.oxycblt.auxio.music.NoAudioPermissionException import org.oxycblt.auxio.music.NoMusicException import org.oxycblt.auxio.music.PERMISSION_READ_AUDIO +import org.oxycblt.auxio.music.Playlist import org.oxycblt.auxio.music.PlaylistDecision +import org.oxycblt.auxio.music.PlaylistMessage import org.oxycblt.auxio.music.Song +import org.oxycblt.auxio.music.external.M3U import org.oxycblt.auxio.playback.PlaybackViewModel import org.oxycblt.auxio.util.collect import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.getColorCompat +import org.oxycblt.auxio.util.isUnder import org.oxycblt.auxio.util.lazyReflectedField +import org.oxycblt.auxio.util.lazyReflectedMethod import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.logW import org.oxycblt.auxio.util.navigateSafe +import org.oxycblt.auxio.util.showToast /** * The starting [SelectionFragment] of Auxio. Shows the user's music library and enables navigation @@ -83,13 +94,17 @@ import org.oxycblt.auxio.util.navigateSafe */ @AndroidEntryPoint class HomeFragment : - SelectionFragment(), AppBarLayout.OnOffsetChangedListener { + SelectionFragment(), + AppBarLayout.OnOffsetChangedListener, + SpeedDialView.OnActionSelectedListener { override val listModel: ListViewModel by activityViewModels() override val musicModel: MusicViewModel by activityViewModels() override val playbackModel: PlaybackViewModel by activityViewModels() private val homeModel: HomeViewModel by activityViewModels() private val detailModel: DetailViewModel by activityViewModels() private var storagePermissionLauncher: ActivityResultLauncher? = null + private var getContentLauncher: ActivityResultLauncher? = null + private var pendingImportTarget: Playlist? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -118,7 +133,39 @@ class HomeFragment : musicModel.refresh() } + getContentLauncher = + registerForActivityResult(ActivityResultContracts.GetContent()) { uri -> + if (uri == null) { + logW("No URI returned from file picker") + return@registerForActivityResult + } + + logD("Received playlist URI $uri") + musicModel.importPlaylist(uri, pendingImportTarget) + } + // --- UI SETUP --- + + binding.root.rootView.apply { + // Stock bottom sheet overlay won't work with our nested UI setup, have to replicate + // it ourselves. + findViewById(R.id.main_scrim).setOnClickListener { + homeModel.setSpeedDialOpen(false) + } + + findViewById(R.id.main_scrim).setOnTouchListener { _, event -> + handleSpeedDialBoundaryTouch(event) + } + + findViewById(R.id.sheet_scrim).setOnClickListener { + homeModel.setSpeedDialOpen(false) + } + + findViewById(R.id.sheet_scrim).setOnTouchListener { _, event -> + handleSpeedDialBoundaryTouch(event) + } + } + binding.homeAppbar.addOnOffsetChangedListener(this) binding.homeNormalToolbar.apply { setOnMenuItemClickListener(this@HomeFragment) @@ -166,14 +213,30 @@ class HomeFragment : // re-creating the ViewPager. setupPager(binding) + binding.homeShuffleFab.setOnClickListener { playbackModel.shuffleAll() } + + binding.homeNewPlaylistFab.apply { + inflate(R.menu.new_playlist_actions) + setOnActionSelectedListener(this@HomeFragment) + setChangeListener(homeModel::setSpeedDialOpen) + } + + hideAllFabs() + updateFabVisibility( + homeModel.songList.value, + homeModel.isFastScrolling.value, + homeModel.currentTabType.value) + // --- VIEWMODEL SETUP --- collect(homeModel.recreateTabs.flow, ::handleRecreate) collectImmediately(homeModel.currentTabType, ::updateCurrentTab) collectImmediately(homeModel.songList, homeModel.isFastScrolling, ::updateFab) + collect(homeModel.speedDialOpen, ::updateSpeedDial) collect(listModel.menu.flow, ::handleMenu) collectImmediately(listModel.selected, ::updateSelection) collectImmediately(musicModel.indexingState, ::updateIndexerState) collect(musicModel.playlistDecision.flow, ::handleDecision) + collectImmediately(musicModel.playlistMessage.flow, ::handlePlaylistMessage) collect(detailModel.toShow.flow, ::handleShow) } @@ -191,6 +254,8 @@ class HomeFragment : storagePermissionLauncher = null binding.homeAppbar.removeOnOffsetChangedListener(this) binding.homeNormalToolbar.setOnMenuItemClickListener(null) + binding.homeNewPlaylistFab.setChangeListener(null) + binding.homeNewPlaylistFab.setOnActionSelectedListener(null) } override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) { @@ -249,6 +314,24 @@ class HomeFragment : } } + override fun onActionSelected(actionItem: SpeedDialActionItem): Boolean { + when (actionItem.id) { + R.id.action_new_playlist -> { + logD("Creating playlist") + musicModel.createPlaylist() + } + R.id.action_import_playlist -> { + logD("Importing playlist") + musicModel.importPlaylist() + } + else -> {} + } + // Returning false to close th speed dial results in no animation, manually close instead. + // Adapted from Material Files: https://github.com/zhanghai/MaterialFiles + requireBinding().homeNewPlaylistFab.close() + return true + } + private fun setupPager(binding: FragmentHomeBinding) { binding.homePager.adapter = HomePagerAdapter(homeModel.currentTabTypes, childFragmentManager, viewLifecycleOwner) @@ -291,17 +374,7 @@ class HomeFragment : MusicType.PLAYLISTS -> R.id.home_playlist_recycler } - if (tabType != MusicType.PLAYLISTS) { - logD("Flipping to shuffle button") - binding.homeFab.flipTo(R.drawable.ic_shuffle_off_24, R.string.desc_shuffle_all) { - playbackModel.shuffleAll() - } - } else { - logD("Flipping to playlist button") - binding.homeFab.flipTo(R.drawable.ic_add_24, R.string.desc_new_playlist) { - musicModel.createPlaylist() - } - } + updateFabVisibility(homeModel.songList.value, homeModel.isFastScrolling.value, tabType) } private fun handleRecreate(recreate: Unit?) { @@ -333,7 +406,10 @@ class HomeFragment : private fun setupCompleteState(binding: FragmentHomeBinding, error: Exception?) { if (error == null) { logD("Received ok response") - binding.homeFab.show() + updateFabVisibility( + homeModel.songList.value, + homeModel.isFastScrolling.value, + homeModel.currentTabType.value) binding.homeIndexingContainer.visibility = View.INVISIBLE return } @@ -420,11 +496,32 @@ class HomeFragment : when (decision) { is PlaylistDecision.New -> { logD("Creating new playlist") - HomeFragmentDirections.newPlaylist(decision.songs.map { it.uid }.toTypedArray()) + HomeFragmentDirections.newPlaylist( + decision.songs.map { it.uid }.toTypedArray(), + decision.template, + decision.reason) + } + is PlaylistDecision.Import -> { + logD("Importing playlist") + pendingImportTarget = decision.target + requireNotNull(getContentLauncher) { + "Content picker launcher was not available" + } + .launch(M3U.MIME_TYPE) + musicModel.playlistDecision.consume() + return } is PlaylistDecision.Rename -> { logD("Renaming ${decision.playlist}") - HomeFragmentDirections.renamePlaylist(decision.playlist.uid) + HomeFragmentDirections.renamePlaylist( + decision.playlist.uid, + decision.template, + decision.applySongs.map { it.uid }.toTypedArray(), + decision.reason) + } + is PlaylistDecision.Export -> { + logD("Exporting ${decision.playlist}") + HomeFragmentDirections.exportPlaylist(decision.playlist.uid) } is PlaylistDecision.Delete -> { logD("Deleting ${decision.playlist}") @@ -439,18 +536,128 @@ class HomeFragment : findNavController().navigateSafe(directions) } + private fun handlePlaylistMessage(message: PlaylistMessage?) { + if (message == null) return + requireContext().showToast(message.stringRes) + musicModel.playlistMessage.consume() + } + private fun updateFab(songs: List, isFastScrolling: Boolean) { + updateFabVisibility(songs, isFastScrolling, homeModel.currentTabType.value) + } + + private fun updateFabVisibility( + songs: List, + isFastScrolling: Boolean, + tabType: MusicType + ) { val binding = requireBinding() // If there are no songs, it's likely that the library has not been loaded, so // displaying the shuffle FAB makes no sense. We also don't want the fast scroll // popup to overlap with the FAB, so we hide the FAB when fast scrolling too. if (songs.isEmpty() || isFastScrolling) { logD("Hiding fab: [empty: ${songs.isEmpty()} scrolling: $isFastScrolling]") - binding.homeFab.hide() + hideAllFabs() } else { - logD("Showing fab") - binding.homeFab.show() + if (tabType != MusicType.PLAYLISTS) { + logD("Showing shuffle button") + if (binding.homeShuffleFab.isOrWillBeShown) { + logD("Nothing to do") + return + } + + if (binding.homeNewPlaylistFab.mainFab.isOrWillBeShown) { + logD("Animating transition") + binding.homeNewPlaylistFab.hide( + object : FloatingActionButton.OnVisibilityChangedListener() { + override fun onHidden(fab: FloatingActionButton) { + super.onHidden(fab) + binding.homeShuffleFab.show() + } + }) + } else { + logD("Showing immediately") + binding.homeShuffleFab.show() + } + } else { + logD("Showing playlist button") + if (binding.homeNewPlaylistFab.mainFab.isOrWillBeShown) { + logD("Nothing to do") + return + } + + if (binding.homeShuffleFab.isOrWillBeShown) { + logD("Animating transition") + binding.homeShuffleFab.hide( + object : FloatingActionButton.OnVisibilityChangedListener() { + override fun onHidden(fab: FloatingActionButton) { + super.onHidden(fab) + binding.homeNewPlaylistFab.show() + } + }) + } else { + logD("Showing immediately") + binding.homeNewPlaylistFab.show() + } + } + } + } + + private fun hideAllFabs() { + val binding = requireBinding() + if (binding.homeShuffleFab.isOrWillBeShown) { + FAB_HIDE_FROM_USER_FIELD.invoke(binding.homeShuffleFab, null, false) } + if (binding.homeNewPlaylistFab.mainFab.isOrWillBeShown) { + FAB_HIDE_FROM_USER_FIELD.invoke(binding.homeNewPlaylistFab.mainFab, null, false) + } + } + + private fun updateSpeedDial(open: Boolean) { + val binding = requireBinding() + + binding.root.rootView.apply { + // Stock bottom sheet overlay won't work with our nested UI setup, have to replicate + // it ourselves. + findViewById(R.id.main_scrim).isClickable = open + findViewById(R.id.sheet_scrim).isClickable = open + } + + if (open) { + binding.homeNewPlaylistFab.open(true) + } else { + binding.homeNewPlaylistFab.close(true) + } + } + + private fun handleSpeedDialBoundaryTouch(event: MotionEvent): Boolean { + val binding = binding ?: return false + + if (homeModel.speedDialOpen.value && binding.homeNewPlaylistFab.isUnder(event.x, event.y)) { + // Convert absolute coordinates to relative coordinates + val offsetX = event.x - binding.homeNewPlaylistFab.x + val offsetY = event.y - binding.homeNewPlaylistFab.y + + // Create a new MotionEvent with relative coordinates + val relativeEvent = + MotionEvent.obtain( + event.downTime, + event.eventTime, + event.action, + offsetX, + offsetY, + event.metaState) + + // Dispatch the relative MotionEvent to the target child view + val handled = binding.homeNewPlaylistFab.dispatchTouchEvent(relativeEvent) + + // Recycle the relative MotionEvent + relativeEvent.recycle() + + return handled + } + + return false } private fun handleShow(show: Show?) { @@ -568,6 +775,12 @@ class HomeFragment : private companion object { val VP_RECYCLER_FIELD: Field by lazyReflectedField(ViewPager2::class, "mRecyclerView") val RV_TOUCH_SLOP_FIELD: Field by lazyReflectedField(RecyclerView::class, "mTouchSlop") + val FAB_HIDE_FROM_USER_FIELD: Method by + lazyReflectedMethod( + FloatingActionButton::class, + "hide", + FloatingActionButton.OnVisibilityChangedListener::class, + Boolean::class) const val KEY_LAST_TRANSITION_ID = BuildConfig.APPLICATION_ID + ".key.LAST_TRANSITION_AXIS" } } diff --git a/app/src/main/java/org/oxycblt/auxio/home/HomeViewModel.kt b/app/src/main/java/org/oxycblt/auxio/home/HomeViewModel.kt index bb9311c84..51bc04976 100644 --- a/app/src/main/java/org/oxycblt/auxio/home/HomeViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/home/HomeViewModel.kt @@ -156,6 +156,10 @@ constructor( /** A marker for whether the user is fast-scrolling in the home view or not. */ val isFastScrolling: StateFlow = _isFastScrolling + private val _speedDialOpen = MutableStateFlow(false) + /** A marker for whether the speed dial is open or not. */ + val speedDialOpen: StateFlow = _speedDialOpen + private val _showOuter = MutableEvent() val showOuter: Event get() = _showOuter @@ -293,6 +297,16 @@ constructor( _isFastScrolling.value = isFastScrolling } + /** + * Update whether the speed dial is open or not. + * + * @param speedDialOpen true if the speed dial is open, false otherwise. + */ + fun setSpeedDialOpen(speedDialOpen: Boolean) { + logD("Updating speed dial state: $speedDialOpen") + _speedDialOpen.value = speedDialOpen + } + fun showSettings() { _showOuter.put(Outer.Settings) } diff --git a/app/src/main/java/org/oxycblt/auxio/home/ThemedSpeedDialView.kt b/app/src/main/java/org/oxycblt/auxio/home/ThemedSpeedDialView.kt new file mode 100644 index 000000000..1a9b5174d --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/home/ThemedSpeedDialView.kt @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2018 Auxio Project + * ThemedSpeedDialView.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.home + +import android.animation.Animator +import android.animation.AnimatorListenerAdapter +import android.animation.AnimatorSet +import android.animation.ObjectAnimator +import android.content.Context +import android.content.res.ColorStateList +import android.graphics.drawable.Drawable +import android.graphics.drawable.RotateDrawable +import android.os.Bundle +import android.os.Parcelable +import android.util.AttributeSet +import android.util.Property +import android.view.View +import android.widget.ImageView +import android.widget.TextView +import androidx.annotation.AttrRes +import androidx.annotation.FloatRange +import androidx.core.os.BundleCompat +import androidx.core.view.setMargins +import androidx.core.view.updateLayoutParams +import androidx.core.widget.TextViewCompat +import androidx.interpolator.view.animation.FastOutSlowInInterpolator +import com.google.android.material.shape.MaterialShapeDrawable +import com.leinardi.android.speeddial.FabWithLabelView +import com.leinardi.android.speeddial.SpeedDialActionItem +import com.leinardi.android.speeddial.SpeedDialView +import kotlin.math.roundToInt +import kotlinx.parcelize.Parcelize +import org.oxycblt.auxio.R +import org.oxycblt.auxio.util.getAttrColorCompat +import org.oxycblt.auxio.util.getDimen +import org.oxycblt.auxio.util.getDimenPixels + +/** + * Customized Speed Dial view with some bug fixes and Material 3 theming. + * + * Adapted from Material Files: + * https://github.com/zhanghai/MaterialFiles/tree/79f1727cec72a6a089eb495f79193f87459fc5e3 + * + * MODIFICATIONS: + * - Removed dynamic theme changes based on the MaterialFile's Material 3 setting + * - Adapted code to the extensions in this project + * + * @author Hai Zhang, Alexander Capehart (OxygenCobalt) + */ +class ThemedSpeedDialView : SpeedDialView { + private var mainFabAnimator: Animator? = null + private val spacingSmall = context.getDimenPixels(R.dimen.spacing_small) + private var innerChangeListener: ((Boolean) -> Unit)? = null + + constructor(context: Context) : super(context) + + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) + + constructor( + context: Context, + attrs: AttributeSet?, + @AttrRes defStyleAttr: Int + ) : super(context, attrs, defStyleAttr) + + init { + // Work around ripple bug on Android 12 when useCompatPadding = true. + // @see https://github.com/material-components/material-components-android/issues/2617 + mainFab.apply { + updateLayoutParams { + setMargins(context.getDimenPixels(R.dimen.spacing_medium)) + } + useCompatPadding = false + } + val context = context + mainFabClosedBackgroundColor = + context + .getAttrColorCompat(com.google.android.material.R.attr.colorPrimaryContainer) + .defaultColor + mainFabClosedIconColor = + context + .getAttrColorCompat(com.google.android.material.R.attr.colorOnPrimaryContainer) + .defaultColor + mainFabOpenedBackgroundColor = + context.getAttrColorCompat(androidx.appcompat.R.attr.colorPrimary).defaultColor + mainFabOpenedIconColor = + context + .getAttrColorCompat(com.google.android.material.R.attr.colorOnPrimary) + .defaultColor + + // Always use our own animation to fix the library issue that ripple is rotated as well. + val mainFabDrawable = + RotateDrawable().apply { + drawable = mainFab.drawable + toDegrees = mainFabAnimationRotateAngle + } + mainFabAnimationRotateAngle = 0f + setMainFabClosedDrawable(mainFabDrawable) + setOnChangeListener( + object : OnChangeListener { + override fun onMainActionSelected(): Boolean = false + + override fun onToggleChanged(isOpen: Boolean) { + mainFabAnimator?.cancel() + mainFabAnimator = + createMainFabAnimator(isOpen).apply { + addListener( + object : AnimatorListenerAdapter() { + override fun onAnimationEnd(animation: Animator) { + mainFabAnimator = null + } + }) + start() + } + innerChangeListener?.invoke(isOpen) + } + }) + } + + private fun createMainFabAnimator(isOpen: Boolean): Animator = + AnimatorSet().apply { + playTogether( + ObjectAnimator.ofArgb( + mainFab, + VIEW_PROPERTY_BACKGROUND_TINT, + if (isOpen) mainFabOpenedBackgroundColor else mainFabClosedBackgroundColor), + ObjectAnimator.ofArgb( + mainFab, + IMAGE_VIEW_PROPERTY_IMAGE_TINT, + if (isOpen) mainFabOpenedIconColor else mainFabClosedIconColor), + ObjectAnimator.ofInt( + mainFab.drawable, DRAWABLE_PROPERTY_LEVEL, if (isOpen) 10000 else 0)) + duration = 200 + interpolator = FastOutSlowInInterpolator() + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + + val overlayLayout = overlayLayout + if (overlayLayout != null) { + val surfaceColor = + context.getAttrColorCompat(com.google.android.material.R.attr.colorSurface) + val overlayColor = surfaceColor.defaultColor.withModulatedAlpha(0.87f) + overlayLayout.setBackgroundColor(overlayColor) + } + } + + private fun Int.withModulatedAlpha( + @FloatRange(from = 0.0, to = 1.0) alphaModulation: Float + ): Int { + val alpha = (alpha * alphaModulation).roundToInt() + return ((alpha shl 24) or (this and 0x00FFFFFF)) + } + + override fun addActionItem( + actionItem: SpeedDialActionItem, + position: Int, + animate: Boolean + ): FabWithLabelView? { + val context = context + val fabImageTintColor = context.getAttrColorCompat(androidx.appcompat.R.attr.colorPrimary) + val fabBackgroundColor = + context.getAttrColorCompat(com.google.android.material.R.attr.colorSurface) + val labelColor = context.getAttrColorCompat(android.R.attr.textColorSecondary) + val labelBackgroundColor = + context.getAttrColorCompat(com.google.android.material.R.attr.colorSurface) + val labelElevation = + context.getDimen(com.google.android.material.R.dimen.m3_card_elevated_elevation) + val cornerRadius = context.getDimenPixels(R.dimen.spacing_medium) + val actionItem = + SpeedDialActionItem.Builder( + actionItem.id, + // Should not be a resource, pass null to fail fast. + actionItem.getFabImageDrawable(null)) + .setLabel(actionItem.getLabel(context)) + .setFabImageTintColor(fabImageTintColor.defaultColor) + .setFabBackgroundColor(fabBackgroundColor.defaultColor) + .setLabelColor(labelColor.defaultColor) + .setLabelBackgroundColor(labelBackgroundColor.defaultColor) + .setLabelClickable(actionItem.isLabelClickable) + .setTheme(actionItem.theme) + .create() + return super.addActionItem(actionItem, position, animate)?.apply { + fab.apply { + updateLayoutParams { + val horizontalMargin = context.getDimenPixels(R.dimen.spacing_mid_large) + setMargins(horizontalMargin, 0, horizontalMargin, 0) + } + useCompatPadding = false + } + + labelBackground.apply { + useCompatPadding = false + setContentPadding(spacingSmall, spacingSmall, spacingSmall, spacingSmall) + background = + MaterialShapeDrawable.createWithElevationOverlay(context).apply { + fillColor = labelBackgroundColor + elevation = labelElevation + setCornerSize(cornerRadius.toFloat()) + } + foreground = null + (getChildAt(0) as TextView).apply { + TextViewCompat.setTextAppearance(this, R.style.TextAppearance_Auxio_LabelLarge) + } + } + } + } + + override fun onSaveInstanceState(): Parcelable { + val superState = + BundleCompat.getParcelable( + super.onSaveInstanceState() as Bundle, "superState", Parcelable::class.java) + return State(superState, isOpen) + } + + override fun onRestoreInstanceState(state: Parcelable) { + state as State + super.onRestoreInstanceState(state.superState) + if (state.isOpen) { + toggle(false) + } + } + + fun setChangeListener(listener: ((Boolean) -> Unit)?) { + innerChangeListener = listener + } + + companion object { + private val VIEW_PROPERTY_BACKGROUND_TINT = + object : Property(Int::class.java, "backgroundTint") { + override fun get(view: View): Int? = view.backgroundTintList!!.defaultColor + + override fun set(view: View, value: Int?) { + view.backgroundTintList = ColorStateList.valueOf(value!!) + } + } + + private val IMAGE_VIEW_PROPERTY_IMAGE_TINT = + object : Property(Int::class.java, "imageTint") { + override fun get(view: ImageView): Int? = view.imageTintList!!.defaultColor + + override fun set(view: ImageView, value: Int?) { + view.imageTintList = ColorStateList.valueOf(value!!) + } + } + + private val DRAWABLE_PROPERTY_LEVEL = + object : Property(Int::class.java, "level") { + override fun get(drawable: Drawable): Int? = drawable.level + + override fun set(drawable: Drawable, value: Int?) { + drawable.level = value!! + } + } + } + + @Parcelize private class State(val superState: Parcelable?, val isOpen: Boolean) : Parcelable +} diff --git a/app/src/main/java/org/oxycblt/auxio/image/CoverView.kt b/app/src/main/java/org/oxycblt/auxio/image/CoverView.kt index f2858479c..792755dc7 100644 --- a/app/src/main/java/org/oxycblt/auxio/image/CoverView.kt +++ b/app/src/main/java/org/oxycblt/auxio/image/CoverView.kt @@ -73,7 +73,7 @@ import org.oxycblt.auxio.util.getInteger * @author Alexander Capehart (OxygenCobalt) */ @AndroidEntryPoint -class CoverView +open class CoverView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) : FrameLayout(context, attrs, defStyleAttr) { diff --git a/app/src/main/java/org/oxycblt/auxio/list/menu/MenuDialogFragmentImpl.kt b/app/src/main/java/org/oxycblt/auxio/list/menu/MenuDialogFragmentImpl.kt index a7eef2392..238d315da 100644 --- a/app/src/main/java/org/oxycblt/auxio/list/menu/MenuDialogFragmentImpl.kt +++ b/app/src/main/java/org/oxycblt/auxio/list/menu/MenuDialogFragmentImpl.kt @@ -178,7 +178,11 @@ class ArtistMenuDialogFragment : MenuDialogFragment() { binding.menuInfo.text = getString( R.string.fmt_two, - context.getPlural(R.plurals.fmt_album_count, menu.artist.albums.size), + if (menu.artist.explicitAlbums.isNotEmpty()) { + context.getPlural(R.plurals.fmt_album_count, menu.artist.explicitAlbums.size) + } else { + context.getString(R.string.def_album_count) + }, if (menu.artist.songs.isNotEmpty()) { context.getPlural(R.plurals.fmt_song_count, menu.artist.songs.size) } else { @@ -284,6 +288,7 @@ class PlaylistMenuDialogFragment : MenuDialogFragment() { R.id.action_play_next, R.id.action_queue_add, R.id.action_playlist_add, + R.id.action_export, R.id.action_share) } else { setOf() @@ -316,6 +321,8 @@ class PlaylistMenuDialogFragment : MenuDialogFragment() { requireContext().showToast(R.string.lng_queue_added) } R.id.action_rename -> musicModel.renamePlaylist(menu.playlist) + R.id.action_import -> musicModel.importPlaylist(target = menu.playlist) + R.id.action_export -> musicModel.exportPlaylist(menu.playlist) R.id.action_delete -> musicModel.deletePlaylist(menu.playlist) R.id.action_share -> requireContext().share(menu.playlist) else -> error("Unexpected menu item $item") diff --git a/app/src/main/java/org/oxycblt/auxio/list/recycler/ViewHolders.kt b/app/src/main/java/org/oxycblt/auxio/list/recycler/ViewHolders.kt index c829248e5..36565b63f 100644 --- a/app/src/main/java/org/oxycblt/auxio/list/recycler/ViewHolders.kt +++ b/app/src/main/java/org/oxycblt/auxio/list/recycler/ViewHolders.kt @@ -164,7 +164,11 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin binding.parentInfo.text = binding.context.getString( R.string.fmt_two, - binding.context.getPlural(R.plurals.fmt_album_count, artist.albums.size), + if (artist.explicitAlbums.isNotEmpty()) { + binding.context.getPlural(R.plurals.fmt_album_count, artist.explicitAlbums.size) + } else { + binding.context.getString(R.string.def_album_count) + }, if (artist.songs.isNotEmpty()) { binding.context.getPlural(R.plurals.fmt_song_count, artist.songs.size) } else { @@ -199,7 +203,7 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin object : SimpleDiffCallback() { override fun areContentsTheSame(oldItem: Artist, newItem: Artist) = oldItem.name == newItem.name && - oldItem.albums.size == newItem.albums.size && + oldItem.explicitAlbums.size == newItem.explicitAlbums.size && oldItem.songs.size == newItem.songs.size } } diff --git a/app/src/main/java/org/oxycblt/auxio/music/Music.kt b/app/src/main/java/org/oxycblt/auxio/music/Music.kt index 766ea462c..1bf23aaf6 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/Music.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/Music.kt @@ -317,12 +317,6 @@ interface Album : MusicParent { * @author Alexander Capehart (OxygenCobalt) */ interface Artist : MusicParent { - /** - * All of the [Album]s this artist is credited to from [explicitAlbums] and [implicitAlbums]. - * Note that any [Song] credited to this artist will have it's [Album] considered to be - * "indirectly" linked to this [Artist], and thus included in this list. - */ - val albums: Collection /** Albums directly credited to this [Artist] via a "Album Artist" tag. */ val explicitAlbums: Collection /** Albums indirectly credited to this [Artist] via an "Artist" tag. */ @@ -354,6 +348,7 @@ interface Genre : MusicParent { * @author Alexander Capehart (OxygenCobalt) */ interface Playlist : MusicParent { + override val name: Name.Known override val songs: List /** The total duration of the songs in this genre, in milliseconds. */ val durationMs: Long diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt index d5263da7b..97ecaa7fd 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt @@ -31,14 +31,18 @@ import kotlinx.coroutines.async import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeout import kotlinx.coroutines.yield import org.oxycblt.auxio.music.cache.CacheRepository import org.oxycblt.auxio.music.device.DeviceLibrary import org.oxycblt.auxio.music.device.RawSong import org.oxycblt.auxio.music.fs.MediaStoreExtractor +import org.oxycblt.auxio.music.info.Name +import org.oxycblt.auxio.music.metadata.Separators import org.oxycblt.auxio.music.metadata.TagExtractor import org.oxycblt.auxio.music.user.MutableUserLibrary import org.oxycblt.auxio.music.user.UserLibrary +import org.oxycblt.auxio.util.forEachWithTimeout import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.logE import org.oxycblt.auxio.util.logW @@ -223,7 +227,8 @@ constructor( private val mediaStoreExtractor: MediaStoreExtractor, private val tagExtractor: TagExtractor, private val deviceLibraryFactory: DeviceLibrary.Factory, - private val userLibraryFactory: UserLibrary.Factory + private val userLibraryFactory: UserLibrary.Factory, + private val musicSettings: MusicSettings ) : MusicRepository { private val updateListeners = mutableListOf() private val indexingListeners = mutableListOf() @@ -337,11 +342,11 @@ constructor( } override fun index(worker: MusicRepository.IndexingWorker, withCache: Boolean) = - worker.scope.launch { indexWrapper(worker, withCache) } + worker.scope.launch { indexWrapper(worker.context, this, withCache) } - private suspend fun indexWrapper(worker: MusicRepository.IndexingWorker, withCache: Boolean) { + private suspend fun indexWrapper(context: Context, scope: CoroutineScope, withCache: Boolean) { try { - indexImpl(worker, withCache) + indexImpl(context, scope, withCache) } catch (e: CancellationException) { // Got cancelled, propagate upwards to top-level co-routine. logD("Loading routine was cancelled") @@ -355,16 +360,29 @@ constructor( } } - private suspend fun indexImpl(worker: MusicRepository.IndexingWorker, withCache: Boolean) { + private suspend fun indexImpl(context: Context, scope: CoroutineScope, withCache: Boolean) { + // TODO: Find a way to break up this monster of a method, preferably as another class. + val start = System.currentTimeMillis() // Make sure we have permissions before going forward. Theoretically this would be better // done at the UI level, but that intertwines logic and display too much. - if (ContextCompat.checkSelfPermission(worker.context, PERMISSION_READ_AUDIO) == + if (ContextCompat.checkSelfPermission(context, PERMISSION_READ_AUDIO) == PackageManager.PERMISSION_DENIED) { logE("Permissions were not granted") throw NoAudioPermissionException() } + // Obtain configuration information + val constraints = + MediaStoreExtractor.Constraints(musicSettings.excludeNonMusic, musicSettings.musicDirs) + val separators = Separators.from(musicSettings.separators) + val nameFactory = + if (musicSettings.intelligentSorting) { + Name.Known.IntelligentFactory + } else { + Name.Known.SimpleFactory + } + // Begin with querying MediaStore and the music cache. The former is needed for Auxio // to figure out what songs are (probably) on the device, and the latter will be needed // for discovery (described later). These have no shared state, so they are done in @@ -373,10 +391,10 @@ constructor( emitIndexingProgress(IndexingProgress.Indeterminate) val mediaStoreQueryJob = - worker.scope.async { + scope.async { val query = try { - mediaStoreExtractor.query() + mediaStoreExtractor.query(constraints) } catch (e: Exception) { // Normally, errors in an async call immediately bubble up to the Looper // and crash the app. Thus, we have to wrap any error into a Result @@ -411,14 +429,15 @@ constructor( // does not exist. In the latter situation, it also applies it's own (inferior) metadata. logD("Starting MediaStore discovery") val mediaStoreJob = - worker.scope.async { + scope.async { try { mediaStoreExtractor.consume(query, cache, incompleteSongs, completeSongs) } catch (e: Exception) { // To prevent a deadlock, we want to close the channel with an exception // to cascade to and cancel all other routines before finally bubbling up // to the main extractor loop. - incompleteSongs.close(e) + logE("MediaStore extraction failed: $e") + incompleteSongs.close(Exception("MediaStore extraction failed: $e")) return@async } incompleteSongs.close() @@ -428,11 +447,12 @@ constructor( // metadata for them, and then forwards it to DeviceLibrary. logD("Starting tag extraction") val tagJob = - worker.scope.async { + scope.async { try { tagExtractor.consume(incompleteSongs, completeSongs) } catch (e: Exception) { - completeSongs.close(e) + logE("Tag extraction failed: $e") + completeSongs.close(Exception("Tag extraction failed: $e")) return@async } completeSongs.close() @@ -442,12 +462,14 @@ constructor( // and then forwards them to the primary loading loop. logD("Starting DeviceLibrary creation") val deviceLibraryJob = - worker.scope.async(Dispatchers.Default) { + scope.async(Dispatchers.Default) { val deviceLibrary = try { - deviceLibraryFactory.create(completeSongs, processedSongs) + deviceLibraryFactory.create( + completeSongs, processedSongs, separators, nameFactory) } catch (e: Exception) { - processedSongs.close(e) + logE("DeviceLibrary creation failed: $e") + processedSongs.close(Exception("DeviceLibrary creation failed: $e")) return@async Result.failure(e) } processedSongs.close() @@ -457,19 +479,20 @@ constructor( // We could keep track of a total here, but we also need to collate this RawSong information // for when we write the cache later on in the finalization step. val rawSongs = LinkedList() - for (rawSong in processedSongs) { - rawSongs.add(rawSong) + // Use a longer timeout so that dependent components can timeout and throw errors that + // provide more context than if we timed out here. + processedSongs.forEachWithTimeout(20000) { + rawSongs.add(it) // Since discovery takes up the bulk of the music loading process, we switch to // indicating a defined amount of loaded songs in comparison to the projected amount // of songs that were queried. emitIndexingProgress(IndexingProgress.Songs(rawSongs.size, query.projectedTotal)) } - // This shouldn't occur, but keep them around just in case there's a regression. - // Note that DeviceLibrary might still actually be doing work (specifically parent - // processing), so we don't check if it's deadlocked. - check(!mediaStoreJob.isActive) { "MediaStore discovery is deadlocked" } - check(!tagJob.isActive) { "Tag extraction is deadlocked" } + withTimeout(10000) { + mediaStoreJob.await() + tagJob.await() + } // Deliberately done after the involved initialization step to make it less likely // that the short-circuit occurs so quickly as to break the UI. @@ -493,7 +516,7 @@ constructor( // working on parent information. logD("Starting UserLibrary query") val userLibraryQueryJob = - worker.scope.async { + scope.async { val rawPlaylists = try { userLibraryFactory.query() @@ -518,7 +541,7 @@ constructor( logD("Awaiting DeviceLibrary creation") val deviceLibrary = deviceLibraryJob.await().getOrThrow() logD("Starting UserLibrary creation") - val userLibrary = userLibraryFactory.create(rawPlaylists, deviceLibrary) + val userLibrary = userLibraryFactory.create(rawPlaylists, deviceLibrary, nameFactory) // Loading process is functionally done, indicate such logD( diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt index 488c98126..e50b0c448 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt @@ -24,8 +24,8 @@ import androidx.core.content.edit import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject import org.oxycblt.auxio.R -import org.oxycblt.auxio.music.fs.Directory -import org.oxycblt.auxio.music.fs.MusicDirectories +import org.oxycblt.auxio.music.dirs.MusicDirectories +import org.oxycblt.auxio.music.fs.DocumentPathFactory import org.oxycblt.auxio.settings.Settings import org.oxycblt.auxio.util.getSystemServiceCompat import org.oxycblt.auxio.util.logD @@ -55,7 +55,9 @@ interface MusicSettings : Settings { } } -class MusicSettingsImpl @Inject constructor(@ApplicationContext context: Context) : +class MusicSettingsImpl +@Inject +constructor(@ApplicationContext context: Context, val documentPathFactory: DocumentPathFactory) : Settings.Impl(context), MusicSettings { private val storageManager = context.getSystemServiceCompat(StorageManager::class) @@ -64,7 +66,7 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext context: Context val dirs = (sharedPreferences.getStringSet(getString(R.string.set_key_music_dirs), null) ?: emptySet()) - .mapNotNull { Directory.fromDocumentTreeUri(storageManager, it) } + .mapNotNull(documentPathFactory::fromDocumentId) return MusicDirectories( dirs, sharedPreferences.getBoolean(getString(R.string.set_key_music_dirs_include), false)) @@ -73,7 +75,7 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext context: Context sharedPreferences.edit { putStringSet( getString(R.string.set_key_music_dirs), - value.dirs.map(Directory::toDocumentTreeUri).toSet()) + value.dirs.map(documentPathFactory::toDocumentId).toSet()) putBoolean(getString(R.string.set_key_music_dirs_include), value.shouldInclude) apply() } diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicViewModel.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicViewModel.kt index 314b38785..6140261a9 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicViewModel.kt @@ -18,6 +18,7 @@ package org.oxycblt.auxio.music +import android.net.Uri import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel @@ -26,10 +27,14 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch +import org.oxycblt.auxio.R import org.oxycblt.auxio.list.ListSettings +import org.oxycblt.auxio.music.external.ExportConfig +import org.oxycblt.auxio.music.external.ExternalPlaylistManager import org.oxycblt.auxio.util.Event import org.oxycblt.auxio.util.MutableEvent import org.oxycblt.auxio.util.logD +import org.oxycblt.auxio.util.logE /** * A [ViewModel] providing data specific to the music loading process. @@ -42,18 +47,22 @@ class MusicViewModel constructor( private val listSettings: ListSettings, private val musicRepository: MusicRepository, + private val externalPlaylistManager: ExternalPlaylistManager ) : ViewModel(), MusicRepository.UpdateListener, MusicRepository.IndexingListener { private val _indexingState = MutableStateFlow(null) + /** The current music loading state, or null if no loading is going on. */ val indexingState: StateFlow = _indexingState private val _statistics = MutableStateFlow(null) + /** [Statistics] about the last completed music load. */ val statistics: StateFlow get() = _statistics private val _playlistDecision = MutableEvent() + /** * A [PlaylistDecision] command that is awaiting a view capable of responding to it. Null if * none currently. @@ -61,6 +70,10 @@ constructor( val playlistDecision: Event get() = _playlistDecision + private val _playlistMessage = MutableEvent() + val playlistMessage: Event + get() = _playlistMessage + init { musicRepository.addUpdateListener(this) musicRepository.addIndexingListener(this) @@ -105,14 +118,103 @@ constructor( * * @param name The name of the new [Playlist]. If null, the user will be prompted for one. * @param songs The [Song]s to be contained in the new playlist. + * @param reason The reason why a new playlist is being created. For all intensive purposes, you + * do not need to specify this. */ - fun createPlaylist(name: String? = null, songs: List = listOf()) { + fun createPlaylist( + name: String? = null, + songs: List = listOf(), + reason: PlaylistDecision.New.Reason = PlaylistDecision.New.Reason.NEW + ) { if (name != null) { logD("Creating $name with ${songs.size} songs]") - viewModelScope.launch(Dispatchers.IO) { musicRepository.createPlaylist(name, songs) } + viewModelScope.launch(Dispatchers.IO) { + musicRepository.createPlaylist(name, songs) + val message = + when (reason) { + PlaylistDecision.New.Reason.NEW -> PlaylistMessage.NewPlaylistSuccess + PlaylistDecision.New.Reason.ADD -> PlaylistMessage.AddSuccess + PlaylistDecision.New.Reason.IMPORT -> PlaylistMessage.ImportSuccess + } + _playlistMessage.put(message) + } } else { logD("Launching creation dialog for ${songs.size} songs") - _playlistDecision.put(PlaylistDecision.New(songs)) + _playlistDecision.put(PlaylistDecision.New(songs, null, reason)) + } + } + + /** + * Import a playlist from a file [Uri]. Errors pushed to [playlistMessage]. + * + * @param uri The [Uri] of the file to import. If null, the user will be prompted with a file + * picker. + * @param target The [Playlist] to import to. If null, a new playlist will be created. Note the + * [Playlist] will not be renamed to the name of the imported playlist. + * @see ExternalPlaylistManager + */ + fun importPlaylist(uri: Uri? = null, target: Playlist? = null) { + if (uri != null) { + viewModelScope.launch(Dispatchers.IO) { + val importedPlaylist = externalPlaylistManager.import(uri) + if (importedPlaylist == null) { + logE("Could not import playlist") + _playlistMessage.put(PlaylistMessage.ImportFailed) + return@launch + } + + val deviceLibrary = musicRepository.deviceLibrary ?: return@launch + val songs = importedPlaylist.paths.mapNotNull(deviceLibrary::findSongByPath) + + if (songs.isEmpty()) { + logE("No songs found") + _playlistMessage.put(PlaylistMessage.ImportFailed) + return@launch + } + + if (target !== null) { + if (importedPlaylist.name != null && importedPlaylist.name != target.name.raw) { + _playlistDecision.put( + PlaylistDecision.Rename( + target, + importedPlaylist.name, + songs, + PlaylistDecision.Rename.Reason.IMPORT)) + } else { + musicRepository.rewritePlaylist(target, songs) + _playlistMessage.put(PlaylistMessage.ImportSuccess) + } + } else { + _playlistDecision.put( + PlaylistDecision.New( + songs, importedPlaylist.name, PlaylistDecision.New.Reason.IMPORT)) + } + } + } else { + logD("Launching import picker") + _playlistDecision.put(PlaylistDecision.Import(target)) + } + } + + /** + * Export a [Playlist] to a file [Uri]. Errors pushed to [playlistMessage]. + * + * @param playlist The [Playlist] to export. + * @param uri The [Uri] to export to. If null, the user will be prompted for one. + */ + fun exportPlaylist(playlist: Playlist, uri: Uri? = null, config: ExportConfig? = null) { + if (uri != null && config != null) { + logD("Exporting playlist to $uri") + viewModelScope.launch(Dispatchers.IO) { + if (externalPlaylistManager.export(playlist, uri, config)) { + _playlistMessage.put(PlaylistMessage.ExportSuccess) + } else { + _playlistMessage.put(PlaylistMessage.ExportFailed) + } + } + } else { + logD("Launching export dialog") + _playlistDecision.put(PlaylistDecision.Export(playlist)) } } @@ -121,14 +223,34 @@ constructor( * * @param playlist The [Playlist] to rename, * @param name The new name of the [Playlist]. If null, the user will be prompted for a name. + * @param applySongs The songs to apply to the playlist after renaming. If empty, no songs will + * be applied. This argument is internal and does not need to be specified in normal use. + * @param reason The reason why the playlist is being renamed. This argument is internal and + * does not need to be specified in normal use. */ - fun renamePlaylist(playlist: Playlist, name: String? = null) { + fun renamePlaylist( + playlist: Playlist, + name: String? = null, + applySongs: List = listOf(), + reason: PlaylistDecision.Rename.Reason = PlaylistDecision.Rename.Reason.ACTION + ) { if (name != null) { logD("Renaming $playlist to $name") - viewModelScope.launch(Dispatchers.IO) { musicRepository.renamePlaylist(playlist, name) } + viewModelScope.launch(Dispatchers.IO) { + musicRepository.renamePlaylist(playlist, name) + if (applySongs.isNotEmpty()) { + musicRepository.rewritePlaylist(playlist, applySongs) + } + val message = + when (reason) { + PlaylistDecision.Rename.Reason.ACTION -> PlaylistMessage.RenameSuccess + PlaylistDecision.Rename.Reason.IMPORT -> PlaylistMessage.ImportSuccess + } + _playlistMessage.put(message) + } } else { logD("Launching rename dialog for $playlist") - _playlistDecision.put(PlaylistDecision.Rename(playlist)) + _playlistDecision.put(PlaylistDecision.Rename(playlist, null, applySongs, reason)) } } @@ -137,12 +259,16 @@ constructor( * * @param playlist The playlist to delete. * @param rude Whether to immediately delete the playlist or prompt the user first. This should - * be false at almost all times. + * be false at almost all times. This argument is internal and does not need to be specified + * in normal use. */ fun deletePlaylist(playlist: Playlist, rude: Boolean = false) { if (rude) { logD("Deleting $playlist") - viewModelScope.launch(Dispatchers.IO) { musicRepository.deletePlaylist(playlist) } + viewModelScope.launch(Dispatchers.IO) { + musicRepository.deletePlaylist(playlist) + _playlistMessage.put(PlaylistMessage.DeleteSuccess) + } } else { logD("Launching deletion dialog for $playlist") _playlistDecision.put(PlaylistDecision.Delete(playlist)) @@ -202,7 +328,10 @@ constructor( fun addToPlaylist(songs: List, playlist: Playlist? = null) { if (playlist != null) { logD("Adding ${songs.size} songs to $playlist") - viewModelScope.launch(Dispatchers.IO) { musicRepository.addToPlaylist(songs, playlist) } + viewModelScope.launch(Dispatchers.IO) { + musicRepository.addToPlaylist(songs, playlist) + _playlistMessage.put(PlaylistMessage.AddSuccess) + } } else { logD("Launching addition dialog for songs=${songs.size}") _playlistDecision.put(PlaylistDecision.Add(songs)) @@ -237,15 +366,50 @@ sealed interface PlaylistDecision { * Navigate to a dialog that allows a user to pick a name for a new [Playlist]. * * @param songs The [Song]s to contain in the new [Playlist]. + * @param template An existing playlist name that should be editable in the opened dialog. If + * null, a placeholder should be created and shown as a hint instead. + * @param context The context in which this decision is being fulfilled. */ - data class New(val songs: List) : PlaylistDecision + data class New(val songs: List, val template: String?, val reason: Reason) : + PlaylistDecision { + enum class Reason { + NEW, + ADD, + IMPORT + } + } + + /** + * Navigate to a file picker to import a playlist from. + * + * @param target The [Playlist] to import to. If null, then the file imported will create a new + * playlist. + */ + data class Import(val target: Playlist?) : PlaylistDecision /** * Navigate to a dialog that allows a user to rename an existing [Playlist]. * * @param playlist The playlist to act on. */ - data class Rename(val playlist: Playlist) : PlaylistDecision + data class Rename( + val playlist: Playlist, + val template: String?, + val applySongs: List, + val reason: Reason + ) : PlaylistDecision { + enum class Reason { + ACTION, + IMPORT + } + } + + /** + * Navigate to a dialog that allows the user to export a [Playlist]. + * + * @param playlist The [Playlist] to export. + */ + data class Export(val playlist: Playlist) : PlaylistDecision /** * Navigate to a dialog that confirms the deletion of an existing [Playlist]. @@ -261,3 +425,47 @@ sealed interface PlaylistDecision { */ data class Add(val songs: List) : PlaylistDecision } + +sealed interface PlaylistMessage { + val stringRes: Int + + data object NewPlaylistSuccess : PlaylistMessage { + override val stringRes: Int + get() = R.string.lng_playlist_created + } + + data object ImportSuccess : PlaylistMessage { + override val stringRes: Int + get() = R.string.lng_playlist_imported + } + + data object ImportFailed : PlaylistMessage { + override val stringRes: Int + get() = R.string.err_import_failed + } + + data object RenameSuccess : PlaylistMessage { + override val stringRes: Int + get() = R.string.lng_playlist_renamed + } + + data object DeleteSuccess : PlaylistMessage { + override val stringRes: Int + get() = R.string.lng_playlist_deleted + } + + data object AddSuccess : PlaylistMessage { + override val stringRes: Int + get() = R.string.lng_playlist_added + } + + data object ExportSuccess : PlaylistMessage { + override val stringRes: Int + get() = R.string.lng_playlist_exported + } + + data object ExportFailed : PlaylistMessage { + override val stringRes: Int + get() = R.string.err_export_failed + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/music/decision/AddToPlaylistDialog.kt b/app/src/main/java/org/oxycblt/auxio/music/decision/AddToPlaylistDialog.kt index 51dcfcf6c..602d1830f 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/decision/AddToPlaylistDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/decision/AddToPlaylistDialog.kt @@ -32,12 +32,12 @@ import org.oxycblt.auxio.R import org.oxycblt.auxio.databinding.DialogMusicChoicesBinding import org.oxycblt.auxio.list.ClickableListListener import org.oxycblt.auxio.music.MusicViewModel +import org.oxycblt.auxio.music.PlaylistDecision import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.ui.ViewBindingMaterialDialogFragment import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.navigateSafe -import org.oxycblt.auxio.util.showToast /** * A dialog that allows the user to pick a specific playlist to add song(s) to. @@ -86,7 +86,6 @@ class AddToPlaylistDialog : override fun onClick(item: PlaylistChoice, viewHolder: RecyclerView.ViewHolder) { musicModel.addToPlaylist(pickerModel.currentSongsToAdd.value ?: return, item.playlist) - requireContext().showToast(R.string.lng_playlist_added) findNavController().navigateUp() } @@ -100,7 +99,8 @@ class AddToPlaylistDialog : val songs = pickerModel.currentSongsToAdd.value ?: return findNavController() .navigateSafe( - AddToPlaylistDialogDirections.newPlaylist(songs.map { it.uid }.toTypedArray())) + AddToPlaylistDialogDirections.newPlaylist( + songs.map { it.uid }.toTypedArray(), null, PlaylistDecision.New.Reason.ADD)) } private fun updatePendingSongs(songs: List?) { diff --git a/app/src/main/java/org/oxycblt/auxio/music/decision/DeletePlaylistDialog.kt b/app/src/main/java/org/oxycblt/auxio/music/decision/DeletePlaylistDialog.kt index a1683c6b0..0e97dea4b 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/decision/DeletePlaylistDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/decision/DeletePlaylistDialog.kt @@ -33,7 +33,6 @@ import org.oxycblt.auxio.music.Playlist import org.oxycblt.auxio.ui.ViewBindingMaterialDialogFragment import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.logD -import org.oxycblt.auxio.util.showToast import org.oxycblt.auxio.util.unlikelyToBeNull /** @@ -56,7 +55,6 @@ class DeletePlaylistDialog : ViewBindingMaterialDialogFragment. + */ + +package org.oxycblt.auxio.music.decision + +import android.os.Bundle +import android.view.LayoutInflater +import androidx.activity.result.ActivityResultLauncher +import androidx.activity.result.contract.ActivityResultContracts +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.activityViewModels +import androidx.fragment.app.viewModels +import androidx.navigation.fragment.findNavController +import androidx.navigation.fragment.navArgs +import dagger.hilt.android.AndroidEntryPoint +import org.oxycblt.auxio.R +import org.oxycblt.auxio.databinding.DialogPlaylistExportBinding +import org.oxycblt.auxio.music.MusicViewModel +import org.oxycblt.auxio.music.Playlist +import org.oxycblt.auxio.music.external.ExportConfig +import org.oxycblt.auxio.music.external.M3U +import org.oxycblt.auxio.ui.ViewBindingMaterialDialogFragment +import org.oxycblt.auxio.util.collectImmediately +import org.oxycblt.auxio.util.logD +import org.oxycblt.auxio.util.logW +import org.oxycblt.auxio.util.unlikelyToBeNull + +/** + * A dialog that allows the user to configure how a playlist will be exported to a file. + * + * @author Alexander Capehart (OxygenCobalt) + */ +@AndroidEntryPoint +class ExportPlaylistDialog : ViewBindingMaterialDialogFragment() { + private val musicModel: MusicViewModel by activityViewModels() + private val pickerModel: PlaylistPickerViewModel by viewModels() + private var createDocumentLauncher: ActivityResultLauncher? = null + // Information about what playlist to name for is initially within the navigation arguments + // as UIDs, as that is the only safe way to parcel playlist information. + private val args: ExportPlaylistDialogArgs by navArgs() + + override fun onConfigDialog(builder: AlertDialog.Builder) { + builder + .setTitle(R.string.lbl_export_playlist) + .setPositiveButton(R.string.lbl_export, null) + .setNegativeButton(R.string.lbl_cancel, null) + } + + override fun onCreateBinding(inflater: LayoutInflater) = + DialogPlaylistExportBinding.inflate(inflater) + + override fun onBindingCreated( + binding: DialogPlaylistExportBinding, + savedInstanceState: Bundle? + ) { + // --- UI SETUP --- + createDocumentLauncher = + registerForActivityResult(ActivityResultContracts.CreateDocument(M3U.MIME_TYPE)) { uri + -> + if (uri == null) { + logW("No URI returned from file picker") + return@registerForActivityResult + } + + val playlist = pickerModel.currentPlaylistToExport.value + if (playlist == null) { + logW("No playlist to export") + findNavController().navigateUp() + return@registerForActivityResult + } + + logD("Received playlist URI $uri") + musicModel.exportPlaylist(playlist, uri, pickerModel.currentExportConfig.value) + findNavController().navigateUp() + } + + binding.exportPathsGroup.addOnButtonCheckedListener { group, checkedId, isChecked -> + if (!isChecked) return@addOnButtonCheckedListener + val current = pickerModel.currentExportConfig.value + pickerModel.setExportConfig( + current.copy(absolute = checkedId == R.id.export_absolute_paths)) + } + + binding.exportWindowsPaths.setOnClickListener { _ -> + val current = pickerModel.currentExportConfig.value + pickerModel.setExportConfig(current.copy(windowsPaths = !current.windowsPaths)) + } + + // --- VIEWMODEL SETUP --- + musicModel.playlistDecision.consume() + pickerModel.setPlaylistToExport(args.playlistUid) + collectImmediately(pickerModel.currentPlaylistToExport, ::updatePlaylistToExport) + collectImmediately(pickerModel.currentExportConfig, ::updateExportConfig) + } + + override fun onStart() { + super.onStart() + (requireDialog() as AlertDialog) + .getButton(AlertDialog.BUTTON_POSITIVE) + .setOnClickListener { _ -> + val pendingPlaylist = unlikelyToBeNull(pickerModel.currentPlaylistToExport.value) + + val fileName = + pendingPlaylist.name + .resolve(requireContext()) + .replace(SAFE_FILE_NAME_REGEX, "_") + ".m3u" + + requireNotNull(createDocumentLauncher) { + "Create document launcher was not available" + } + .launch(fileName) + } + } + + private fun updatePlaylistToExport(playlist: Playlist?) { + if (playlist == null) { + logD("No playlist to export, leaving") + findNavController().navigateUp() + return + } + } + + private fun updateExportConfig(config: ExportConfig) { + val binding = requireBinding() + binding.exportPathsGroup.check( + if (config.absolute) { + R.id.export_absolute_paths + } else { + R.id.export_relative_paths + }) + logD(config.windowsPaths) + binding.exportWindowsPaths.isChecked = config.windowsPaths + } + + private companion object { + val SAFE_FILE_NAME_REGEX = Regex("[^a-zA-Z0-9.-]") + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/music/decision/NewPlaylistDialog.kt b/app/src/main/java/org/oxycblt/auxio/music/decision/NewPlaylistDialog.kt index 46a2b3d0a..ac3b82ec0 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/decision/NewPlaylistDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/decision/NewPlaylistDialog.kt @@ -19,6 +19,7 @@ package org.oxycblt.auxio.music.decision import android.os.Bundle +import android.text.Editable import android.view.LayoutInflater import androidx.appcompat.app.AlertDialog import androidx.core.widget.addTextChangedListener @@ -30,10 +31,10 @@ import dagger.hilt.android.AndroidEntryPoint import org.oxycblt.auxio.R import org.oxycblt.auxio.databinding.DialogPlaylistNameBinding import org.oxycblt.auxio.music.MusicViewModel +import org.oxycblt.auxio.music.PlaylistDecision import org.oxycblt.auxio.ui.ViewBindingMaterialDialogFragment import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.logD -import org.oxycblt.auxio.util.showToast import org.oxycblt.auxio.util.unlikelyToBeNull /** @@ -48,12 +49,18 @@ class NewPlaylistDialog : ViewBindingMaterialDialogFragment R.string.lbl_new_playlist + PlaylistDecision.New.Reason.IMPORT -> R.string.lbl_import_playlist + }) .setPositiveButton(R.string.lbl_ok) { _, _ -> - val pendingPlaylist = unlikelyToBeNull(pickerModel.currentPendingPlaylist.value) + val pendingPlaylist = unlikelyToBeNull(pickerModel.currentPendingNewPlaylist.value) val name = when (val chosenName = pickerModel.chosenName.value) { is ChosenName.Valid -> chosenName.value @@ -61,8 +68,7 @@ class NewPlaylistDialog : ViewBindingMaterialDialogFragment throw IllegalStateException() } // TODO: Navigate to playlist if there are songs in it - musicModel.createPlaylist(name, pendingPlaylist.songs) - requireContext().showToast(R.string.lng_playlist_created) + musicModel.createPlaylist(name, pendingPlaylist.songs, pendingPlaylist.reason) findNavController().apply { navigateUp() // Do an additional navigation away from the playlist addition dialog, if @@ -84,23 +90,37 @@ class NewPlaylistDialog : ViewBindingMaterialDialogFragment(null) + private val _currentPendingNewPlaylist = MutableStateFlow(null) /** A new [Playlist] having it's name chosen by the user. Null if none yet. */ - val currentPendingPlaylist: StateFlow - get() = _currentPendingPlaylist + val currentPendingNewPlaylist: StateFlow + get() = _currentPendingNewPlaylist - private val _currentPlaylistToRename = MutableStateFlow(null) + private val _currentPendingRenamePlaylist = MutableStateFlow(null) /** An existing [Playlist] that is being renamed. Null if none yet. */ - val currentPlaylistToRename: StateFlow - get() = _currentPlaylistToRename + val currentPendingRenamePlaylist: StateFlow + get() = _currentPendingRenamePlaylist + + private val _currentPlaylistToExport = MutableStateFlow(null) + /** An existing [Playlist] that is being exported. Null if none yet. */ + val currentPlaylistToExport: StateFlow + get() = _currentPlaylistToExport + + private val _currentExportConfig = MutableStateFlow(DEFAULT_EXPORT_CONFIG) + /** The current [ExportConfig] to use when exporting a playlist. */ + val currentExportConfig: StateFlow + get() = _currentExportConfig private val _currentPlaylistToDelete = MutableStateFlow(null) /** The current [Playlist] that needs it's deletion confirmed. Null if none yet. */ @@ -59,7 +71,7 @@ class PlaylistPickerViewModel @Inject constructor(private val musicRepository: M get() = _currentPlaylistToDelete private val _chosenName = MutableStateFlow(ChosenName.Empty) - /** The users chosen name for [currentPendingPlaylist] or [currentPlaylistToRename]. */ + /** The users chosen name for [currentPendingNewPlaylist] or [currentPendingRenamePlaylist]. */ val chosenName: StateFlow get() = _chosenName @@ -81,13 +93,15 @@ class PlaylistPickerViewModel @Inject constructor(private val musicRepository: M var refreshChoicesWith: List? = null val deviceLibrary = musicRepository.deviceLibrary if (changes.deviceLibrary && deviceLibrary != null) { - _currentPendingPlaylist.value = - _currentPendingPlaylist.value?.let { pendingPlaylist -> - PendingPlaylist( + _currentPendingNewPlaylist.value = + _currentPendingNewPlaylist.value?.let { pendingPlaylist -> + PendingNewPlaylist( pendingPlaylist.preferredName, - pendingPlaylist.songs.mapNotNull { deviceLibrary.findSong(it.uid) }) + pendingPlaylist.songs.mapNotNull { deviceLibrary.findSong(it.uid) }, + pendingPlaylist.template, + pendingPlaylist.reason) } - logD("Updated pending playlist: ${_currentPendingPlaylist.value?.preferredName}") + logD("Updated pending playlist: ${_currentPendingNewPlaylist.value?.preferredName}") _currentSongsToAdd.value = _currentSongsToAdd.value?.let { pendingSongs -> @@ -110,6 +124,14 @@ class PlaylistPickerViewModel @Inject constructor(private val musicRepository: M } logD("Updated chosen name to $chosenName") refreshChoicesWith = refreshChoicesWith ?: _currentSongsToAdd.value + + // TODO: Add music syncing for other playlist states here + + _currentPlaylistToExport.value = + _currentPlaylistToExport.value?.let { playlist -> + musicRepository.userLibrary?.findPlaylist(playlist.uid) + } + logD("Updated playlist to export to ${_currentPlaylistToExport.value}") } refreshChoicesWith?.let(::refreshPlaylistChoices) @@ -120,12 +142,18 @@ class PlaylistPickerViewModel @Inject constructor(private val musicRepository: M } /** - * Set a new [currentPendingPlaylist] from a new batch of pending [Song] [Music.UID]s. + * Set a new [currentPendingNewPlaylist] from a new batch of pending [Song] [Music.UID]s. * * @param context [Context] required to generate a playlist name. * @param songUids The [Music.UID]s of songs to be present in the playlist. + * @param reason The reason the playlist is being created. */ - fun setPendingPlaylist(context: Context, songUids: Array) { + fun setPendingPlaylist( + context: Context, + songUids: Array, + template: String?, + reason: PlaylistDecision.New.Reason + ) { logD("Opening ${songUids.size} songs to create a playlist from") val userLibrary = musicRepository.userLibrary ?: return val songs = @@ -147,9 +175,9 @@ class PlaylistPickerViewModel @Inject constructor(private val musicRepository: M possibleName } - _currentPendingPlaylist.value = + _currentPendingNewPlaylist.value = if (possibleName != null && songs != null) { - PendingPlaylist(possibleName, songs) + PendingNewPlaylist(possibleName, songs, template, reason) } else { logW("Given song UIDs to create were invalid") null @@ -157,20 +185,59 @@ class PlaylistPickerViewModel @Inject constructor(private val musicRepository: M } /** - * Set a new [currentPlaylistToRename] from a [Playlist] [Music.UID]. + * Set a new [currentPendingRenamePlaylist] from a [Playlist] [Music.UID]. * * @param playlistUid The [Music.UID]s of the [Playlist] to rename. */ - fun setPlaylistToRename(playlistUid: Music.UID) { + fun setPlaylistToRename( + playlistUid: Music.UID, + applySongUids: Array, + template: String?, + reason: PlaylistDecision.Rename.Reason + ) { logD("Opening playlist $playlistUid to rename") - _currentPlaylistToRename.value = musicRepository.userLibrary?.findPlaylist(playlistUid) - if (_currentPlaylistToDelete.value == null) { - logW("Given playlist UID to rename was invalid") + val playlist = musicRepository.userLibrary?.findPlaylist(playlistUid) + val applySongs = + musicRepository.deviceLibrary?.let { applySongUids.mapNotNull(it::findSong) } + + _currentPendingRenamePlaylist.value = + if (playlist != null && applySongs != null) { + PendingRenamePlaylist(playlist, applySongs, template, reason) + } else { + logW("Given playlist UID to rename was invalid") + null + } + } + + /** + * Set a new [currentPlaylisttoExport] from a [Playlist] [Music.UID]. + * + * @param playlistUid The [Music.UID] of the [Playlist] to export. + */ + fun setPlaylistToExport(playlistUid: Music.UID) { + logD("Opening playlist $playlistUid to export") + // TODO: Add this guard to the rest of the methods here + if (_currentPlaylistToExport.value?.uid == playlistUid) return + _currentPlaylistToExport.value = musicRepository.userLibrary?.findPlaylist(playlistUid) + if (_currentPlaylistToExport.value == null) { + logW("Given playlist UID to export was invalid") + } else { + _currentExportConfig.value = DEFAULT_EXPORT_CONFIG } } /** - * Set a new [currentPendingPlaylist] from a new [Playlist] [Music.UID]. + * Update [currentExportConfig] based on new user input. + * + * @param exportConfig The new [ExportConfig] to use. + */ + fun setExportConfig(exportConfig: ExportConfig) { + logD("Setting export config to $exportConfig") + _currentExportConfig.value = exportConfig + } + + /** + * Set a new [currentPendingNewPlaylist] from a new [Playlist] [Music.UID]. * * @param playlistUid The [Music.UID] of the [Playlist] to delete. */ @@ -238,16 +305,33 @@ class PlaylistPickerViewModel @Inject constructor(private val musicRepository: M PlaylistChoice(it, songs.all(songSet::contains)) } } + + private companion object { + private val DEFAULT_EXPORT_CONFIG = ExportConfig(absolute = false, windowsPaths = false) + } } /** * Represents a playlist that will be created as soon as a name is chosen. * * @param preferredName The name to be used by default if no other name is chosen. - * @param songs The [Song]s to be contained in the [PendingPlaylist] + * @param songs The [Song]s to be contained in the [PendingNewPlaylist] + * @param reason The reason the playlist is being created. * @author Alexander Capehart (OxygenCobalt) */ -data class PendingPlaylist(val preferredName: String, val songs: List) +data class PendingNewPlaylist( + val preferredName: String, + val songs: List, + val template: String?, + val reason: PlaylistDecision.New.Reason +) + +data class PendingRenamePlaylist( + val playlist: Playlist, + val applySongs: List, + val template: String?, + val reason: PlaylistDecision.Rename.Reason +) /** * Represents the (processed) user input from the playlist naming dialogs. diff --git a/app/src/main/java/org/oxycblt/auxio/music/decision/RenamePlaylistDialog.kt b/app/src/main/java/org/oxycblt/auxio/music/decision/RenamePlaylistDialog.kt index 4e287dc87..da5265daf 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/decision/RenamePlaylistDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/decision/RenamePlaylistDialog.kt @@ -30,11 +30,9 @@ import dagger.hilt.android.AndroidEntryPoint import org.oxycblt.auxio.R import org.oxycblt.auxio.databinding.DialogPlaylistNameBinding import org.oxycblt.auxio.music.MusicViewModel -import org.oxycblt.auxio.music.Playlist import org.oxycblt.auxio.ui.ViewBindingMaterialDialogFragment import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.logD -import org.oxycblt.auxio.util.showToast import org.oxycblt.auxio.util.unlikelyToBeNull /** @@ -55,10 +53,14 @@ class RenamePlaylistDialog : ViewBindingMaterialDialogFragment - val playlist = unlikelyToBeNull(pickerModel.currentPlaylistToRename.value) + val pendingRenamePlaylist = + unlikelyToBeNull(pickerModel.currentPendingRenamePlaylist.value) val chosenName = pickerModel.chosenName.value as ChosenName.Valid - musicModel.renamePlaylist(playlist, chosenName.value) - requireContext().showToast(R.string.lng_playlist_renamed) + musicModel.renamePlaylist( + pendingRenamePlaylist.playlist, + chosenName.value, + pendingRenamePlaylist.applySongs, + pendingRenamePlaylist.reason) findNavController().navigateUp() } .setNegativeButton(R.string.lbl_cancel, null) @@ -75,20 +77,23 @@ class RenamePlaylistDialog : ViewBindingMaterialDialogFragment, processedSongs: Channel, + separators: Separators, + nameFactory: Name.Known.Factory ): DeviceLibraryImpl } } -class DeviceLibraryFactoryImpl @Inject constructor(private val musicSettings: MusicSettings) : - DeviceLibrary.Factory { +class DeviceLibraryFactoryImpl @Inject constructor() : DeviceLibrary.Factory { override suspend fun create( rawSongs: Channel, - processedSongs: Channel + processedSongs: Channel, + separators: Separators, + nameFactory: Name.Known.Factory ): DeviceLibraryImpl { - val nameFactory = Name.Known.Factory.from(musicSettings) - val separators = Separators.from(musicSettings) - val songGrouping = mutableMapOf() val albumGrouping = mutableMapOf>() val artistGrouping = mutableMapOf>() @@ -131,7 +141,7 @@ class DeviceLibraryFactoryImpl @Inject constructor(private val musicSettings: Mu // TODO: Use comparators here // All music information is grouped as it is indexed by other components. - for (rawSong in rawSongs) { + rawSongs.forEachWithTimeout { rawSong -> val song = SongImpl(rawSong, nameFactory, separators) // At times the indexer produces duplicate songs, try to filter these. Comparing by // UID is sufficient for something like this, and also prevents collisions from @@ -143,8 +153,8 @@ class DeviceLibraryFactoryImpl @Inject constructor(private val musicSettings: Mu // We still want to say that we "processed" the song so that the user doesn't // get confused at why the bar was only partly filled by the end of the loading // process. - processedSongs.send(rawSong) - continue + processedSongs.sendWithTimeout(rawSong) + return@forEachWithTimeout } songGrouping[song.uid] = song @@ -207,7 +217,7 @@ class DeviceLibraryFactoryImpl @Inject constructor(private val musicSettings: Mu } } - processedSongs.send(rawSong) + processedSongs.sendWithTimeout(rawSong) } // Now that all songs are processed, also process albums and group them into their @@ -265,6 +275,7 @@ class DeviceLibraryImpl( ) : DeviceLibrary { // Use a mapping to make finding information based on it's UID much faster. private val songUidMap = buildMap { songs.forEach { put(it.uid, it.finalize()) } } + private val songPathMap = buildMap { songs.forEach { put(it.path, it) } } private val albumUidMap = buildMap { albums.forEach { put(it.uid, it.finalize()) } } private val artistUidMap = buildMap { artists.forEach { put(it.uid, it.finalize()) } } private val genreUidMap = buildMap { genres.forEach { put(it.uid, it.finalize()) } } @@ -286,6 +297,8 @@ class DeviceLibraryImpl( override fun findGenre(uid: Music.UID): Genre? = genreUidMap[uid] + override fun findSongByPath(path: Path) = songPathMap[path] + override fun findSongForUri(context: Context, uri: Uri) = context.contentResolverSafe.useQuery( uri, arrayOf(OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE)) { cursor -> diff --git a/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt b/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt index 91a4e1702..7b16070cc 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/device/DeviceMusicImpl.kt @@ -28,7 +28,6 @@ import org.oxycblt.auxio.music.Music import org.oxycblt.auxio.music.MusicType import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.music.fs.MimeType -import org.oxycblt.auxio.music.fs.Path import org.oxycblt.auxio.music.fs.toAudioUri import org.oxycblt.auxio.music.fs.toCoverUri import org.oxycblt.auxio.music.info.Date @@ -75,41 +74,31 @@ class SongImpl( } override val name = nameFactory.parse( - requireNotNull(rawSong.name) { "Invalid raw ${rawSong.fileName}: No title" }, + requireNotNull(rawSong.name) { "Invalid raw ${rawSong.path}: No title" }, rawSong.sortName) override val track = rawSong.track override val disc = rawSong.disc?.let { Disc(it, rawSong.subtitle) } override val date = rawSong.date override val uri = - requireNotNull(rawSong.mediaStoreId) { "Invalid raw ${rawSong.fileName}: No id" } - .toAudioUri() - override val path = - Path( - name = - requireNotNull(rawSong.fileName) { - "Invalid raw ${rawSong.fileName}: No display name" - }, - parent = - requireNotNull(rawSong.directory) { - "Invalid raw ${rawSong.fileName}: No parent directory" - }) + requireNotNull(rawSong.mediaStoreId) { "Invalid raw ${rawSong.path}: No id" }.toAudioUri() + override val path = requireNotNull(rawSong.path) { "Invalid raw ${rawSong.path}: No path" } override val mimeType = MimeType( fromExtension = requireNotNull(rawSong.extensionMimeType) { - "Invalid raw ${rawSong.fileName}: No mime type" + "Invalid raw ${rawSong.path}: No mime type" }, fromFormat = null) - override val size = requireNotNull(rawSong.size) { "Invalid raw ${rawSong.fileName}: No size" } + override val size = requireNotNull(rawSong.size) { "Invalid raw ${rawSong.path}: No size" } override val durationMs = - requireNotNull(rawSong.durationMs) { "Invalid raw ${rawSong.fileName}: No duration" } + requireNotNull(rawSong.durationMs) { "Invalid raw ${rawSong.path}: No duration" } override val replayGainAdjustment = ReplayGainAdjustment( track = rawSong.replayGainTrackAdjustment, album = rawSong.replayGainAlbumAdjustment) override val dateAdded = - requireNotNull(rawSong.dateAdded) { "Invalid raw ${rawSong.fileName}: No date added" } + requireNotNull(rawSong.dateAdded) { "Invalid raw ${rawSong.path}: No date added" } private var _album: AlbumImpl? = null override val album: Album @@ -150,37 +139,37 @@ class SongImpl( val artistSortNames = separators.split(rawSong.artistSortNames) val rawIndividualArtists = artistNames - .mapIndexedTo(mutableSetOf()) { i, name -> + .mapIndexed { i, name -> RawArtist( artistMusicBrainzIds.getOrNull(i)?.toUuidOrNull(), name, artistSortNames.getOrNull(i)) } - .toList() + .distinctBy { it.key } val albumArtistMusicBrainzIds = separators.split(rawSong.albumArtistMusicBrainzIds) val albumArtistNames = separators.split(rawSong.albumArtistNames) val albumArtistSortNames = separators.split(rawSong.albumArtistSortNames) val rawAlbumArtists = albumArtistNames - .mapIndexedTo(mutableSetOf()) { i, name -> + .mapIndexed { i, name -> RawArtist( albumArtistMusicBrainzIds.getOrNull(i)?.toUuidOrNull(), name, albumArtistSortNames.getOrNull(i)) } - .toList() + .distinctBy { it.key } rawAlbum = RawAlbum( mediaStoreId = requireNotNull(rawSong.albumMediaStoreId) { - "Invalid raw ${rawSong.fileName}: No album id" + "Invalid raw ${rawSong.path}: No album id" }, musicBrainzId = rawSong.albumMusicBrainzId?.toUuidOrNull(), name = requireNotNull(rawSong.albumName) { - "Invalid raw ${rawSong.fileName}: No album name" + "Invalid raw ${rawSong.path}: No album name" }, sortName = rawSong.albumSortName, releaseType = ReleaseType.parse(separators.split(rawSong.releaseTypes)), @@ -195,10 +184,7 @@ class SongImpl( val genreNames = (rawSong.genreNames.parseId3GenreNames() ?: separators.split(rawSong.genreNames)) rawGenres = - genreNames - .mapTo(mutableSetOf()) { RawGenre(it) } - .toList() - .ifEmpty { listOf(RawGenre()) } + genreNames.map { RawGenre(it) }.distinctBy { it.key }.ifEmpty { listOf(RawGenre()) } hashCode = 31 * hashCode + rawSong.hashCode() hashCode = 31 * hashCode + nameFactory.hashCode() @@ -250,11 +236,11 @@ class SongImpl( * @return This instance upcasted to [Song]. */ fun finalize(): Song { - checkNotNull(_album) { "Malformed song ${path.name}: No album" } + checkNotNull(_album) { "Malformed song ${path}: No album" } - check(_artists.isNotEmpty()) { "Malformed song ${path.name}: No artists" } + check(_artists.isNotEmpty()) { "Malformed song ${path}: No artists" } check(_artists.size == rawArtists.size) { - "Malformed song ${path.name}: Artist grouping mismatch" + "Malformed song ${path}: Artist grouping mismatch" } for (i in _artists.indices) { // Non-destructively reorder the linked artists so that they align with @@ -265,10 +251,8 @@ class SongImpl( _artists[i] = other } - check(_genres.isNotEmpty()) { "Malformed song ${path.name}: No genres" } - check(_genres.size == rawGenres.size) { - "Malformed song ${path.name}: Genre grouping mismatch" - } + check(_genres.isNotEmpty()) { "Malformed song ${path}: No genres" } + check(_genres.size == rawGenres.size) { "Malformed song ${path}: Genre grouping mismatch" } for (i in _genres.indices) { // Non-destructively reorder the linked genres so that they align with // the genre ordering within the song metadata. @@ -432,7 +416,6 @@ class ArtistImpl( ?: Name.Unknown(R.string.def_artist) override val songs: Set - override val albums: Set override val explicitAlbums: Set override val implicitAlbums: Set override val durationMs: Long? @@ -463,7 +446,7 @@ class ArtistImpl( } songs = distinctSongs - albums = albumMap.keys + val albums = albumMap.keys explicitAlbums = albums.filterTo(mutableSetOf()) { albumMap[it] == true } implicitAlbums = albums.filterNotTo(mutableSetOf()) { albumMap[it] == true } durationMs = songs.sumOf { it.durationMs }.positiveOrNull() @@ -506,7 +489,16 @@ class ArtistImpl( * @return This instance upcasted to [Artist]. */ fun finalize(): Artist { - check(songs.isNotEmpty() || albums.isNotEmpty()) { "Malformed artist $name: Empty" } + // There are valid artist configurations: + // 1. No songs, no implicit albums, some explicit albums + // 2. Some songs, no implicit albums, some explicit albums + // 3. Some songs, some implicit albums, no implicit albums + // 4. Some songs, some implicit albums, some explicit albums + // I'm pretty sure the latter check could be reduced to just explicitAlbums.isNotEmpty, + // but I can't be 100% certain. + check(songs.isNotEmpty() || (implicitAlbums.size + explicitAlbums.size) > 0) { + "Malformed artist $name: Empty" + } genres = Sort(Sort.Mode.ByName, Sort.Direction.ASCENDING) .genres(songs.flatMapTo(mutableSetOf()) { it.genres }) @@ -514,6 +506,7 @@ class ArtistImpl( return this } } + /** * Library-backed implementation of [Genre]. * diff --git a/app/src/main/java/org/oxycblt/auxio/music/device/RawMusic.kt b/app/src/main/java/org/oxycblt/auxio/music/device/RawMusic.kt index 73fa3c753..2f3b6ec73 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/device/RawMusic.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/device/RawMusic.kt @@ -22,7 +22,7 @@ import java.util.UUID import org.oxycblt.auxio.music.Album import org.oxycblt.auxio.music.Music import org.oxycblt.auxio.music.Song -import org.oxycblt.auxio.music.fs.Directory +import org.oxycblt.auxio.music.fs.Path import org.oxycblt.auxio.music.info.Date import org.oxycblt.auxio.music.info.ReleaseType @@ -42,9 +42,7 @@ data class RawSong( /** The latest date the [SongImpl]'s audio file was modified, as a unix epoch timestamp. */ var dateModified: Long? = null, /** @see Song.path */ - var fileName: String? = null, - /** @see Song.path */ - var directory: Directory? = null, + var path: Path? = null, /** @see Song.size */ var size: Long? = null, /** @see Song.durationMs */ diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/DirectoryAdapter.kt b/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryAdapter.kt similarity index 70% rename from app/src/main/java/org/oxycblt/auxio/music/fs/DirectoryAdapter.kt rename to app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryAdapter.kt index 5e0799d72..9beedd79f 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/fs/DirectoryAdapter.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryAdapter.kt @@ -16,13 +16,14 @@ * along with this program. If not, see . */ -package org.oxycblt.auxio.music.fs +package org.oxycblt.auxio.music.dirs import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import org.oxycblt.auxio.databinding.ItemMusicDirBinding import org.oxycblt.auxio.list.recycler.DialogRecyclerView +import org.oxycblt.auxio.music.fs.Path import org.oxycblt.auxio.util.context import org.oxycblt.auxio.util.inflater import org.oxycblt.auxio.util.logD @@ -35,11 +36,11 @@ import org.oxycblt.auxio.util.logD */ class DirectoryAdapter(private val listener: Listener) : RecyclerView.Adapter() { - private val _dirs = mutableListOf() + private val _dirs = mutableListOf() /** - * The current list of [Directory]s, may not line up with [MusicDirectories] due to removals. + * The current list of [SystemPath]s, may not line up with [MusicDirectories] due to removals. */ - val dirs: List = _dirs + val dirs: List = _dirs override fun getItemCount() = dirs.size @@ -50,37 +51,37 @@ class DirectoryAdapter(private val listener: Listener) : holder.bind(dirs[position], listener) /** - * Add a [Directory] to the end of the list. + * Add a [Path] to the end of the list. * - * @param dir The [Directory] to add. + * @param path The [Path] to add. */ - fun add(dir: Directory) { - if (_dirs.contains(dir)) return - logD("Adding $dir") - _dirs.add(dir) + fun add(path: Path) { + if (_dirs.contains(path)) return + logD("Adding $path") + _dirs.add(path) notifyItemInserted(_dirs.lastIndex) } /** - * Add a list of [Directory] instances to the end of the list. + * Add a list of [Path] instances to the end of the list. * - * @param dirs The [Directory] instances to add. + * @param path The [Path] instances to add. */ - fun addAll(dirs: List) { - logD("Adding ${dirs.size} directories") - val oldLastIndex = dirs.lastIndex - _dirs.addAll(dirs) - notifyItemRangeInserted(oldLastIndex, dirs.size) + fun addAll(path: List) { + logD("Adding ${path.size} directories") + val oldLastIndex = path.lastIndex + _dirs.addAll(path) + notifyItemRangeInserted(oldLastIndex, path.size) } /** - * Remove a [Directory] from the list. + * Remove a [Path] from the list. * - * @param dir The [Directory] to remove. Must exist in the list. + * @param path The [Path] to remove. Must exist in the list. */ - fun remove(dir: Directory) { - logD("Removing $dir") - val idx = _dirs.indexOf(dir) + fun remove(path: Path) { + logD("Removing $path") + val idx = _dirs.indexOf(path) _dirs.removeAt(idx) notifyItemRemoved(idx) } @@ -88,7 +89,7 @@ class DirectoryAdapter(private val listener: Listener) : /** A Listener for [DirectoryAdapter] interactions. */ interface Listener { /** Called when the delete button on a directory item is clicked. */ - fun onRemoveDirectory(dir: Directory) + fun onRemoveDirectory(dir: Path) } } @@ -102,12 +103,12 @@ class MusicDirViewHolder private constructor(private val binding: ItemMusicDirBi /** * Bind new data to this instance. * - * @param dir The new [Directory] to bind. + * @param path The new [Path] to bind. * @param listener A [DirectoryAdapter.Listener] to bind interactions to. */ - fun bind(dir: Directory, listener: DirectoryAdapter.Listener) { - binding.dirPath.text = dir.resolveName(binding.context) - binding.dirDelete.setOnClickListener { listener.onRemoveDirectory(dir) } + fun bind(path: Path, listener: DirectoryAdapter.Listener) { + binding.dirPath.text = path.resolve(binding.context) + binding.dirDelete.setOnClickListener { listener.onRemoveDirectory(path) } } companion object { diff --git a/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryModule.kt b/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryModule.kt new file mode 100644 index 000000000..eec4918ea --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryModule.kt @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Auxio Project + * DirectoryModule.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.music.dirs + +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent + +@Module @InstallIn(SingletonComponent::class) interface DirectoryModule {} diff --git a/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirectories.kt b/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirectories.kt new file mode 100644 index 000000000..c85b21ad5 --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirectories.kt @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Auxio Project + * MusicDirectories.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.music.dirs + +import org.oxycblt.auxio.music.fs.Path + +/** + * Represents the configuration for specific directories to filter to/from when loading music. + * + * @param dirs A list of [Directory] instances. How these are interpreted depends on [shouldInclude] + * @param shouldInclude True if the library should only load from the [Directory] instances, false + * if the library should not load from the [Directory] instances. + * @author Alexander Capehart (OxygenCobalt) + */ +data class MusicDirectories(val dirs: List, val shouldInclude: Boolean) diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/MusicDirsDialog.kt b/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirsDialog.kt similarity index 84% rename from app/src/main/java/org/oxycblt/auxio/music/fs/MusicDirsDialog.kt rename to app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirsDialog.kt index bca211f9a..64c4bdc2e 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/fs/MusicDirsDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirsDialog.kt @@ -16,13 +16,11 @@ * along with this program. If not, see . */ -package org.oxycblt.auxio.music.fs +package org.oxycblt.auxio.music.dirs import android.content.ActivityNotFoundException import android.net.Uri import android.os.Bundle -import android.os.storage.StorageManager -import android.provider.DocumentsContract import android.view.LayoutInflater import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts @@ -35,8 +33,9 @@ import org.oxycblt.auxio.BuildConfig import org.oxycblt.auxio.R import org.oxycblt.auxio.databinding.DialogMusicDirsBinding import org.oxycblt.auxio.music.MusicSettings +import org.oxycblt.auxio.music.fs.DocumentPathFactory +import org.oxycblt.auxio.music.fs.Path import org.oxycblt.auxio.ui.ViewBindingMaterialDialogFragment -import org.oxycblt.auxio.util.getSystemServiceCompat import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.showToast @@ -50,7 +49,7 @@ class MusicDirsDialog : ViewBindingMaterialDialogFragment(), DirectoryAdapter.Listener { private val dirAdapter = DirectoryAdapter(this) private var openDocumentTreeLauncher: ActivityResultLauncher? = null - private var storageManager: StorageManager? = null + @Inject lateinit var documentPathFactory: DocumentPathFactory @Inject lateinit var musicSettings: MusicSettings override fun onCreateBinding(inflater: LayoutInflater) = @@ -70,10 +69,6 @@ class MusicDirsDialog : } override fun onBindingCreated(binding: DialogMusicDirsBinding, savedInstanceState: Bundle?) { - val context = requireContext() - val storageManager = - context.getSystemServiceCompat(StorageManager::class).also { storageManager = it } - openDocumentTreeLauncher = registerForActivityResult( ActivityResultContracts.OpenDocumentTree(), ::addDocumentTreeUriToDirs) @@ -107,9 +102,7 @@ class MusicDirsDialog : if (pendingDirs != null) { dirs = MusicDirectories( - pendingDirs.mapNotNull { - Directory.fromDocumentTreeUri(storageManager, it) - }, + pendingDirs.mapNotNull(documentPathFactory::fromDocumentId), savedInstanceState.getBoolean(KEY_PENDING_MODE)) } } @@ -133,18 +126,17 @@ class MusicDirsDialog : override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) outState.putStringArrayList( - KEY_PENDING_DIRS, ArrayList(dirAdapter.dirs.map { it.toString() })) + KEY_PENDING_DIRS, ArrayList(dirAdapter.dirs.map(documentPathFactory::toDocumentId))) outState.putBoolean(KEY_PENDING_MODE, isUiModeInclude(requireBinding())) } override fun onDestroyBinding(binding: DialogMusicDirsBinding) { super.onDestroyBinding(binding) - storageManager = null openDocumentTreeLauncher = null binding.dirsRecycler.adapter = null } - override fun onRemoveDirectory(dir: Directory) { + override fun onRemoveDirectory(dir: Path) { dirAdapter.remove(dir) requireBinding().dirsEmpty.isVisible = dirAdapter.dirs.isEmpty() } @@ -162,15 +154,7 @@ class MusicDirsDialog : return } - // Convert the document tree URI into it's relative path form, which can then be - // parsed into a Directory instance. - val docUri = - DocumentsContract.buildDocumentUriUsingTree( - uri, DocumentsContract.getTreeDocumentId(uri)) - val treeUri = DocumentsContract.getTreeDocumentId(docUri) - val dir = - Directory.fromDocumentTreeUri( - requireNotNull(storageManager) { "StorageManager was not available" }, treeUri) + val dir = documentPathFactory.unpackDocumentTreeUri(uri) if (dir != null) { dirAdapter.add(dir) diff --git a/app/src/main/java/org/oxycblt/auxio/music/external/ExternalModule.kt b/app/src/main/java/org/oxycblt/auxio/music/external/ExternalModule.kt new file mode 100644 index 000000000..af29c3620 --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/music/external/ExternalModule.kt @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 Auxio Project + * ExternalModule.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.music.external + +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent + +@Module +@InstallIn(SingletonComponent::class) +interface ExternalModule { + @Binds + fun externalPlaylistManager( + externalPlaylistManager: ExternalPlaylistManagerImpl + ): ExternalPlaylistManager + + @Binds fun m3u(m3u: M3UImpl): M3U +} diff --git a/app/src/main/java/org/oxycblt/auxio/music/external/ExternalPlaylistManager.kt b/app/src/main/java/org/oxycblt/auxio/music/external/ExternalPlaylistManager.kt new file mode 100644 index 000000000..1cf0b0810 --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/music/external/ExternalPlaylistManager.kt @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2023 Auxio Project + * ExternalPlaylistManager.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.music.external + +import android.content.Context +import android.net.Uri +import dagger.hilt.android.qualifiers.ApplicationContext +import javax.inject.Inject +import org.oxycblt.auxio.music.Playlist +import org.oxycblt.auxio.music.fs.Components +import org.oxycblt.auxio.music.fs.DocumentPathFactory +import org.oxycblt.auxio.music.fs.Path +import org.oxycblt.auxio.music.fs.contentResolverSafe +import org.oxycblt.auxio.util.logE + +/** + * Generic playlist file importing abstraction. + * + * @see ImportedPlaylist + * @see M3U + * @author Alexander Capehart (OxygenCobalt) + */ +interface ExternalPlaylistManager { + /** + * Import the playlist file at the given [uri]. + * + * @param uri The [Uri] of the playlist file to import. + * @return An [ImportedPlaylist] containing the paths to the files listed in the playlist file, + * or null if the playlist could not be imported. + */ + suspend fun import(uri: Uri): ImportedPlaylist? + + /** + * Export the given [playlist] to the given [uri]. + * + * @param playlist The playlist to export. + * @param uri The [Uri] to export the playlist to. + * @param config The configuration to use when exporting the playlist. + * @return True if the playlist was successfully exported, false otherwise. + */ + suspend fun export(playlist: Playlist, uri: Uri, config: ExportConfig): Boolean +} + +/** + * Configuration to use when exporting playlists. + * + * @property absolute Whether or not to use absolute paths when exporting. If not, relative paths + * will be used. + * @property windowsPaths Whether or not to use Windows-style paths when exporting (i.e prefixed + * with C:\\ and using \). If not, Unix-style paths will be used (i.e prefixed with /). + * @see ExternalPlaylistManager.export + */ +data class ExportConfig(val absolute: Boolean, val windowsPaths: Boolean) + +/** + * A playlist that has been imported. + * + * @property name The name of the playlist. May be null if not provided. + * @property paths The paths of the files in the playlist. + * @see ExternalPlaylistManager + * @see M3U + */ +data class ImportedPlaylist(val name: String?, val paths: List) + +class ExternalPlaylistManagerImpl +@Inject +constructor( + @ApplicationContext private val context: Context, + private val documentPathFactory: DocumentPathFactory, + private val m3u: M3U +) : ExternalPlaylistManager { + override suspend fun import(uri: Uri): ImportedPlaylist? { + val filePath = documentPathFactory.unpackDocumentUri(uri) ?: return null + + return try { + context.contentResolverSafe.openInputStream(uri)?.use { + return m3u.read(it, filePath.directory) + } + } catch (e: Exception) { + logE("Failed to import playlist: $e") + null + } + } + + override suspend fun export(playlist: Playlist, uri: Uri, config: ExportConfig): Boolean { + val filePath = documentPathFactory.unpackDocumentUri(uri) ?: return false + val workingDirectory = + if (config.absolute) { + Path(filePath.volume, Components.parseUnix("/")) + } else { + filePath.directory + } + return try { + val outputStream = context.contentResolverSafe.openOutputStream(uri) + if (outputStream == null) { + logE("Failed to export playlist: Could not open output stream") + return false + } + outputStream.use { + m3u.write(playlist, it, workingDirectory, config) + true + } + } catch (e: Exception) { + logE("Failed to export playlist: $e") + false + } + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/music/external/M3U.kt b/app/src/main/java/org/oxycblt/auxio/music/external/M3U.kt new file mode 100644 index 000000000..11ce3dea1 --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/music/external/M3U.kt @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2023 Auxio Project + * M3U.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.music.external + +import android.content.Context +import dagger.hilt.android.qualifiers.ApplicationContext +import java.io.BufferedReader +import java.io.BufferedWriter +import java.io.InputStream +import java.io.InputStreamReader +import java.io.OutputStream +import javax.inject.Inject +import org.oxycblt.auxio.music.Playlist +import org.oxycblt.auxio.music.fs.Components +import org.oxycblt.auxio.music.fs.Path +import org.oxycblt.auxio.music.metadata.correctWhitespace +import org.oxycblt.auxio.music.resolveNames +import org.oxycblt.auxio.util.logE + +/** + * Minimal M3U file format implementation. + * + * @author Alexander Capehart (OxygenCobalt) + */ +interface M3U { + /** + * Reads an M3U file from the given [stream] and returns a [ImportedPlaylist] containing the + * paths to the files listed in the M3U file. + * + * @param stream The stream to read the M3U file from. + * @param workingDirectory The directory that the M3U file is contained in. This is used to + * resolve relative paths. + * @return An [ImportedPlaylist] containing the paths to the files listed in the M3U file, + */ + fun read(stream: InputStream, workingDirectory: Path): ImportedPlaylist? + + /** + * Writes the given [playlist] to the given [outputStream] in the M3U format,. + * + * @param playlist The playlist to write. + * @param outputStream The stream to write the M3U file to. + * @param workingDirectory The directory that the M3U file is contained in. This is used to + * create relative paths to where the M3U file is assumed to be stored. + * @param config The configuration to use when exporting the playlist. + */ + fun write( + playlist: Playlist, + outputStream: OutputStream, + workingDirectory: Path, + config: ExportConfig + ) + + companion object { + /** The mime type used for M3U files by the android system. */ + const val MIME_TYPE = "audio/x-mpegurl" + } +} + +class M3UImpl @Inject constructor(@ApplicationContext private val context: Context) : M3U { + override fun read(stream: InputStream, workingDirectory: Path): ImportedPlaylist? { + val reader = BufferedReader(InputStreamReader(stream)) + val paths = mutableListOf() + var name: String? = null + + consumeFile@ while (true) { + var path: String? + collectMetadata@ while (true) { + // The M3U format consists of "entries" that begin with a bunch of metadata + // prefixed with "#", and then a relative/absolute path or url to the file. + // We don't really care about the metadata except for the playlist name, so + // we discard everything but that. + val currentLine = + (reader.readLine() ?: break@consumeFile).correctWhitespace() + ?: continue@collectMetadata + if (currentLine.startsWith("#")) { + // Metadata entries are roughly structured + val split = currentLine.split(":", limit = 2) + when (split[0]) { + // Playlist name + "#PLAYLIST" -> name = split.getOrNull(1)?.correctWhitespace() + // Add more metadata handling here if needed. + else -> {} + } + } else { + // Something that isn't a metadata entry, assume it's a path. It could be + // a URL, but it'll just get mangled really badly and not match with anything, + // so it's okay. + path = currentLine + break@collectMetadata + } + } + + if (path == null) { + logE("Expected a path, instead got an EOF") + break@consumeFile + } + + // There is basically no formal specification of file paths in M3U, and it differs + // based on the US that generated it. These are the paths though that I assume most + // programs will generate. + val components = + when { + path.startsWith('/') -> { + // Unix absolute path. Note that we still assume this absolute path is in + // the same volume as the M3U file. There's no sane way to map the volume + // to the phone's volumes, so this is the only thing we can do. + Components.parseUnix(path) + } + path.startsWith("./") -> { + // Unix relative path, resolve it + Components.parseUnix(path).absoluteTo(workingDirectory.components) + } + path.matches(WINDOWS_VOLUME_PREFIX_REGEX) -> { + // Windows absolute path, we should get rid of the volume prefix, but + // otherwise + // the rest should be fine. Again, we have to disregard what the volume + // actually + // is since there's no sane way to map it to the phone's volumes. + Components.parseWindows(path.substring(2)) + } + path.startsWith(".\\") -> { + // Windows relative path, we need to remove the .\\ prefix + Components.parseWindows(path).absoluteTo(workingDirectory.components) + } + else -> { + // No clue, parse by all separators and assume it's relative. + Components.parseAny(path).absoluteTo(workingDirectory.components) + } + } + + paths.add(Path(workingDirectory.volume, components)) + } + + return if (paths.isNotEmpty()) { + ImportedPlaylist(name, paths) + } else { + // Couldn't get anything useful out of this file. + null + } + } + + override fun write( + playlist: Playlist, + outputStream: OutputStream, + workingDirectory: Path, + config: ExportConfig + ) { + val writer = outputStream.bufferedWriter() + // Try to be as compliant to the spec as possible while also cramming it full of extensions + // I imagine other players will use. + writer.writeLine("#EXTM3U") + writer.writeLine("#EXTENC:UTF-8") + writer.writeLine("#PLAYLIST:${playlist.name.resolve(context)}") + for (song in playlist.songs) { + writer.writeLine("#EXTINF:${song.durationMs},${song.name.resolve(context)}") + writer.writeLine("#EXTALB:${song.album.name.resolve(context)}") + writer.writeLine("#EXTART:${song.artists.resolveNames(context)}") + writer.writeLine("#EXTGEN:${song.genres.resolveNames(context)}") + + val formattedPath = + if (config.absolute) { + // The path is already absolute in this case, but we need to prefix and separate + // it differently depending on the setting. + if (config.windowsPaths) { + // Assume the plain windows C volume, since that's probably where most music + // libraries are on a windows PC. + "C:\\\\${song.path.components.windowsString}" + } else { + "/${song.path.components.unixString}" + } + } else { + // First need to make this path relative to the working directory of the M3U + // file, and then format it with the correct separators. + val relativePath = song.path.components.relativeTo(workingDirectory.components) + if (config.windowsPaths) { + relativePath.windowsString + } else { + relativePath.unixString + } + } + writer.writeLine(formattedPath) + } + writer.flush() + } + + private fun BufferedWriter.writeLine(line: String) { + write(line) + newLine() + } + + private fun Components.absoluteTo(workingDirectory: Components): Components { + var absoluteComponents = workingDirectory + for (component in components) { + when (component) { + // Parent specifier, go "back" one directory (in practice cleave off the last + // component) + ".." -> absoluteComponents = absoluteComponents.parent() + // Current directory, the components are already there. + "." -> {} + // New directory, add it + else -> absoluteComponents = absoluteComponents.child(component) + } + } + return absoluteComponents + } + + private fun Components.relativeTo(workingDirectory: Components): Components { + // We want to find the common prefix of the working directory and path, and then + // and them combine them with the correct relative elements to make sure they + // resolve the same. + var commonIndex = 0 + while (commonIndex < components.size && + commonIndex < workingDirectory.components.size && + components[commonIndex] == workingDirectory.components[commonIndex]) { + ++commonIndex + } + + var relativeComponents = Components.parseUnix(".") + + // TODO: Simplify this logic + when { + commonIndex == components.size && commonIndex == workingDirectory.components.size -> { + // The paths are the same. This shouldn't occur. + } + commonIndex == components.size -> { + // The working directory is deeper in the path, backtrack. + for (i in 0..workingDirectory.components.size - commonIndex - 1) { + relativeComponents = relativeComponents.child("..") + } + } + commonIndex == workingDirectory.components.size -> { + // Working directory is shallower than the path, can just append the + // non-common remainder of the path + relativeComponents = relativeComponents.child(depth(commonIndex)) + } + else -> { + // The paths are siblings. Backtrack and append as needed. + for (i in 0..workingDirectory.components.size - commonIndex - 1) { + relativeComponents = relativeComponents.child("..") + } + relativeComponents = relativeComponents.child(depth(commonIndex)) + } + } + + return relativeComponents + } + + private companion object { + val WINDOWS_VOLUME_PREFIX_REGEX = Regex("^[A-Za-z]:\\\\.*") + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/DocumentPathFactory.kt b/app/src/main/java/org/oxycblt/auxio/music/fs/DocumentPathFactory.kt new file mode 100644 index 000000000..eb977a1fe --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/music/fs/DocumentPathFactory.kt @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2023 Auxio Project + * DocumentPathFactory.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.music.fs + +import android.content.ContentUris +import android.content.Context +import android.net.Uri +import android.provider.DocumentsContract +import dagger.hilt.android.qualifiers.ApplicationContext +import java.io.File +import javax.inject.Inject + +/** + * A factory for parsing the reverse-engineered format of the URIs obtained from document picker. + * + * @author Alexander Capehart (OxygenCobalt) + */ +interface DocumentPathFactory { + /** + * Unpacks a document URI into a [Path] instance, using [fromDocumentId]. + * + * @param uri The document URI to unpack. + * @return The [Path] instance, or null if the URI could not be unpacked. + */ + fun unpackDocumentUri(uri: Uri): Path? + + /** + * Unpacks a document tree URI into a [Path] instance, using [fromDocumentId]. + * + * @param uri The document tree URI to unpack. + * @return The [Path] instance, or null if the URI could not be unpacked. + */ + fun unpackDocumentTreeUri(uri: Uri): Path? + + /** + * Serializes a [Path] instance into a document tree URI format path. + * + * @param path The [Path] instance to serialize. + * @return The serialized path. + */ + fun toDocumentId(path: Path): String + + /** + * Deserializes a document tree URI format path into a [Path] instance. + * + * @param path The path to deserialize. + * @return The [Path] instance, or null if the path could not be deserialized. + */ + fun fromDocumentId(path: String): Path? +} + +class DocumentPathFactoryImpl +@Inject +constructor( + @ApplicationContext private val context: Context, + private val volumeManager: VolumeManager, + private val mediaStorePathInterpreterFactory: MediaStorePathInterpreter.Factory +) : DocumentPathFactory { + override fun unpackDocumentUri(uri: Uri): Path? { + val id = DocumentsContract.getDocumentId(uri) + val numericId = id.toLongOrNull() + return if (numericId != null) { + // The document URI is special and points to an entry only accessible via + // ContentResolver. In this case, we have to manually query MediaStore. + for (prefix in POSSIBLE_CONTENT_URI_PREFIXES) { + val contentUri = ContentUris.withAppendedId(prefix, numericId) + + val path = + context.contentResolverSafe.useQuery( + contentUri, mediaStorePathInterpreterFactory.projection) { + it.moveToFirst() + mediaStorePathInterpreterFactory.wrap(it).extract() + } + + if (path != null) { + return path + } + } + + null + } else { + fromDocumentId(id) + } + } + + override fun unpackDocumentTreeUri(uri: Uri): Path? { + // Convert the document tree URI into it's relative path form, which can then be + // parsed into a Directory instance. + val docUri = + DocumentsContract.buildDocumentUriUsingTree( + uri, DocumentsContract.getTreeDocumentId(uri)) + val treeUri = DocumentsContract.getTreeDocumentId(docUri) + return fromDocumentId(treeUri) + } + + override fun toDocumentId(path: Path): String = + when (val volume = path.volume) { + // The primary storage has a volume prefix of "primary", regardless + // of if it's internal or not. + is Volume.Internal -> "$DOCUMENT_URI_PRIMARY_NAME:${path.components}" + // Document tree URIs consist of a prefixed volume name followed by a relative path. + is Volume.External -> "${volume.id}:${path.components}" + } + + override fun fromDocumentId(path: String): Path? { + // Document tree URIs consist of a prefixed volume name followed by a relative path, + // delimited with a colon. + val split = path.split(File.pathSeparator, limit = 2) + val volume = + when (split[0]) { + // The primary storage has a volume prefix of "primary", regardless + // of if it's internal or not. + DOCUMENT_URI_PRIMARY_NAME -> volumeManager.getInternalVolume() + // Removable storage has a volume prefix of it's UUID, try to find it + // within StorageManager's volume list. + else -> + volumeManager.getVolumes().find { it is Volume.External && it.id == split[0] } + } + val relativePath = split.getOrNull(1) ?: return null + return Path(volume ?: return null, Components.parseUnix(relativePath)) + } + + private companion object { + const val DOCUMENT_URI_PRIMARY_NAME = "primary" + + private val POSSIBLE_CONTENT_URI_PREFIXES = + arrayOf( + Uri.parse("content://downloads/public_downloads"), + Uri.parse("content://downloads/my_downloads")) + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/Fs.kt b/app/src/main/java/org/oxycblt/auxio/music/fs/Fs.kt index 93a777a6a..2639ec207 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/fs/Fs.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/fs/Fs.kt @@ -24,119 +24,229 @@ import android.os.storage.StorageManager import android.os.storage.StorageVolume import android.webkit.MimeTypeMap import java.io.File +import javax.inject.Inject import org.oxycblt.auxio.R /** - * A full absolute path to a file. Only intended for display purposes. For accessing files, URIs are - * preferred in all cases due to scoped storage limitations. + * An abstraction of an android file system path, including the volume and relative path. * - * @param name The name of the file. - * @param parent The parent [Directory] of the file. - * @author Alexander Capehart (OxygenCobalt) + * @param volume The volume that the path is on. + * @param components The components of the path of the file, relative to the root of the volume. */ -data class Path(val name: String, val parent: Directory) +data class Path( + val volume: Volume, + val components: Components, +) { + /** The name of the file/directory. */ + val name: String? + get() = components.name + + /** The parent directory of the path, or itself if it's the root path. */ + val directory: Path + get() = Path(volume, components.parent()) + + /** + * Transforms this [Path] into a "file" of the given name that's within the "directory" + * represented by the current path. Ex. "/storage/emulated/0/Music" -> + * "/storage/emulated/0/Music/file.mp3" + * + * @param fileName The name of the file to append to the path. + * @return The new [Path] instance. + */ + fun file(fileName: String) = Path(volume, components.child(fileName)) + + /** + * Resolves the [Path] in a human-readable format. + * + * @param context [Context] required to obtain human-readable strings. + */ + fun resolve(context: Context) = "${volume.resolveName(context)}/$components" +} + +sealed interface Volume { + /** The name of the volume as it appears in MediaStore. */ + val mediaStoreName: String? + + /** + * The components of the path to the volume, relative from the system root. Should not be used + * except for compatibility purposes. + */ + val components: Components? + + /** Resolves the name of the volume in a human-readable format. */ + fun resolveName(context: Context): String + + /** A volume representing the device's internal storage. */ + interface Internal : Volume + + /** A volume representing an external storage device, identified by a UUID. */ + interface External : Volume { + /** The UUID of the volume. */ + val id: String? + } +} /** - * A volume-aware relative path to a directory. + * The components of a path. This allows the path to be manipulated without having tp handle + * separator parsing. * - * @param volume The [StorageVolume] that the [Directory] is contained in. - * @param relativePath The relative path from within the [StorageVolume] to the [Directory]. - * @author Alexander Capehart (OxygenCobalt) + * @param components The components of the path. */ -class Directory private constructor(val volume: StorageVolume, val relativePath: String) { +@JvmInline +value class Components private constructor(val components: List) { + /** The name of the file/directory. */ + val name: String? + get() = components.lastOrNull() + + override fun toString() = unixString + + /** Formats these components using the unix file separator (/) */ + val unixString: String + get() = components.joinToString(File.separator) + + /** Formats these components using the windows file separator (\). */ + val windowsString: String + get() = components.joinToString("\\") + /** - * Resolve the [Directory] instance into a human-readable path name. + * Returns a new [Components] instance with the last element of the path removed as a "parent" + * element of the original instance. * - * @param context [Context] required to obtain volume descriptions. - * @return A human-readable path. - * @see StorageVolume.getDescription + * @return The new [Components] instance, or the original instance if it's the root path. */ - fun resolveName(context: Context) = - context.getString(R.string.fmt_path, volume.getDescriptionCompat(context), relativePath) + fun parent() = Components(components.dropLast(1)) /** - * Converts this [Directory] instance into an opaque document tree path. This is a huge - * violation of the document tree URI contract, but it's also the only one can sensibly work - * with these uris in the UI, and it doesn't exactly matter since we never write or read to - * directory. + * Returns a new [Components] instance with the given name appended to the end of the path as a + * "child" element of the original instance. * - * @return A URI [String] abiding by the document tree specification, or null if the [Directory] - * is not valid. + * @param name The name of the file/directory to append to the path. */ - fun toDocumentTreeUri() = - // Document tree URIs consist of a prefixed volume name followed by a relative path. - if (volume.isInternalCompat) { - // The primary storage has a volume prefix of "primary", regardless - // of if it's internal or not. - "$DOCUMENT_URI_PRIMARY_NAME:$relativePath" + fun child(name: String) = + if (name.isNotEmpty()) { + Components(components + name.trimSlashes()) } else { - // Removable storage has a volume prefix of it's UUID. - volume.uuidCompat?.let { uuid -> "$uuid:$relativePath" } + this } - override fun hashCode(): Int { - var result = volume.hashCode() - result = 31 * result + relativePath.hashCode() - return result - } + /** + * Removes the first [n] elements of the path, effectively resulting in a path that is n levels + * deep. + * + * @param n The number of elements to remove. + * @return The new [Components] instance. + */ + fun depth(n: Int) = Components(components.drop(n)) + + /** + * Concatenates this [Components] instance with another. + * + * @param other The [Components] instance to concatenate with. + * @return The new [Components] instance. + */ + fun child(other: Components) = Components(components + other.components) + + /** + * Returns the given [Components] has a prefix equal to this [Components] instance. Effectively, + * as if the given [Components] instance was a child of this [Components] instance. + */ + fun contains(other: Components): Boolean { + if (other.components.size < components.size) { + return false + } - override fun equals(other: Any?) = - other is Directory && other.volume == volume && other.relativePath == relativePath + return components == other.components.take(components.size) + } companion object { - /** The name given to the internal volume when in a document tree URI. */ - private const val DOCUMENT_URI_PRIMARY_NAME = "primary" + /** + * Parses a path string into a [Components] instance by the unix path separator (/). + * + * @param path The path string to parse. + * @return The [Components] instance. + */ + fun parseUnix(path: String) = + Components(path.trimSlashes().split(File.separatorChar).filter { it.isNotEmpty() }) /** - * Create a new directory instance from the given components. + * Parses a path string into a [Components] instance by the windows path separator. * - * @param volume The [StorageVolume] that the [Directory] is contained in. - * @param relativePath The relative path from within the [StorageVolume] to the [Directory]. - * Will be stripped of any trailing separators for a consistent internal representation. - * @return A new [Directory] created from the components. + * @param path The path string to parse. + * @return The [Components] instance. */ - fun from(volume: StorageVolume, relativePath: String) = - Directory( - volume, relativePath.removePrefix(File.separator).removeSuffix(File.separator)) + fun parseWindows(path: String) = + Components(path.trimSlashes().split('\\').filter { it.isNotEmpty() }) /** - * Create a new directory from a document tree URI. This is a huge violation of the document - * tree URI contract, but it's also the only one can sensibly work with these uris in the - * UI, and it doesn't exactly matter since we never write or read directory. + * Parses a path string into a [Components] instance by any path separator, either unix or + * windows. This is useful for parsing paths when you can't determine the separators any + * other way, however also risks mangling the paths if they use unix-style escapes. * - * @param storageManager [StorageManager] in order to obtain the [StorageVolume] specified - * in the given URI. - * @param uri The URI string to parse into a [Directory]. - * @return A new [Directory] parsed from the URI, or null if the URI is not valid. + * @param path The path string to parse. + * @return The [Components] instance. */ - fun fromDocumentTreeUri(storageManager: StorageManager, uri: String): Directory? { - // Document tree URIs consist of a prefixed volume name followed by a relative path, - // delimited with a colon. - val split = uri.split(File.pathSeparator, limit = 2) - val volume = - when (split[0]) { - // The primary storage has a volume prefix of "primary", regardless - // of if it's internal or not. - DOCUMENT_URI_PRIMARY_NAME -> storageManager.primaryStorageVolumeCompat - // Removable storage has a volume prefix of it's UUID, try to find it - // within StorageManager's volume list. - else -> storageManager.storageVolumesCompat.find { it.uuidCompat == split[0] } - } - val relativePath = split.getOrNull(1) - return from(volume ?: return null, relativePath ?: return null) - } + fun parseAny(path: String) = + Components( + path.trimSlashes().split(File.separatorChar, '\\').filter { it.isNotEmpty() }) + + private fun String.trimSlashes() = trimStart(File.separatorChar).trimEnd(File.separatorChar) } } -/** - * Represents the configuration for specific directories to filter to/from when loading music. - * - * @param dirs A list of [Directory] instances. How these are interpreted depends on [shouldInclude] - * @param shouldInclude True if the library should only load from the [Directory] instances, false - * if the library should not load from the [Directory] instances. - * @author Alexander Capehart (OxygenCobalt) - */ -data class MusicDirectories(val dirs: List, val shouldInclude: Boolean) +/** A wrapper around [StorageManager] that provides instances of the [Volume] interface. */ +interface VolumeManager { + /** + * The internal storage volume of the device. + * + * @see StorageManager.getPrimaryStorageVolume + */ + fun getInternalVolume(): Volume.Internal + + /** + * The list of [Volume]s currently recognized by [StorageManager]. + * + * @see StorageManager.getStorageVolumes + */ + fun getVolumes(): List +} + +class VolumeManagerImpl @Inject constructor(private val storageManager: StorageManager) : + VolumeManager { + override fun getInternalVolume(): Volume.Internal = + InternalVolumeImpl(storageManager.primaryStorageVolume) + + override fun getVolumes() = + storageManager.storageVolumesCompat.map { + if (it.isInternalCompat) { + InternalVolumeImpl(it) + } else { + ExternalVolumeImpl(it) + } + } + + private data class InternalVolumeImpl(val storageVolume: StorageVolume) : Volume.Internal { + override val mediaStoreName + get() = storageVolume.mediaStoreVolumeNameCompat + + override val components + get() = storageVolume.directoryCompat?.let(Components::parseUnix) + + override fun resolveName(context: Context) = storageVolume.getDescriptionCompat(context) + } + + private data class ExternalVolumeImpl(val storageVolume: StorageVolume) : Volume.External { + override val id + get() = storageVolume.uuidCompat + + override val mediaStoreName + get() = storageVolume.mediaStoreVolumeNameCompat + + override val components + get() = storageVolume.directoryCompat?.let(Components::parseUnix) + + override fun resolveName(context: Context) = storageVolume.getDescriptionCompat(context) + } +} /** * A mime type of a file. Only intended for display. diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/FsModule.kt b/app/src/main/java/org/oxycblt/auxio/music/fs/FsModule.kt index 10c4192bc..46a200562 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/fs/FsModule.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/fs/FsModule.kt @@ -18,18 +18,43 @@ package org.oxycblt.auxio.music.fs +import android.content.ContentResolver import android.content.Context +import android.os.storage.StorageManager +import dagger.Binds import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent -import org.oxycblt.auxio.music.MusicSettings +import org.oxycblt.auxio.util.getSystemServiceCompat @Module @InstallIn(SingletonComponent::class) class FsModule { @Provides - fun mediaStoreExtractor(@ApplicationContext context: Context, musicSettings: MusicSettings) = - MediaStoreExtractor.from(context, musicSettings) + fun volumeManager(@ApplicationContext context: Context): VolumeManager = + VolumeManagerImpl(context.getSystemServiceCompat(StorageManager::class)) + + @Provides + fun mediaStoreExtractor( + @ApplicationContext context: Context, + mediaStorePathInterpreterFactory: MediaStorePathInterpreter.Factory + ) = MediaStoreExtractor.from(context, mediaStorePathInterpreterFactory) + + @Provides + fun mediaStorePathInterpreterFactory( + volumeManager: VolumeManager + ): MediaStorePathInterpreter.Factory = MediaStorePathInterpreter.Factory.from(volumeManager) + + @Provides + fun contentResolver(@ApplicationContext context: Context): ContentResolver = + context.contentResolverSafe +} + +@Module +@InstallIn(SingletonComponent::class) +interface FsBindsModule { + @Binds + fun documentPathFactory(documentTreePathFactory: DocumentPathFactoryImpl): DocumentPathFactory } diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt index 76e62e897..90b5e2051 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt @@ -21,22 +21,19 @@ package org.oxycblt.auxio.music.fs import android.content.Context import android.database.Cursor import android.os.Build -import android.os.storage.StorageManager import android.provider.MediaStore -import androidx.annotation.RequiresApi import androidx.core.database.getIntOrNull import androidx.core.database.getStringOrNull -import java.io.File import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.yield -import org.oxycblt.auxio.music.MusicSettings import org.oxycblt.auxio.music.cache.Cache import org.oxycblt.auxio.music.device.RawSong +import org.oxycblt.auxio.music.dirs.MusicDirectories import org.oxycblt.auxio.music.info.Date import org.oxycblt.auxio.music.metadata.parseId3v2PositionField import org.oxycblt.auxio.music.metadata.transformPositionField -import org.oxycblt.auxio.util.getSystemServiceCompat import org.oxycblt.auxio.util.logD +import org.oxycblt.auxio.util.sendWithTimeout /** * The layer that loads music from the [MediaStore] database. This is an intermediate step in the @@ -50,9 +47,11 @@ interface MediaStoreExtractor { /** * Query the media database. * + * @param constraints Configuration parameter to restrict what music should be ignored when + * querying. * @return A new [Query] returned from the media database. */ - suspend fun query(): Query + suspend fun query(constraints: Constraints): Query /** * Consume the [Cursor] loaded after [query]. @@ -79,83 +78,87 @@ interface MediaStoreExtractor { fun close() - fun populateFileInfo(rawSong: RawSong) + fun populateFileInfo(rawSong: RawSong): Boolean fun populateTags(rawSong: RawSong) } + data class Constraints(val excludeNonMusic: Boolean, val musicDirs: MusicDirectories) + companion object { /** * Create a framework-backed instance. * * @param context [Context] required. - * @param musicSettings [MusicSettings] required. + * @param volumeManager [VolumeManager] required. * @return A new [MediaStoreExtractor] that will work best on the device's API level. */ - fun from(context: Context, musicSettings: MusicSettings): MediaStoreExtractor = - when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> - Api30MediaStoreExtractor(context, musicSettings) - Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> - Api29MediaStoreExtractor(context, musicSettings) - else -> Api21MediaStoreExtractor(context, musicSettings) - } + fun from( + context: Context, + pathInterpreterFactory: MediaStorePathInterpreter.Factory + ): MediaStoreExtractor { + val tagInterpreterFactory = + when { + Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> Api30TagInterpreter.Factory() + else -> Api21TagInterpreter.Factory() + } + + return MediaStoreExtractorImpl(context, pathInterpreterFactory, tagInterpreterFactory) + } } } -private abstract class BaseMediaStoreExtractor( - protected val context: Context, - private val musicSettings: MusicSettings +private class MediaStoreExtractorImpl( + private val context: Context, + private val mediaStorePathInterpreterFactory: MediaStorePathInterpreter.Factory, + private val tagInterpreterFactory: TagInterpreter.Factory ) : MediaStoreExtractor { - final override suspend fun query(): MediaStoreExtractor.Query { + override suspend fun query( + constraints: MediaStoreExtractor.Constraints + ): MediaStoreExtractor.Query { val start = System.currentTimeMillis() - val args = mutableListOf() - var selector = BASE_SELECTOR + val projection = + BASE_PROJECTION + + mediaStorePathInterpreterFactory.projection + + tagInterpreterFactory.projection + var uniSelector = BASE_SELECTOR + var uniArgs = listOf() // Filter out audio that is not music, if enabled. - if (musicSettings.excludeNonMusic) { + if (constraints.excludeNonMusic) { logD("Excluding non-music") - selector += " AND ${MediaStore.Audio.AudioColumns.IS_MUSIC}=1" + uniSelector += " AND ${MediaStore.Audio.AudioColumns.IS_MUSIC}=1" } // Set up the projection to follow the music directory configuration. - val dirs = musicSettings.musicDirs - if (dirs.dirs.isNotEmpty()) { - selector += " AND " - if (!dirs.shouldInclude) { - logD("Excluding directories in selector") - // Without a NOT, the query will be restricted to the specified paths, resulting - // in the "Include" mode. With a NOT, the specified paths will not be included, - // resulting in the "Exclude" mode. - selector += "NOT " - } - selector += " (" - - // Specifying the paths to filter is version-specific, delegate to the concrete - // implementations. - for (i in dirs.dirs.indices) { - if (addDirToSelector(dirs.dirs[i], args)) { - selector += - if (i < dirs.dirs.lastIndex) { - "$dirSelectorTemplate OR " - } else { - dirSelectorTemplate - } + if (constraints.musicDirs.dirs.isNotEmpty()) { + val pathSelector = + mediaStorePathInterpreterFactory.createSelector(constraints.musicDirs.dirs) + if (pathSelector != null) { + logD("Must select for directories") + uniSelector += " AND " + if (!constraints.musicDirs.shouldInclude) { + logD("Excluding directories in selector") + // Without a NOT, the query will be restricted to the specified paths, resulting + // in the "Include" mode. With a NOT, the specified paths will not be included, + // resulting in the "Exclude" mode. + uniSelector += "NOT " } + uniSelector += " (${pathSelector.template})" + uniArgs = pathSelector.args } - - selector += ')' } // Now we can actually query MediaStore. - logD("Starting song query [proj=${projection.toList()}, selector=$selector, args=$args]") + logD( + "Starting song query [proj=${projection.toList()}, selector=$uniSelector, args=$uniArgs]") val cursor = context.contentResolverSafe.safeQuery( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, - selector, - args.toTypedArray()) + uniSelector, + uniArgs.toTypedArray()) logD("Successfully queried for ${cursor.count} songs") val genreNamesMap = mutableMapOf() @@ -193,10 +196,14 @@ private abstract class BaseMediaStoreExtractor( logD("Read ${genreNamesMap.values.distinct().size} genres from MediaStore") logD("Finished initialization in ${System.currentTimeMillis() - start}ms") - return wrapQuery(cursor, genreNamesMap) + return QueryImpl( + cursor, + mediaStorePathInterpreterFactory.wrap(cursor), + tagInterpreterFactory.wrap(cursor), + genreNamesMap) } - final override suspend fun consume( + override suspend fun consume( query: MediaStoreExtractor.Query, cache: Cache?, incompleteSongs: Channel, @@ -204,12 +211,14 @@ private abstract class BaseMediaStoreExtractor( ) { while (query.moveToNext()) { val rawSong = RawSong() - query.populateFileInfo(rawSong) + if (!query.populateFileInfo(rawSong)) { + continue + } if (cache?.populate(rawSong) == true) { - completeSongs.send(rawSong) + completeSongs.sendWithTimeout(rawSong) } else { query.populateTags(rawSong) - incompleteSongs.send(rawSong) + incompleteSongs.sendWithTimeout(rawSong) } yield() } @@ -218,60 +227,14 @@ private abstract class BaseMediaStoreExtractor( query.close() } - /** - * The database columns available to all android versions supported by Auxio. Concrete - * implementations can extend this projection to add version-specific columns. - */ - protected open val projection: Array - get() = - arrayOf( - // These columns are guaranteed to work on all versions of android - MediaStore.Audio.AudioColumns._ID, - MediaStore.Audio.AudioColumns.DATE_ADDED, - MediaStore.Audio.AudioColumns.DATE_MODIFIED, - MediaStore.Audio.AudioColumns.DISPLAY_NAME, - MediaStore.Audio.AudioColumns.SIZE, - MediaStore.Audio.AudioColumns.DURATION, - MediaStore.Audio.AudioColumns.MIME_TYPE, - MediaStore.Audio.AudioColumns.TITLE, - MediaStore.Audio.AudioColumns.YEAR, - MediaStore.Audio.AudioColumns.ALBUM, - MediaStore.Audio.AudioColumns.ALBUM_ID, - MediaStore.Audio.AudioColumns.ARTIST, - AUDIO_COLUMN_ALBUM_ARTIST) - - /** - * The companion template to add to the projection's selector whenever arguments are added by - * [addDirToSelector]. - * - * @see addDirToSelector - */ - protected abstract val dirSelectorTemplate: String - - /** - * Add a [Directory] to the given list of projection selector arguments. - * - * @param dir The [Directory] to add. - * @param args The destination list to append selector arguments to that are analogous to the - * given [Directory]. - * @return true if the [Directory] was added, false otherwise. - * @see dirSelectorTemplate - */ - protected abstract fun addDirToSelector(dir: Directory, args: MutableList): Boolean - - protected abstract fun wrapQuery( - cursor: Cursor, - genreNamesMap: Map - ): MediaStoreExtractor.Query - - abstract class Query( - protected val cursor: Cursor, + class QueryImpl( + private val cursor: Cursor, + private val mediaStorePathInterpreter: MediaStorePathInterpreter, + private val tagInterpreter: TagInterpreter, private val genreNamesMap: Map ) : MediaStoreExtractor.Query { private val idIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns._ID) private val titleIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.TITLE) - private val displayNameIndex = - cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DISPLAY_NAME) private val mimeTypeIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.MIME_TYPE) private val sizeIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.SIZE) @@ -288,21 +251,20 @@ private abstract class BaseMediaStoreExtractor( private val artistIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.ARTIST) private val albumArtistIndex = cursor.getColumnIndexOrThrow(AUDIO_COLUMN_ALBUM_ARTIST) - final override val projectedTotal = cursor.count + override val projectedTotal = cursor.count - final override fun moveToNext() = cursor.moveToNext() + override fun moveToNext() = cursor.moveToNext() - final override fun close() = cursor.close() + override fun close() = cursor.close() - override fun populateFileInfo(rawSong: RawSong) { + override fun populateFileInfo(rawSong: RawSong): Boolean { rawSong.mediaStoreId = cursor.getLong(idIndex) rawSong.dateAdded = cursor.getLong(dateAddedIndex) rawSong.dateModified = cursor.getLong(dateModifiedIndex) - // Try to use the DISPLAY_NAME column to obtain a (probably sane) file name - // from the android system. - rawSong.fileName = cursor.getStringOrNull(displayNameIndex) rawSong.extensionMimeType = cursor.getString(mimeTypeIndex) rawSong.albumMediaStoreId = cursor.getLong(albumIdIndex) + rawSong.path = mediaStorePathInterpreter.extract() ?: return false + return true } override fun populateTags(rawSong: RawSong) { @@ -319,7 +281,8 @@ private abstract class BaseMediaStoreExtractor( // A non-existent album name should theoretically be the name of the folder it contained // in, but in practice it is more often "0" (as in /storage/emulated/0), even when it // the file is not actually in the root internal storage directory. We can't do - // anything to fix this, really. + // anything to fix this, really. We also can't really filter it out, since how can we + // know when it corresponds to the folder and not, say, Low Roar's breakout album "0"? rawSong.albumName = cursor.getString(albumIndex) // Android does not make a non-existent artist tag null, it instead fills it in // as , which makes absolutely no sense given how other columns default @@ -333,16 +296,12 @@ private abstract class BaseMediaStoreExtractor( cursor.getStringOrNull(albumArtistIndex)?.let { rawSong.albumArtistNames = listOf(it) } // Get the genre value we had to query for in initialization genreNamesMap[rawSong.mediaStoreId]?.let { rawSong.genreNames = listOf(it) } + // Get version/device-specific tags + tagInterpreter.populate(rawSong) } } companion object { - /** - * The base selector that works across all versions of android. Does not exclude - * directories. - */ - private const val BASE_SELECTOR = "NOT ${MediaStore.Audio.Media.SIZE}=0" - /** * The album artist of a song. This column has existed since at least API 21, but until API * 30 it was an undocumented extension for Google Play Music. This column will work on all @@ -356,259 +315,122 @@ private abstract class BaseMediaStoreExtractor( * until API 29. This will work on all versions that Auxio supports. */ @Suppress("InlinedApi") private const val VOLUME_EXTERNAL = MediaStore.VOLUME_EXTERNAL - } -} - -// Note: The separation between version-specific backends may not be the cleanest. To preserve -// speed, we only want to add redundancy on known issues, not with possible issues. - -private class Api21MediaStoreExtractor(context: Context, musicSettings: MusicSettings) : - BaseMediaStoreExtractor(context, musicSettings) { - override val projection: Array - get() = - super.projection + - arrayOf( - MediaStore.Audio.AudioColumns.TRACK, - // Below API 29, we are restricted to the absolute path (Called DATA by - // MediaStore) when working with audio files. - MediaStore.Audio.AudioColumns.DATA) - - // The selector should be configured to convert the given directories instances to their - // absolute paths and then compare them to DATA. - - override val dirSelectorTemplate: String - get() = "${MediaStore.Audio.Media.DATA} LIKE ?" - - override fun addDirToSelector(dir: Directory, args: MutableList): Boolean { - // "%" signifies to accept any DATA value that begins with the Directory's path, - // thus recursively filtering all files in the directory. - args.add("${dir.volume.directoryCompat ?: return false}/${dir.relativePath}%") - return true - } - - override fun wrapQuery( - cursor: Cursor, - genreNamesMap: Map, - ): MediaStoreExtractor.Query = - Query(cursor, genreNamesMap, context.getSystemServiceCompat(StorageManager::class)) - - private class Query( - cursor: Cursor, - genreNamesMap: Map, - storageManager: StorageManager - ) : BaseMediaStoreExtractor.Query(cursor, genreNamesMap) { - // Set up cursor indices for later use. - private val trackIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.TRACK) - private val dataIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DATA) - private val volumes = storageManager.storageVolumesCompat - - override fun populateFileInfo(rawSong: RawSong) { - super.populateFileInfo(rawSong) - - val data = cursor.getString(dataIndex) - // On some OEM devices below API 29, DISPLAY_NAME may not be present. I assume - // that this only applies to below API 29, as beyond API 29, this column not being - // present would completely break the scoped storage system. Fill it in with DATA - // if it's not available. - if (rawSong.fileName == null) { - rawSong.fileName = data.substringAfterLast(File.separatorChar, "").ifEmpty { null } - } - // Find the volume that transforms the DATA column into a relative path. This is - // the Directory we will use. - val rawPath = data.substringBeforeLast(File.separatorChar) - for (volume in volumes) { - val volumePath = volume.directoryCompat ?: continue - val strippedPath = rawPath.removePrefix(volumePath) - if (strippedPath != rawPath) { - rawSong.directory = Directory.from(volume, strippedPath) - break - } - } - } + /** + * The base selector that works across all versions of android. Does not exclude + * directories. + */ + private const val BASE_SELECTOR = "NOT ${MediaStore.Audio.Media.SIZE}=0" - override fun populateTags(rawSong: RawSong) { - super.populateTags(rawSong) - // See unpackTrackNo/unpackDiscNo for an explanation - // of how this column is set up. - val rawTrack = cursor.getIntOrNull(trackIndex) - if (rawTrack != null) { - rawTrack.unpackTrackNo()?.let { rawSong.track = it } - rawTrack.unpackDiscNo()?.let { rawSong.disc = it } - } - } + /** The base projection that works across all versions of android. */ + private val BASE_PROJECTION = + arrayOf( + // These columns are guaranteed to work on all versions of android + MediaStore.Audio.AudioColumns._ID, + MediaStore.Audio.AudioColumns.DATE_ADDED, + MediaStore.Audio.AudioColumns.DATE_MODIFIED, + MediaStore.Audio.AudioColumns.SIZE, + MediaStore.Audio.AudioColumns.DURATION, + MediaStore.Audio.AudioColumns.MIME_TYPE, + MediaStore.Audio.AudioColumns.TITLE, + MediaStore.Audio.AudioColumns.YEAR, + MediaStore.Audio.AudioColumns.ALBUM, + MediaStore.Audio.AudioColumns.ALBUM_ID, + MediaStore.Audio.AudioColumns.ARTIST, + AUDIO_COLUMN_ALBUM_ARTIST) } } /** - * A [BaseMediaStoreExtractor] that implements common behavior supported from API 29 onwards. + * Wrapper around a [Cursor] that interprets certain tags on a per-API basis. * - * @param context [Context] required to query the media database. * @author Alexander Capehart (OxygenCobalt) */ -@RequiresApi(Build.VERSION_CODES.Q) -private abstract class BaseApi29MediaStoreExtractor( - context: Context, - musicSettings: MusicSettings -) : BaseMediaStoreExtractor(context, musicSettings) { - override val projection: Array - get() = - super.projection + - arrayOf( - // After API 29, we now have access to the volume name and relative - // path, which simplifies working with Paths significantly. - MediaStore.Audio.AudioColumns.VOLUME_NAME, - MediaStore.Audio.AudioColumns.RELATIVE_PATH) - - // The selector should be configured to compare both the volume name and relative path - // of the given directories, albeit with some conversion to the analogous MediaStore - // column values. - - override val dirSelectorTemplate: String - get() = - "(${MediaStore.Audio.AudioColumns.VOLUME_NAME} LIKE ? " + - "AND ${MediaStore.Audio.AudioColumns.RELATIVE_PATH} LIKE ?)" - - override fun addDirToSelector(dir: Directory, args: MutableList): Boolean { - // MediaStore uses a different naming scheme for it's volume column convert this - // directory's volume to it. - args.add(dir.volume.mediaStoreVolumeNameCompat ?: return false) - // "%" signifies to accept any DATA value that begins with the Directory's path, - // thus recursively filtering all files in the directory. - args.add("${dir.relativePath}%") - return true - } +private sealed interface TagInterpreter { + /** + * Populate the [RawSong] with version-specific tags. + * + * @param rawSong The [RawSong] to populate. + */ + fun populate(rawSong: RawSong) - abstract class Query( - cursor: Cursor, - genreNamesMap: Map, - storageManager: StorageManager - ) : BaseMediaStoreExtractor.Query(cursor, genreNamesMap) { - private val volumeIndex = - cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.VOLUME_NAME) - private val relativePathIndex = - cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.RELATIVE_PATH) - private val volumes = storageManager.storageVolumesCompat - - final override fun populateFileInfo(rawSong: RawSong) { - super.populateFileInfo(rawSong) - // Find the StorageVolume whose MediaStore name corresponds to this song. - // This is combined with the plain relative path column to create the directory. - val volumeName = cursor.getString(volumeIndex) - val relativePath = cursor.getString(relativePathIndex) - val volume = volumes.find { it.mediaStoreVolumeNameCompat == volumeName } - if (volume != null) { - rawSong.directory = Directory.from(volume, relativePath) - } - } + interface Factory { + /** The columns that must be added to a query to support this interpreter. */ + val projection: Array + + /** + * Wrap a [Cursor] with this interpreter. This cursor should be the result of a query + * containing the columns specified by [projection]. + * + * @param cursor The [Cursor] to wrap. + * @return A new [TagInterpreter] that will work best on the device's API level. + */ + fun wrap(cursor: Cursor): TagInterpreter } } -/** - * A [BaseMediaStoreExtractor] that completes the music loading process in a way compatible with at - * API 29. - * - * @param context [Context] required to query the media database. - * @author Alexander Capehart (OxygenCobalt) - */ -@RequiresApi(Build.VERSION_CODES.Q) -private class Api29MediaStoreExtractor(context: Context, musicSettings: MusicSettings) : - BaseApi29MediaStoreExtractor(context, musicSettings) { - - override val projection: Array - get() = super.projection + arrayOf(MediaStore.Audio.AudioColumns.TRACK) - - override fun wrapQuery( - cursor: Cursor, - genreNamesMap: Map - ): MediaStoreExtractor.Query = - Query(cursor, genreNamesMap, context.getSystemServiceCompat(StorageManager::class)) - - private class Query( - cursor: Cursor, - genreNamesMap: Map, - storageManager: StorageManager - ) : BaseApi29MediaStoreExtractor.Query(cursor, genreNamesMap, storageManager) { - private val trackIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.TRACK) +private class Api21TagInterpreter(private val cursor: Cursor) : TagInterpreter { + private val trackIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.TRACK) - override fun populateTags(rawSong: RawSong) { - super.populateTags(rawSong) - // This extractor is volume-aware, but does not support the modern track columns. - // Use the old column instead. See unpackTrackNo/unpackDiscNo for an explanation - // of how this column is set up. - val rawTrack = cursor.getIntOrNull(trackIndex) - if (rawTrack != null) { - rawTrack.unpackTrackNo()?.let { rawSong.track = it } - rawTrack.unpackDiscNo()?.let { rawSong.disc = it } - } + override fun populate(rawSong: RawSong) { + // See unpackTrackNo/unpackDiscNo for an explanation + // of how this column is set up. + val rawTrack = cursor.getIntOrNull(trackIndex) + if (rawTrack != null) { + rawTrack.unpackTrackNo()?.let { rawSong.track = it } + rawTrack.unpackDiscNo()?.let { rawSong.disc = it } } } + + class Factory : TagInterpreter.Factory { + override val projection: Array + get() = arrayOf(MediaStore.Audio.AudioColumns.TRACK) + + override fun wrap(cursor: Cursor): TagInterpreter = Api21TagInterpreter(cursor) + } + + /** + * Unpack the track number from a combined track + disc [Int] field. These fields appear within + * MediaStore's TRACK column, and combine the track and disc value into a single field where the + * disc number is the 4th+ digit. + * + * @return The track number extracted from the combined integer value, or null if the value was + * zero. + */ + private fun Int.unpackTrackNo() = transformPositionField(mod(1000), null) + + /** + * Unpack the disc number from a combined track + disc [Int] field. These fields appear within + * MediaStore's TRACK column, and combine the track and disc value into a single field where the + * disc number is the 4th+ digit. + * + * @return The disc number extracted from the combined integer field, or null if the value was + * zero. + */ + private fun Int.unpackDiscNo() = transformPositionField(div(1000), null) } -/** - * A [BaseMediaStoreExtractor] that completes the music loading process in a way compatible from API - * 30 onwards. - * - * @param context [Context] required to query the media database. - * @author Alexander Capehart (OxygenCobalt) - */ -@RequiresApi(Build.VERSION_CODES.R) -private class Api30MediaStoreExtractor(context: Context, musicSettings: MusicSettings) : - BaseApi29MediaStoreExtractor(context, musicSettings) { - override val projection: Array - get() = - super.projection + +private class Api30TagInterpreter(private val cursor: Cursor) : TagInterpreter { + private val trackIndex = + cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.CD_TRACK_NUMBER) + private val discIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DISC_NUMBER) + + override fun populate(rawSong: RawSong) { + // Both CD_TRACK_NUMBER and DISC_NUMBER tend to be formatted as they are in + // the tag itself, which is to say that it is formatted as NN/TT tracks, where + // N is the number and T is the total. Parse the number while ignoring the + // total, as we have no use for it. + cursor.getStringOrNull(trackIndex)?.parseId3v2PositionField()?.let { rawSong.track = it } + cursor.getStringOrNull(discIndex)?.parseId3v2PositionField()?.let { rawSong.disc = it } + } + + class Factory : TagInterpreter.Factory { + override val projection: Array + get() = arrayOf( - // API 30 grant us access to the superior CD_TRACK_NUMBER and DISC_NUMBER - // fields, which take the place of TRACK. MediaStore.Audio.AudioColumns.CD_TRACK_NUMBER, MediaStore.Audio.AudioColumns.DISC_NUMBER) - override fun wrapQuery( - cursor: Cursor, - genreNamesMap: Map - ): MediaStoreExtractor.Query = - Query(cursor, genreNamesMap, context.getSystemServiceCompat(StorageManager::class)) - - private class Query( - cursor: Cursor, - genreNamesMap: Map, - storageManager: StorageManager - ) : BaseApi29MediaStoreExtractor.Query(cursor, genreNamesMap, storageManager) { - private val trackIndex = - cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.CD_TRACK_NUMBER) - private val discIndex = - cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DISC_NUMBER) - - override fun populateTags(rawSong: RawSong) { - super.populateTags(rawSong) - // Both CD_TRACK_NUMBER and DISC_NUMBER tend to be formatted as they are in - // the tag itself, which is to say that it is formatted as NN/TT tracks, where - // N is the number and T is the total. Parse the number while ignoring the - // total, as we have no use for it. - cursor.getStringOrNull(trackIndex)?.parseId3v2PositionField()?.let { - rawSong.track = it - } - cursor.getStringOrNull(discIndex)?.parseId3v2PositionField()?.let { rawSong.disc = it } - } + override fun wrap(cursor: Cursor): TagInterpreter = Api30TagInterpreter(cursor) } } - -/** - * Unpack the track number from a combined track + disc [Int] field. These fields appear within - * MediaStore's TRACK column, and combine the track and disc value into a single field where the - * disc number is the 4th+ digit. - * - * @return The track number extracted from the combined integer value, or null if the value was - * zero. - */ -private fun Int.unpackTrackNo() = transformPositionField(mod(1000), null) - -/** - * Unpack the disc number from a combined track + disc [Int] field. These fields appear within - * MediaStore's TRACK column, and combine the track and disc value into a single field where the - * disc number is the 4th+ digit. - * - * @return The disc number extracted from the combined integer field, or null if the value was zero. - */ -private fun Int.unpackDiscNo() = transformPositionField(div(1000), null) diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStorePathInterpreter.kt b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStorePathInterpreter.kt new file mode 100644 index 000000000..1f821aaf4 --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStorePathInterpreter.kt @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2024 Auxio Project + * MediaStorePathInterpreter.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.music.fs + +import android.database.Cursor +import android.os.Build +import android.provider.MediaStore + +/** + * Wrapper around a [Cursor] that interprets path information on a per-API/manufacturer basis. + * + * @author Alexander Capehart (OxygenCobalt) + */ +sealed interface MediaStorePathInterpreter { + /** + * Extract a [Path] from the wrapped [Cursor]. This should be called after the cursor has been + * moved to the row that should be interpreted. + * + * @return The [Path] instance, or null if the path could not be extracted. + */ + fun extract(): Path? + + interface Factory { + /** The columns that must be added to a query to support this interpreter. */ + val projection: Array + + /** + * Wrap a [Cursor] with this interpreter. This cursor should be the result of a query + * containing the columns specified by [projection]. + * + * @param cursor The [Cursor] to wrap. + * @return A new [MediaStorePathInterpreter] that will work best on the device's API level. + */ + fun wrap(cursor: Cursor): MediaStorePathInterpreter + + /** + * Create a selector that will filter the given paths. By default this will filter *to* the + * given paths, to exclude them, use a NOT. + * + * @param paths The paths to filter for. + * @return A selector that will filter to the given paths, or null if a selector could not + * be created from the paths. + */ + fun createSelector(paths: List): Selector? + + /** + * A selector that will filter to the given paths. + * + * @param template The template to use for the selector. + * @param args The arguments to use for the selector. + * @see Factory.createSelector + */ + data class Selector(val template: String, val args: List) + + companion object { + /** + * Create a [MediaStorePathInterpreter.Factory] that will work best on the device's API + * level. + * + * @param volumeManager The [VolumeManager] to use for volume information. + */ + fun from(volumeManager: VolumeManager) = + when { + // Huawei violates the API docs and prevents you from accessing the new path + // fields without first granting access to them through SAF. Fall back to DATA + // instead. + Build.MANUFACTURER.equals("huawei", ignoreCase = true) || + Build.VERSION.SDK_INT < Build.VERSION_CODES.Q -> + DataMediaStorePathInterpreter.Factory(volumeManager) + else -> VolumeMediaStorePathInterpreter.Factory(volumeManager) + } + } + } +} + +/** + * Wrapper around a [Cursor] that interprets the DATA column as a path. Create an instance with + * [Factory]. + */ +private class DataMediaStorePathInterpreter +private constructor(private val cursor: Cursor, volumeManager: VolumeManager) : + MediaStorePathInterpreter { + private val dataIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DATA) + private val volumes = volumeManager.getVolumes() + + override fun extract(): Path? { + val data = Components.parseUnix(cursor.getString(dataIndex)) + + // Find the volume that transforms the DATA column into a relative path. This is + // the Directory we will use. + for (volume in volumes) { + val volumePath = volume.components ?: continue + if (volumePath.contains(data)) { + return Path(volume, data.depth(volumePath.components.size)) + } + } + + return null + } + + /** + * Factory for [DataMediaStorePathInterpreter]. + * + * @param volumeManager The [VolumeManager] to use for volume information. + */ + class Factory(private val volumeManager: VolumeManager) : MediaStorePathInterpreter.Factory { + override val projection: Array + get() = + arrayOf( + MediaStore.Audio.AudioColumns.DISPLAY_NAME, MediaStore.Audio.AudioColumns.DATA) + + override fun createSelector( + paths: List + ): MediaStorePathInterpreter.Factory.Selector? { + val args = mutableListOf() + var template = "" + for (i in paths.indices) { + val path = paths[i] + val volume = path.volume.components ?: continue + template += + if (i == 0) { + "${MediaStore.Audio.AudioColumns.DATA} LIKE ?" + } else { + " OR ${MediaStore.Audio.AudioColumns.DATA} LIKE ?" + } + args.add("${volume}${path.components}%") + } + + if (template.isEmpty()) { + return null + } + + return MediaStorePathInterpreter.Factory.Selector(template, args) + } + + override fun wrap(cursor: Cursor): MediaStorePathInterpreter = + DataMediaStorePathInterpreter(cursor, volumeManager) + } +} + +/** + * Wrapper around a [Cursor] that interprets the VOLUME_NAME, RELATIVE_PATH, and DISPLAY_NAME + * columns as a path. Create an instance with [Factory]. + */ +private class VolumeMediaStorePathInterpreter +private constructor(private val cursor: Cursor, volumeManager: VolumeManager) : + MediaStorePathInterpreter { + private val displayNameIndex = + cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.DISPLAY_NAME) + private val volumeIndex = + cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.VOLUME_NAME) + private val relativePathIndex = + cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.RELATIVE_PATH) + private val volumes = volumeManager.getVolumes() + + override fun extract(): Path? { + // Find the StorageVolume whose MediaStore name corresponds to it. + val volumeName = cursor.getString(volumeIndex) + val volume = volumes.find { it.mediaStoreName == volumeName } ?: return null + // Relative path does not include file name, must use DISPLAY_NAME and add it + // in manually. + val relativePath = cursor.getString(relativePathIndex) + val displayName = cursor.getString(displayNameIndex) + val components = Components.parseUnix(relativePath).child(displayName) + return Path(volume, components) + } + + /** + * Factory for [VolumeMediaStorePathInterpreter]. + * + * @param volumeManager The [VolumeManager] to use for volume information. + */ + class Factory(private val volumeManager: VolumeManager) : MediaStorePathInterpreter.Factory { + override val projection: Array + get() = + arrayOf( + // After API 29, we now have access to the volume name and relative + // path, which hopefully are more standard and less likely to break + // compared to DATA. + MediaStore.Audio.AudioColumns.DISPLAY_NAME, + MediaStore.Audio.AudioColumns.VOLUME_NAME, + MediaStore.Audio.AudioColumns.RELATIVE_PATH) + + // The selector should be configured to compare both the volume name and relative path + // of the given directories, albeit with some conversion to the analogous MediaStore + // column values. + + override fun createSelector( + paths: List + ): MediaStorePathInterpreter.Factory.Selector? { + val args = mutableListOf() + var template = "" + for (i in paths.indices) { + val path = paths[i] + template = + if (i == 0) { + "(${MediaStore.Audio.AudioColumns.VOLUME_NAME} LIKE ? " + + "AND ${MediaStore.Audio.AudioColumns.RELATIVE_PATH} LIKE ?)" + } else { + " OR (${MediaStore.Audio.AudioColumns.VOLUME_NAME} LIKE ? " + + "AND ${MediaStore.Audio.AudioColumns.RELATIVE_PATH} LIKE ?)" + } + // MediaStore uses a different naming scheme for it's volume column. Convert this + // directory's volume to it. + args.add(path.volume.mediaStoreName ?: return null) + // "%" signifies to accept any DATA value that begins with the Directory's path, + // thus recursively filtering all files in the directory. + args.add("${path.components}%") + } + + if (template.isEmpty()) { + return null + } + + return MediaStorePathInterpreter.Factory.Selector(template, args) + } + + override fun wrap(cursor: Cursor): MediaStorePathInterpreter = + VolumeMediaStorePathInterpreter(cursor, volumeManager) + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/music/info/Name.kt b/app/src/main/java/org/oxycblt/auxio/music/info/Name.kt index 09f4d8035..30626f01e 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/info/Name.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/info/Name.kt @@ -23,12 +23,11 @@ import androidx.annotation.StringRes import androidx.annotation.VisibleForTesting import java.text.CollationKey import java.text.Collator -import org.oxycblt.auxio.music.MusicSettings /** * The name of a music item. * - * This class automatically implements + * This class automatically implements advanced sorting heuristics for music naming, * * @author Alexander Capehart */ @@ -80,7 +79,7 @@ sealed interface Name : Comparable { is Unknown -> 1 } - interface Factory { + sealed interface Factory { /** * Create a new instance of [Name.Known] * @@ -88,22 +87,16 @@ sealed interface Name : Comparable { * @param sort The raw sort name obtained from the music item */ fun parse(raw: String, sort: String?): Known + } - companion object { - /** - * Creates a new instance from the **current state** of the given [MusicSettings]'s - * user-defined name configuration. - * - * @param settings The [MusicSettings] to use. - * @return A [Factory] instance reflecting the configuration state. - */ - fun from(settings: MusicSettings) = - if (settings.intelligentSorting) { - IntelligentKnownName.Factory - } else { - SimpleKnownName.Factory - } - } + /** Produces a simple [Known] with basic sorting heuristics that are locale-independent. */ + data object SimpleFactory : Factory { + override fun parse(raw: String, sort: String?) = SimpleKnownName(raw, sort) + } + + /** Produces an intelligent [Known] with advanced, but more fragile heuristics. */ + data object IntelligentFactory : Factory { + override fun parse(raw: String, sort: String?) = IntelligentKnownName(raw, sort) } } @@ -137,7 +130,6 @@ private val punctRegex by lazy { Regex("[\\p{Punct}+]") } * * @author Alexander Capehart (OxygenCobalt) */ -@VisibleForTesting data class SimpleKnownName(override val raw: String, override val sort: String?) : Name.Known() { override val sortTokens = listOf(parseToken(sort ?: raw)) @@ -148,10 +140,6 @@ data class SimpleKnownName(override val raw: String, override val sort: String?) // Always use lexicographic mode since we aren't parsing any numeric components return SortToken(collationKey, SortToken.Type.LEXICOGRAPHIC) } - - data object Factory : Name.Known.Factory { - override fun parse(raw: String, sort: String?) = SimpleKnownName(raw, sort) - } } /** @@ -159,7 +147,6 @@ data class SimpleKnownName(override val raw: String, override val sort: String?) * * @author Alexander Capehart (OxygenCobalt) */ -@VisibleForTesting data class IntelligentKnownName(override val raw: String, override val sort: String?) : Name.Known() { override val sortTokens = parseTokens(sort ?: raw) @@ -208,10 +195,6 @@ data class IntelligentKnownName(override val raw: String, override val sort: Str } } - data object Factory : Name.Known.Factory { - override fun parse(raw: String, sort: String?) = IntelligentKnownName(raw, sort) - } - companion object { private val TOKEN_REGEX by lazy { Regex("(\\d+)|(\\D+)") } } diff --git a/app/src/main/java/org/oxycblt/auxio/music/info/ReleaseType.kt b/app/src/main/java/org/oxycblt/auxio/music/info/ReleaseType.kt index 24260912b..3fe45b202 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/info/ReleaseType.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/info/ReleaseType.kt @@ -143,6 +143,18 @@ sealed interface ReleaseType { get() = R.string.lbl_mixtape } + /** + * A demo. These are usually [EP]-sized releases of music made to promote an Artist or a future + * release. + */ + data object Demo : ReleaseType { + override val refinement: Refinement? + get() = null + + override val stringRes: Int + get() = R.string.lbl_demo + } + /** A specification of what kind of performance a particular release is. */ enum class Refinement { /** A release consisting of a live performance */ @@ -220,6 +232,7 @@ sealed interface ReleaseType { type.equals("dj-mix", true) -> Mix type.equals("live", true) -> convertRefinement(Refinement.LIVE) type.equals("remix", true) -> convertRefinement(Refinement.REMIX) + type.equals("demo", true) -> Demo else -> convertRefinement(null) } } diff --git a/app/src/main/java/org/oxycblt/auxio/music/metadata/Separators.kt b/app/src/main/java/org/oxycblt/auxio/music/metadata/Separators.kt index 8d2740e74..678e1ef2f 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/metadata/Separators.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/metadata/Separators.kt @@ -18,9 +18,6 @@ package org.oxycblt.auxio.music.metadata -import androidx.annotation.VisibleForTesting -import org.oxycblt.auxio.music.MusicSettings - /** * Defines the user-specified parsing of multi-value tags. This should be used to parse any tags * that may be delimited with a separator character. @@ -45,15 +42,12 @@ interface Separators { const val AND = '&' /** - * Creates a new instance from the **current state** of the given [MusicSettings]'s - * user-defined separator configuration. + * Creates a new instance from a string of separator characters to use. * - * @param settings The [MusicSettings] to use. - * @return A new [Separators] instance reflecting the configuration state. + * @param chars The separator characters to use. Each character in the string will be + * checked for when splitting a string list. + * @return A new [Separators] instance reflecting the separators. */ - fun from(settings: MusicSettings) = from(settings.separators) - - @VisibleForTesting fun from(chars: String) = if (chars.isNotEmpty()) { CharSeparators(chars.toSet()) diff --git a/app/src/main/java/org/oxycblt/auxio/music/metadata/TagExtractor.kt b/app/src/main/java/org/oxycblt/auxio/music/metadata/TagExtractor.kt index 4cca1a824..de49e2e81 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/metadata/TagExtractor.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/metadata/TagExtractor.kt @@ -23,7 +23,9 @@ import javax.inject.Inject import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.yield import org.oxycblt.auxio.music.device.RawSong +import org.oxycblt.auxio.util.forEachWithTimeout import org.oxycblt.auxio.util.logD +import org.oxycblt.auxio.util.sendWithTimeout /** * The extractor that leverages ExoPlayer's [MetadataRetriever] API to parse metadata. This is the @@ -55,14 +57,14 @@ class TagExtractorImpl @Inject constructor(private val tagWorkerFactory: TagWork logD("Beginning primary extraction loop") - for (incompleteRawSong in incompleteSongs) { + incompleteSongs.forEachWithTimeout { incompleteRawSong -> spin@ while (true) { for (i in tagWorkerPool.indices) { val worker = tagWorkerPool[i] if (worker != null) { val completeRawSong = worker.poll() if (completeRawSong != null) { - completeSongs.send(completeRawSong) + completeSongs.sendWithTimeout(completeRawSong) yield() } else { continue @@ -83,7 +85,7 @@ class TagExtractorImpl @Inject constructor(private val tagWorkerFactory: TagWork if (task != null) { val completeRawSong = task.poll() if (completeRawSong != null) { - completeSongs.send(completeRawSong) + completeSongs.sendWithTimeout(completeRawSong) tagWorkerPool[i] = null yield() } else { diff --git a/app/src/main/java/org/oxycblt/auxio/music/system/IndexerService.kt b/app/src/main/java/org/oxycblt/auxio/music/system/IndexerService.kt index 37b32f8ef..d3cad75c6 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/system/IndexerService.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/system/IndexerService.kt @@ -32,7 +32,6 @@ import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job -import kotlinx.coroutines.launch import org.oxycblt.auxio.BuildConfig import org.oxycblt.auxio.music.IndexingProgress import org.oxycblt.auxio.music.IndexingState @@ -124,12 +123,11 @@ class IndexerService : // --- CONTROLLER CALLBACKS --- override fun requestIndex(withCache: Boolean) { - logD("Starting new indexing job") + logD("Starting new indexing job (previous=${currentIndexJob?.hashCode()})") // Cancel the previous music loading job. currentIndexJob?.cancel() // Start a new music loading job on a co-routine. - currentIndexJob = - indexScope.launch { musicRepository.index(this@IndexerService, withCache) } + currentIndexJob = musicRepository.index(this@IndexerService, withCache) } override val context = this diff --git a/app/src/main/java/org/oxycblt/auxio/music/user/UserLibrary.kt b/app/src/main/java/org/oxycblt/auxio/music/user/UserLibrary.kt index faae9594b..70943b7d3 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/user/UserLibrary.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/user/UserLibrary.kt @@ -22,7 +22,6 @@ import java.lang.Exception import javax.inject.Inject import org.oxycblt.auxio.music.Music import org.oxycblt.auxio.music.MusicRepository -import org.oxycblt.auxio.music.MusicSettings import org.oxycblt.auxio.music.Playlist import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.music.device.DeviceLibrary @@ -82,7 +81,8 @@ interface UserLibrary { */ suspend fun create( rawPlaylists: List, - deviceLibrary: DeviceLibrary + deviceLibrary: DeviceLibrary, + nameFactory: Name.Known.Factory ): MutableUserLibrary } } @@ -139,9 +139,7 @@ interface MutableUserLibrary : UserLibrary { suspend fun rewritePlaylist(playlist: Playlist, songs: List): Boolean } -class UserLibraryFactoryImpl -@Inject -constructor(private val playlistDao: PlaylistDao, private val musicSettings: MusicSettings) : +class UserLibraryFactoryImpl @Inject constructor(private val playlistDao: PlaylistDao) : UserLibrary.Factory { override suspend fun query() = try { @@ -155,22 +153,22 @@ constructor(private val playlistDao: PlaylistDao, private val musicSettings: Mus override suspend fun create( rawPlaylists: List, - deviceLibrary: DeviceLibrary + deviceLibrary: DeviceLibrary, + nameFactory: Name.Known.Factory ): MutableUserLibrary { - val nameFactory = Name.Known.Factory.from(musicSettings) val playlistMap = mutableMapOf() for (rawPlaylist in rawPlaylists) { val playlistImpl = PlaylistImpl.fromRaw(rawPlaylist, deviceLibrary, nameFactory) playlistMap[playlistImpl.uid] = playlistImpl } - return UserLibraryImpl(playlistDao, playlistMap, musicSettings) + return UserLibraryImpl(playlistDao, playlistMap, nameFactory) } } private class UserLibraryImpl( private val playlistDao: PlaylistDao, private val playlistMap: MutableMap, - private val musicSettings: MusicSettings + private val nameFactory: Name.Known.Factory ) : MutableUserLibrary { override fun hashCode() = playlistMap.hashCode() @@ -186,7 +184,7 @@ private class UserLibraryImpl( override fun findPlaylist(name: String) = playlistMap.values.find { it.name.raw == name } override suspend fun createPlaylist(name: String, songs: List): Playlist? { - val playlistImpl = PlaylistImpl.from(name, songs, Name.Known.Factory.from(musicSettings)) + val playlistImpl = PlaylistImpl.from(name, songs, nameFactory) synchronized(this) { playlistMap[playlistImpl.uid] = playlistImpl } val rawPlaylist = RawPlaylist( @@ -209,9 +207,7 @@ private class UserLibraryImpl( val playlistImpl = synchronized(this) { requireNotNull(playlistMap[playlist.uid]) { "Cannot rename invalid playlist" } - .also { - playlistMap[it.uid] = it.edit(name, Name.Known.Factory.from(musicSettings)) - } + .also { playlistMap[it.uid] = it.edit(name, nameFactory) } } return try { diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackPanelFragment.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackPanelFragment.kt index b7228d508..d03e0cb1c 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackPanelFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackPanelFragment.kt @@ -38,7 +38,9 @@ import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.music.resolveNames import org.oxycblt.auxio.playback.state.RepeatMode +import org.oxycblt.auxio.playback.ui.PlaybackPagerAdapter import org.oxycblt.auxio.playback.ui.StyledSeekBar +import org.oxycblt.auxio.playback.ui.SwipeCoverView import org.oxycblt.auxio.ui.ViewBindingFragment import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.logD @@ -58,11 +60,13 @@ import org.oxycblt.auxio.util.systemBarInsetsCompat class PlaybackPanelFragment : ViewBindingFragment(), Toolbar.OnMenuItemClickListener, - StyledSeekBar.Listener { + StyledSeekBar.Listener, + SwipeCoverView.OnSwipeListener { private val playbackModel: PlaybackViewModel by activityViewModels() private val detailModel: DetailViewModel by activityViewModels() private val listModel: ListViewModel by activityViewModels() private var equalizerLauncher: ActivityResultLauncher? = null + private var coverAdapter: PlaybackPagerAdapter? = null override fun onCreateBinding(inflater: LayoutInflater) = FragmentPlaybackPanelBinding.inflate(inflater) @@ -99,20 +103,10 @@ class PlaybackPanelFragment : } } - // Set up marquee on song information, alongside click handlers that navigate to each - // respective item. - binding.playbackSong.apply { - isSelected = true - setOnClickListener { playbackModel.song.value?.let(detailModel::showAlbum) } - } - binding.playbackArtist.apply { - isSelected = true - setOnClickListener { navigateToCurrentArtist() } - } - binding.playbackAlbum.apply { - isSelected = true - setOnClickListener { navigateToCurrentAlbum() } - } + binding.playbackCover.onSwipeListener = this + binding.playbackSong.setOnClickListener { navigateToCurrentSong() } + binding.playbackArtist.setOnClickListener { navigateToCurrentArtist() } + binding.playbackAlbum.setOnClickListener { navigateToCurrentAlbum() } binding.playbackSeekBar.listener = this @@ -135,11 +129,8 @@ class PlaybackPanelFragment : override fun onDestroyBinding(binding: FragmentPlaybackPanelBinding) { equalizerLauncher = null + coverAdapter = null binding.playbackToolbar.setOnMenuItemClickListener(null) - // Marquee elements leak if they are not disabled when the views are destroyed. - binding.playbackSong.isSelected = false - binding.playbackArtist.isSelected = false - binding.playbackAlbum.isSelected = false } override fun onMenuItemClick(item: MenuItem): Boolean { @@ -170,6 +161,14 @@ class PlaybackPanelFragment : playbackModel.seekTo(positionDs) } + override fun onSwipePrevious() { + playbackModel.prev() + } + + override fun onSwipeNext() { + playbackModel.next() + } + private fun updateSong(song: Song?) { if (song == null) { // Nothing to do. @@ -212,6 +211,10 @@ class PlaybackPanelFragment : requireBinding().playbackShuffle.isActivated = isShuffled } + private fun navigateToCurrentSong() { + playbackModel.song.value?.let(detailModel::showAlbum) + } + private fun navigateToCurrentArtist() { playbackModel.song.value?.let(detailModel::showArtist) } diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt index 2db007971..7a70bc6e8 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt @@ -22,6 +22,7 @@ import android.os.Bundle import android.view.LayoutInflater import androidx.core.view.isInvisible import androidx.fragment.app.activityViewModels +import androidx.fragment.app.viewModels import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -42,7 +43,7 @@ import org.oxycblt.auxio.util.logD */ @AndroidEntryPoint class QueueFragment : ViewBindingFragment(), EditClickListListener { - private val queueModel: QueueViewModel by activityViewModels() + private val queueModel: QueueViewModel by viewModels() private val playbackModel: PlaybackViewModel by activityViewModels() private val queueAdapter = QueueAdapter(this) private var touchHelper: ItemTouchHelper? = null diff --git a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt index 15c8cf0eb..7ac1c66cf 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt @@ -121,14 +121,14 @@ class PlaybackService : // battery/apk size/cache size val audioRenderer = RenderersFactory { handler, _, audioListener, _, _ -> arrayOf( + FfmpegAudioRenderer(handler, audioListener, replayGainProcessor), MediaCodecAudioRenderer( this, MediaCodecSelector.DEFAULT, handler, audioListener, AudioCapabilities.DEFAULT_AUDIO_CAPABILITIES, - replayGainProcessor), - FfmpegAudioRenderer(handler, audioListener, replayGainProcessor)) + replayGainProcessor)) } player = diff --git a/app/src/main/java/org/oxycblt/auxio/playback/ui/PlaybackPagerAdapter.kt b/app/src/main/java/org/oxycblt/auxio/playback/ui/PlaybackPagerAdapter.kt new file mode 100644 index 000000000..f98498c71 --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/playback/ui/PlaybackPagerAdapter.kt @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2023 Auxio Project + * PlaybackPagerAdapter.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.playback.ui + +import android.view.ViewGroup +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.RecyclerView +import kotlin.jvm.internal.Intrinsics +import org.oxycblt.auxio.databinding.ItemPlaybackSongBinding +import org.oxycblt.auxio.list.adapter.FlexibleListAdapter +import org.oxycblt.auxio.music.Song +import org.oxycblt.auxio.music.resolveNames +import org.oxycblt.auxio.util.inflater + +/** @author Koitharu, Alexander Capehart (OxygenCobalt) */ +class PlaybackPagerAdapter(private val listener: Listener) : + FlexibleListAdapter(CoverViewHolder.DIFF_CALLBACK) { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CoverViewHolder { + return CoverViewHolder.from(parent) + } + + override fun onBindViewHolder(holder: CoverViewHolder, position: Int) { + holder.bind(getItem(position), listener) + } + + override fun onViewRecycled(holder: CoverViewHolder) { + holder.recycle() + super.onViewRecycled(holder) + } + + interface Listener { + fun navigateToCurrentArtist() + + fun navigateToCurrentAlbum() + + fun navigateToCurrentSong() + + fun navigateToMenu() + } +} + +class CoverViewHolder private constructor(private val binding: ItemPlaybackSongBinding) : + RecyclerView.ViewHolder(binding.root), DefaultLifecycleObserver { + init { + binding.root.layoutParams = + RecyclerView.LayoutParams( + RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.MATCH_PARENT) + } + + /** + * Bind new data to this instance. + * + * @param item The new [Song] to bind. + */ + fun bind(item: Song, listener: PlaybackPagerAdapter.Listener) { + val context = binding.root.context + binding.playbackCover.bind(item) + // binding.playbackCover.bind(item) + binding.playbackSong.apply { text = item.name.resolve(context) } + binding.playbackArtist.apply { + text = item.artists.resolveNames(context) + setOnClickListener { listener.navigateToCurrentArtist() } + } + binding.playbackAlbum.apply { + text = item.album.name.resolve(context) + setOnClickListener { listener.navigateToCurrentAlbum() } + } + setSelected(true) + } + + fun recycle() { + // Marquee elements leak if they are not disabled when the views are destroyed. + // TODO: Move to TextView impl to avoid having to deal with lifecycle here + setSelected(false) + } + + private fun setSelected(value: Boolean) { + binding.playbackSong.isSelected = value + binding.playbackArtist.isSelected = value + binding.playbackAlbum.isSelected = value + } + + companion object { + /** + * Create a new instance. + * + * @param parent The parent to inflate this instance from. + * @return A new instance. + */ + fun from(parent: ViewGroup) = + CoverViewHolder(ItemPlaybackSongBinding.inflate(parent.context.inflater)) + + /** A comparator that can be used with DiffUtil. */ + val DIFF_CALLBACK = + object : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: Song, newItem: Song) = + oldItem.uid == newItem.uid + + override fun areContentsTheSame(oldItem: Song, newItem: Song): Boolean { + return Intrinsics.areEqual(oldItem, newItem) + } + } + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/playback/ui/SwipeCoverView.kt b/app/src/main/java/org/oxycblt/auxio/playback/ui/SwipeCoverView.kt new file mode 100644 index 000000000..08bb46b85 --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/playback/ui/SwipeCoverView.kt @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2023 Auxio Project + * SwipeCoverView.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.playback.ui + +import android.annotation.SuppressLint +import android.content.Context +import android.util.AttributeSet +import android.view.GestureDetector +import android.view.GestureDetector.OnGestureListener +import android.view.MotionEvent +import android.view.ViewConfiguration +import androidx.annotation.AttrRes +import kotlin.math.abs +import org.oxycblt.auxio.image.CoverView +import org.oxycblt.auxio.util.isRtl + +class SwipeCoverView +@JvmOverloads +constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr: Int = 0) : + CoverView(context, attrs, defStyleAttr), OnGestureListener { + + private val gestureDetector = GestureDetector(context, this) + private val viewConfig = ViewConfiguration.get(context) + + var onSwipeListener: OnSwipeListener? = null + + override fun onInterceptTouchEvent(event: MotionEvent): Boolean { + return gestureDetector.onTouchEvent(event) + } + + @SuppressLint("ClickableViewAccessibility") + override fun onTouchEvent(event: MotionEvent): Boolean { + return gestureDetector.onTouchEvent(event) || super.onTouchEvent(event) + } + + override fun onGenericMotionEvent(event: MotionEvent): Boolean { + return gestureDetector.onGenericMotionEvent(event) || super.onGenericMotionEvent(event) + } + + override fun onDown(e: MotionEvent): Boolean = true + + override fun onShowPress(e: MotionEvent) = Unit + + override fun onSingleTapUp(e: MotionEvent): Boolean = false + + override fun onScroll( + e1: MotionEvent?, + e2: MotionEvent, + velocityX: Float, + velocityY: Float + ): Boolean = false + + override fun onFling( + e1: MotionEvent?, + e2: MotionEvent, + velocityX: Float, + velocityY: Float + ): Boolean { + e1 ?: return false + val diffY = e2.y - e1.y + val diffX = e2.x - e1.x + if (abs(diffX) > abs(diffY) && + abs(diffX) > viewConfig.scaledTouchSlop && + abs(velocityX) > viewConfig.scaledMinimumFlingVelocity) { + if (diffX > 0) { + onSwipeRight() + } else { + onSwipeLeft() + } + return true + } + return false + } + + override fun onLongPress(e: MotionEvent) = Unit + + private fun onSwipeRight() { + onSwipeListener?.run { if (isRtl) onSwipeNext() else onSwipePrevious() } + } + + private fun onSwipeLeft() { + onSwipeListener?.run { if (isRtl) onSwipePrevious() else onSwipeNext() } + } + + interface OnSwipeListener { + + fun onSwipePrevious() + + fun onSwipeNext() + } +} diff --git a/app/src/main/java/org/oxycblt/auxio/search/SearchEngine.kt b/app/src/main/java/org/oxycblt/auxio/search/SearchEngine.kt index 2c8d9158f..0e0944961 100644 --- a/app/src/main/java/org/oxycblt/auxio/search/SearchEngine.kt +++ b/app/src/main/java/org/oxycblt/auxio/search/SearchEngine.kt @@ -71,7 +71,7 @@ class SearchEngineImpl @Inject constructor(@ApplicationContext private val conte return SearchEngine.Items( songs = items.songs?.searchListImpl(query) { q, song -> - song.path.name.contains(q, ignoreCase = true) + song.path.name?.contains(q, ignoreCase = true) == true }, albums = items.albums?.searchListImpl(query), artists = items.artists?.searchListImpl(query), diff --git a/app/src/main/java/org/oxycblt/auxio/search/SearchFragment.kt b/app/src/main/java/org/oxycblt/auxio/search/SearchFragment.kt index da74d66a2..01c5205ff 100644 --- a/app/src/main/java/org/oxycblt/auxio/search/SearchFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/search/SearchFragment.kt @@ -23,6 +23,8 @@ import android.view.LayoutInflater import android.view.MenuItem import android.view.View import android.view.inputmethod.InputMethodManager +import androidx.activity.result.ActivityResultLauncher +import androidx.activity.result.contract.ActivityResultContracts import androidx.core.view.isInvisible import androidx.core.view.postDelayed import androidx.core.widget.addTextChangedListener @@ -50,7 +52,9 @@ import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.MusicViewModel import org.oxycblt.auxio.music.Playlist import org.oxycblt.auxio.music.PlaylistDecision +import org.oxycblt.auxio.music.PlaylistMessage import org.oxycblt.auxio.music.Song +import org.oxycblt.auxio.music.external.M3U import org.oxycblt.auxio.playback.PlaybackDecision import org.oxycblt.auxio.playback.PlaybackViewModel import org.oxycblt.auxio.util.collect @@ -58,8 +62,10 @@ import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.context import org.oxycblt.auxio.util.getSystemServiceCompat import org.oxycblt.auxio.util.logD +import org.oxycblt.auxio.util.logW import org.oxycblt.auxio.util.navigateSafe import org.oxycblt.auxio.util.setFullWidthLookup +import org.oxycblt.auxio.util.showToast /** * The [ListFragment] providing search functionality for the music library. @@ -77,6 +83,8 @@ class SearchFragment : ListFragment() { override val playbackModel: PlaybackViewModel by activityViewModels() override val musicModel: MusicViewModel by activityViewModels() private val searchAdapter = SearchAdapter(this) + private var getContentLauncher: ActivityResultLauncher? = null + private var pendingImportTarget: Playlist? = null private var imm: InputMethodManager? = null private var launchedKeyboard = false @@ -98,6 +106,19 @@ class SearchFragment : ListFragment() { imm = binding.context.getSystemServiceCompat(InputMethodManager::class) + getContentLauncher = + registerForActivityResult(ActivityResultContracts.GetContent()) { uri -> + if (uri == null) { + logW("No URI returned from file picker") + return@registerForActivityResult + } + + logD("Received playlist URI $uri") + musicModel.importPlaylist(uri, pendingImportTarget) + } + + // --- UI SETUP --- + binding.searchNormalToolbar.apply { // Initialize the current filtering mode. menu.findItem(searchModel.getFilterOptionId()).isChecked = true @@ -141,7 +162,8 @@ class SearchFragment : ListFragment() { collectImmediately(searchModel.searchResults, ::updateSearchResults) collectImmediately(listModel.selected, ::updateSelection) collect(listModel.menu.flow, ::handleMenu) - collect(musicModel.playlistDecision.flow, ::handleDecision) + collect(musicModel.playlistDecision.flow, ::handlePlaylistDecision) + collect(musicModel.playlistMessage.flow, ::handlePlaylistMessage) collectImmediately( playbackModel.song, playbackModel.parent, playbackModel.isPlaying, ::updatePlayback) collect(playbackModel.playbackDecision.flow, ::handlePlaybackDecision) @@ -283,18 +305,36 @@ class SearchFragment : ListFragment() { } } - private fun handleDecision(decision: PlaylistDecision?) { + private fun handlePlaylistDecision(decision: PlaylistDecision?) { if (decision == null) return val directions = when (decision) { + is PlaylistDecision.Import -> { + logD("Importing playlist") + pendingImportTarget = decision.target + requireNotNull(getContentLauncher) { + "Content picker launcher was not available" + } + .launch(M3U.MIME_TYPE) + musicModel.playlistDecision.consume() + return + } is PlaylistDecision.Rename -> { logD("Renaming ${decision.playlist}") - SearchFragmentDirections.renamePlaylist(decision.playlist.uid) + SearchFragmentDirections.renamePlaylist( + decision.playlist.uid, + decision.template, + decision.applySongs.map { it.uid }.toTypedArray(), + decision.reason) } is PlaylistDecision.Delete -> { logD("Deleting ${decision.playlist}") SearchFragmentDirections.deletePlaylist(decision.playlist.uid) } + is PlaylistDecision.Export -> { + logD("Exporting ${decision.playlist}") + SearchFragmentDirections.exportPlaylist(decision.playlist.uid) + } is PlaylistDecision.Add -> { logD("Adding ${decision.songs.size} to a playlist") SearchFragmentDirections.addToPlaylist( @@ -307,6 +347,12 @@ class SearchFragment : ListFragment() { findNavController().navigateSafe(directions) } + private fun handlePlaylistMessage(message: PlaylistMessage?) { + if (message == null) return + requireContext().showToast(message.stringRes) + musicModel.playlistMessage.consume() + } + private fun updatePlayback(song: Song?, parent: MusicParent?, isPlaying: Boolean) { searchAdapter.setPlaying(parent ?: song, isPlaying) } diff --git a/app/src/main/java/org/oxycblt/auxio/ui/BottomSheetContentBehavior.kt b/app/src/main/java/org/oxycblt/auxio/ui/BottomSheetContentBehavior.kt index c8fc0305c..238086454 100644 --- a/app/src/main/java/org/oxycblt/auxio/ui/BottomSheetContentBehavior.kt +++ b/app/src/main/java/org/oxycblt/auxio/ui/BottomSheetContentBehavior.kt @@ -68,12 +68,6 @@ class BottomSheetContentBehavior(context: Context, attributeSet: Attri if (consumed != lastConsumed) { logD("Consumed amount changed, re-applying insets") lastConsumed = consumed - - val insets = lastInsets - if (insets != null) { - child.dispatchApplyWindowInsets(insets) - } - lastInsets?.let(child::dispatchApplyWindowInsets) measureContent(parent, child, consumed) layoutContent(child) diff --git a/app/src/main/java/org/oxycblt/auxio/util/StateUtil.kt b/app/src/main/java/org/oxycblt/auxio/util/StateUtil.kt index eb74d8f15..6e60eadf2 100644 --- a/app/src/main/java/org/oxycblt/auxio/util/StateUtil.kt +++ b/app/src/main/java/org/oxycblt/auxio/util/StateUtil.kt @@ -22,11 +22,16 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle +import java.util.concurrent.TimeoutException import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.TimeoutCancellationException +import kotlinx.coroutines.channels.ReceiveChannel +import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.launch +import kotlinx.coroutines.withTimeout /** * A wrapper around [StateFlow] exposing a one-time consumable event. @@ -146,3 +151,57 @@ private fun Fragment.launch( ) { viewLifecycleOwner.lifecycleScope.launch { viewLifecycleOwner.repeatOnLifecycle(state, block) } } + +/** + * Wraps [SendChannel.send] with a specified timeout. + * + * @param element The element to send. + * @param timeout The timeout in milliseconds. Defaults to 10 seconds. + * @throws TimeoutException If the timeout is reached, provides context on what element + * specifically. + */ +suspend fun SendChannel.sendWithTimeout(element: E, timeout: Long = 10000) { + try { + withTimeout(timeout) { send(element) } + } catch (e: TimeoutCancellationException) { + throw TimeoutException("Timed out sending element $element to channel: $e") + } +} + +/** + * Wraps a [ReceiveChannel] consumption with a specified timeout. Note that the timeout will only + * start on the first element received, as to prevent initialization of dependent coroutines being + * interpreted as a timeout. + * + * @param action The action to perform on each element received. + * @param timeout The timeout in milliseconds. Defaults to 10 seconds. + * @throws TimeoutException If the timeout is reached, provides context on what element + * specifically. + */ +suspend fun ReceiveChannel.forEachWithTimeout( + timeout: Long = 10000, + action: suspend (E) -> Unit +) { + var exhausted = false + var subsequent = false + val handler: suspend () -> Unit = { + val value = receiveCatching() + if (value.isClosed && value.exceptionOrNull() == null) { + exhausted = true + } else { + action(value.getOrThrow()) + } + } + while (!exhausted) { + try { + if (subsequent) { + withTimeout(timeout) { handler() } + } else { + handler() + subsequent = true + } + } catch (e: TimeoutCancellationException) { + throw TimeoutException("Timed out receiving element from channel: $e") + } + } +} diff --git a/app/src/main/res/drawable/ic_add_24.xml b/app/src/main/res/drawable/ic_add_24.xml index c056f550e..91ccc34d8 100644 --- a/app/src/main/res/drawable/ic_add_24.xml +++ b/app/src/main/res/drawable/ic_add_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_copy_24.xml b/app/src/main/res/drawable/ic_copy_24.xml index 65bb96df5..35480bed7 100644 --- a/app/src/main/res/drawable/ic_copy_24.xml +++ b/app/src/main/res/drawable/ic_copy_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_details_24.xml b/app/src/main/res/drawable/ic_details_24.xml index 525ec5618..ea9ffe732 100644 --- a/app/src/main/res/drawable/ic_details_24.xml +++ b/app/src/main/res/drawable/ic_details_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_edit_24.xml b/app/src/main/res/drawable/ic_edit_24.xml index 9ce54759b..06285a565 100644 --- a/app/src/main/res/drawable/ic_edit_24.xml +++ b/app/src/main/res/drawable/ic_edit_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_import_24.xml b/app/src/main/res/drawable/ic_import_24.xml new file mode 100644 index 000000000..9cfbef4c0 --- /dev/null +++ b/app/src/main/res/drawable/ic_import_24.xml @@ -0,0 +1,11 @@ + + + + diff --git a/app/src/main/res/drawable/ic_play_next_24.xml b/app/src/main/res/drawable/ic_play_next_24.xml index df1a8dd79..b507eea91 100644 --- a/app/src/main/res/drawable/ic_play_next_24.xml +++ b/app/src/main/res/drawable/ic_play_next_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_playlist_24.xml b/app/src/main/res/drawable/ic_playlist_24.xml index d92e150b1..e24a5e217 100644 --- a/app/src/main/res/drawable/ic_playlist_24.xml +++ b/app/src/main/res/drawable/ic_playlist_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="24"> + diff --git a/app/src/main/res/drawable/ic_playlist_add_24.xml b/app/src/main/res/drawable/ic_playlist_add_24.xml index 6d0cfca3f..fba53c9fd 100644 --- a/app/src/main/res/drawable/ic_playlist_add_24.xml +++ b/app/src/main/res/drawable/ic_playlist_add_24.xml @@ -2,11 +2,11 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_queue_add_24.xml b/app/src/main/res/drawable/ic_queue_add_24.xml index a9e7e0ac3..d0ea17445 100644 --- a/app/src/main/res/drawable/ic_queue_add_24.xml +++ b/app/src/main/res/drawable/ic_queue_add_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_save_24.xml b/app/src/main/res/drawable/ic_save_24.xml index 4fc73a9f3..2fa6cd2e4 100644 --- a/app/src/main/res/drawable/ic_save_24.xml +++ b/app/src/main/res/drawable/ic_save_24.xml @@ -2,11 +2,11 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_share_24.xml b/app/src/main/res/drawable/ic_share_24.xml index 17485830b..816d28711 100644 --- a/app/src/main/res/drawable/ic_share_24.xml +++ b/app/src/main/res/drawable/ic_share_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_shuffle_off_24.xml b/app/src/main/res/drawable/ic_shuffle_off_24.xml index d73a3c489..28a688e1d 100644 --- a/app/src/main/res/drawable/ic_shuffle_off_24.xml +++ b/app/src/main/res/drawable/ic_shuffle_off_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ic_shuffle_on_24.xml b/app/src/main/res/drawable/ic_shuffle_on_24.xml index 1e4330f55..52d82252f 100644 --- a/app/src/main/res/drawable/ic_shuffle_on_24.xml +++ b/app/src/main/res/drawable/ic_shuffle_on_24.xml @@ -2,10 +2,10 @@ - + android:viewportHeight="960"> + diff --git a/app/src/main/res/drawable/ui_selection_badge_bg.xml b/app/src/main/res/drawable/ui_selection_badge_bg.xml index d6ae300cc..88a78c3bb 100644 --- a/app/src/main/res/drawable/ui_selection_badge_bg.xml +++ b/app/src/main/res/drawable/ui_selection_badge_bg.xml @@ -1,8 +1,7 @@ - + diff --git a/app/src/main/res/layout-h480dp/fragment_playback_panel.xml b/app/src/main/res/layout-h480dp/fragment_playback_panel.xml index e68de3423..4157231ac 100644 --- a/app/src/main/res/layout-h480dp/fragment_playback_panel.xml +++ b/app/src/main/res/layout-h480dp/fragment_playback_panel.xml @@ -16,7 +16,7 @@ app:title="@string/lbl_playback" tools:subtitle="@string/lbl_all_songs" /> - + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-h600dp/item_detail_header.xml b/app/src/main/res/layout-h600dp/item_detail_header.xml index e94d8538f..cdaf0e484 100644 --- a/app/src/main/res/layout-h600dp/item_detail_header.xml +++ b/app/src/main/res/layout-h600dp/item_detail_header.xml @@ -4,18 +4,19 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="@dimen/spacing_medium" android:paddingStart="@dimen/spacing_medium" + android:paddingTop="@dimen/spacing_medium" android:paddingEnd="@dimen/spacing_medium" android:paddingBottom="@dimen/spacing_mid_medium"> + - - - \ No newline at end of file + diff --git a/app/src/main/res/layout-sw600dp/item_detail_header.xml b/app/src/main/res/layout-sw600dp/item_detail_header.xml index 84632e573..4b354bc58 100644 --- a/app/src/main/res/layout-sw600dp/item_detail_header.xml +++ b/app/src/main/res/layout-sw600dp/item_detail_header.xml @@ -10,9 +10,9 @@ diff --git a/app/src/main/res/layout-sw600dp/item_playback_song.xml b/app/src/main/res/layout-sw600dp/item_playback_song.xml new file mode 100644 index 000000000..9ce0bcf47 --- /dev/null +++ b/app/src/main/res/layout-sw600dp/item_playback_song.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw840dp/item_detail_header.xml b/app/src/main/res/layout-sw840dp/item_detail_header.xml index 87dcf941e..d66af44bb 100644 --- a/app/src/main/res/layout-sw840dp/item_detail_header.xml +++ b/app/src/main/res/layout-sw840dp/item_detail_header.xml @@ -9,10 +9,10 @@ + + + + diff --git a/app/src/main/res/layout/design_bottom_sheet_dialog.xml b/app/src/main/res/layout/design_bottom_sheet_dialog.xml index bb70eccbb..3a72a5d9d 100644 --- a/app/src/main/res/layout/design_bottom_sheet_dialog.xml +++ b/app/src/main/res/layout/design_bottom_sheet_dialog.xml @@ -1,5 +1,4 @@ - - - - - - + android:fitsSystemWindows="true"> - + + + - + diff --git a/app/src/main/res/layout/dialog_delete_playlist.xml b/app/src/main/res/layout/dialog_delete_playlist.xml index 4987c3290..1fba917ff 100644 --- a/app/src/main/res/layout/dialog_delete_playlist.xml +++ b/app/src/main/res/layout/dialog_delete_playlist.xml @@ -1,11 +1,11 @@ \ No newline at end of file + tools:text="Delete Playlist 16? This cannot be undone." /> \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_error_details.xml b/app/src/main/res/layout/dialog_error_details.xml index 729c17d0b..e19d930ab 100644 --- a/app/src/main/res/layout/dialog_error_details.xml +++ b/app/src/main/res/layout/dialog_error_details.xml @@ -1,24 +1,23 @@ - + app:layout_constraintTop_toTopOf="parent"> @@ -56,10 +55,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" - app:icon="@drawable/ic_copy_24" android:layout_margin="@dimen/spacing_small" + android:src="@drawable/ic_code_24" app:backgroundTint="?attr/colorPrimaryContainer" - android:src="@drawable/ic_code_24" /> + app:icon="@drawable/ic_copy_24" /> diff --git a/app/src/main/res/layout/dialog_music_dirs.xml b/app/src/main/res/layout/dialog_music_dirs.xml index fa48b8a9c..0885dbc22 100644 --- a/app/src/main/res/layout/dialog_music_dirs.xml +++ b/app/src/main/res/layout/dialog_music_dirs.xml @@ -30,8 +30,8 @@ android:layout_marginTop="@dimen/spacing_tiny" android:layout_marginEnd="@dimen/spacing_large" android:gravity="center" - app:layout_constraintTop_toBottomOf="@+id/dirs_mode_header" app:checkedButton="@+id/dirs_mode_exclude" + app:layout_constraintTop_toBottomOf="@+id/dirs_mode_header" app:selectionRequired="true" app:singleSelection="true"> @@ -41,8 +41,8 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - tools:icon="@drawable/ic_check_24" - android:text="@string/set_dirs_mode_exclude" /> + android:text="@string/set_dirs_mode_exclude" + tools:icon="@drawable/ic_check_24" /> + app:layout_constraintTop_toBottomOf="@+id/dirs_mode_desc" /> + android:contentDescription="@string/lbl_add" + app:icon="@drawable/ic_add_24" + app:layout_constraintEnd_toEndOf="@+id/dirs_list_header" + app:layout_constraintTop_toBottomOf="@+id/dirs_list_header_divider" /> + app:layout_constraintTop_toTopOf="@+id/dirs_recycler" /> diff --git a/app/src/main/res/layout/dialog_playlist_export.xml b/app/src/main/res/layout/dialog_playlist_export.xml new file mode 100644 index 000000000..6809ad38d --- /dev/null +++ b/app/src/main/res/layout/dialog_playlist_export.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_playlist_name.xml b/app/src/main/res/layout/dialog_playlist_name.xml index 5d237fd74..f181cd72e 100644 --- a/app/src/main/res/layout/dialog_playlist_name.xml +++ b/app/src/main/res/layout/dialog_playlist_name.xml @@ -1,12 +1,12 @@ + android:layout_height="match_parent" + android:paddingBottom="@dimen/spacing_tiny"> + android:orientation="vertical" + android:paddingBottom="@dimen/spacing_tiny"> + app:menu="@menu/toolbar_selection" + app:navigationIcon="@drawable/ic_close_24" /> + app:menu="@menu/toolbar_edit" + app:navigationIcon="@drawable/ic_close_24" /> diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index f1b5c8c80..d8344e9bb 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -8,6 +8,7 @@ android:background="?attr/colorSurface" android:transitionGroup="true"> + @@ -31,8 +32,8 @@ android:layout_height="wrap_content" android:clickable="true" android:focusable="true" - app:navigationIcon="@drawable/ic_close_24" - app:menu="@menu/toolbar_selection" /> + app:menu="@menu/toolbar_selection" + app:navigationIcon="@drawable/ic_close_24" /> @@ -70,8 +71,8 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="@dimen/spacing_medium" - android:visibility="invisible" - android:fitsSystemWindows="true"> + android:fitsSystemWindows="true" + android:visibility="invisible"> @@ -147,17 +148,33 @@ - - + + + + android:layout_gravity="bottom|end" + android:clickable="true" + android:focusable="true" + android:gravity="bottom|end" + app:sdMainFabAnimationRotateAngle="135" + app:sdMainFabClosedIconColor="@android:color/white" + app:sdMainFabClosedSrc="@drawable/ic_add_24"/> + + diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml index 98328654d..0e85a7e51 100644 --- a/app/src/main/res/layout/fragment_main.xml +++ b/app/src/main/res/layout/fragment_main.xml @@ -13,11 +13,13 @@ android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" + app:defaultNavHost="true" app:layout_behavior="org.oxycblt.auxio.ui.BottomSheetContentBehavior" app:navGraph="@navigation/inner" - app:defaultNavHost="true" tools:layout="@layout/fragment_home" /> + + + android:layout_height="@dimen/size_bottom_sheet_bar" + android:contentDescription="@string/desc_queue_bar"> + + diff --git a/app/src/main/res/layout/fragment_playback_panel.xml b/app/src/main/res/layout/fragment_playback_panel.xml index 857cb7545..050d2b86b 100644 --- a/app/src/main/res/layout/fragment_playback_panel.xml +++ b/app/src/main/res/layout/fragment_playback_panel.xml @@ -16,7 +16,8 @@ app:title="@string/lbl_playback" tools:subtitle="@string/lbl_all_songs" /> - - - - \ No newline at end of file + diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index d8eba32d7..dcaf57b1b 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -55,8 +55,8 @@ android:layout_height="wrap_content" android:clickable="true" android:focusable="true" - app:navigationIcon="@drawable/ic_close_24" - app:menu="@menu/toolbar_selection" /> + app:menu="@menu/toolbar_selection" + app:navigationIcon="@drawable/ic_close_24" /> diff --git a/app/src/main/res/layout/item_album_song.xml b/app/src/main/res/layout/item_album_song.xml index 3d495dd40..0e1fc4254 100644 --- a/app/src/main/res/layout/item_album_song.xml +++ b/app/src/main/res/layout/item_album_song.xml @@ -26,9 +26,9 @@ android:id="@+id/song_track_placeholder" android:layout_width="match_parent" android:layout_height="match_parent" - android:src="@drawable/ic_song_24" - android:scaleType="center" android:contentDescription="@string/def_track" + android:scaleType="center" + android:src="@drawable/ic_song_24" android:visibility="invisible" app:tint="@color/sel_on_cover_bg" tools:ignore="ContentDescription" /> diff --git a/app/src/main/res/layout/item_detail_header.xml b/app/src/main/res/layout/item_detail_header.xml index 56c756f38..0ea6a4111 100644 --- a/app/src/main/res/layout/item_detail_header.xml +++ b/app/src/main/res/layout/item_detail_header.xml @@ -5,16 +5,16 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="@dimen/spacing_medium" android:paddingStart="@dimen/spacing_medium" + android:paddingTop="@dimen/spacing_medium" android:paddingEnd="@dimen/spacing_medium" android:paddingBottom="@dimen/spacing_mid_medium"> @@ -54,9 +54,9 @@ android:layout_marginEnd="@dimen/spacing_mid_medium" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - tools:visibility="gone" app:layout_constraintStart_toEndOf="@+id/disc_cover" app:layout_constraintTop_toBottomOf="@+id/disc_number" - tools:text="Part 1" /> + tools:text="Part 1" + tools:visibility="gone" /> diff --git a/app/src/main/res/layout/item_edit_header.xml b/app/src/main/res/layout/item_edit_header.xml index e3bbb9009..8894c79b0 100644 --- a/app/src/main/res/layout/item_edit_header.xml +++ b/app/src/main/res/layout/item_edit_header.xml @@ -3,17 +3,17 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" + android:layout_height="wrap_content" android:background="?attr/colorSurface" - android:orientation="horizontal" - android:layout_height="wrap_content"> + android:orientation="horizontal"> diff --git a/app/src/main/res/layout/item_header.xml b/app/src/main/res/layout/item_header.xml index 4adf76f0c..66d4b8e45 100644 --- a/app/src/main/res/layout/item_header.xml +++ b/app/src/main/res/layout/item_header.xml @@ -1,9 +1,9 @@ \ No newline at end of file + tools:text="Songs" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_menu_option.xml b/app/src/main/res/layout/item_menu_option.xml index 894882598..ad603d078 100644 --- a/app/src/main/res/layout/item_menu_option.xml +++ b/app/src/main/res/layout/item_menu_option.xml @@ -3,13 +3,13 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@android:id/title" + style="@style/Widget.Auxio.TextView.Icon.Clickable" android:layout_width="match_parent" android:layout_height="wrap_content" android:clickable="true" android:focusable="true" android:padding="@dimen/spacing_medium" android:textColor="@color/sel_selectable_text_primary" - style="@style/Widget.Auxio.TextView.Icon.Clickable" app:drawableStartCompat="@drawable/ic_edit_24" app:drawableTint="@color/sel_activatable_icon" tools:text="Songs" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_music_dir.xml b/app/src/main/res/layout/item_music_dir.xml index 48dbddfd8..ae1082de6 100644 --- a/app/src/main/res/layout/item_music_dir.xml +++ b/app/src/main/res/layout/item_music_dir.xml @@ -4,10 +4,10 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="@dimen/spacing_small" - android:paddingBottom="@dimen/spacing_small" android:gravity="center" - android:orientation="horizontal"> + android:orientation="horizontal" + android:paddingTop="@dimen/spacing_small" + android:paddingBottom="@dimen/spacing_small"> + app:layout_constraintTop_toTopOf="parent"> @@ -37,12 +37,12 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="@dimen/spacing_mid_medium" + android:text="@string/lbl_new_playlist" android:textColor="@color/sel_selectable_text_primary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/picker_image" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintVertical_chainStyle="packed" - android:text="@string/lbl_new_playlist" /> + app:layout_constraintVertical_chainStyle="packed" /> diff --git a/app/src/main/res/layout/item_playback_song.xml b/app/src/main/res/layout/item_playback_song.xml new file mode 100644 index 000000000..3e8c0c6a1 --- /dev/null +++ b/app/src/main/res/layout/item_playback_song.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_song_property.xml b/app/src/main/res/layout/item_song_property.xml index 5334756bd..893eab015 100644 --- a/app/src/main/res/layout/item_song_property.xml +++ b/app/src/main/res/layout/item_song_property.xml @@ -1,16 +1,16 @@ + app:expandedHintEnabled="false" + tools:hint="@string/lbl_path"> + android:orientation="horizontal"> diff --git a/app/src/main/res/layout/item_sort_mode.xml b/app/src/main/res/layout/item_sort_mode.xml index 7d8129737..79c9d483f 100644 --- a/app/src/main/res/layout/item_sort_mode.xml +++ b/app/src/main/res/layout/item_sort_mode.xml @@ -17,8 +17,8 @@ android:layout_marginStart="@dimen/spacing_mid_medium" android:layout_marginEnd="@dimen/spacing_mid_medium" android:clickable="false" - android:focusable="false" android:drawableTint="?attr/colorControlNormal" + android:focusable="false" android:paddingStart="@dimen/spacing_medium" android:textAlignment="viewStart" android:textAppearance="@style/TextAppearance.Auxio.BodyLarge" diff --git a/app/src/main/res/layout/view_preference_switch.xml b/app/src/main/res/layout/view_preference_switch.xml index 51b1df5ad..ba3fd967a 100644 --- a/app/src/main/res/layout/view_preference_switch.xml +++ b/app/src/main/res/layout/view_preference_switch.xml @@ -2,4 +2,4 @@ \ No newline at end of file + android:layout_height="wrap_content" /> \ No newline at end of file diff --git a/app/src/main/res/menu/album.xml b/app/src/main/res/menu/album.xml index f560baefc..cc3f9e24c 100644 --- a/app/src/main/res/menu/album.xml +++ b/app/src/main/res/menu/album.xml @@ -2,34 +2,34 @@

+ android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_parent_detail" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_artist_24" + android:title="@string/lbl_artist_details" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/album_song.xml b/app/src/main/res/menu/album_song.xml index fdbc3fc5f..3b68c0766 100644 --- a/app/src/main/res/menu/album_song.xml +++ b/app/src/main/res/menu/album_song.xml @@ -2,34 +2,34 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_artist_24" + android:title="@string/lbl_artist_details" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_song_detail" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/artist_album.xml b/app/src/main/res/menu/artist_album.xml index 8c159d9c6..3ec1b90eb 100644 --- a/app/src/main/res/menu/artist_album.xml +++ b/app/src/main/res/menu/artist_album.xml @@ -2,30 +2,30 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_parent_detail" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/artist_song.xml b/app/src/main/res/menu/artist_song.xml index 803a12785..8a6b33c0b 100644 --- a/app/src/main/res/menu/artist_song.xml +++ b/app/src/main/res/menu/artist_song.xml @@ -2,34 +2,34 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_album_24" + android:title="@string/lbl_album_details" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_song_detail" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/detail_album.xml b/app/src/main/res/menu/detail_album.xml index 742abdb11..4dd418008 100644 --- a/app/src/main/res/menu/detail_album.xml +++ b/app/src/main/res/menu/detail_album.xml @@ -2,30 +2,30 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_artist_24" + android:title="@string/lbl_artist_details" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/detail_parent.xml b/app/src/main/res/menu/detail_parent.xml index a6a1b6d09..99f35f8ba 100644 --- a/app/src/main/res/menu/detail_parent.xml +++ b/app/src/main/res/menu/detail_parent.xml @@ -2,26 +2,26 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/detail_playlist.xml b/app/src/main/res/menu/detail_playlist.xml index 178588c3b..cea8e98bd 100644 --- a/app/src/main/res/menu/detail_playlist.xml +++ b/app/src/main/res/menu/detail_playlist.xml @@ -2,30 +2,30 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_edit_24" + android:title="@string/lbl_rename" /> + android:icon="@drawable/ic_delete_24" + android:title="@string/lbl_delete" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/new_playlist_actions.xml b/app/src/main/res/menu/new_playlist_actions.xml new file mode 100644 index 000000000..b50413e5d --- /dev/null +++ b/app/src/main/res/menu/new_playlist_actions.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/app/src/main/res/menu/parent.xml b/app/src/main/res/menu/parent.xml index cae1e0c53..b431eb7b5 100644 --- a/app/src/main/res/menu/parent.xml +++ b/app/src/main/res/menu/parent.xml @@ -2,31 +2,31 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_parent_detail" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/playback_song.xml b/app/src/main/res/menu/playback_song.xml index 2cfc524b2..87061766b 100644 --- a/app/src/main/res/menu/playback_song.xml +++ b/app/src/main/res/menu/playback_song.xml @@ -7,20 +7,20 @@ android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_artist_24" + android:title="@string/lbl_artist_details" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/playlist.xml b/app/src/main/res/menu/playlist.xml index af3277d8a..c56c2f799 100644 --- a/app/src/main/res/menu/playlist.xml +++ b/app/src/main/res/menu/playlist.xml @@ -2,34 +2,42 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_parent_detail" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_edit_24" + android:title="@string/lbl_rename" /> + + + android:icon="@drawable/ic_delete_24" + android:title="@string/lbl_delete" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/playlist_song.xml b/app/src/main/res/menu/playlist_song.xml index 934d8b514..c60b57f89 100644 --- a/app/src/main/res/menu/playlist_song.xml +++ b/app/src/main/res/menu/playlist_song.xml @@ -2,34 +2,34 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_artist_24" + android:title="@string/lbl_artist_details" /> + android:icon="@drawable/ic_album_24" + android:title="@string/lbl_album_details" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_song_detail" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/selection.xml b/app/src/main/res/menu/selection.xml index 1d4f3d94d..61749966e 100644 --- a/app/src/main/res/menu/selection.xml +++ b/app/src/main/res/menu/selection.xml @@ -3,28 +3,28 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> + android:title="@string/lbl_play" + app:showAsAction="never" /> + android:title="@string/lbl_shuffle" + app:showAsAction="never" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/song.xml b/app/src/main/res/menu/song.xml index d82272d49..fa9f28538 100644 --- a/app/src/main/res/menu/song.xml +++ b/app/src/main/res/menu/song.xml @@ -2,38 +2,38 @@ + android:icon="@drawable/ic_play_24" + android:title="@string/lbl_play" /> + android:icon="@drawable/ic_shuffle_off_24" + android:title="@string/lbl_shuffle" /> + android:icon="@drawable/ic_play_next_24" + android:title="@string/lbl_play_next" /> + android:icon="@drawable/ic_queue_add_24" + android:title="@string/lbl_queue_add" /> + android:icon="@drawable/ic_playlist_add_24" + android:title="@string/lbl_playlist_add" /> + android:icon="@drawable/ic_artist_24" + android:title="@string/lbl_artist_details" /> + android:icon="@drawable/ic_album_24" + android:title="@string/lbl_album_details" /> + android:icon="@drawable/ic_details_24" + android:title="@string/lbl_song_detail" /> + android:icon="@drawable/ic_share_24" + android:title="@string/lbl_share" /> \ No newline at end of file diff --git a/app/src/main/res/menu/toolbar_edit.xml b/app/src/main/res/menu/toolbar_edit.xml index 10ac3d9ef..c3436fee7 100644 --- a/app/src/main/res/menu/toolbar_edit.xml +++ b/app/src/main/res/menu/toolbar_edit.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> + app:showAsAction="always" /> \ No newline at end of file diff --git a/app/src/main/res/menu/toolbar_selection.xml b/app/src/main/res/menu/toolbar_selection.xml index e1cf43ef0..dadf1e709 100644 --- a/app/src/main/res/menu/toolbar_selection.xml +++ b/app/src/main/res/menu/toolbar_selection.xml @@ -3,14 +3,14 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> + android:title="@string/lbl_play_next" + app:showAsAction="ifRoom" /> + android:title="@string/lbl_playlist_add" + app:showAsAction="ifRoom" /> + @@ -180,6 +183,9 @@ + @@ -376,6 +382,9 @@ + @@ -404,6 +413,13 @@ + + + + + + + + + الغاء التنسيق الحجم - المسار إحصائيات المكتبة معدل البت - اسم الملف تجميع مباشر تجميعات خصائص الاغنية diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index ca6f6fafd..51bb12461 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -32,7 +32,6 @@ اذهب للفنان عرض والتحكم في تشغيل الموسيقى خلط - اسم الملف خلط الكل إلغاء حفظ diff --git a/app/src/main/res/values-be/strings.xml b/app/src/main/res/values-be/strings.xml index 0084fbd04..28a0b7797 100644 --- a/app/src/main/res/values-be/strings.xml +++ b/app/src/main/res/values-be/strings.xml @@ -83,10 +83,8 @@ Чарга Перайсці да альбома Перайсці да выканаўцы - Імя файла Праглядзіце ўласцівасці Уласцівасці песні - Бацькоўскі шлях Фармат Перамяшаць усё Бітрэйт @@ -304,4 +302,21 @@ Скапіравана Інфармацыя пра памылку Справаздача пра памылку + Няма альбомаў + Дэма + Дэманстрацыі + Імпартаваны плэйліст + Шлях + Немагчыма імпартаваць плэйліст з гэтага файла + Пусты плэйліст + Абсалютны + Імпарт + Выкарыстоўваць шляхі, сумяшчальныя з Windows + Экспарт + Адносны + Плэйліст імпартаваны + Стыль шляху + Плэйліст экспартаваны + Экспартаваць плэйліст + Немагчыма экспартаваць плэйліст ў гэты файл \ No newline at end of file diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 3a2ef1255..57d8ea84a 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -185,8 +185,6 @@ Přehrát ze zobrazené položky Zobrazit vlastnosti Vlastnosti skladby - Název souboru - Nadřazená cesta Formát Velikost Přenosová rychlost @@ -315,4 +313,21 @@ Informace o chybě Zkopírovat Nahlásit + Žádná alba + Demo + Dema + Importovaný seznam skladeb + Cesta + Prázdný seznam skladeb + Nepodařilo se importovat seznam skladeb z tohoto souboru + Absolutní + Použít cesty kompatibilní s Windows + Export + Relativní + Styl cesty + Exportovat seznam skladeb + Nepodařilo se exportovat seznam skladeb do tohoto souboru + Import + Seznam skladeb importován + Seznam skladeb exportován \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 35e2abb16..32626f27c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -179,8 +179,6 @@ Abtastrate Eigenschaften ansehen Lied-Eigenschaften - Dateiname - Elternpfad Format Größe Bitrate @@ -306,4 +304,11 @@ Kopiert Melden Fehlerinformation + Keine Alben + Demo + Demos + Importierte Wiedergabeliste + Pfad + Wiedergabeliste konnte nicht aus dieser Datei importiert werden + Leere Wiedergabeliste \ No newline at end of file diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index b5730db8e..039c864ec 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -80,7 +80,6 @@ %d kbps Πρόσθεση Ιδιότητες τραγουδιού - Όνομα αρχείου Προβολή Ιδιοτήτων Στατιστικά συλλογής Ζωντανό άλμπουμ diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index a4a109704..fbf304499 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -14,7 +14,7 @@ Buscar Filtrar Todo - Organizar + Ordenar Nombre Artista Álbum @@ -43,7 +43,7 @@ Desarrollado por Alexander Capehart Ajustes - Aspecto y sensación + Aspecto y Comportamiento Tema Automático Claro @@ -52,31 +52,31 @@ Tema negro Usar un tema completamente negro Pantalla - Pestañas de biblioteca + Pestañas de la biblioteca Cambiar visibilidad y orden de las pestañas de la biblioteca Carátulas redondeadas - Habilite las esquinas redondeadas en los elementos adicionales de la interfaz del usuario (requiere que las portadas de los álbumes estén redondeadas) - Usar acciones de notificación alternativas + Habilitar las esquinas redondeadas en los elementos adicionales de la interfaz del usuario (requiere que las portadas de los álbumes estén redondeadas) + Usar acciones de notificación personalizadas Sonido Estrategia de la ganancia de la repetición - Por pista - Por álbum + Preferir pista + Preferir álbum Preferir el álbum si se está en reproducción - Comportamiento + Personalizar Cuando se está reproduciendo de la biblioteca Recordar mezcla - Mantener mezcla cuando se reproduce una nueva canción - Rebobinar atrás - Rebobinar al saltar a la canción anterior - Pausa en repetición - Pausa cuando se repite una canción + Mantener mezcla activada cuando se reproduce una nueva canción + Rebobinar antes de saltar al anterior + Rebobinar antes de saltar a la canción anterior + Pausar al repetir + Pausar cuando se repite una canción Contenido Guardar estado de reproducción - Guardar el estado de reproduccion ahora + Guardar el estado de reproducción ahora Actualizar música Recargar la biblioteca musical, utilizando las etiquetas en caché cuando sea posible - Sin música + No se ha encontrado música Falló la carga de música Auxio necesita permiso para leer su biblioteca de música No se encontró ninguna aplicación que pueda manejar esta tarea @@ -89,12 +89,12 @@ Saltar a la siguiente canción Saltar a la última canción Cambiar modo de repetición - Act/des mezcla - Mezclar todo + Activar o desactivar mezcla + Mezclar todas las canciones Quitar canción de la cola Mover canción en la cola Mover pestaña - Borrar historial de búsqueda + Borrar búsqueda Quitar carpeta Icono de Auxio Carátula de álbum @@ -177,11 +177,11 @@ Frecuencia de muestreo Cancelar Reproducción automática con auriculares - Reestablecer el estado de reproducción - Reestablecer el estado de reproducción guardado previamente (si existe) + Restablecer el estado de reproducción + Restablecer el estado de reproducción guardado previamente (si existe) Carpetas de música Gestionar de dónde se cargará la música - La músicasolo se cargará de las carpetas que añadas. + La música solo se cargará de las carpetas que añadas. Dinámico Disco %d Reproducción extendidas (EPs) @@ -193,9 +193,8 @@ Pistas de audio Mixtapes (recopilación de canciones) Mixtape (recopilación de canciones) - Remezcla - Nombre de archivo - Siempre empezar la reproducción cuando se conectan unos auriculares (puede no funcionar en todos los dispositivos) + Remezclas + Siempre empezar la reproducción cuando se conecten auriculares (puede no funcionar en todos los dispositivos) Pre-amp ReplayGain El pre-amp se aplica al ajuste existente durante la reproducción Ajuste con etiquetas @@ -206,7 +205,7 @@ Álbum en directo Single en directo Compilación - Directo + En directo Audio MPEG-1 Audio MPEG-4 %d kbps @@ -214,23 +213,22 @@ EP en directo Single remix Compilaciones - EP remix - Directorio superior + EP de remixes Eliminar el estado de reproducción guardado previamente (si existe) Abrir la cola Género Estado limpiado Limpiar el estado de reproducción Separadores de varios valores - Excluye la música + Excluye los archivos que no sean música Configurar caracteres que denotan múltiples valores de la etiqueta Coma (,) Punto y coma (;) Barra oblicua (/) Recopilación en directo - Compilaciones de remezclas - Mezclas del DJ - Mezclas del DJ + Compilación de remezclas + Mezclas de DJ + Mezcla de DJ Ecualizador Portadas de álbumes Apagado @@ -251,7 +249,7 @@ %d artistas %d artistas - Imposible guardar el estado + No se pudo guardar el estado No se puede borrar el estado Borrar la caché de las etiquetas y recargar completamente la biblioteca musical (más lento, pero más completo) Volver a escanear la música @@ -297,11 +295,11 @@ Aparece en Compartir Sin disco - Carátula del álbum Force Square + Forzar carátulas de álbum cuadradas Recorta todas las portadas de los álbumes a una relación de aspecto 1:1 Canción Vista - Reproducir la canción por tí mismo + Reproducir la canción por sí misma Ordenar por Dirección Selección de imágenes @@ -310,4 +308,21 @@ Información sobre el error Copiado Informar + Sin álbumes + Demostración + Demostraciones + Lista de reproducción importada + Ruta + No se puede importar una lista de reproducción desde este archivo + Lista de reproducción vacía + Absoluto + Importar + Utilizar rutas compatibles con Windows + Exportar + Relativo + Lista de reproducción importada + Estilo de la ruta + Lista de reproducción exportada + Exportar lista de reproducción + No se puede exportar la lista de reproducción a este archivo \ No newline at end of file diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 262cfde7b..0bbdde9ec 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -43,8 +43,6 @@ Siirry albumiin Näytä ominaisuudet Kappaleen ominaisuudet - Tiedostonimi - Ylätason polku Muoto Koko Bittitaajuus diff --git a/app/src/main/res/values-fil/strings.xml b/app/src/main/res/values-fil/strings.xml index d7e2bdc59..bc3ad9dc4 100644 --- a/app/src/main/res/values-fil/strings.xml +++ b/app/src/main/res/values-fil/strings.xml @@ -46,7 +46,6 @@ Puntahan ang album Tignan ang katangian Katangian ng kanta - Pangalan ng file Pormat Laki Tulin ng mga bit diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 742007eb0..eaacbbc02 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -82,8 +82,6 @@ Débit binaire Utiliser une autre action de notification Taux d\'échantillonnage - Chemin parent - Nom du fichier Tout mélanger Annuler Enregistrer @@ -300,7 +298,7 @@ Chanson Voir Jouer la chanson par elle-même - Image de sélection + Image sélectionnée Trier par Direction Sélection @@ -308,4 +306,7 @@ Copié Signaler Info sur l\'erreur + Aucun album + Démo + Démos \ No newline at end of file diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index faf684102..d1a992526 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -53,11 +53,9 @@ Engadir á cola Excluir o que non é música Ir ao artista - Nome do arquivo Mesturar Mesturar todo Restablecer - Directorio superior Formato Tamaño Tasa de bits diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index 0384924fd..d29a3564e 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -61,14 +61,12 @@ एंड्रॉयड के लिए एक सीधा साधा, विवेकशील गाने बजाने वाला ऐप। नई प्लेलिस्ट अगला चलाएं - फ़ाइल का नाम लायब्रेरी टैब्स एल्बम से चलाएं सामग्री %d चयनित प्रारूप प्लेलिस्ट में जोड़ें - मुख्य पथ बिट-रेट रद्द करें सहेजें @@ -305,4 +303,21 @@ रिपोर्ट करें कापी किया गया और + कोई एल्बम नहीं + डेमो + डेमो + इम्पोर्टेड प्लेलिस्ट + पथ + इस फ़ाइल से प्लेलिस्ट इम्पोर्ट करने में असमर्थ + खाली प्लेलिस्ट + पूर्ण + इंपोर्ट करें + विंडोज़-संगत पथों का उपयोग करें + एक्सपोर्ट करें + सापेक्ष + प्लेलिस्ट इंपोर्ट की गयी + पथ शैली + प्लेलिस्ट एक्सपोर्ट की गई + प्लेलिस्ट एक्सपोर्ट करें + प्लेलिस्ट को इस फ़ाइल में एक्सपोर्ट करने में असमर्थ \ No newline at end of file diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 22bab4d29..0aa0251a7 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -40,8 +40,6 @@ Popis pjesama Reproduciraj sljedeću Svojstva pjesme - Naziv datoteke - Glavni direktorij Format Veličina Brzina prijenosa @@ -119,7 +117,7 @@ Slika žanra za %s Nepoznat izvođač Nepoznat žanr - Nema staze + Nema zvučnog zapisa Bez datuma Glazba se ne reproducira MPEG-1 zvuk @@ -301,4 +299,11 @@ Podaci greške Prijavi grešku Kopirano + Nema albuma + Uvezen popis pjesama + Staza + Demo snimka + Demo snimke + Nije bilo moguće uvesti popis pjesama iz ove datoteke + Prazan popis pjesama \ No newline at end of file diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index c92aa6abf..ad272228a 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -83,7 +83,6 @@ Keverés be/ki kapcsolása %s album borítója Visszajátszás - Szülő útvonal Mappa eltávolítása Lejátszólistához ad Formátum @@ -160,7 +159,6 @@ Inkább album, ha egyet játszik Zene frissítése Mégse - Fájl név Egyéni lejátszási sáv művelet A lejátszás mindig akkor indul el, ha a fejhallgató csatlakoztatva van (nem minden eszközön működik) Automatikus újratöltés diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 3b2486eb4..05c65a556 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -52,7 +52,6 @@ %d Album Properti lagu - Nama berkas Laju bit OK Batal @@ -65,7 +64,6 @@ Putar otomatis headset Selalu mulai memutar ketika headset tersambung (mungkin tidak berfungsi pada semua perangkat) Strategi ReplayGain - Path induk Ukuran Tingkat sampel Tab Pustaka diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 1a4bf8938..68d67a9de 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -181,8 +181,6 @@ Frequenza di campionamento Vedi proprietà Proprietà brano - Nome file - Directory superiore Formato Dimensione Bitrate diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index d74cc9319..ecdb73c14 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -131,7 +131,6 @@ רצועה תור מעבר לאומן - שם קובץ ערבוב המצב שוחזר אודות @@ -242,7 +241,6 @@ תמונת רשימת השמעה עבור %s אדום ירוק - נתיב ראשי לא ניתן לשחזר את המצב רצועה %d יצירת רשימת השמעה חדשה diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 7c011f04e..e3b8dc43c 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -57,7 +57,6 @@ 表示されたアイテムから再生 再生停止 - ファイル名 追加した日付け サンプルレート 降順 @@ -245,7 +244,6 @@ 初期 (高速読み込み) 再生中の場合はアルバムを優先 複数値セパレータ - 親パス 変更されるたびに音楽ライブラリをリロードします (永続的な通知が必要です) サウンドと再生の動作を構成する 戻る前に巻き戻す diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 0d9822a7f..78848acd3 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -163,7 +163,6 @@ 추가한 폴더에서만 음악을 불러옵니다. 곡 속성 속성 보기 - 파일 이름 샘플 속도 전송 속도 크기 @@ -195,7 +194,6 @@ 앰퍼샌드 (&) MPEG-1 오디오 추가한 날짜 - 상위 경로 맞춤형 재생 동작 버튼 반복 방식 대기열 열기 @@ -306,4 +304,9 @@ 복사했습니다. 오류 보고 오류 정보 + 앨범 없음 + 경로 + 데모 + 데모 + 빈 재생 목록 \ No newline at end of file diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 0b2138093..da150c3ea 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -36,7 +36,6 @@ Maišyti Pridėtas į eilę Dainų ypatybės - Failo pavadinimas Išsaugoti Apie Pridėti @@ -214,7 +213,6 @@ DJ miksas Gyvai kompiliacija Remikso kompiliacija - Pirminis kelias Išvalyti anksčiau išsaugotą grojimo būseną (jei yra) Daugiareikšmiai separatoriai Pasvirasis brūkšnys (/) @@ -304,4 +302,7 @@ Nukopijuota Daugiau Pranešti + Nėra albumų + Demo + Demos \ No newline at end of file diff --git a/app/src/main/res/values-ml/strings.xml b/app/src/main/res/values-ml/strings.xml index f1ae5be53..b93ec52f9 100644 --- a/app/src/main/res/values-ml/strings.xml +++ b/app/src/main/res/values-ml/strings.xml @@ -25,7 +25,6 @@ വലിപ്പം ചേർക്കുക ശരി - ഉത്ഭവ പാത റദ്ദാക്കുക വെളിച്ചം കുറിച്ച് diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index c276bd0bd..230f1fe37 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -192,8 +192,6 @@ Format Vis egenskaper Spor-egenskaper - Filnavn - Overnevnt sti Pause ved gjentagelse Rød diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index c0ecc5905..8c760d532 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -121,9 +121,7 @@ Annuleren Bibliotheek tabbladen Jaar - Ouderpad Lied eigenschappen - Bestandsnaam Voorkeur album als er een speelt Voorkeur titel Voorkeur album diff --git a/app/src/main/res/values-pa/strings.xml b/app/src/main/res/values-pa/strings.xml index 1d385c7bc..6176826db 100644 --- a/app/src/main/res/values-pa/strings.xml +++ b/app/src/main/res/values-pa/strings.xml @@ -55,7 +55,6 @@ ਐਲਬਮ \'ਤੇ ਜਾਓ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਵੇਖੋ ਗੀਤ ਦੀਆਂ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ - ਪੇਰੈਂਟ ਮਾਰਗ ਫਾਰਮੈਟ ਆਕਾਰ ਸ਼ਫਲ @@ -76,7 +75,6 @@ ਗੀਤ ਦੀ ਗਿਣਤੀ ਘਟਦੇ ਹੋਏ ਕਲਾਕਾਰ \'ਤੇ ਜਾਓ - ਫਾਈਲ ਦਾ ਨਾਮ ਬਿੱਟ ਰੇਟ ਸੈਂਪਲ ਰੇਟ ਸ਼ਾਮਿਲ ਕਰੋ @@ -298,4 +296,21 @@ ਤਰੁੱਟੀ ਦੀ ਜਾਣਕਾਰੀ ਕਾਪੀ ਕੀਤਾ ਗਿਆ ਰਿਪੋਰਟ ਕਰੋ + ਕੋਈ ਐਲਬਮ ਨਹੀਂ + ਡੈਮੋ + ਡੈਮੋ + ਇੰਪੋਰਟਡ ਪਲੇਲਿਸਟ + ਮਾਰਗ + ਇਸ ਫਾਈਲ ਤੋਂ ਪਲੇਲਿਸਟ ਨੂੰ ਆਯਾਤ ਕਰਨ ਵਿੱਚ ਅਸਮਰੱਥ + ਖਾਲੀ ਪਲੇਲਿਸਟ + ਪੂਰਨ + ਆਯਾਤ ਕਰੋ + ਵਿੰਡੋਜ਼-ਅਨੁਕੂਲ ਮਾਰਗਾਂ ਦੀ ਵਰਤੋਂ ਕਰੋ + ਨਿਰਯਾਤ ਕਰੋ + ਰਿਲੇਟਿਵ + ਪਲੇਲਿਸਟ ਆਯਾਤ ਕੀਤੀ ਗਈ + ਮਾਰਗ ਸਟਾਈਲ + ਪਲੇਲਿਸਟ ਨਿਰਯਾਤ ਕੀਤੀ ਗਈ + ਪਲੇਲਿਸਟ ਨਿਰਯਾਤ ਕਰੋ + ਪਲੇਲਿਸਟ ਨੂੰ ਇਸ ਫ਼ਾਈਲ ਵਿੱਚ ਨਿਰਯਾਤ ਕਰਨ ਵਿੱਚ ਅਸਮਰੱਥ \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 737838fe6..fa4993f8d 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -90,8 +90,6 @@ Autoodtwarzanie w słuchawkach Morski +%.1f dB - Nazwa pliku - Ścieżka katalogu Format Niebieskozielony Płyta %d diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 6716a415a..366aa1e2e 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -106,7 +106,6 @@ Artista Álbum Propriedades da música - Nome do arquivo Formato Tamanho Taxa de bits @@ -158,7 +157,6 @@ Ajuste em faixas sem metadados Reprodução automática em fones de ouvido Pré-amplificação da normalização de volume - Caminho principal OK Exibição Ativa cantos arredondados em elementos adicionais da interface do usuário diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index e02dbbe6c..2fa1582f3 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -115,7 +115,6 @@ Taxa de amostragem Salvar Separadores multi-valor - Nome do ficheiro Tamanho Propriedades Propriedades da música @@ -217,7 +216,6 @@ A carregar a sua biblioteca de músicas… (%1$d/%2$d) Retroceder antes de voltar Parar reprodução - Caminho principal Ativar cantos arredondados em elementos adicionais da interface do utilizador (requer que as capas dos álbuns sejam arredondadas) %d Selecionadas Misturas DJ diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index e892e2739..3ad8ebd47 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -103,10 +103,8 @@ Egalizator Bit rate Data adăugării - Calea principală Format Proprietățile cântecului - Numele fișierului Amestecare Adaugă Frecvența de eșantionare diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 2dc979122..cb7dd1a08 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -157,7 +157,6 @@ Внимание: Изменение предусиления на большое положительное значение может привести к появлению искажений на некоторых звуковых дорожках. Сведения Свойства трека - Путь Формат Размер Частота дискретизации @@ -165,7 +164,6 @@ Статистика библиотеки Восстановить состояние воспроизведения Продолжительность - Имя файла Мини-альбом Мини-альбомы Сингл @@ -313,4 +311,21 @@ Информация об ошибке Отчёт об ошибке Скопировано + Нет альбомов + Демо + Демонстрации + Импортированный плейлист + Путь + Невозможно импортировать плейлист из этого файла + Пустой плейлист + Абсолютный + Импорт + Использовать пути, совместимые с Windows + Экспорт + Относительный + Плейлист импортирован + Стиль пути + Плейлист экспортирован + Экспортировать плейлист + Невозможно экспортировать плейлист в этот файл \ No newline at end of file diff --git a/app/src/main/res/values-sl/strings.xml b/app/src/main/res/values-sl/strings.xml index 5d8da013d..1cbd74549 100644 --- a/app/src/main/res/values-sl/strings.xml +++ b/app/src/main/res/values-sl/strings.xml @@ -59,7 +59,6 @@ Shrani trenutno stanje predvajanja zdaj Preskoči na zadnjo pesem Ponovno naloži glasbeno knjižnico vsakič, ko se zazna sprememba (zahteva vztrajno obvestilo) - Pot do datoteke %d pesem %d pesmi @@ -79,7 +78,6 @@ Mešanice Izvajalec Pravilno razvrsti imena, ki se začnejo z številkami ali besedami, kot so \'the\' (najbolje deluje z angleško glasbo) - Ime datoteke Zelenkasto modra Vztrajnost Premešaj vse pesmi diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 16af4e8f1..2c9a072cb 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -52,7 +52,6 @@ Visa egenskaper Dela Egenskaper för låt - Överordnad mapp Format Storlek Samplingsfrekvens @@ -99,7 +98,6 @@ Disk Sortera Lägg till kö - Filnamn Lägg till Tillstånd tog bort Bithastighet diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 5e77b99ab..68997f497 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -52,10 +52,8 @@ %d albüm %d albümler - Dosya adı Özellikleri görüntüle Şarkı özellikleri - Ana yol Biçim Karıştır Hepsini karıştır diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index f4b12a5aa..9d8b54c34 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -54,7 +54,6 @@ %d альбомів %d альбомів - Ім\'я файлу Формат Добре Скасувати @@ -79,7 +78,6 @@ Збірки Збірка Концертний альбом - Шлях до каталогу Екран Рік Обкладинки альбомів @@ -310,4 +308,21 @@ Інформація про помилку Скопійовано Звіт + Альбомів немає + Демо + Демонстрації + Імпортований список відтворення + Шлях + Неможливо імпортувати список відтворення з цього файлу + Порожній список відтворення + Абсолютний + Імпорт + Використовувати шляхи, сумісні з Windows + Експорт + Відносний + Список відтворення імпортовано + Стиль шляху + Список відтворення експортовано + Експортувати список відтворення + Неможливо експортувати список відтворення в цей файл \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 51381f724..e0449d0bd 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -176,8 +176,6 @@ 音轨 查看属性 曲目属性 - 文件名 - 上级目录 格式 大小 比特率 @@ -304,4 +302,21 @@ 更多 已复制 错误信息 + 无专辑 + 演示 + 样曲 + 导入了播放列表 + 路径 + 清空播放列表 + 无法从此文件导入播放列表 + 绝对 + 导入 + 使用兼容 Windows 系统的路径 + 导出 + 相对 + 路径样式 + 导出播放列表 + 无法将播放列表导出到此文件 + 导入了播放列表 + 导出了播放列表 \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b46cd1c4a..c59791d5c 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -72,4 +72,5 @@ 專輯 單曲 單曲 + 在更多的用戶界面元素上啟用圓角(需要專輯封面也要設定圓角) \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 31700900b..045965a4d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -63,6 +63,10 @@ Mixtapes Mixtape + + Demo + + Demos DJ Mixes @@ -84,6 +88,12 @@ Playlist Playlists New playlist + Empty playlist + Imported playlist + Import + Import playlist + Export + Export playlist Rename Rename playlist Delete @@ -129,8 +139,7 @@ Share Song properties - File name - Parent path + Path Format @@ -152,6 +161,12 @@ Add + Path style + Absolute + Relative + + Use Windows-compatible paths + State saved @@ -182,7 +197,9 @@ Monitoring your music library for changes… Added to queue Playlist created + Playlist imported Playlist renamed + Playlist exported Playlist deleted Added to playlist Developed by Alexander Capehart @@ -305,6 +322,8 @@ No music found Music loading failed Auxio needs permission to read your music library + Unable to import a playlist from this file + Unable to export the playlist to this file No app found that can handle this task No folders @@ -353,6 +372,7 @@ No disc No track No songs + No albums No music playing diff --git a/app/src/main/res/xml/backup_descriptor.xml b/app/src/main/res/xml/backup_descriptor.xml index 587567dab..b977c9b69 100644 --- a/app/src/main/res/xml/backup_descriptor.xml +++ b/app/src/main/res/xml/backup_descriptor.xml @@ -1,5 +1,7 @@ - + diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xml index a95e572f9..32c6c4b64 100644 --- a/app/src/main/res/xml/data_extraction_rules.xml +++ b/app/src/main/res/xml/data_extraction_rules.xml @@ -2,9 +2,13 @@ - + - + \ No newline at end of file diff --git a/app/src/test/java/org/oxycblt/auxio/music/info/NameTest.kt b/app/src/test/java/org/oxycblt/auxio/music/info/NameTest.kt index fd80d51c4..078a1f154 100644 --- a/app/src/test/java/org/oxycblt/auxio/music/info/NameTest.kt +++ b/app/src/test/java/org/oxycblt/auxio/music/info/NameTest.kt @@ -18,30 +18,14 @@ package org.oxycblt.auxio.music.info -import io.mockk.every -import io.mockk.mockk import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals -import org.junit.Assert.assertTrue import org.junit.Test -import org.oxycblt.auxio.music.MusicSettings class NameTest { - @Test - fun name_simple_from_settings() { - val musicSettings = mockk { every { intelligentSorting } returns false } - assertTrue(Name.Known.Factory.from(musicSettings) is SimpleKnownName.Factory) - } - - @Test - fun name_intelligent_from_settings() { - val musicSettings = mockk { every { intelligentSorting } returns true } - assertTrue(Name.Known.Factory.from(musicSettings) is IntelligentKnownName.Factory) - } - @Test fun name_simple_withoutPunct() { - val name = SimpleKnownName("Loveless", null) + val name = Name.Known.SimpleFactory.parse("Loveless", null) assertEquals("Loveless", name.raw) assertEquals(null, name.sort) assertEquals("L", name.thumb) @@ -52,7 +36,7 @@ class NameTest { @Test fun name_simple_withPunct() { - val name = SimpleKnownName("alt-J", null) + val name = Name.Known.SimpleFactory.parse("alt-J", null) assertEquals("alt-J", name.raw) assertEquals(null, name.sort) assertEquals("A", name.thumb) @@ -63,7 +47,7 @@ class NameTest { @Test fun name_simple_oopsAllPunct() { - val name = SimpleKnownName("!!!", null) + val name = Name.Known.SimpleFactory.parse("!!!", null) assertEquals("!!!", name.raw) assertEquals(null, name.sort) assertEquals("!", name.thumb) @@ -74,7 +58,7 @@ class NameTest { @Test fun name_simple_spacedPunct() { - val name = SimpleKnownName("& Yet & Yet", null) + val name = Name.Known.SimpleFactory.parse("& Yet & Yet", null) assertEquals("& Yet & Yet", name.raw) assertEquals(null, name.sort) assertEquals("Y", name.thumb) @@ -85,7 +69,7 @@ class NameTest { @Test fun name_simple_withSort() { - val name = SimpleKnownName("The Smile", "Smile") + val name = Name.Known.SimpleFactory.parse("The Smile", "Smile") assertEquals("The Smile", name.raw) assertEquals("Smile", name.sort) assertEquals("S", name.thumb) @@ -96,7 +80,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withoutArticle_withoutNumerics() { - val name = IntelligentKnownName("Loveless", null) + val name = Name.Known.IntelligentFactory.parse("Loveless", null) assertEquals("Loveless", name.raw) assertEquals(null, name.sort) assertEquals("L", name.thumb) @@ -107,7 +91,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withoutArticle_withSpacedStartNumerics() { - val name = IntelligentKnownName("15 Step", null) + val name = Name.Known.IntelligentFactory.parse("15 Step", null) assertEquals("15 Step", name.raw) assertEquals(null, name.sort) assertEquals("#", name.thumb) @@ -121,7 +105,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withoutArticle_withPackedStartNumerics() { - val name = IntelligentKnownName("23Kid", null) + val name = Name.Known.IntelligentFactory.parse("23Kid", null) assertEquals("23Kid", name.raw) assertEquals(null, name.sort) assertEquals("#", name.thumb) @@ -135,7 +119,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withoutArticle_withSpacedMiddleNumerics() { - val name = IntelligentKnownName("Foo 1 2 Bar", null) + val name = Name.Known.IntelligentFactory.parse("Foo 1 2 Bar", null) assertEquals("Foo 1 2 Bar", name.raw) assertEquals(null, name.sort) assertEquals("F", name.thumb) @@ -158,7 +142,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withoutArticle_withPackedMiddleNumerics() { - val name = IntelligentKnownName("Foo12Bar", null) + val name = Name.Known.IntelligentFactory.parse("Foo12Bar", null) assertEquals("Foo12Bar", name.raw) assertEquals(null, name.sort) assertEquals("F", name.thumb) @@ -175,7 +159,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withoutArticle_withSpacedEndNumerics() { - val name = IntelligentKnownName("Foo 1", null) + val name = Name.Known.IntelligentFactory.parse("Foo 1", null) assertEquals("Foo 1", name.raw) assertEquals(null, name.sort) assertEquals("F", name.thumb) @@ -189,7 +173,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withoutArticle_withPackedEndNumerics() { - val name = IntelligentKnownName("Error404", null) + val name = Name.Known.IntelligentFactory.parse("Error404", null) assertEquals("Error404", name.raw) assertEquals(null, name.sort) assertEquals("E", name.thumb) @@ -203,7 +187,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withThe_withoutNumerics() { - val name = IntelligentKnownName("The National Anthem", null) + val name = Name.Known.IntelligentFactory.parse("The National Anthem", null) assertEquals("The National Anthem", name.raw) assertEquals(null, name.sort) assertEquals("N", name.thumb) @@ -214,7 +198,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withAn_withoutNumerics() { - val name = IntelligentKnownName("An Eagle in Your Mind", null) + val name = Name.Known.IntelligentFactory.parse("An Eagle in Your Mind", null) assertEquals("An Eagle in Your Mind", name.raw) assertEquals(null, name.sort) assertEquals("E", name.thumb) @@ -225,7 +209,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_withA_withoutNumerics() { - val name = IntelligentKnownName("A Song For Our Fathers", null) + val name = Name.Known.IntelligentFactory.parse("A Song For Our Fathers", null) assertEquals("A Song For Our Fathers", name.raw) assertEquals(null, name.sort) assertEquals("S", name.thumb) @@ -236,7 +220,7 @@ class NameTest { @Test fun name_intelligent_withPunct_withoutArticle_withoutNumerics() { - val name = IntelligentKnownName("alt-J", null) + val name = Name.Known.IntelligentFactory.parse("alt-J", null) assertEquals("alt-J", name.raw) assertEquals(null, name.sort) assertEquals("A", name.thumb) @@ -247,7 +231,7 @@ class NameTest { @Test fun name_intelligent_oopsAllPunct_withoutArticle_withoutNumerics() { - val name = IntelligentKnownName("!!!", null) + val name = Name.Known.IntelligentFactory.parse("!!!", null) assertEquals("!!!", name.raw) assertEquals(null, name.sort) assertEquals("!", name.thumb) @@ -258,7 +242,7 @@ class NameTest { @Test fun name_intelligent_withoutPunct_shortArticle_withNumerics() { - val name = IntelligentKnownName("the 1", null) + val name = Name.Known.IntelligentFactory.parse("the 1", null) assertEquals("the 1", name.raw) assertEquals(null, name.sort) assertEquals("#", name.thumb) @@ -269,7 +253,7 @@ class NameTest { @Test fun name_intelligent_spacedPunct_withoutArticle_withoutNumerics() { - val name = IntelligentKnownName("& Yet & Yet", null) + val name = Name.Known.IntelligentFactory.parse("& Yet & Yet", null) assertEquals("& Yet & Yet", name.raw) assertEquals(null, name.sort) assertEquals("Y", name.thumb) @@ -280,7 +264,7 @@ class NameTest { @Test fun name_intelligent_withPunct_withoutArticle_withNumerics() { - val name = IntelligentKnownName("Design : 2 : 3", null) + val name = Name.Known.IntelligentFactory.parse("Design : 2 : 3", null) assertEquals("Design : 2 : 3", name.raw) assertEquals(null, name.sort) assertEquals("D", name.thumb) @@ -300,7 +284,7 @@ class NameTest { @Test fun name_intelligent_oopsAllPunct_withoutArticle_oopsAllNumerics() { - val name = IntelligentKnownName("2 + 2 = 5", null) + val name = Name.Known.IntelligentFactory.parse("2 + 2 = 5", null) assertEquals("2 + 2 = 5", name.raw) assertEquals(null, name.sort) assertEquals("#", name.thumb) @@ -323,7 +307,7 @@ class NameTest { @Test fun name_intelligent_withSort() { - val name = IntelligentKnownName("The Smile", "Smile") + val name = Name.Known.IntelligentFactory.parse("The Smile", "Smile") assertEquals("The Smile", name.raw) assertEquals("Smile", name.sort) assertEquals("S", name.thumb) @@ -334,40 +318,40 @@ class NameTest { @Test fun name_equals_simple() { - val a = SimpleKnownName("The Same", "Same") - val b = SimpleKnownName("The Same", "Same") + val a = Name.Known.SimpleFactory.parse("The Same", "Same") + val b = Name.Known.SimpleFactory.parse("The Same", "Same") assertEquals(a, b) } @Test fun name_equals_differentSort() { - val a = SimpleKnownName("The Same", "Same") - val b = SimpleKnownName("The Same", null) + val a = Name.Known.SimpleFactory.parse("The Same", "Same") + val b = Name.Known.SimpleFactory.parse("The Same", null) assertNotEquals(a, b) assertNotEquals(a.hashCode(), b.hashCode()) } @Test fun name_equals_intelligent_differentTokens() { - val a = IntelligentKnownName("The Same", "Same") - val b = IntelligentKnownName("Same", "Same") + val a = Name.Known.IntelligentFactory.parse("The Same", "Same") + val b = Name.Known.IntelligentFactory.parse("Same", "Same") assertNotEquals(a, b) assertNotEquals(a.hashCode(), b.hashCode()) } @Test fun name_compareTo_simple_withoutSort_withoutArticle_withoutNumeric() { - val a = SimpleKnownName("A", null) - val b = SimpleKnownName("B", null) + val a = Name.Known.SimpleFactory.parse("A", null) + val b = Name.Known.SimpleFactory.parse("B", null) assertEquals(-1, a.compareTo(b)) } @Test fun name_compareTo_simple_withoutSort_withArticle_withoutNumeric() { - val a = SimpleKnownName("A Brain in a Bottle", null) - val b = SimpleKnownName("Acid Rain", null) - val c = SimpleKnownName("Boralis / Contrastellar", null) - val d = SimpleKnownName("Breathe In", null) + val a = Name.Known.SimpleFactory.parse("A Brain in a Bottle", null) + val b = Name.Known.SimpleFactory.parse("Acid Rain", null) + val c = Name.Known.SimpleFactory.parse("Boralis / Contrastellar", null) + val d = Name.Known.SimpleFactory.parse("Breathe In", null) assertEquals(-1, a.compareTo(b)) assertEquals(-1, a.compareTo(c)) assertEquals(-1, a.compareTo(d)) @@ -375,40 +359,40 @@ class NameTest { @Test fun name_compareTo_simple_withSort_withoutArticle_withNumeric() { - val a = SimpleKnownName("15 Step", null) - val b = SimpleKnownName("128 Harps", null) - val c = SimpleKnownName("1969", null) + val a = Name.Known.SimpleFactory.parse("15 Step", null) + val b = Name.Known.SimpleFactory.parse("128 Harps", null) + val c = Name.Known.SimpleFactory.parse("1969", null) assertEquals(1, a.compareTo(b)) assertEquals(-1, a.compareTo(c)) } @Test fun name_compareTo_simple_withPartialSort() { - val a = SimpleKnownName("A", "C") - val b = SimpleKnownName("B", null) + val a = Name.Known.SimpleFactory.parse("A", "C") + val b = Name.Known.SimpleFactory.parse("B", null) assertEquals(1, a.compareTo(b)) } @Test fun name_compareTo_simple_withSort() { - val a = SimpleKnownName("D", "A") - val b = SimpleKnownName("C", "B") + val a = Name.Known.SimpleFactory.parse("D", "A") + val b = Name.Known.SimpleFactory.parse("C", "B") assertEquals(-1, a.compareTo(b)) } @Test fun name_compareTo_intelligent_withoutSort_withoutArticle_withoutNumeric() { - val a = IntelligentKnownName("A", null) - val b = IntelligentKnownName("B", null) + val a = Name.Known.IntelligentFactory.parse("A", null) + val b = Name.Known.IntelligentFactory.parse("B", null) assertEquals(-1, a.compareTo(b)) } @Test fun name_compareTo_intelligent_withoutSort_withArticle_withoutNumeric() { - val a = IntelligentKnownName("A Brain in a Bottle", null) - val b = IntelligentKnownName("Acid Rain", null) - val c = IntelligentKnownName("Boralis / Contrastellar", null) - val d = IntelligentKnownName("Breathe In", null) + val a = Name.Known.IntelligentFactory.parse("A Brain in a Bottle", null) + val b = Name.Known.IntelligentFactory.parse("Acid Rain", null) + val c = Name.Known.IntelligentFactory.parse("Boralis / Contrastellar", null) + val d = Name.Known.IntelligentFactory.parse("Breathe In", null) assertEquals(1, a.compareTo(b)) assertEquals(1, a.compareTo(c)) assertEquals(-1, a.compareTo(d)) @@ -416,9 +400,9 @@ class NameTest { @Test fun name_compareTo_intelligent_withoutSort_withoutArticle_withNumeric() { - val a = IntelligentKnownName("15 Step", null) - val b = IntelligentKnownName("128 Harps", null) - val c = IntelligentKnownName("1969", null) + val a = Name.Known.IntelligentFactory.parse("15 Step", null) + val b = Name.Known.IntelligentFactory.parse("128 Harps", null) + val c = Name.Known.IntelligentFactory.parse("1969", null) assertEquals(-1, a.compareTo(b)) assertEquals(-1, b.compareTo(c)) assertEquals(-2, a.compareTo(c)) @@ -426,15 +410,15 @@ class NameTest { @Test fun name_compareTo_intelligent_withPartialSort_withoutArticle_withoutNumeric() { - val a = SimpleKnownName("A", "C") - val b = SimpleKnownName("B", null) + val a = Name.Known.SimpleFactory.parse("A", "C") + val b = Name.Known.SimpleFactory.parse("B", null) assertEquals(1, a.compareTo(b)) } @Test fun name_compareTo_intelligent_withSort_withoutArticle_withoutNumeric() { - val a = IntelligentKnownName("D", "A") - val b = IntelligentKnownName("C", "B") + val a = Name.Known.IntelligentFactory.parse("D", "A") + val b = Name.Known.IntelligentFactory.parse("C", "B") assertEquals(-1, a.compareTo(b)) } @@ -447,7 +431,7 @@ class NameTest { @Test fun name_compareTo_mixed() { val a = Name.Unknown(0) - val b = IntelligentKnownName("A", null) + val b = Name.Known.IntelligentFactory.parse("A", null) assertEquals(-1, a.compareTo(b)) } } diff --git a/app/src/test/java/org/oxycblt/auxio/music/info/ReleaseTypeTest.kt b/app/src/test/java/org/oxycblt/auxio/music/info/ReleaseTypeTest.kt index 9ca019a40..1294e3daf 100644 --- a/app/src/test/java/org/oxycblt/auxio/music/info/ReleaseTypeTest.kt +++ b/app/src/test/java/org/oxycblt/auxio/music/info/ReleaseTypeTest.kt @@ -36,6 +36,7 @@ class ReleaseTypeTest { assertEquals(ReleaseType.Soundtrack, ReleaseType.parse(listOf("album", "soundtrack"))) assertEquals(ReleaseType.Mix, ReleaseType.parse(listOf("album", "dj-mix"))) assertEquals(ReleaseType.Mixtape, ReleaseType.parse(listOf("album", "mixtape/street"))) + assertEquals(ReleaseType.Demo, ReleaseType.parse(listOf("album", "demo"))) } @Test diff --git a/app/src/test/java/org/oxycblt/auxio/music/user/DeviceLibraryTest.kt b/app/src/test/java/org/oxycblt/auxio/music/user/DeviceLibraryTest.kt index cdbbc6af9..e89c8d241 100644 --- a/app/src/test/java/org/oxycblt/auxio/music/user/DeviceLibraryTest.kt +++ b/app/src/test/java/org/oxycblt/auxio/music/user/DeviceLibraryTest.kt @@ -31,6 +31,8 @@ import org.oxycblt.auxio.music.device.ArtistImpl import org.oxycblt.auxio.music.device.DeviceLibraryImpl import org.oxycblt.auxio.music.device.GenreImpl import org.oxycblt.auxio.music.device.SongImpl +import org.oxycblt.auxio.music.fs.Components +import org.oxycblt.auxio.music.fs.Path class DeviceLibraryTest { @@ -42,12 +44,14 @@ class DeviceLibraryTest { mockk { every { uid } returns songUidA every { durationMs } returns 0 + every { path } returns Path(mockk(), Components.parseUnix("./")) every { finalize() } returns this } val songB = mockk { every { uid } returns songUidB every { durationMs } returns 1 + every { path } returns Path(mockk(), Components.parseUnix("./")) every { finalize() } returns this } val deviceLibrary = DeviceLibraryImpl(listOf(songA, songB), listOf(), listOf(), listOf()) @@ -156,11 +160,13 @@ class DeviceLibraryTest { val songA = mockk { every { uid } returns Music.UID.auxio(MusicType.SONGS) + every { path } returns Path(mockk(), Components.parseUnix("./")) every { finalize() } returns this } val songB = mockk { every { uid } returns Music.UID.auxio(MusicType.SONGS) + every { path } returns Path(mockk(), Components.parseUnix("./")) every { finalize() } returns this } val album = diff --git a/build.gradle b/build.gradle index e2f1717dc..fdb033f43 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { } plugins { - id "com.android.application" version '8.1.2' apply false + id "com.android.application" version '8.2.0' apply false id "androidx.navigation.safeargs.kotlin" version "$navigation_version" apply false id "org.jetbrains.kotlin.android" version "$kotlin_version" apply false id "com.google.devtools.ksp" version '1.9.10-1.0.13' apply false diff --git a/fastlane/metadata/android/be/full_description.txt b/fastlane/metadata/android/be/full_description.txt index 25badc179..dc3182282 100644 --- a/fastlane/metadata/android/be/full_description.txt +++ b/fastlane/metadata/android/be/full_description.txt @@ -19,4 +19,4 @@ Auxio - гэта мясцовы музычны плэер з хуткім і н - Аўтазапуск гарнітуры - Стыльныя віджэты, якія аўтаматычна адаптуюцца да іх памеру - Цалкам прыватны і ў аўтаномным рэжыме -- Ніякіх круглявых вокладак альбомаў (Калі вы не хочаце іх. Тады вы можаце.) +- Ніякіх круглявых вокладак альбомаў (па змаўчанні) diff --git a/fastlane/metadata/android/cs/full_description.txt b/fastlane/metadata/android/cs/full_description.txt index 26cabb0d0..caf9e51ef 100644 --- a/fastlane/metadata/android/cs/full_description.txt +++ b/fastlane/metadata/android/cs/full_description.txt @@ -20,4 +20,4 @@ přesná/původní data, štítky pro řazení a další - Automatické přehrávání při připojení sluchátek - Stylové widgety, které se automaticky adaptují své velikosti - Plně soukromý a offline -- Žádné zakulacené obaly alb (Pokud je tedy nechcete. Jinak jsou k dispozici.) +- Žádné zakulacené obaly alb (ve výchozím nastavení) diff --git a/fastlane/metadata/android/de/full_description.txt b/fastlane/metadata/android/de/full_description.txt index 00b49f827..3eedd16a2 100644 --- a/fastlane/metadata/android/de/full_description.txt +++ b/fastlane/metadata/android/de/full_description.txt @@ -20,4 +20,4 @@ Auxio ist ein lokaler Musik-Player mit einer schnellen, verlässlichen UI/UX, ab - Autoplay bei Kopfhörern - Stylische Widgets, die ihre Größe anpassen - vollständig privat und offline -- keine abgerundeten Album-Cover (Außer die willst. Dann geht das.) +- keine abgerundeten Album-Cover (standardmäßig) diff --git a/fastlane/metadata/android/en-US/changelogs/36.txt b/fastlane/metadata/android/en-US/changelogs/36.txt index b0ac8dc87..397a4fefa 100644 --- a/fastlane/metadata/android/en-US/changelogs/36.txt +++ b/fastlane/metadata/android/en-US/changelogs/36.txt @@ -1,3 +1,3 @@ Auxio 3.2.0 refreshes the item management experience, with a new menu UI and playback options. This release fixes several critical issues identified in the previous version. -For more information, see https://github.com/OxygenCobalt/Auxio/releases/tag/v3.2.0. \ No newline at end of file +For more information, see https://github.com/OxygenCobalt/Auxio/releases/tag/v3.3.0. \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/37.txt b/fastlane/metadata/android/en-US/changelogs/37.txt new file mode 100644 index 000000000..fe19658d7 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/37.txt @@ -0,0 +1,2 @@ +Auxio 3.3.0 adds the ability to import and export playlists, skip gestures, and fixes/improvements to the music loader. +For more information, see https://github.com/OxygenCobalt/Auxio/releases/tag/v3.3.0 \ No newline at end of file diff --git a/fastlane/metadata/android/es-ES/full_description.txt b/fastlane/metadata/android/es-ES/full_description.txt index fca66cb77..67ee646c7 100644 --- a/fastlane/metadata/android/es-ES/full_description.txt +++ b/fastlane/metadata/android/es-ES/full_description.txt @@ -20,4 +20,4 @@ fechas precisas/originales, ordenar etiquetas y más - Reproducción automática de auriculares - Widgets con estilo que se adaptan automáticamente a su tamaño - Completamente privado y fuera de línea -- No hay portadas de álbumes redondeadas (a menos que las quieras. Entonces puedes) +- Sin carátulas redondeadas (por defecto) diff --git a/fastlane/metadata/android/fr-FR/full_description.txt b/fastlane/metadata/android/fr-FR/full_description.txt index 107936eaf..7567e8b1c 100644 --- a/fastlane/metadata/android/fr-FR/full_description.txt +++ b/fastlane/metadata/android/fr-FR/full_description.txt @@ -20,4 +20,4 @@ les dates précises/originales, le classement par tags, and plus encore - Lecture automatique pour les casques - Widgets stylisés qui s'adaptent automatiquement à leur taille - Complètement privé et hors-ligne -- On arrondit pas les couvertures d'albums (Sauf si vous le voulez. Dans ce cas c'est possible.) +- On arrondit pas les couvertures d'albums (par défaut) diff --git a/fastlane/metadata/android/hi/full_description.txt b/fastlane/metadata/android/hi/full_description.txt index 2c5fdb04a..81b86358b 100644 --- a/fastlane/metadata/android/hi/full_description.txt +++ b/fastlane/metadata/android/hi/full_description.txt @@ -20,4 +20,4 @@ Auxio एक तेज़, विश्वसनीय UI/UX वाला एक - हेडसेट ऑटोप्ले - स्टाइलिश विजेट जो स्वचालित रूप से अपने आकार के अनुकूल हो जाते हैं - पूरी तरह से निजी और ऑफ़लाइन -- कोई गोलाकार एल्बम कवर नहीं (जब तक आप उन्हें नहीं चाहते। फिर तुम कर सकते हो।) +- कोई गोलाकार एल्बम कवर नहीं (डिफ़ॉल्ट तौर पर) diff --git a/fastlane/metadata/android/it/full_description.txt b/fastlane/metadata/android/it/full_description.txt index 7f8f718ce..db4cabec8 100644 --- a/fastlane/metadata/android/it/full_description.txt +++ b/fastlane/metadata/android/it/full_description.txt @@ -20,4 +20,4 @@ date precise/originali, tag di ordinamento e altro ancora - Riproduzione automatica delle cuffie - Widget eleganti che si adattano automaticamente alle loro dimensioni - Completamente privato e offline -- Niente copertine arrotondate degli album (a meno che tu non le voglia, in tal caso puoi) +- Niente copertine arrotondate degli album (comportamento predefinito) diff --git a/fastlane/metadata/android/ko/full_description.txt b/fastlane/metadata/android/ko/full_description.txt index 2d5d002c0..387682b2c 100644 --- a/fastlane/metadata/android/ko/full_description.txt +++ b/fastlane/metadata/android/ko/full_description.txt @@ -1,23 +1,23 @@ -Auxio는 다른 음악 플레이어에 있는 쓸모없는 많은 기능 없이 빠르고 안정적인 UI/UX를 갖춘 로컬 음악 플레이어입니다. 최신 미디어 재생 라이브러리를 기반으로 구축된 Auxio는 오래된 안드로이드 기능을 사용하는 다른 앱에 비해 뛰어난 라이브러리 지원과 청취 품질을 제공합니다. 즉, 제대로 된 음악을 재생합니다. +Auxio는 다른 음악 플레이어에 존재하는 쓸모없는 기능 없이, 빠르고 안정적인 UI/UX를 갖춘 로컬 음악 플레이어입니다. 최신 미디어 재생 라이브러리를 기반으로 구축된 Auxio는 오래된 Android 기능을 사용하는 다른 앱에 비해 뛰어난 라이브러리 지원과 음악 재생 품질을 제공합니다. 즉, 음악을 제대로 재생하는 플레이어입니다. 기능 -- Media3 ExoPlayer 기반 재생 -- 최신주목할 만한 디자인 가이드라인에서 파생된 Snappy UI -- 엣지 케이스보다 사용 편의성을 우선시하는 의견이 많은 UX +- Media3 ExoPlayer 기반 +- 머티리얼 디자인 가이드라인을 따르는 깔끔한 UI +- 엣지 케이스보다는 사용 편의성을 우선시한 UX - 사용자 정의 가능한 동작 - 디스크 번호, 여러 아티스트, 릴리스 유형 지원, 정확한/원본 날짜, 정렬 태그 등 지원 -- 아티스트와 앨범 아티스트를 통합하는 고급 아티스트 시스템 -- SD 카드 인식 폴더 관리 +- 아티스트와 앨범 아티스트를 통합한 고급 아티스트 시스템 +- SD 카드를 지원하는 폴더 관리 기능 - 안정적인 재생 목록 기능 -- 재생 상태 지속성 -- 전체 ReplayGain 지원 (MP3, FLAC, OGG, OPUS, MP4) -- 외부 이퀄라이저 지원 (예: Wavelet) +- 이전 재생 상태 기억 +- ReplayGain 완벽 지원 (MP3, FLAC, OGG, OPUS, MP4) +- 외부 이퀄라이저 지원 (Wavelet 등) - Edge-to-edge -- 임베디드 커버 지원 +- 파일 내장 앨범 커버 지원 - 검색 기능 -- 헤드셋 자동 재생 +- 헤드셋 연결 시 자동 재생 - 크기에 따라 자동으로 조정되는 세련된 위젯 -- 완전한 비공개 및 오프라인 -- 둥근 앨범 커버 사용 안 함 (필요하면 설정할 수 있습니다.) +- 인터넷 사용 없음 +- 둥근 앨범 커버 없음 (기본값) diff --git a/fastlane/metadata/android/lt/full_description.txt b/fastlane/metadata/android/lt/full_description.txt index 372e28de5..043666dfc 100644 --- a/fastlane/metadata/android/lt/full_description.txt +++ b/fastlane/metadata/android/lt/full_description.txt @@ -1,4 +1,4 @@ -Auxio yra vietinis muzikos grotuvas su greita, patikima UI/UX be daugybės nenaudingų funkcijų, esančių kituose muzikos grotuvuose. Sukurta remiantis iš šiuolaikinių medijos grojimo bibliotekų, Auxio turi geresnį bibliotekos palaikymą ir klausymo kokybę, palyginti su kitomis programomis, kurios naudoja pasenusias Android funkcijas. Trumpai tariant, Jame groja muziką. +Auxio yra vietinis muzikos grotuvas su greita, patikima UI/UX be daugybės nenaudingų funkcijų, esančių kituose muzikos grotuvuose. Sukurta remiantis iš šiuolaikinių medijos grojimo bibliotekų, Auxio turi geresnį bibliotekos palaikymą ir klausymo kokybę, palyginti su kitomis programomis, kurios naudoja pasenusias Android funkcijas. Trumpai tariant, jame groja muziką. Funkcijos @@ -20,4 +20,4 @@ tikslias/originalias datas, rūšiavimo žymas ir dar daugiau - Automatinis ausinių grojimas - Stilingi valdikliai, kurie automatiškai prisitaiko prie savo dydžio - Visiškai privatus ir neprisijungęs -- Jokių suapvalintų albumų viršelių (Nebent nori. Tada gali.) +- Jokių suapvalintų albumų viršelių (pagal numatytuosius nustatymus) diff --git a/fastlane/metadata/android/pa/full_description.txt b/fastlane/metadata/android/pa/full_description.txt index c98396ffa..c896207aa 100644 --- a/fastlane/metadata/android/pa/full_description.txt +++ b/fastlane/metadata/android/pa/full_description.txt @@ -20,4 +20,4 @@ Auxio ਇੱਕ ਤੇਜ਼, ਭਰੋਸੇਮੰਦ UI/UX ਵਾਲਾ ਇੱ - ਹੈੱਡਸੈੱਟ ਆਟੋਪਲੇ - ਸਟਾਈਲਿਸ਼ ਵਿਜੇਟਸ ਜੋ ਆਪਣੇ ਆਪ ਉਹਨਾਂ ਦੇ ਆਕਾਰ ਦੇ ਅਨੁਕੂਲ ਬਣਦੇ ਹਨ - ਪੂਰੀ ਤਰ੍ਹਾਂ ਨਿੱਜੀ ਅਤੇ ਆਫਲਾਈਨ -- ਕੋਈ ਗੋਲ ਐਲਬਮ ਕਵਰ ਨਹੀਂ (ਜਦੋਂ ਤੱਕ ਤੁਸੀਂ ਉਹਨਾਂ ਨੂੰ ਨਹੀਂ ਚਾਹੁੰਦੇ ਹੋ। ਤੁਸੀਂ ਕਰ ਸਕਦੇ ਹੋ।) +- ਕੋਈ ਗੋਲ ਐਲਬਮ ਕਵਰ ਨਹੀਂ (ਡਿਫ਼ਾਲਟ ਤੌਰ ਤੇ) diff --git a/fastlane/metadata/android/ru/full_description.txt b/fastlane/metadata/android/ru/full_description.txt index c58195709..634f1e263 100644 --- a/fastlane/metadata/android/ru/full_description.txt +++ b/fastlane/metadata/android/ru/full_description.txt @@ -19,4 +19,4 @@ Auxio — это локальный музыкальный плеер с быс - Автоматическое воспроизведение в наушниках - Адаптивные виджеты - Полностью частный и офлайн -- Никаких закруглённых обложек альбомов (если вы их не хотите) +- Никаких закруглённых обложек альбомов (по умолчанию) diff --git a/fastlane/metadata/android/uk/full_description.txt b/fastlane/metadata/android/uk/full_description.txt index afbd7ac2c..890722b67 100644 --- a/fastlane/metadata/android/uk/full_description.txt +++ b/fastlane/metadata/android/uk/full_description.txt @@ -20,4 +20,4 @@ Auxio – це локальний музичний плеєр зі швидки - Автоматичне відтворення в навушниках - Стильні віджети, які автоматично підлаштовуються під розмір - Повністю приватний і офлайн -- Жодних заокруглених обкладинок альбомів (якщо ви їх не хочете) +- Жодних заокруглених обкладинок альбомів (за замовчуванням) diff --git a/fastlane/metadata/android/zh-CN/full_description.txt b/fastlane/metadata/android/zh-CN/full_description.txt index 25b518644..318031e5c 100644 --- a/fastlane/metadata/android/zh-CN/full_description.txt +++ b/fastlane/metadata/android/zh-CN/full_description.txt @@ -20,4 +20,4 @@ Auxio 是一款本地音乐播放器,它拥有快速、可靠的 UI/UX,没 - 耳机连接时自动播放 - 按桌面尺寸自适应的风格化微件 - 完全离线且私密 -- 没有圆角的专辑封面(如果你想要也可以拥有) +- 没有圆角的专辑封面(默认设置) diff --git a/fastlane/metadata/android/zh-Hant/full_description.txt b/fastlane/metadata/android/zh-Hant/full_description.txt new file mode 100644 index 000000000..26596541a --- /dev/null +++ b/fastlane/metadata/android/zh-Hant/full_description.txt @@ -0,0 +1,22 @@ +Auxio 是一款本機音樂播放器,擁有快速且可靠的 UI/UX,不含其他音樂播放器中許多無用的功能。Auxio 基於現代媒體播放庫構建,與使用過時 Android 功能的其他應用相比,擁有更優越的庫支援和聆聽品質。簡而言之,它播放音樂。 + +功能 + +- 基於 Media3 ExoPlayer 的播放功能 +- 源自最新 Material Design 指南的靈敏 UI +- 優化 UX,重視易用性高於邊緣情況 +- 可自訂的行為 +- 支援碟數、多位藝術家、發行類型、精確/原始日期、排序標籤等等 +- 進階藝術家系統,統一藝術家與專輯藝術家 +- 支援 SD 卡的資料夾管理 +- 可靠的播放列表功能 +- 播放狀態持久性 +- 完整的 ReplayGain 支援(適用於 MP3、FLAC、OGG、OPUS 和 MP4 檔案) +- 外部均衡器支援(例如 Wavelet) +- 無邊界設計 +- 內嵌封面支援 +- 搜尋功能 +- 耳機自動播放 +- 時尚的小工具,自動適應大小 +- 完全私密且離線 +- 默認不使用圓角專輯封面 diff --git a/media b/media index 40c3e5c68..2cfefb8f3 160000 --- a/media +++ b/media @@ -1 +1 @@ -Subproject commit 40c3e5c68cbdf8758037aa40b4071cca8a53ee89 +Subproject commit 2cfefb8f39d84412920d17be4ba76ebaabf2d6a6