Commit fed88280 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Move the navigation to a bottom bar

parent 3ea5e588
......@@ -29,7 +29,7 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillAlpha="1"
android:fillColor="#fafafa"
android:fillColor="?attr/colorControlNormal"
android:fillType="nonZero"
android:pathData="m12,3.8594 l-2,6.2188 -6.5625,0 5.3125,3.8125 -2.0313,6.25 5.2813,-3.875 5.2813,3.875 -2.0313,-6.25 5.3125,-3.8125 -6.5625,0 -2,-6.2188zM12,7.8594 L13.125,11.2969 16.75,11.2969 13.8125,13.4219 14.9375,16.8906 12,14.7344 9.0625,16.8906 10.1875,13.4219 7.25,11.2969 10.875,11.2969 12,7.8594z"
android:strokeColor="#00000000"
......
......@@ -29,7 +29,7 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillAlpha="1"
android:fillColor="#fafafa"
android:fillColor="?attr/colorControlNormal"
android:fillType="nonZero"
android:pathData="m12,3.8594 l2.0102,6.2332 6.5493,-0.0143 -5.3069,3.838 2.0375,6.2243 -5.2901,-3.8612 -5.2901,3.8612 2.0375,-6.2243 -5.3069,-3.838 6.5493,0.0143z"
android:strokeColor="#00000000"
......
......@@ -80,7 +80,7 @@
<dimen name="fastscroller_track_width">6dp</dimen>
<dimen name="fastscroller_track_padding">5dp</dimen>
<dimen name="audio_player_cover_margin">8dp</dimen>
<dimen name="audio_player_elevation">16dp</dimen>
<dimen name="audio_player_elevation">8dp</dimen>
<dimen name="progress_layout_height">20dp</dimen>
<dimen name="dialog_sd_wisard_width">320dp</dimen>
<dimen name="dialog_sd_wisard_height">420dp</dimen>
......
......@@ -822,4 +822,6 @@
<string name="all_subfolders">Add this folder and subfolders</string>
<string name="playlist_existing">Playlist %s already exists</string>
<string name="new_title">New title</string>
<string name="browse">Browse</string>
<string name="library">Library</string>
</resources>
<?xml version="1.0" encoding="utf-8"?><!--
~ *************************************************************************
~ bottom_navigation_selector.xml
~ **************************************************************************
~ Copyright © 2020 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/orange500" android:state_checked="true" />
<item android:color="?attr/colorControlNormal" />
</selector>
\ No newline at end of file
......@@ -7,8 +7,8 @@
android:layout_height="match_parent"
android:elevation="@dimen/audio_player_elevation"
android:visibility="gone"
app:layout_behavior="org.videolan.vlc.gui.helpers.BottomSheetBehavior"
tools:targetApi="lollipop">
app:layout_behavior="org.videolan.vlc.gui.helpers.PlayerBehavior"
tools:targetApi="lollipop">
<androidx.appcompat.widget.ViewStubCompat
android:id="@+id/audio_player_stub"
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<org.videolan.vlc.gui.view.HackyDrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nextFocusLeft="@+id/ml_menu_search"
android:nextFocusRight="@+id/ml_menu_search"
android:nextFocusUp="@+id/ml_menu_search"
android:nextFocusDown="@+id/ml_menu_search"
android:nextFocusForward="@+id/ml_menu_search" >
<androidx.coordinatorlayout.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<include layout="@layout/toolbar"/>
<include
layout="@layout/toolbar"
android:nextFocusLeft="@+id/ml_menu_search"
android:nextFocusRight="@+id/ml_menu_search"
android:nextFocusUp="@+id/ml_menu_search"
android:nextFocusDown="@+id/ml_menu_search"
android:nextFocusForward="@+id/ml_menu_search" />
<androidx.fragment.app.FragmentContainerView
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:keyboardNavigationCluster="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:targetApi="o" />
<androidx.appcompat.widget.ViewStubCompat
<androidx.appcompat.widget.ViewStubCompat
android:id="@+id/scan_viewstub"
android:layout_width="match_parent"
android:layout_height="@dimen/progress_layout_height"
android:layout_gravity="bottom"
android:layout="@layout/scan_progress"/>
android:layout="@layout/scan_progress" />
<include layout="@layout/audioplayercontainer"/>
<include layout="@layout/audioplayercontainer" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/default_margin"
app:srcCompat="@drawable/ic_fab_add"
android:tint="@color/grey50"
android:visibility="invisible"
app:borderWidth="0dp"
app:rippleColor="@color/orange50"
app:layout_anchor="@+id/fragment_placeholder"
app:layout_anchorGravity="bottom|end"
app:layout_behavior="org.videolan.vlc.gui.helpers.FloatingActionButtonBehavior"
android:visibility="invisible"
android:layout_margin="@dimen/default_margin"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<!-- The navigation drawer -->
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/navigation"
app:rippleColor="@color/orange50" />
app:headerLayout="@layout/nav_drawer_header"
app:itemTextColor="?attr/navigationview_item_color"
app:itemIconTint="?attr/navigationview_item_color"
android:keyboardNavigationCluster="true"
tools:targetApi="o" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/background_default"
app:elevation="8dp"
app:itemIconTint="@color/bottom_navigation_selector"
app:itemTextColor="@color/bottom_navigation_selector"
app:labelVisibilityMode="labeled"
app:itemRippleColor="@color/orange500focus"
app:layout_behavior="org.videolan.vlc.gui.helpers.BottomNavigationBehavior"
app:layout_insetEdge="bottom"
app:menu="@menu/bottom_navigation" />
<androidx.appcompat.widget.ViewStubCompat
android:id="@+id/audio_playlist_tips"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="@layout/audio_playlist_tips"/>
android:id="@+id/audio_playlist_tips"
android:layout="@layout/audio_playlist_tips"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<androidx.appcompat.widget.ViewStubCompat
android:id="@+id/audio_player_tips"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="@layout/audio_player_tips"/>
android:id="@+id/audio_player_tips"
android:layout="@layout/audio_player_tips"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</org.videolan.vlc.gui.view.HackyDrawerLayout>
......@@ -28,6 +28,7 @@
vlc:contentScrim="?attr/background_actionbar"
vlc:expandedTitleMarginEnd="64dp"
vlc:expandedTitleMarginStart="48dp"
vlc:expandedTitleTextAppearance="@style/TextAppearance.Design.CollapsingToolbar.Expanded.Shadow"
vlc:layout_scrollFlags="scroll|exitUntilCollapsed"
android:keyboardNavigationCluster="true"
tools:targetApi="O">
......
......@@ -19,8 +19,28 @@
app:navigationIcon="?attr/homeAsUpIndicator"
app:popupTheme="?attr/toolbar_popup_style"
app:theme="@style/Toolbar.VLC"
app:titleTextColor="@color/orange500"
app:titleMarginStart="@dimen/default_margin"
tools:targetApi="o" />
tools:targetApi="o">
<ImageView
android:id="@+id/toolbar_icon"
android:layout_width="36dp"
android:layout_height="36dp"
app:srcCompat="@drawable/icon" />
<TextView
android:id="@+id/toolbar_vlc_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/ToolbarTitleText"
android:text="@string/app_name" />
</com.google.android.material.appbar.MaterialToolbar>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/ariane"
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ *************************************************************************
~ bottom_navigation.xml
~ **************************************************************************
~ Copyright © 2020 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/nav_video"
android:title="@string/video"
android:icon="@drawable/ic_menu_video" />
<item
android:id="@+id/nav_audio"
android:title="@string/audio"
android:icon="@drawable/ic_menu_audio" />
<item
android:id="@+id/nav_playlists"
android:title="@string/playlists"
android:icon="@drawable/ic_menu_playlist" />
<item
android:id="@+id/nav_directories"
android:title="@string/browse"
android:icon="@drawable/ic_menu_folder" />
<item
android:id="@+id/nav_library"
android:title="@string/library"
android:icon="@drawable/ic_menu_folder" />
</menu>
\ No newline at end of file
......@@ -494,6 +494,14 @@
<item name="colorControlNormal">@color/grey700</item>
</style>
<style name="TextAppearance.Design.CollapsingToolbar.Expanded.Shadow">
<item name="android:shadowDy">0</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowRadius">4</item>
<item name="android:shadowColor">@color/black</item>
<item name="android:textColor">@color/white</item>
</style>
<style name="TabLayout.VLC" parent="Widget.MaterialComponents.TabLayout">
<item name="tabBackground">?attr/background_default</item>
<item name="android:background">?attr/background_default</item>
......@@ -601,7 +609,11 @@
<item name="android:gravity">center_vertical</item>
<item name="android:textColor">?attr/colorAccent</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ToolbarTitleText" parent="@style/TextAppearance.MaterialComponents.Headline6">
<item name="android:textStyle">bold</item>
<item name="android:textColor">?attr/colorControlNormal</item>
</style>
</resources>
......@@ -43,6 +43,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.tabs.TabLayout
......@@ -51,8 +52,6 @@ import kotlinx.android.synthetic.main.toolbar.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.delay
import org.videolan.tools.dp
import org.videolan.tools.isVisible
import org.videolan.medialibrary.interfaces.Medialibrary
import org.videolan.resources.util.getFromMl
import org.videolan.resources.util.startMedialibrary
......@@ -60,7 +59,7 @@ import org.videolan.tools.*
import org.videolan.vlc.*
import org.videolan.vlc.gui.audio.AudioPlayer
import org.videolan.vlc.gui.browser.StorageBrowserFragment
import org.videolan.vlc.gui.helpers.BottomSheetBehavior
import org.videolan.vlc.gui.helpers.PlayerBehavior
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.interfaces.IRefreshable
import org.videolan.vlc.media.PlaylistManager
......@@ -76,12 +75,13 @@ private const val ACTION_HIDE_PLAYER = 1341
@ObsoleteCoroutinesApi
open class AudioPlayerContainerActivity : BaseActivity() {
private var bottomBar: BottomNavigationView? = null
protected lateinit var appBarLayout: AppBarLayout
protected lateinit var toolbar: Toolbar
private var tabLayout: TabLayout? = null
protected lateinit var audioPlayer: AudioPlayer
private lateinit var audioPlayerContainer: FrameLayout
lateinit var bottomSheetBehavior: BottomSheetBehavior<*>
lateinit var playerBehavior: PlayerBehavior<*>
protected lateinit var fragmentContainer: View
protected var originalBottomPadding: Int = 0
private var scanProgressLayout: View? = null
......@@ -104,7 +104,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
get() = ::audioPlayer.isInitialized
val isAudioPlayerExpanded: Boolean
get() = isAudioPlayerReady && bottomSheetBehavior.state == STATE_EXPANDED
get() = isAudioPlayerReady && playerBehavior.state == STATE_EXPANDED
override fun onCreate(savedInstanceState: Bundle?) {
//Init Medialibrary if KO
......@@ -127,6 +127,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
appBarLayout = findViewById(R.id.appbar)
tabLayout = findViewById(R.id.sliding_tabs)
appBarLayout.setExpanded(true)
bottomBar = findViewById(R.id.navigation)
sliding_tabs?.viewTreeObserver?.addOnGlobalLayoutListener {
//add a shadow if there are tabs
appbar.elevation = if (sliding_tabs.isVisible()) 4.dp.toFloat() else 0.dp.toFloat()
......@@ -141,9 +142,9 @@ open class AudioPlayerContainerActivity : BaseActivity() {
private fun initAudioPlayer() {
findViewById<View>(R.id.audio_player_stub).visibility = View.VISIBLE
audioPlayer = supportFragmentManager.findFragmentById(R.id.audio_player) as AudioPlayer
bottomSheetBehavior = from(audioPlayerContainer) as BottomSheetBehavior<*>
bottomSheetBehavior.peekHeight = resources.getDimensionPixelSize(R.dimen.player_peek_height)
bottomSheetBehavior.addBottomSheetCallback(object : BottomSheetCallback() {
playerBehavior = from(audioPlayerContainer) as PlayerBehavior<*>
playerBehavior.peekHeight = resources.getDimensionPixelSize(R.dimen.player_peek_height)
playerBehavior.addBottomSheetCallback(object : BottomSheetCallback() {
override fun onSlide(bottomSheet: View, slideOffset: Float) {
audioPlayer.onSlide(slideOffset)
}
......@@ -152,6 +153,8 @@ open class AudioPlayerContainerActivity : BaseActivity() {
onPlayerStateChanged(bottomSheet, newState)
audioPlayer.onStateChanged(newState)
if (newState == STATE_COLLAPSED || newState == STATE_HIDDEN) removeTipViewIfDisplayed()
if (newState == STATE_DRAGGING) bottomBar?.animate()?.translationY(bottomBar?.height?.toFloat()
?: 0F)
}
})
showTipViewIfNeeded(R.id.audio_player_tips, PREF_AUDIOPLAYER_TIPS_SHOWN)
......@@ -253,7 +256,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
if (audioPlayerContainer.visibility != View.VISIBLE) {
audioPlayerContainer.visibility = View.VISIBLE
}
bottomSheetBehavior.run {
playerBehavior.run {
if (state == STATE_HIDDEN) state = STATE_COLLAPSED
isHideable = false
lock(false)
......@@ -265,8 +268,8 @@ open class AudioPlayerContainerActivity : BaseActivity() {
* @return true on success else false.
*/
fun slideDownAudioPlayer(): Boolean {
if (isAudioPlayerReady && bottomSheetBehavior.state == STATE_EXPANDED) {
bottomSheetBehavior.state = STATE_COLLAPSED
if (isAudioPlayerReady && playerBehavior.state == STATE_EXPANDED) {
playerBehavior.state = STATE_COLLAPSED
return true
}
return false
......@@ -276,8 +279,8 @@ open class AudioPlayerContainerActivity : BaseActivity() {
* Slide up and down the audio player depending on its current state.
*/
fun slideUpOrDownAudioPlayer() {
if (!isAudioPlayerReady || bottomSheetBehavior.state == STATE_HIDDEN) return
bottomSheetBehavior.state = if (bottomSheetBehavior.state == STATE_EXPANDED)
if (!isAudioPlayerReady || playerBehavior.state == STATE_HIDDEN) return
playerBehavior.state = if (playerBehavior.state == STATE_EXPANDED)
STATE_COLLAPSED
else
STATE_EXPANDED
......@@ -294,8 +297,8 @@ open class AudioPlayerContainerActivity : BaseActivity() {
private fun hideAudioPlayerImpl() {
if (!isAudioPlayerReady) return
bottomSheetBehavior.isHideable = true
bottomSheetBehavior.state = STATE_HIDDEN
playerBehavior.isHideable = true
playerBehavior.state = STATE_HIDDEN
}
private fun updateProgressVisibility(show: Boolean, discovery: String? = null, parsing: Int = -1) {
......@@ -312,21 +315,21 @@ open class AudioPlayerContainerActivity : BaseActivity() {
private fun showProgressBar(discovery: String, parsing: Int) {
if (!Medialibrary.getInstance().isWorking) return
val vsc = findViewById<View>(R.id.scan_viewstub)
if (vsc != null) {
vsc.visibility = View.VISIBLE
scanProgressLayout = findViewById(R.id.scan_progress_layout)
scanProgressText = findViewById(R.id.scan_progress_text)
scanProgressBar = findViewById(R.id.scan_progress_bar)
} else scanProgressLayout?.visibility = View.VISIBLE
scanProgressText?.text = discovery
scanProgressBar?.progress = parsing
val vsc = findViewById<View>(R.id.scan_viewstub)
if (vsc != null) {
vsc.visibility = View.VISIBLE
scanProgressLayout = findViewById(R.id.scan_progress_layout)
scanProgressText = findViewById(R.id.scan_progress_text)
scanProgressBar = findViewById(R.id.scan_progress_bar)
} else scanProgressLayout?.visibility = View.VISIBLE
scanProgressText?.text = discovery
scanProgressBar?.progress = parsing
}
protected fun updateContainerPadding(show: Boolean) {
if (!::fragmentContainer.isInitialized) return
val factor = if (show) 1 else 0
val peekHeight = if (show && isAudioPlayerReady) bottomSheetBehavior.peekHeight else 0
val peekHeight = if (show && isAudioPlayerReady) playerBehavior.peekHeight else 0
fragmentContainer.run {
setPadding(paddingLeft, paddingTop, paddingRight, originalBottomPadding + factor * peekHeight)
}
......@@ -347,7 +350,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
if (showPlayer == true) showAudioPlayer()
else {
hideAudioPlayer()
if (isAudioPlayerReady) bottomSheetBehavior.lock(true)
if (isAudioPlayerReady) playerBehavior.lock(true)
}
})
MediaParsingService.progress.observe(this, Observer { scanProgress ->
......@@ -392,7 +395,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
if (this::resumeCard.isInitialized && resumeCard.isShown) resumeCard.dismiss()
showAudioPlayerImpl()
updateContainerPadding(true)
bottomSheetBehavior.let { owner.applyMarginToProgressBar(it.peekHeight) }
playerBehavior.let { owner.applyMarginToProgressBar(it.peekHeight) }
}
ACTION_HIDE_PLAYER -> owner.run {
hideAudioPlayerImpl()
......
......@@ -37,6 +37,7 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.libvlc.RendererItem
import org.videolan.resources.AndroidDevices
import org.videolan.tools.Settings
import org.videolan.tools.setGone
import org.videolan.vlc.PlaybackService
import org.videolan.vlc.R
import org.videolan.vlc.RendererDelegate
......@@ -53,6 +54,7 @@ open class ContentActivity : AudioPlayerContainerActivity(), SearchView.OnQueryT
private lateinit var searchView: SearchView
private var showRenderers = !AndroidDevices.isChromeBook && !RendererDelegate.renderers.value.isNullOrEmpty()
private val searchHiddenMenuItem = ArrayList<MenuItem>()
open val displayTitle = false
override fun initAudioPlayerContainerActivity() {
......@@ -75,6 +77,10 @@ open class ContentActivity : AudioPlayerContainerActivity(), SearchView.OnQueryT
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
UiTools.setOnDragListener(this)
if (displayTitle) {
findViewById<View>(R.id.toolbar_icon).setGone()
findViewById<View>(R.id.toolbar_vlc_title).setGone()
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
......
......@@ -37,10 +37,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.medialibrary.interfaces.Medialibrary
import org.videolan.resources.ACTIVITY_RESULT_OPEN
import org.videolan.resources.ACTIVITY_RESULT_PREFERENCES
import org.videolan.resources.ACTIVITY_RESULT_SECONDARY
import org.videolan.resources.EXTRA_TARGET
import org.videolan.resources.*
import org.videolan.tools.*
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
......@@ -101,16 +98,12 @@ class MainActivity : ContentActivity(),
mainLoadingProgress.indeterminateDrawable.setColorFilter(color, android.graphics.PorterDuff.Mode.SRC_IN)
}
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
// Sync the toggle state after onRestoreInstanceState has occurred.
drawerToggle.syncState()
}
private fun prepareActionBar() {
supportActionBar?.run {
setDisplayHomeAsUpEnabled(true)
setHomeButtonEnabled(true)
setDisplayHomeAsUpEnabled(false)
setHomeButtonEnabled(false)
setDisplayShowTitleEnabled(!AndroidDevices.isPhone)
}
}
......@@ -145,11 +138,7 @@ class MainActivity : ContentActivity(),
@TargetApi(Build.VERSION_CODES.N)
override fun onBackPressed() {
/* Close the menu first */
if (drawerLayout.isDrawerOpen(navigationView)) {
closeDrawer()
return
}
/* Close playlist search if open or Slide down the audio player if it is shown entirely. */
if (isAudioPlayerReady && (audioPlayer.backPressed() || slideDownAudioPlayer()))
......@@ -179,8 +168,7 @@ class MainActivity : ContentActivity(),
* Handle onClick form menu buttons
*/
override fun onOptionsItemSelected(item: MenuItem): Boolean {
closeDrawer()
if (item.itemId != R.id.ml_menu_filter) UiTools.setKeyboardVisibility(drawerLayout, false)
if (item.itemId != R.id.ml_menu_filter) UiTools.setKeyboardVisibility(appBarLayout, false)
// Handle item selection
return when (item.itemId) {
......@@ -191,7 +179,7 @@ class MainActivity : ContentActivity(),
}
android.R.id.home ->
// Slide down the audio player or toggle the sidebar
slideDownAudioPlayer() || drawerToggle.onOptionsItemSelected(item)
slideDownAudioPlayer()
else -> super.onOptionsItemSelected(item)
}
}
......
......@@ -53,6 +53,7 @@ import org.videolan.vlc.reloadLibrary
class SecondaryActivity : ContentActivity() {
private var fragment: Fragment? = null
override val displayTitle = true
override fun onCreate(savedInstanceState: Bundle?) {