Browse Source

Frontend logic for displaying only own music.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
746ae8897d
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 12
      app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt
  2. 1
      app/src/main/java/com/github/apognu/otter/utils/Util.kt
  3. 6
      app/src/main/res/menu/toolbar.xml
  4. 1
      app/src/main/res/values-fr/strings.xml
  5. 1
      app/src/main/res/values/strings.xml

12
app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt

@ -129,6 +129,10 @@ class MainActivity : AppCompatActivity() { @@ -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() { @@ -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)
}

1
app/src/main/java/com/github/apognu/otter/utils/Util.kt

@ -57,4 +57,5 @@ object Settings { @@ -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")
}

6
app/src/main/res/menu/toolbar.xml

@ -21,6 +21,12 @@ @@ -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"

1
app/src/main/res/values-fr/strings.xml

@ -95,4 +95,5 @@ @@ -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>

1
app/src/main/res/values/strings.xml

@ -96,4 +96,5 @@ @@ -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>

Loading…
Cancel
Save