all: fix misc issues

Fix miscellanious issues with documentation and the playback system
This commit is contained in:
OxygenCobalt 2022-05-20 11:30:56 -06:00
parent 9edc113ebb
commit 059652d2f1
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
12 changed files with 50 additions and 33 deletions

View file

@ -26,12 +26,12 @@ assignees: ''
If possible, provide a stack trace or a Logcat. This can help identify the issue. If possible, provide a stack trace or a Logcat. This can help identify the issue.
To take a logcat, you must do the following: To take a logcat, you must do the following:
1. Use a desktop/laptop to download the android platform tools from https://developer.android.com/studio/releases/platform-tools. 1. Use a desktop/laptop to download the android platform tools from https://developer.android.com/studio/releases/platform-tools.
2. Extract the downloaded file to a folder 2. Extract the downloaded file to a folder.
3. Enable USB debugging on your phone [See https://developer.android.com/studio/command-line/adb#Enabling], and then connect your 3. Enable USB debugging on your phone [See https://developer.android.com/studio/command-line/adb#Enabling], and then connect your
phone to a laptop. You will get a prompt to "Allow USB debugging" when you run the logcat command. Accept this. phone to a laptop. You will get a prompt to "Allow USB debugging" when you run the logcat command. Accept this.
4. Open up a terminal/command prompt in that folder and run: 4. Open up a terminal/command prompt in that folder and run:
- `./adb -d logcat | grep -i "[DWE] Auxio"` in the case of a bug [may require some changes on windows] - `./adb -d logcat | grep -i "[DWE] Auxio"` in the case of a bug [may require some changes on windows]
- `./adb -d logcat AndroidRuntime:E *:S` in the case of a crash. - `./adb -d logcat AndroidRuntime:E *:S` in the case of a crash
5. Copy and paste the output to this area of the issue. 5. Copy and paste the output to this area of the issue.
--> -->

View file

@ -7,6 +7,14 @@ assignees: ''
--- ---
<!--
!!! PLEASE READ THIS BEFORE WRITING YOUR ISSUE !!!
There have been several major features that Auxio has already rejected, due to either technical
issues or due to it not being in scope for the app. To ensure that you are not requesting a
feature that was already rejected, please go here:
https://github.com/OxygenCobalt/Auxio/issues?q=label%3Awontadd-technical%2Cwontadd-out-of-scope+
-->
#### Describe the feature you want to implement: #### Describe the feature you want to implement:
<!-- A clear and concise description of what you want to be added. --> <!-- A clear and concise description of what you want to be added. -->

View file

@ -67,7 +67,7 @@ dependencies {
// UI // UI
implementation "androidx.recyclerview:recyclerview:1.2.1" implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.3" implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.dynamicanimation:dynamicanimation:1.0.0" implementation "androidx.dynamicanimation:dynamicanimation:1.0.0"
implementation "androidx.viewpager2:viewpager2:1.1.0-beta01" implementation "androidx.viewpager2:viewpager2:1.1.0-beta01"
@ -99,7 +99,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["extension-*.aar"]) implementation fileTree(dir: "libs", include: ["extension-*.aar"])
// Image loading // Image loading
implementation "io.coil-kt:coil:2.0.0-rc03" implementation "io.coil-kt:coil:2.1.0"
// Material // Material
implementation "com.google.android.material:material:1.6.0" implementation "com.google.android.material:material:1.6.0"

View file

@ -32,7 +32,7 @@ import org.oxycblt.auxio.music.Song
* Pretty much each service component needs to load bitmaps of some kind, but doing a blind image * Pretty much each service component needs to load bitmaps of some kind, but doing a blind image
* request with some target callbacks could result in overlapping requests causing unrelated * request with some target callbacks could result in overlapping requests causing unrelated
* updates. This class (to an extent) resolves this by keeping track of the current request and * updates. This class (to an extent) resolves this by keeping track of the current request and
* disposes of it every time a new request is created. This greatly reduces the surface for race * disposing of it every time a new request is created. This greatly reduces the surface for race
* conditions save the case of instruction-by-instruction data races, which are effectively * conditions save the case of instruction-by-instruction data races, which are effectively
* impossible to solve. * impossible to solve.
* *

View file

@ -136,7 +136,6 @@ object Indexer {
*/ */
private fun loadSongs(context: Context): List<Song> { private fun loadSongs(context: Context): List<Song> {
val excludedDatabase = ExcludedDatabase.getInstance(context) val excludedDatabase = ExcludedDatabase.getInstance(context)
val paths = excludedDatabase.readPaths()
var selector = "${MediaStore.Audio.Media.IS_MUSIC}=1" var selector = "${MediaStore.Audio.Media.IS_MUSIC}=1"
val args = mutableListOf<String>() val args = mutableListOf<String>()
@ -189,14 +188,14 @@ object Indexer {
val title = cursor.getString(titleIndex) val title = cursor.getString(titleIndex)
// Try to use the DISPLAY_NAME field to obtain a (probably sane) file name // Try to use the DISPLAY_NAME field to obtain a (probably sane) file name
// from the android system. Once gain though, OEM issues get in our way and // from the android system. Once again though, OEM issues get in our way and
// this field isn't available on some platforms. In that case, see if we can // this field isn't available on some platforms. In that case, see if we can
// grok a file name from the DATA field. // grok a file name from the DATA field.
val fileName = val fileName =
cursor.getStringOrNull(fileIndex) cursor.getStringOrNull(fileIndex)
?: cursor.getStringOrNull(dataIndex)?.run { ?: cursor
substringAfterLast('/', "").ifEmpty { null } .getStringOrNull(dataIndex)
} ?.substringAfterLast('/', MediaStore.UNKNOWN_STRING)
?: MediaStore.UNKNOWN_STRING ?: MediaStore.UNKNOWN_STRING
// The TRACK field is for some reason formatted as DTTT, where D is the disk // The TRACK field is for some reason formatted as DTTT, where D is the disk

View file

@ -51,6 +51,7 @@ sealed class Music : Item() {
* [Album] or [Artist] * [Album] or [Artist]
*/ */
sealed class MusicParent : Music() { sealed class MusicParent : Music() {
/** The songs that this parent owns. */
abstract val songs: List<Song> abstract val songs: List<Song>
} }

View file

@ -36,7 +36,6 @@ import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.ui.MainNavigationAction import org.oxycblt.auxio.ui.MainNavigationAction
import org.oxycblt.auxio.ui.NavigationViewModel import org.oxycblt.auxio.ui.NavigationViewModel
import org.oxycblt.auxio.ui.ViewBindingFragment import org.oxycblt.auxio.ui.ViewBindingFragment
import org.oxycblt.auxio.util.clamp
import org.oxycblt.auxio.util.formatDuration import org.oxycblt.auxio.util.formatDuration
import org.oxycblt.auxio.util.getAttrColorSafe import org.oxycblt.auxio.util.getAttrColorSafe
import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.logD
@ -187,8 +186,7 @@ class PlaybackPanelFragment :
binding.playbackDuration.textSafe = seconds.formatDuration(false) binding.playbackDuration.textSafe = seconds.formatDuration(false)
binding.playbackSeekBar.apply { binding.playbackSeekBar.apply {
isEnabled = seconds > 0L isEnabled = seconds > 0L
valueTo = max(seconds, 1L).toFloat() valueToSafe = max(seconds, 1L).toFloat()
value = seconds.clamp(0, valueTo.toLong()).toFloat()
} }
} }
@ -202,7 +200,7 @@ class PlaybackPanelFragment :
// around. // around.
val binding = requireBinding() val binding = requireBinding()
if (!binding.playbackPosition.isActivated) { if (!binding.playbackPosition.isActivated) {
binding.playbackSeekBar.value = position.toFloat() binding.playbackSeekBar.valueSafe = position.toFloat()
binding.playbackPosition.textSafe = position.formatDuration(true) binding.playbackPosition.textSafe = position.formatDuration(true)
} }
} }
@ -221,4 +219,26 @@ class PlaybackPanelFragment :
private fun updateShuffled(isShuffled: Boolean) { private fun updateShuffled(isShuffled: Boolean) {
requireBinding().playbackShuffle.isActivated = isShuffled requireBinding().playbackShuffle.isActivated = isShuffled
} }
private var Slider.valueSafe: Float
get() = value
set(v) {
value =
if (v > valueTo) {
valueTo
} else {
v
}
}
private var Slider.valueToSafe: Float
get() = valueTo
set(v) {
valueTo =
if (value > v) {
value
} else {
v
}
}
} }

View file

@ -294,6 +294,7 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
private fun restorePlaybackState() { private fun restorePlaybackState() {
logD("Attempting to restore playback state") logD("Attempting to restore playback state")
onNewPlayback(playbackManager.index, playbackManager.queue, playbackManager.parent)
onPositionChanged(playbackManager.positionMs) onPositionChanged(playbackManager.positionMs)
onPlayingChanged(playbackManager.isPlaying) onPlayingChanged(playbackManager.isPlaying)
onShuffledChanged(playbackManager.isShuffled) onShuffledChanged(playbackManager.isShuffled)

View file

@ -127,7 +127,6 @@ class PlaybackStateManager private constructor() {
applyNewQueue(library, settingsManager.keepShuffle && isShuffled, song) applyNewQueue(library, settingsManager.keepShuffle && isShuffled, song)
notifyNewPlayback() notifyNewPlayback()
notifyShuffledChanged() notifyShuffledChanged()
seekTo(0)
isPlaying = true isPlaying = true
isInitialized = true isInitialized = true
} }
@ -142,7 +141,6 @@ class PlaybackStateManager private constructor() {
applyNewQueue(library, shuffled, null) applyNewQueue(library, shuffled, null)
notifyNewPlayback() notifyNewPlayback()
notifyShuffledChanged() notifyShuffledChanged()
seekTo(0)
isPlaying = true isPlaying = true
isInitialized = true isInitialized = true
} }
@ -154,7 +152,6 @@ class PlaybackStateManager private constructor() {
applyNewQueue(library, true, null) applyNewQueue(library, true, null)
notifyNewPlayback() notifyNewPlayback()
notifyShuffledChanged() notifyShuffledChanged()
seekTo(0)
isPlaying = true isPlaying = true
isInitialized = true isInitialized = true
} }
@ -186,7 +183,6 @@ class PlaybackStateManager private constructor() {
private fun goto(idx: Int, play: Boolean) { private fun goto(idx: Int, play: Boolean) {
index = idx index = idx
notifyIndexMoved() notifyIndexMoved()
seekTo(0)
isPlaying = play isPlaying = play
} }
@ -262,9 +258,11 @@ class PlaybackStateManager private constructor() {
sort.songsInPlace(newQueue) sort.songsInPlace(newQueue)
newIndex = keep?.let(queue::indexOf) ?: 0 newIndex = keep?.let(newQueue::indexOf) ?: 0
} }
logD("$newIndex $newQueue")
_queue = newQueue _queue = newQueue
index = newIndex index = newIndex
isShuffled = shuffled isShuffled = shuffled

View file

@ -24,7 +24,6 @@ import android.os.SystemClock
import android.support.v4.media.MediaMetadataCompat import android.support.v4.media.MediaMetadataCompat
import android.support.v4.media.session.MediaSessionCompat import android.support.v4.media.session.MediaSessionCompat
import android.support.v4.media.session.PlaybackStateCompat import android.support.v4.media.session.PlaybackStateCompat
import androidx.media.session.MediaButtonReceiver
import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.Player
import org.oxycblt.auxio.coil.BitmapProvider import org.oxycblt.auxio.coil.BitmapProvider
import org.oxycblt.auxio.music.MusicParent import org.oxycblt.auxio.music.MusicParent
@ -56,10 +55,6 @@ class MediaSessionComponent(private val context: Context, private val player: Pl
mediaSession.setCallback(this) mediaSession.setCallback(this)
} }
fun handleMediaButtonIntent(intent: Intent) {
MediaButtonReceiver.handleIntent(mediaSession, intent)
}
fun release() { fun release() {
provider.release() provider.release()
player.removeListener(this) player.removeListener(this)

View file

@ -262,6 +262,7 @@ class PlaybackService :
} }
logD("Loading ${song.rawName}") logD("Loading ${song.rawName}")
player.seekTo(0)
player.setMediaItem(MediaItem.fromUri(song.uri)) player.setMediaItem(MediaItem.fromUri(song.uri))
player.prepare() player.prepare()
notificationComponent.updateMetadata(song, playbackManager.parent) notificationComponent.updateMetadata(song, playbackManager.parent)

View file

@ -16,12 +16,6 @@ This does not rule out these additions, but they are not accepted as often as ot
Feel free to fork Auxio to add your own feature set however. Feel free to fork Auxio to add your own feature set however.
#### Additions that have already been rejected (and why): ## Additions that have already been rejected
- Folder View/Grouping [#10] (Out of scope)
- Recently added list [#18] (Out of scope) To see an up-to-date list on all of the features that have been rejected, see [this link](https://github.com/OxygenCobalt/Auxio/issues?q=label%3Awontadd-technical%2Cwontadd-out-of-scope+)
- Lyrics [#19] (Out of scope)
- Tag editing [#33] (Out of scope)
- Gapless Playback [#35] (Technical issues, may change in the future)
- Reduce leading instrument [#45] (Technical issues, Out of scope)
- Opening music through a provider [#30] (Out of scope)
- Cuesheet support [#83]