Frontend logic for displaying only own music.

This commit is contained in:
Antoine POPINEAU 2020-06-13 18:34:28 +02:00
parent fc1419c2fb
commit 746ae8897d
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
5 changed files with 21 additions and 0 deletions

View File

@ -129,6 +129,10 @@ class MainActivity : AppCompatActivity() {
// CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.cast)
menu?.let {
menu.findItem(R.id.nav_only_my_music).isChecked = Settings.getScope() == "me"
}
return true
}
@ -148,6 +152,14 @@ class MainActivity : AppCompatActivity() {
R.id.nav_queue -> launchDialog(QueueFragment())
R.id.nav_search -> startActivity(Intent(this, SearchActivity::class.java))
R.id.nav_only_my_music -> {
item.isChecked = !item.isChecked
when (item.isChecked) {
true -> PowerPreference.getDefaultFile().set("scope", "me")
false -> PowerPreference.getDefaultFile().set("scope", "all")
}
}
R.id.settings -> startActivityForResult(Intent(this, SettingsActivity::class.java), 0)
}

View File

@ -57,4 +57,5 @@ object Settings {
fun getAccessToken(): String = PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).getString("access_token", "")
fun isAnonymous() = PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).getBoolean("anonymous", false)
fun areExperimentsEnabled() = PowerPreference.getDefaultFile().getBoolean("experiments", false)
fun getScope() = PowerPreference.getDefaultFile().getString("scope", "all")
}

View File

@ -21,6 +21,12 @@
android:title="@string/toolbar_search"
app:showAsAction="ifRoom" />
<item
android:id="@+id/nav_only_my_music"
android:checkable="true"
android:title="@string/only_my_music"
app:showAsAction="never" />
<item
android:id="@+id/settings"
android:icon="@drawable/settings"

View File

@ -95,4 +95,5 @@
<item quantity="one">%1$d piste • %2$s</item>
<item quantity="other">%1$d pistes • %2$s</item>
</plurals>
<string name="only_my_music">Ma musique seulement</string>
</resources>

View File

@ -96,4 +96,5 @@
<item quantity="one">%1$d track • %2$s"</item>
<item quantity="other">%1$d tracks • %2$s"</item>
</plurals>
<string name="only_my_music">Only my music</string>
</resources>