search: reformat
This commit is contained in:
@@ -21,10 +21,10 @@ package org.oxycblt.auxio.search
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
|
import javax.inject.Inject
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.music.MusicType
|
import org.oxycblt.auxio.music.MusicType
|
||||||
import org.oxycblt.auxio.settings.Settings
|
import org.oxycblt.auxio.settings.Settings
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User configuration specific to the search UI.
|
* User configuration specific to the search UI.
|
||||||
@@ -48,32 +48,29 @@ class SearchSettingsImpl @Inject constructor(@ApplicationContext context: Contex
|
|||||||
if (intCode and BIT_PLAYLISTS == BIT_PLAYLISTS) add(MusicType.PLAYLISTS)
|
if (intCode and BIT_PLAYLISTS == BIT_PLAYLISTS) add(MusicType.PLAYLISTS)
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
var intCode = 0;
|
var intCode = 0
|
||||||
if (MusicType.SONGS in value) intCode = intCode or BIT_SONGS
|
if (MusicType.SONGS in value) intCode = intCode or BIT_SONGS
|
||||||
if (MusicType.ALBUMS in value) intCode = intCode or BIT_ALBUMS
|
if (MusicType.ALBUMS in value) intCode = intCode or BIT_ALBUMS
|
||||||
if (MusicType.ARTISTS in value) intCode = intCode or BIT_ARTISTS
|
if (MusicType.ARTISTS in value) intCode = intCode or BIT_ARTISTS
|
||||||
if (MusicType.GENRES in value) intCode = intCode or BIT_GENRES
|
if (MusicType.GENRES in value) intCode = intCode or BIT_GENRES
|
||||||
if (MusicType.PLAYLISTS in value) intCode = intCode or BIT_PLAYLISTS
|
if (MusicType.PLAYLISTS in value) intCode = intCode or BIT_PLAYLISTS
|
||||||
sharedPreferences.edit {
|
sharedPreferences.edit { putInt(getString(R.string.set_key_search_filters), intCode) }
|
||||||
putInt(getString(R.string.set_key_search_filters), intCode)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun migrate() {
|
override fun migrate() {
|
||||||
val filter = MusicType.fromIntCode(sharedPreferences.getInt(OLD_KEY_SEARCH_FILTER, 0))
|
val filter = MusicType.fromIntCode(sharedPreferences.getInt(OLD_KEY_SEARCH_FILTER, 0))
|
||||||
val intCode = when (filter) {
|
val intCode =
|
||||||
MusicType.SONGS -> BIT_SONGS
|
when (filter) {
|
||||||
MusicType.ALBUMS -> BIT_ALBUMS
|
MusicType.SONGS -> BIT_SONGS
|
||||||
MusicType.ARTISTS -> BIT_ARTISTS
|
MusicType.ALBUMS -> BIT_ALBUMS
|
||||||
MusicType.GENRES -> BIT_GENRES
|
MusicType.ARTISTS -> BIT_ARTISTS
|
||||||
MusicType.PLAYLISTS -> BIT_PLAYLISTS
|
MusicType.GENRES -> BIT_GENRES
|
||||||
else -> 0
|
MusicType.PLAYLISTS -> BIT_PLAYLISTS
|
||||||
}
|
else -> 0
|
||||||
sharedPreferences.edit {
|
}
|
||||||
putInt(getString(R.string.set_key_search_filters), intCode)
|
sharedPreferences.edit { putInt(getString(R.string.set_key_search_filters), intCode) }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
const val OLD_KEY_SEARCH_FILTER = "KEY_SEARCH_FILTER"
|
const val OLD_KEY_SEARCH_FILTER = "KEY_SEARCH_FILTER"
|
||||||
const val BIT_SONGS = 0b00001
|
const val BIT_SONGS = 0b00001
|
||||||
|
|||||||
@@ -182,14 +182,13 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** The current filters used for search. */
|
||||||
* The current filters used for search.
|
|
||||||
*/
|
|
||||||
val filters: Set<MusicType>
|
val filters: Set<MusicType>
|
||||||
get() = searchSettings.filters
|
get() = searchSettings.filters
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the filters used by search. Will trigger a research.
|
* Update the filters used by search. Will trigger a research.
|
||||||
|
*
|
||||||
* @param filters The new filters to use.
|
* @param filters The new filters to use.
|
||||||
*/
|
*/
|
||||||
fun updateFilters(filters: Set<MusicType>) {
|
fun updateFilters(filters: Set<MusicType>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user