merge song repetition items into one

This commit is contained in:
tibbi 2016-12-03 19:39:48 +01:00
parent f285ecc6e6
commit 2f0778f3a4
2 changed files with 10 additions and 17 deletions

View file

@ -67,8 +67,9 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu, menu)
menu.findItem(R.id.enable_song_repetition).isVisible = !mConfig.repeatSong
menu.findItem(R.id.disable_song_repetition).isVisible = mConfig.repeatSong
val songRepetition = menu.findItem(R.id.toggle_song_repetition)
songRepetition.title = getString(if (mConfig.repeatSong) R.string.disable_song_repetition else R.string.enable_song_repetition)
val shuffle = menu.findItem(R.id.toggle_shuffle)
shuffle.title = getString(if (mConfig.isShuffleEnabled) R.string.disable_shuffle else R.string.enable_shuffle)
@ -86,6 +87,10 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
toggleShuffle()
true
}
R.id.toggle_song_repetition -> {
toggleSongRepetition()
true
}
R.id.settings -> {
startActivity(Intent(applicationContext, SettingsActivity::class.java))
true
@ -94,14 +99,6 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
startActivity(Intent(applicationContext, AboutActivity::class.java))
true
}
R.id.enable_song_repetition -> {
toggleSongRepetition(true)
true
}
R.id.disable_song_repetition -> {
toggleSongRepetition(false)
true
}
else -> super.onOptionsItemSelected(item)
}
}
@ -129,8 +126,8 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
invalidateOptionsMenu()
}
private fun toggleSongRepetition(enable: Boolean) {
mConfig.repeatSong = enable
private fun toggleSongRepetition() {
mConfig.repeatSong = !mConfig.repeatSong
invalidateOptionsMenu()
}

View file

@ -7,11 +7,7 @@
android:title="@string/sort_by"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/enable_song_repetition"
android:title="@string/enable_song_repetition"
app:showAsAction="never"/>
<item
android:id="@+id/disable_song_repetition"
android:id="@+id/toggle_song_repetition"
android:title="@string/disable_song_repetition"
app:showAsAction="never"/>
<item