mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-11 18:40:28 +00:00
Moved overflow menu to a left drawer to make it more accessible, and
also make transitions between main and browse feel less janky.
This commit is contained in:
parent
7597d0edff
commit
b0e8ca9a9d
@ -32,6 +32,7 @@ import io.casey.musikcube.remote.ui.shared.activity.BaseActivity
|
||||
import io.casey.musikcube.remote.ui.shared.extension.getColorCompat
|
||||
import io.casey.musikcube.remote.ui.shared.extension.setCheckWithoutEvent
|
||||
import io.casey.musikcube.remote.ui.shared.extension.showSnackbar
|
||||
import io.casey.musikcube.remote.ui.shared.extension.toolbar
|
||||
import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin
|
||||
import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin
|
||||
import io.casey.musikcube.remote.ui.shared.util.Duration
|
||||
@ -111,12 +112,8 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
val connected = data.wss.state === WebSocketService.State.Connected
|
||||
val streaming = isStreamingSelected
|
||||
|
||||
menu.findItem(R.id.action_categories).isEnabled = connected
|
||||
menu.findItem(R.id.action_remote_manage).isEnabled = connected
|
||||
|
||||
val remoteToggle = menu.findItem(R.id.action_remote_toggle)
|
||||
|
||||
remoteToggle.actionView?.findViewById<ImageView>(R.id.icon)?.setImageResource(
|
||||
@ -158,36 +155,14 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_remote_toggle -> {
|
||||
if (playback.service.state != PlaybackState.Stopped) {
|
||||
showPlaybackTogglePopup()
|
||||
}
|
||||
else {
|
||||
togglePlaybackService()
|
||||
}
|
||||
return true
|
||||
if (item.itemId == R.id.action_remote_toggle) {
|
||||
if (playback.service.state != PlaybackState.Stopped) {
|
||||
showPlaybackTogglePopup()
|
||||
}
|
||||
|
||||
R.id.action_settings -> {
|
||||
startActivity(SettingsActivity.getStartIntent(this))
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.action_categories -> {
|
||||
Navigate.toAllCategories(this)
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.action_offline_tracks -> {
|
||||
onOfflineTracksSelected()
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.action_remote_manage -> {
|
||||
startActivity(RemoteSettingsActivity.getStartIntent(this))
|
||||
return true
|
||||
else {
|
||||
togglePlaybackService()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item)
|
||||
@ -385,6 +360,37 @@ class MainActivity : BaseActivity() {
|
||||
showOfflineButton.setOnClickListener {
|
||||
onOfflineTracksSelected()
|
||||
}
|
||||
|
||||
toolbar?.let { tb ->
|
||||
tb.navigationIcon = getDrawable(R.drawable.ic_menu)
|
||||
tb.setNavigationOnClickListener {
|
||||
val popup = PopupMenu(this, tb)
|
||||
popup.inflate(R.menu.left_menu)
|
||||
|
||||
val connected = data.wss.state === WebSocketService.State.Connected
|
||||
popup.menu.findItem(R.id.action_categories).isEnabled = connected
|
||||
popup.menu.findItem(R.id.action_remote_manage).isEnabled = connected
|
||||
|
||||
popup.setOnMenuItemClickListener {
|
||||
when(it.itemId) {
|
||||
R.id.action_settings -> {
|
||||
startActivity(SettingsActivity.getStartIntent(this))
|
||||
}
|
||||
R.id.action_categories -> {
|
||||
Navigate.toAllCategories(this)
|
||||
}
|
||||
R.id.action_offline_tracks -> {
|
||||
onOfflineTracksSelected()
|
||||
}
|
||||
R.id.action_remote_manage -> {
|
||||
startActivity(RemoteSettingsActivity.getStartIntent(this))
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
popup.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun rebindUi() {
|
||||
|
5
src/musikdroid/app/src/main/res/drawable-v21/ic_menu.xml
Normal file
5
src/musikdroid/app/src/main/res/drawable-v21/ic_menu.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
|
||||
</vector>
|
25
src/musikdroid/app/src/main/res/menu/left_menu.xml
Normal file
25
src/musikdroid/app/src/main/res/menu/left_menu.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_categories"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_categories"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_offline_tracks"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_offline_tracks"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_remote_manage"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_remote_manage"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_settings"/>
|
||||
</menu>
|
@ -8,24 +8,5 @@
|
||||
app:showAsAction="always"
|
||||
app:actionLayout="@layout/remote_toggle"
|
||||
android:title="@string/menu_remote_toggle" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_categories"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_categories"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_offline_tracks"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_offline_tracks"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_remote_manage"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_remote_manage"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_settings"/>
|
||||
</menu>
|
Loading…
x
Reference in New Issue
Block a user