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.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
}
}

View file

@ -166,19 +166,18 @@ 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 {
MusicPlayerRemote.playNext(songs[index])
}
SongGlideRequest.Builder.from(Glide.with(activity), songs[index])
.asBitmap()
.build()
.into(itemView.findViewById(i))
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(id))
}
}
}

View file

@ -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

View file

@ -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)
}

View file

@ -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)
}

View file

@ -66,5 +66,5 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
}
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"
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"

View file

@ -1,132 +1,105 @@
<?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:background="?attr/colorSurface"
android:orientation="vertical">
<code.name.monkey.retromusic.views.StatusBarView
android:id="@+id/status_bar"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/colorSurface"
tools:ignore="UnusedAttribute" />
android:layout_height="wrap_content">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
<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:liftOnScroll="true">
app:navigationIcon="@drawable/ic_keyboard_backspace_black"
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Toolbar"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:navigationIcon="@drawable/ic_keyboard_backspace_black"
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal">
android:gravity="center_vertical">
<LinearLayout
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchView"
android:layout_width="match_parent"
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
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">
<requestFocus />
</com.google.android.material.textfield.TextInputEditText>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@null"
android:hint="@string/action_search"
android:inputType="text|textAutoComplete"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewSubtitle1">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0">
<requestFocus />
</com.google.android.material.textfield.TextInputEditText>
</com.google.android.material.textfield.TextInputLayout>
<FrameLayout
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/voiceSearch"
android:layout_width="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
android:id="@+id/voiceSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?roundSelector"
android:padding="12dp"
app:srcCompat="@drawable/ic_mic"
app:tint="?attr/colorControlNormal"
tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/clearText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?roundSelector"
android:padding="12dp"
android:visibility="gone"
app:srcCompat="@drawable/ic_close"
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
android:id="@+id/clearText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?roundSelector"
android:padding="12dp"
android:visibility="gone"
app:srcCompat="@drawable/ic_close"
app:tint="?attr/colorControlNormal"
tools:visibility="visible" />
</FrameLayout>
</LinearLayout>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/no_results"
android:textAppearance="@style/TextViewHeadline6"
android:visibility="gone"
tools:visibility="visible" />
<com.google.android.material.textview.MaterialTextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/no_results"
android:textAppearance="@style/TextViewHeadline6"
android:visibility="gone"
tools:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:overScrollMode="never"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:overScrollMode="never"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
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>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
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>

View file

@ -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

View file

@ -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"