Fix bottom navigation hiding

This commit is contained in:
Hemanth S 2020-08-13 18:06:24 +05:30
parent 3a68c7de12
commit ff20b3a052
10 changed files with 114 additions and 138 deletions

View file

@ -14,7 +14,6 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.RetroBottomSheetBehavior import code.name.monkey.retromusic.RetroBottomSheetBehavior
import code.name.monkey.retromusic.extensions.dimToPixel
import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.extensions.whichFragment import code.name.monkey.retromusic.extensions.whichFragment
@ -180,7 +179,7 @@ abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() {
} }
private fun hideBottomBar(hide: Boolean) { private fun hideBottomBar(hide: Boolean) {
val heightOfBar = dimToPixel(R.dimen.mini_player_height) val heightOfBar = bottomNavigationView.height
val isBottomBarVisible = bottomNavigationView.isVisible val isBottomBarVisible = bottomNavigationView.isVisible
if (hide) { if (hide) {
@ -192,7 +191,7 @@ abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() {
ViewCompat.setElevation(bottomNavigationView, 10f) ViewCompat.setElevation(bottomNavigationView, 10f)
ViewCompat.setElevation(slidingPanel, 10f) ViewCompat.setElevation(slidingPanel, 10f)
behavior.isHideable = false behavior.isHideable = false
behavior.peekHeight = if (isBottomBarVisible) heightOfBar * 2 else heightOfBar behavior.peekHeight = (if (isBottomBarVisible) heightOfBar * 2 else heightOfBar) - 24
} }
} }

View file

@ -166,19 +166,18 @@ class HomeAdapter(
val color = ThemeStore.accentColor(activity) val color = ThemeStore.accentColor(activity)
itemView.findViewById<TextView>(R.id.message).setTextColor(color) itemView.findViewById<TextView>(R.id.message).setTextColor(color)
itemView.findViewById<MaterialCardView>(R.id.card6).apply { itemView.findViewById<MaterialCardView>(R.id.card6).apply {
setCardBackgroundColor(ColorUtil.withAlpha(color, 0.2f)) setCardBackgroundColor(ColorUtil.withAlpha(color, 0.12f))
} }
if (songs.size > 9) images.forEachIndexed { index, id ->
images.forEachIndexed { index, i -> itemView.findViewById<View>(id).setOnClickListener {
itemView.findViewById<View>(i).setOnClickListener { MusicPlayerRemote.playNext(songs[index])
MusicPlayerRemote.playNext(songs[index])
}
SongGlideRequest.Builder.from(Glide.with(activity), songs[index])
.asBitmap()
.build()
.into(itemView.findViewById(i))
} }
SongGlideRequest.Builder.from(Glide.with(activity), songs[index])
.asBitmap()
.build()
.into(itemView.findViewById(id))
}
} }
} }

View file

@ -15,6 +15,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.common.ATHToolbarActivity.getToolbarBackgroundColor import code.name.monkey.appthemehelper.common.ATHToolbarActivity.getToolbarBackgroundColor
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.EXTRA_ALBUM_ID
import code.name.monkey.retromusic.EXTRA_ARTIST_ID import code.name.monkey.retromusic.EXTRA_ARTIST_ID
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
@ -65,6 +66,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
mainActivity.hideBottomBarVisibility(false) mainActivity.hideBottomBarVisibility(false)
mainActivity.addMusicServiceEventListener(detailsViewModel) mainActivity.addMusicServiceEventListener(detailsViewModel)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
toolbar.title = null toolbar.title = null
postponeEnterTransition() postponeEnterTransition()
@ -238,7 +240,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
override fun onAlbumClick(albumId: Int, view: View) { override fun onAlbumClick(albumId: Int, view: View) {
findNavController().navigate( findNavController().navigate(
R.id.albumDetailsFragment, R.id.albumDetailsFragment,
bundleOf("extra_album_id" to albumId) bundleOf(EXTRA_ALBUM_ID to albumId)
) )
} }
@ -263,6 +265,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
var sortOrder: String? = null var sortOrder: String? = null
val songs = simpleSongAdapter.dataSet val songs = simpleSongAdapter.dataSet
when (item.itemId) { when (item.itemId) {
android.R.id.home -> findNavController().navigateUp()
R.id.action_play_next -> { R.id.action_play_next -> {
MusicPlayerRemote.playNext(songs) MusicPlayerRemote.playNext(songs)
return true return true

View file

@ -10,6 +10,8 @@ import android.view.View
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat.getSystemService import androidx.core.content.ContextCompat.getSystemService
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -38,14 +40,13 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mainActivity.setSupportActionBar(toolbar) mainActivity.setSupportActionBar(toolbar)
mainActivity.hideBottomNavigation()
mainActivity.hideBottomBarVisibility(false) mainActivity.hideBottomBarVisibility(false)
setupRecyclerView() setupRecyclerView()
setupSearchView() keyboardPopup.accentColor()
searchView.addTextChangedListener(this)
voiceSearch.setOnClickListener { startMicSearch() } voiceSearch.setOnClickListener { startMicSearch() }
clearText.setOnClickListener { searchView.clearText() } clearText.setOnClickListener { searchView.clearText() }
keyboardPopup.setOnClickListener { keyboardPopup.setOnClickListener {
val inputManager = val inputManager =
getSystemService<InputMethodManager>( getSystemService<InputMethodManager>(
@ -54,7 +55,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
) )
inputManager?.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT) inputManager?.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT)
} }
keyboardPopup.accentColor()
if (savedInstanceState != null) { if (savedInstanceState != null) {
query = savedInstanceState.getString(QUERY) query = savedInstanceState.getString(QUERY)
} }
@ -78,7 +79,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
searchAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { searchAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
override fun onChanged() { override fun onChanged() {
super.onChanged() super.onChanged()
empty.visibility = if (searchAdapter.itemCount < 1) View.VISIBLE else View.GONE empty.isVisible = searchAdapter.itemCount < 1
} }
}) })
recyclerView.apply { recyclerView.apply {
@ -97,10 +98,6 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
} }
} }
private fun setupSearchView() {
searchView.addTextChangedListener(this)
}
override fun afterTextChanged(newText: Editable?) { override fun afterTextChanged(newText: Editable?) {
search(newText.toString()) search(newText.toString())
} }
@ -116,8 +113,8 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
private fun search(query: String) { private fun search(query: String) {
this.query = query this.query = query
TransitionManager.beginDelayedTransition(appBarLayout) TransitionManager.beginDelayedTransition(appBarLayout)
voiceSearch.visibility = if (query.isNotEmpty()) View.GONE else View.VISIBLE voiceSearch.isGone = query.isNotEmpty()
clearText.visibility = if (query.isNotEmpty()) View.VISIBLE else View.GONE clearText.isVisible = query.isNotEmpty()
viewModel.search(query) viewModel.search(query)
} }

View file

@ -143,9 +143,10 @@ class RepositoryImpl(
override suspend fun suggestionsHome(): Home { override suspend fun suggestionsHome(): Home {
val songs = val songs =
NotRecentlyPlayedPlaylist(context).getSongs(context).shuffled().takeUnless { NotRecentlyPlayedPlaylist(context).getSongs(context).shuffled().takeIf {
it.size > 9 it.size > 9
}?.take(9) ?: emptyList<Song>() } ?: emptyList()
println(songs.size)
return Home(songs, SUGGESTIONS) return Home(songs, SUGGESTIONS)
} }

View file

@ -66,5 +66,5 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
} }
fun Int.addAlpha(): Int { fun Int.addAlpha(): Int {
return ColorUtil.withAlpha(this, 0.38f) return ColorUtil.withAlpha(this, 0.12f)
} }

View file

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/miniPlayerContent" android:id="@+id/miniPlayerContent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_peek_1_height" android:layout_height="56dp"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"

View file

@ -1,132 +1,105 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:orientation="vertical"> android:orientation="vertical">
<code.name.monkey.retromusic.views.StatusBarView <com.google.android.material.appbar.AppBarLayout
android:id="@+id/status_bar" android:id="@+id/appBarLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="wrap_content">
android:background="?attr/colorSurface"
tools:ignore="UnusedAttribute" />
<androidx.coordinatorlayout.widget.CoordinatorLayout <com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent" android:id="@+id/toolbar"
android:layout_height="match_parent" style="@style/Toolbar"
android:background="?attr/colorSurface"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
app:liftOnScroll="true"> app:navigationIcon="@drawable/ic_keyboard_backspace_black"
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal">
<com.google.android.material.appbar.MaterialToolbar <LinearLayout
android:id="@+id/toolbar"
style="@style/Toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:navigationIcon="@drawable/ic_keyboard_backspace_black" android:gravity="center_vertical">
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal">
<LinearLayout <com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical"> android:layout_weight="1"
android:background="@null"
android:hint="@string/action_search"
android:inputType="text|textAutoComplete"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewSubtitle1">
<com.google.android.material.textfield.TextInputLayout <requestFocus />
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" </com.google.android.material.textfield.TextInputEditText>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:boxStrokeColor="?attr/colorControlNormal"
app:boxStrokeWidth="1dp"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText <FrameLayout
android:id="@+id/searchView" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="@dimen/toolbar_height" android:layout_weight="0">
android:background="@null"
android:hint="@string/action_search"
android:inputType="text|textAutoComplete"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewSubtitle1">
<requestFocus /> <androidx.appcompat.widget.AppCompatImageView
</com.google.android.material.textfield.TextInputEditText> android:id="@+id/voiceSearch"
</com.google.android.material.textfield.TextInputLayout>
<FrameLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"> android:background="?roundSelector"
android:padding="12dp"
app:srcCompat="@drawable/ic_mic"
app:tint="?attr/colorControlNormal"
tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/voiceSearch" android:id="@+id/clearText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?roundSelector" android:background="?roundSelector"
android:padding="12dp" android:padding="12dp"
app:srcCompat="@drawable/ic_mic" android:visibility="gone"
app:tint="?attr/colorControlNormal" app:srcCompat="@drawable/ic_close"
tools:visibility="visible" /> app:tint="?attr/colorControlNormal"
tools:visibility="visible" />
</FrameLayout>
</LinearLayout>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.appcompat.widget.AppCompatImageView <com.google.android.material.textview.MaterialTextView
android:id="@+id/clearText" android:id="@android:id/empty"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?roundSelector" android:layout_gravity="center"
android:padding="12dp" android:gravity="center"
android:visibility="gone" android:text="@string/no_results"
app:srcCompat="@drawable/ic_close" android:textAppearance="@style/TextViewHeadline6"
app:tint="?attr/colorControlNormal" android:visibility="gone"
tools:visibility="visible" /> tools:visibility="visible" />
</FrameLayout>
</LinearLayout>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.textview.MaterialTextView <androidx.recyclerview.widget.RecyclerView
android:id="@android:id/empty" android:id="@+id/recyclerView"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:clipToPadding="false"
android:gravity="center" android:overScrollMode="never"
android:text="@string/no_results" android:scrollbarStyle="outsideOverlay"
android:textAppearance="@style/TextViewHeadline6" android:scrollbars="vertical"
android:visibility="gone" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
tools:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/recyclerView" android:id="@+id/keyboardPopup"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clipToPadding="false" android:layout_gravity="end|bottom"
android:overScrollMode="never" android:layout_marginEnd="16dp"
android:scrollbarStyle="outsideOverlay" android:layout_marginBottom="62dp"
android:scrollbars="vertical" android:text="@string/keyboard"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" /> android:textAppearance="@style/TextViewHeadline6"
app:icon="@drawable/ic_keyboard" />
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton </androidx.coordinatorlayout.widget.CoordinatorLayout>
android:id="@+id/keyboardPopup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginEnd="16dp"
android:layout_marginBottom="62dp"
android:text="@string/keyboard"
android:textAppearance="@style/TextViewHeadline6"
app:icon="@drawable/ic_keyboard" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>

View file

@ -140,10 +140,14 @@
android:id="@+id/message" android:id="@+id/message"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:autoSizeTextType="uniform"
android:padding="8dp" android:padding="8dp"
android:text="New music mix" android:text="New music mix"
android:textAppearance="@style/TextViewHeadline4" android:textAppearance="@style/TextViewNormal"
android:textStyle="bold" /> android:textStyle="bold"
app:autoSizeMaxTextSize="32sp"
app:autoSizeMinTextSize="18sp"
app:autoSizeStepGranularity="1sp" />
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView

View file

@ -46,7 +46,7 @@
<code.name.monkey.retromusic.views.BottomNavigationBarTinted <code.name.monkey.retromusic.views.BottomNavigationBarTinted
android:id="@+id/bottomNavigationView" android:id="@+id/bottomNavigationView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="56dp"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:elevation="0dp" android:elevation="0dp"
app:itemHorizontalTranslationEnabled="false" app:itemHorizontalTranslationEnabled="false"