Fix bottom navigation hiding
This commit is contained in:
parent
3a68c7de12
commit
ff20b3a052
10 changed files with 114 additions and 138 deletions
|
@ -14,7 +14,6 @@ import code.name.monkey.appthemehelper.util.ATHUtil
|
|||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
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.show
|
||||
import code.name.monkey.retromusic.extensions.whichFragment
|
||||
|
@ -180,7 +179,7 @@ abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() {
|
|||
}
|
||||
|
||||
private fun hideBottomBar(hide: Boolean) {
|
||||
val heightOfBar = dimToPixel(R.dimen.mini_player_height)
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
val isBottomBarVisible = bottomNavigationView.isVisible
|
||||
|
||||
if (hide) {
|
||||
|
@ -192,7 +191,7 @@ abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() {
|
|||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
behavior.isHideable = false
|
||||
behavior.peekHeight = if (isBottomBarVisible) heightOfBar * 2 else heightOfBar
|
||||
behavior.peekHeight = (if (isBottomBarVisible) heightOfBar * 2 else heightOfBar) - 24
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -166,17 +166,16 @@ class HomeAdapter(
|
|||
val color = ThemeStore.accentColor(activity)
|
||||
itemView.findViewById<TextView>(R.id.message).setTextColor(color)
|
||||
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, i ->
|
||||
itemView.findViewById<View>(i).setOnClickListener {
|
||||
images.forEachIndexed { index, id ->
|
||||
itemView.findViewById<View>(id).setOnClickListener {
|
||||
MusicPlayerRemote.playNext(songs[index])
|
||||
}
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), songs[index])
|
||||
.asBitmap()
|
||||
.build()
|
||||
.into(itemView.findViewById(i))
|
||||
.into(itemView.findViewById(id))
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity.getToolbarBackgroundColor
|
||||
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.R
|
||||
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
|
||||
|
@ -65,6 +66,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
mainActivity.hideBottomBarVisibility(false)
|
||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
|
||||
toolbar.title = null
|
||||
|
||||
postponeEnterTransition()
|
||||
|
@ -238,7 +240,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
override fun onAlbumClick(albumId: Int, view: View) {
|
||||
findNavController().navigate(
|
||||
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
|
||||
val songs = simpleSongAdapter.dataSet
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> findNavController().navigateUp()
|
||||
R.id.action_play_next -> {
|
||||
MusicPlayerRemote.playNext(songs)
|
||||
return true
|
||||
|
|
|
@ -10,6 +10,8 @@ import android.view.View
|
|||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat.getSystemService
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -38,14 +40,13 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.hideBottomNavigation()
|
||||
mainActivity.hideBottomBarVisibility(false)
|
||||
|
||||
setupRecyclerView()
|
||||
setupSearchView()
|
||||
keyboardPopup.accentColor()
|
||||
searchView.addTextChangedListener(this)
|
||||
voiceSearch.setOnClickListener { startMicSearch() }
|
||||
clearText.setOnClickListener { searchView.clearText() }
|
||||
|
||||
keyboardPopup.setOnClickListener {
|
||||
val inputManager =
|
||||
getSystemService<InputMethodManager>(
|
||||
|
@ -54,7 +55,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
)
|
||||
inputManager?.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
keyboardPopup.accentColor()
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
query = savedInstanceState.getString(QUERY)
|
||||
}
|
||||
|
@ -78,7 +79,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
searchAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
empty.visibility = if (searchAdapter.itemCount < 1) View.VISIBLE else View.GONE
|
||||
empty.isVisible = searchAdapter.itemCount < 1
|
||||
}
|
||||
})
|
||||
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?) {
|
||||
search(newText.toString())
|
||||
}
|
||||
|
@ -116,8 +113,8 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
private fun search(query: String) {
|
||||
this.query = query
|
||||
TransitionManager.beginDelayedTransition(appBarLayout)
|
||||
voiceSearch.visibility = if (query.isNotEmpty()) View.GONE else View.VISIBLE
|
||||
clearText.visibility = if (query.isNotEmpty()) View.VISIBLE else View.GONE
|
||||
voiceSearch.isGone = query.isNotEmpty()
|
||||
clearText.isVisible = query.isNotEmpty()
|
||||
viewModel.search(query)
|
||||
}
|
||||
|
||||
|
|
|
@ -143,9 +143,10 @@ class RepositoryImpl(
|
|||
|
||||
override suspend fun suggestionsHome(): Home {
|
||||
val songs =
|
||||
NotRecentlyPlayedPlaylist(context).getSongs(context).shuffled().takeUnless {
|
||||
NotRecentlyPlayedPlaylist(context).getSongs(context).shuffled().takeIf {
|
||||
it.size > 9
|
||||
}?.take(9) ?: emptyList<Song>()
|
||||
} ?: emptyList()
|
||||
println(songs.size)
|
||||
return Home(songs, SUGGESTIONS)
|
||||
}
|
||||
|
||||
|
|
|
@ -66,5 +66,5 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
fun Int.addAlpha(): Int {
|
||||
return ColorUtil.withAlpha(this, 0.38f)
|
||||
return ColorUtil.withAlpha(this, 0.12f)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/miniPlayerContent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_peek_1_height"
|
||||
android:layout_height="56dp"
|
||||
android:background="?attr/colorSurface"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
|
|
|
@ -1,19 +1,7 @@
|
|||
<?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:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<code.name.monkey.retromusic.views.StatusBarView
|
||||
android:id="@+id/status_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:background="?attr/colorSurface"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
|
@ -22,15 +10,14 @@
|
|||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorSurface"
|
||||
app:liftOnScroll="true">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorSurface"
|
||||
app:navigationIcon="@drawable/ic_keyboard_backspace_black"
|
||||
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal">
|
||||
|
||||
|
@ -39,23 +26,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
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
|
||||
android:id="@+id/searchView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:hint="@string/action_search"
|
||||
android:inputType="text|textAutoComplete"
|
||||
|
@ -65,7 +40,6 @@
|
|||
|
||||
<requestFocus />
|
||||
</com.google.android.material.textfield.TextInputEditText>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -128,5 +102,4 @@
|
|||
android:text="@string/keyboard"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
app:icon="@drawable/ic_keyboard" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -140,10 +140,14 @@
|
|||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:padding="8dp"
|
||||
android:text="New music mix"
|
||||
android:textAppearance="@style/TextViewHeadline4"
|
||||
android:textStyle="bold" />
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textStyle="bold"
|
||||
app:autoSizeMaxTextSize="32sp"
|
||||
app:autoSizeMinTextSize="18sp"
|
||||
app:autoSizeStepGranularity="1sp" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||
android:id="@+id/bottomNavigationView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:elevation="0dp"
|
||||
app:itemHorizontalTranslationEnabled="false"
|
||||
|
|
Loading…
Reference in a new issue