Browse Source

#65: added an option to select preference towards playback order.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
9b0c8b0bf6
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 8
      app/src/main/java/com/github/apognu/otter/activities/SettingsActivity.kt
  2. 24
      app/src/main/java/com/github/apognu/otter/fragments/TracksFragment.kt
  3. 4
      app/src/main/res/menu/album.xml
  4. 6
      app/src/main/res/values-fr/strings.xml
  5. 10
      app/src/main/res/values/array.xml
  6. 6
      app/src/main/res/values/strings.xml
  7. 8
      app/src/main/res/xml/settings.xml

8
app/src/main/java/com/github/apognu/otter/activities/SettingsActivity.kt

@ -112,6 +112,14 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP @@ -112,6 +112,14 @@ class SettingsFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedP
}
}
preferenceManager.findPreference<ListPreference>("play_order")?.let {
it.summary = when (it.value) {
"shuffle" -> activity.getString(R.string.settings_play_order_shuffle_summary)
"in_order" -> activity.getString(R.string.settings_play_order_in_order_summary)
else -> activity.getString(R.string.settings_play_order_shuffle_summary)
}
}
preferenceManager.findPreference<ListPreference>("night_mode")?.let {
when (it.value) {
"on" -> {

24
app/src/main/java/com/github/apognu/otter/fragments/TracksFragment.kt

@ -3,6 +3,7 @@ package com.github.apognu.otter.fragments @@ -3,6 +3,7 @@ package com.github.apognu.otter.fragments
import android.os.Bundle
import android.view.Gravity
import android.view.View
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.PopupMenu
import androidx.core.os.bundleOf
import androidx.lifecycle.lifecycleScope
@ -14,6 +15,7 @@ import com.github.apognu.otter.repositories.FavoritesRepository @@ -14,6 +15,7 @@ import com.github.apognu.otter.repositories.FavoritesRepository
import com.github.apognu.otter.repositories.TracksRepository
import com.github.apognu.otter.utils.*
import com.google.android.exoplayer2.offline.Download
import com.preference.PowerPreference
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
import kotlinx.android.synthetic.main.fragment_tracks.*
@ -107,8 +109,16 @@ class TracksFragment : OtterFragment<Track, TracksAdapter>() { @@ -107,8 +109,16 @@ class TracksFragment : OtterFragment<Track, TracksAdapter>() {
}
}
when (PowerPreference.getDefaultFile().getString("play_order")) {
"in_order" -> play.text = getString(R.string.playback_play)
else -> play.text = getString(R.string.playback_shuffle)
}
play.setOnClickListener {
CommandBus.send(Command.ReplaceQueue(adapter.data.shuffled()))
when (PowerPreference.getDefaultFile().getString("play_order")) {
"in_order" -> CommandBus.send(Command.ReplaceQueue(adapter.data))
else -> CommandBus.send(Command.ReplaceQueue(adapter.data.shuffled()))
}
context.toast("All tracks were added to your queue")
}
@ -118,8 +128,20 @@ class TracksFragment : OtterFragment<Track, TracksAdapter>() { @@ -118,8 +128,20 @@ class TracksFragment : OtterFragment<Track, TracksAdapter>() {
PopupMenu(context, actions, Gravity.START, R.attr.actionOverflowMenuStyle, 0).apply {
inflate(R.menu.album)
menu.findItem(R.id.play_secondary)?.let { item ->
when (PowerPreference.getDefaultFile().getString("play_order")) {
"in_order" -> item.title = getString(R.string.playback_shuffle)
else -> item.title = getString(R.string.playback_play)
}
}
setOnMenuItemClickListener {
when (it.itemId) {
R.id.play_secondary -> when (PowerPreference.getDefaultFile().getString("play_order")) {
"in_order" -> CommandBus.send(Command.ReplaceQueue(adapter.data.shuffled()))
else -> CommandBus.send(Command.ReplaceQueue(adapter.data))
}
R.id.add_to_queue -> {
CommandBus.send(Command.AddToQueue(adapter.data))

4
app/src/main/res/menu/album.xml

@ -1,6 +1,10 @@ @@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/play_secondary"
android:title="@string/playback_shuffle" />
<item
android:id="@+id/add_to_queue"
android:title="@string/playback_queue" />

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

@ -26,6 +26,11 @@ @@ -26,6 +26,11 @@
<string name="settings_media_quality_summary_size">Les pistes les plus légères seront utilisées</string>
<string name="settings_media_cache_size">Taille du cache</string>
<string name="settings_media_cache_size_summary">%d Go seront utilisés pour mettre en cache les pistes pour la lecture hors-ligne</string>
<string name="settings_play_order">Ordre de lecture préféré</string>
<string name="settings_play_order_shuffle">Lecture aléatoire</string>
<string name="settings_play_order_shuffle_summary">Vous préférez écouter les albums aléatoirement</string>
<string name="settings_play_order_in_order">Lecture dans l\'ordre</string>
<string name="settings_play_order_in_order_summary">Vous préférez écouter les albums dans l\'ordre</string>
<string name="settings_other">Autres</string>
<string name="settings_night_mode">Mode nuit</string>
<string name="settings_night_mode_on">Toujours activé (mode sombre)</string>
@ -54,6 +59,7 @@ @@ -54,6 +59,7 @@
<string name="playlists">Playlists</string>
<string name="radios">Radios</string>
<string name="favorites">Favoris</string>
<string name="playback_play">Jouer</string>
<string name="playback_media_controls">Contrôle de lecture</string>
<string name="playback_media_controls_description">Contrôler la lecture musicale</string>
<string name="playback_shuffle">Lecture aléatoire</string>

10
app/src/main/res/values/array.xml

@ -10,6 +10,16 @@ @@ -10,6 +10,16 @@
<item>size</item>
</array>
<array name="play_orders">
<item>@string/settings_play_order_shuffle</item>
<item>@string/settings_play_order_in_order</item>
</array>
<array name="play_orders_values">
<item>shuffle</item>
<item>in_order</item>
</array>
<array name="night_mode">
<item>@string/settings_night_mode_on</item>
<item>@string/settings_night_mode_off</item>

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

@ -27,6 +27,11 @@ @@ -27,6 +27,11 @@
<string name="settings_media_quality_summary_size">Smallest available track will be played</string>
<string name="settings_media_cache_size">Media cache size</string>
<string name="settings_media_cache_size_summary">%d GB will be used to store tracks for offline playback</string>
<string name="settings_play_order">Preferred playback order</string>
<string name="settings_play_order_shuffle">Shuffle albums</string>
<string name="settings_play_order_shuffle_summary">You prefer shuffling album tracks</string>
<string name="settings_play_order_in_order">Play albums in order</string>
<string name="settings_play_order_in_order_summary">You prefer playing albums in order</string>
<string name="settings_other">Other</string>
<string name="settings_night_mode">Dark mode</string>
<string name="settings_night_mode_on">Always on (dark mode)</string>
@ -57,6 +62,7 @@ @@ -57,6 +62,7 @@
<string name="favorites">Favorites</string>
<string name="playback_media_controls">Media controls</string>
<string name="playback_media_controls_description">Control media playback</string>
<string name="playback_play">Play</string>
<string name="playback_shuffle">Shuffle</string>
<string name="playback_queue">Queue</string>
<string name="playback_queue_empty">Your queue is empty</string>

8
app/src/main/res/xml/settings.xml

@ -22,6 +22,14 @@ @@ -22,6 +22,14 @@
app:showSeekBarValue="true"
app:updatesContinuously="true" />
<ListPreference
android:defaultValue="shuffle"
android:entries="@array/play_orders"
android:entryValues="@array/play_orders_values"
android:icon="@drawable/play"
android:key="play_order"
android:title="@string/settings_play_order" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/settings_other">

Loading…
Cancel
Save