Skip to content

Commit

Permalink
Android Auto: Streamlined browsing settings to single option
Browse files Browse the repository at this point in the history
  • Loading branch information
ISO-B committed Nov 17, 2024
1 parent b7c8e72 commit f68f31c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ data class DeviceSettings(
var languageCode: String,
var downloadUsingCellular: DownloadUsingCellularSetting,
var streamingUsingCellular: StreamingUsingCellularSetting,
var androidAutoBrowseForceGrouping: Boolean,
var androidAutoBrowseTopLevelLimitForGrouping: Int,
var androidAutoBrowseLimitForGrouping: Int,
var androidAutoBrowseSeriesSequenceOrder: AndroidAutoBrowseSeriesSequenceOrderSetting
) {
Expand Down Expand Up @@ -168,8 +166,6 @@ data class DeviceSettings(
languageCode = "en-us",
downloadUsingCellular = DownloadUsingCellularSetting.ALWAYS,
streamingUsingCellular = StreamingUsingCellularSetting.ALWAYS,
androidAutoBrowseForceGrouping = false,
androidAutoBrowseTopLevelLimitForGrouping = 100,
androidAutoBrowseLimitForGrouping = 50,
androidAutoBrowseSeriesSequenceOrder = AndroidAutoBrowseSeriesSequenceOrderSetting.ASC
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,8 @@ object DeviceManager {
if (deviceData.deviceSettings?.streamingUsingCellular == null) {
deviceData.deviceSettings?.streamingUsingCellular = StreamingUsingCellularSetting.ALWAYS
}

if (deviceData.deviceSettings?.androidAutoBrowseForceGrouping == null) {
deviceData.deviceSettings?.androidAutoBrowseForceGrouping = false
}
if (deviceData.deviceSettings?.androidAutoBrowseTopLevelLimitForGrouping == null) {
deviceData.deviceSettings?.androidAutoBrowseTopLevelLimitForGrouping = 100
}
if (deviceData.deviceSettings?.androidAutoBrowseLimitForGrouping == null) {
deviceData.deviceSettings?.androidAutoBrowseLimitForGrouping = 50
deviceData.deviceSettings?.androidAutoBrowseLimitForGrouping = 100
}
if (deviceData.deviceSettings?.androidAutoBrowseSeriesSequenceOrder == null) {
deviceData.deviceSettings?.androidAutoBrowseSeriesSequenceOrder = AndroidAutoBrowseSeriesSequenceOrderSetting.ASC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
val serverConnConfig = if (DeviceManager.isConnectedToServer) DeviceManager.serverConnectionConfig else DeviceManager.deviceData.getLastServerConnectionConfig()

if (!DeviceManager.isConnectedToServer || !DeviceManager.checkConnectivity(ctx) || serverConnConfig == null || serverConnConfig.id !== serverConfigIdUsed) {
Log.d(tag, "Reset caches")
podcastEpisodeLibraryItemMap = mutableMapOf()
serverLibraries = listOf()
serverLibraryItems = mutableListOf()
Expand All @@ -141,6 +142,8 @@ class MediaManager(private var apiHandler: ApiHandler, var ctx: Context) {
cachedLibraryDiscovery = hashMapOf()
cachedLibraryPodcasts = hashMapOf()
isLibraryPodcastsCached = hashMapOf()
allLibraryPersonalizationsDone = false
libraryPersonalizationsDone = 0
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
// No further calls will be made to other media browsing methods.
null
} else {
Log.d(tag, "Android Auto starting")
isStarted = true
mediaManager.checkResetServerItems() // Reset any server items if no longer connected to server

Expand Down Expand Up @@ -1140,6 +1141,11 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
result.sendResult(children as MutableList<MediaBrowserCompat.MediaItem>?)
}
} else if (parentMediaId == LIBRARIES_ROOT || parentMediaId == RECENTLY_ROOT) {
Log.d(tag, "First load done: $firstLoadDone")
if (!firstLoadDone) {
result.sendResult(null)
return
}
while (!this::browseTree.isInitialized) {}
val children = browseTree[parentMediaId]?.map { item ->
Log.d(tag, "[MENU: $parentMediaId] Showing list item ${item.description.title}")
Expand Down Expand Up @@ -1386,7 +1392,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
Log.d(tag, "Loading series from library ${mediaIdParts[2]}")
mediaManager.loadLibrarySeriesWithAudio(mediaIdParts[2]) { seriesItems ->
Log.d(tag, "Received ${seriesItems.size} series")
if (DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseForceGrouping || seriesItems.size > DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseTopLevelLimitForGrouping) {
if (seriesItems.size > DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseLimitForGrouping) {
val seriesLetters = seriesItems.groupingBy { iwb -> iwb.title.first().uppercaseChar() }.eachCount()
val children = seriesLetters.map { (seriesLetter, seriesCount) ->
MediaBrowserCompat.MediaItem(
Expand Down Expand Up @@ -1457,7 +1463,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
Log.d(tag, "Loading authors from library ${mediaIdParts[2]}")
mediaManager.loadAuthorsWithBooks(mediaIdParts[2]) { authorItems ->
Log.d(tag, "Received ${authorItems.size} authors")
if (DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseForceGrouping || authorItems.size > DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseTopLevelLimitForGrouping) {
if (authorItems.size > DeviceManager.deviceData.deviceSettings!!.androidAutoBrowseLimitForGrouping) {
val authorLetters = authorItems.groupingBy { iwb -> iwb.name.first().uppercaseChar() }.eachCount()
val children = authorLetters.map { (authorLetter, authorCount) ->
MediaBrowserCompat.MediaItem(
Expand Down
38 changes: 4 additions & 34 deletions pages/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,6 @@
<!-- Android Auto settings -->
<template v-if="!isiOS">
<p class="uppercase text-xs font-semibold text-fg-muted mb-2 mt-10">{{ $strings.HeaderAndroidAutoSettings }}</p>
<div class="flex items-center py-3">
<div class="w-10 flex justify-center" @click="toggleAndroidAutoBrowseForceGrouping">
<ui-toggle-switch v-model="settings.androidAutoBrowseForceGrouping" @input="saveSettings" />
</div>
<p class="pl-4">{{ $strings.LabelAndroidAutoBrowseForceGrouping }}</p>
<span class="material-icons-outlined ml-2" @click.stop="showInfo('androidAutoBrowseForceGrouping')">info</span>
</div>
<div v-if="!settings.androidAutoBrowseForceGrouping" class="py-3 flex items-center">
<p class="pr-4 w-36">{{ $strings.LabelAndroidAutoBrowseTopLevelLimitForGrouping }}</p>
<ui-text-input type="number" v-model="settings.androidAutoBrowseTopLevelLimitForGrouping" style="width: 145px; max-width: 145px" @input="androidAutoBrowseTopLevelLimitForGroupingUpdated" />
<span class="material-icons-outlined ml-2" @click.stop="showInfo('androidAutoBrowseTopLevelLimitForGrouping')">info</span>
</div>
<div class="py-3 flex items-center">
<p class="pr-4 w-36">{{ $strings.LabelAndroidAutoBrowseLimitForGrouping }}</p>
<ui-text-input type="number" v-model="settings.androidAutoBrowseLimitForGrouping" style="width: 145px; max-width: 145px" @input="androidAutoBrowseLimitForGroupingUpdated" />
Expand Down Expand Up @@ -222,8 +210,6 @@ export default {
languageCode: 'en-us',
downloadUsingCellular: 'ALWAYS',
streamingUsingCellular: 'ALWAYS',
androidAutoBrowseForceGrouping: false,
androidAutoBrowseTopLevelLimitForGrouping: 100,
androidAutoBrowseLimitForGrouping: 50,
androidAutoBrowseSeriesSequenceOrder: 'ASC'
},
Expand Down Expand Up @@ -254,13 +240,9 @@ export default {
name: this.$strings.LabelEnableMp3IndexSeeking,
message: this.$strings.LabelEnableMp3IndexSeekingHelp
},
androidAutoBrowseForceGrouping: {
name: this.$strings.LabelAndroidAutoBrowseForceGrouping,
message: this.$strings.LabelAndroidAutoBrowseForceGroupingHelp
},
androidAutoBrowseTopLevelLimitForGrouping: {
name: this.$strings.LabelAndroidAutoBrowseTopLevelLimitForGrouping,
message: this.$strings.LabelAndroidAutoBrowseTopLevelLimitForGroupingHelp
androidAutoBrowseLimitForGrouping: {
name: this.$strings.LabelAndroidAutoBrowseLimitForGrouping,
message: this.$strings.LabelAndroidAutoBrowseLimitForGroupingHelp
}
},
hapticFeedbackItems: [
Expand Down Expand Up @@ -513,16 +495,10 @@ export default {
if (!val) return // invalid times return falsy
this.saveSettings()
},
androidAutoBrowseTopLevelLimitForGroupingUpdated(val) {
if (!val) return // invalid times return falsy
if (val > 1000) val = 1000
if (val < 20) val = 20
this.saveSettings()
},
androidAutoBrowseLimitForGroupingUpdated(val) {
if (!val) return // invalid times return falsy
if (val > 1000) val = 1000
if (val < 20) val = 20
if (val < 30) val = 30
this.saveSettings()
},
hapticFeedbackUpdated(val) {
Expand Down Expand Up @@ -567,10 +543,6 @@ export default {
this.settings.disableShakeToResetSleepTimer = !this.settings.disableShakeToResetSleepTimer
this.saveSettings()
},
toggleAndroidAutoBrowseForceGrouping() {
this.settings.androidAutoBrowseForceGrouping = !this.settings.androidAutoBrowseForceGrouping
this.saveSettings()
},
toggleDisableSleepTimerResetFeedback() {
this.settings.disableSleepTimerResetFeedback = !this.settings.disableSleepTimerResetFeedback
this.saveSettings()
Expand Down Expand Up @@ -655,8 +627,6 @@ export default {
this.settings.downloadUsingCellular = deviceSettings.downloadUsingCellular || 'ALWAYS'
this.settings.streamingUsingCellular = deviceSettings.streamingUsingCellular || 'ALWAYS'
this.settings.androidAutoBrowseForceGrouping = deviceSettings.androidAutoBrowseForceGrouping
this.settings.androidAutoBrowseTopLevelLimitForGrouping = deviceSettings.androidAutoBrowseTopLevelLimitForGrouping
this.settings.androidAutoBrowseLimitForGrouping = deviceSettings.androidAutoBrowseLimitForGrouping
this.settings.androidAutoBrowseSeriesSequenceOrder = deviceSettings.androidAutoBrowseSeriesSequenceOrder || 'ASC'
},
Expand Down
6 changes: 1 addition & 5 deletions strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,9 @@
"LabelAll": "All",
"LabelAllowSeekingOnMediaControls": "Allow position seeking on media notification controls",
"LabelAlways": "Always",
"LabelAndroidAutoBrowseForceGrouping": "Force alphabetical drawdown",
"LabelAndroidAutoBrowseForceGroupingHelp": "Forces alphabetical drawdown while browsing library and series in Android Auto",
"LabelAndroidAutoBrowseLimitForGrouping": "Alphabetical drawdown stopitems",
"LabelAndroidAutoBrowseLimitForGrouping": "Alphabetical drawdown limit",
"LabelAndroidAutoBrowseLimitForGroupingHelp": "Stop alphabetical drawdown when there is less than this amount of items to show",
"LabelAndroidAutoBrowseSeriesSequenceOrder": "Series books order",
"LabelAndroidAutoBrowseTopLevelLimitForGrouping": "Alphabetical drawdown start items",
"LabelAndroidAutoBrowseTopLevelLimitForGroupingHelp": "If top-level has more items than this alphabetical drawdown will be used",
"LabelAskConfirmation": "Ask for confirmation",
"LabelAuthor": "Author",
"LabelAuthorFirstLast": "Author (First Last)",
Expand Down

0 comments on commit f68f31c

Please sign in to comment.