Skip to content

Commit

Permalink
Fixes #451 the Spotify RHMI icon selection behavior
Browse files Browse the repository at this point in the history
The RHMI icon is clicked when the Media button is pushed while having audio context
So there is a debounce watching the HMI Context to check if the user dwells in the menu first
Now the debounce resets only when the window title changes, because the
HMI Context itself changes as the user scrolls around the list
  • Loading branch information
hufman committed Nov 3, 2021
1 parent a03c21f commit 0edffdf
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import me.hufman.androidautoidrive.music.MusicAppDiscovery
import me.hufman.androidautoidrive.music.MusicAppInfo
import me.hufman.androidautoidrive.music.MusicController
import me.hufman.androidautoidrive.utils.GraphicsHelpers
import me.hufman.androidautoidrive.utils.GsonNullable.tryAsJsonObject
import me.hufman.androidautoidrive.utils.GsonNullable.tryAsJsonPrimitive
import me.hufman.androidautoidrive.utils.GsonNullable.tryAsString
import me.hufman.androidautoidrive.utils.Utils.loadZipfile
import me.hufman.androidautoidrive.utils.removeFirst

Expand All @@ -36,6 +39,7 @@ class MusicApp(val iDriveConnectionStatus: IDriveConnectionStatus, val securityA

val globalMetadata: GlobalMetadata
var hmiContextChangedTime = 0L
var hmiContextMenuTitle = ""
val playbackId5View: PlaybackView?
val playbackView: PlaybackView
val appSwitcherView: AppSwitcherView
Expand Down Expand Up @@ -97,9 +101,13 @@ class MusicApp(val iDriveConnectionStatus: IDriveConnectionStatus, val securityA

// listen for HMI Context events
cdsData.setConnection(CDSConnectionEtch(carConnection))
cdsData.subscriptions.defaultIntervalLimit = 50
cdsData.subscriptions.defaultIntervalLimit = 300
cdsData.subscriptions[CDS.HMI.GRAPHICALCONTEXT] = {
hmiContextChangedTime = System.currentTimeMillis()
val title = it.tryAsJsonObject("graphicalContext")?.tryAsJsonPrimitive("menuTitle")?.tryAsString ?: ""
if (title != hmiContextMenuTitle) {
hmiContextChangedTime = System.currentTimeMillis()
hmiContextMenuTitle = title
}
}
}

Expand Down Expand Up @@ -332,7 +340,7 @@ class MusicApp(val iDriveConnectionStatus: IDriveConnectionStatus, val securityA
// when the Media button is pressed, it shows the Media/Radio window for a short time
// and then selects the Entrybutton
val contextChangeDelay = System.currentTimeMillis() - hmiContextChangedTime
if (musicAppMode.shouldId5Playback() && (contextChangeDelay > 1500 || bookmarkButton)) {
if (musicAppMode.supportsId5Playback() && (contextChangeDelay > 1500 || bookmarkButton)) {
// there's no spotify AM icon for the user to push
// so handle this spotify icon push
// but only if the user has dwelled on a screen for a second
Expand Down

0 comments on commit 0edffdf

Please sign in to comment.