Revert "Revert "Scroll helper""
This commit is contained in:
parent
886112d7df
commit
a051bb7722
22 changed files with 217 additions and 194 deletions
|
@ -184,6 +184,8 @@ dependencies {
|
|||
|
||||
implementation 'com.github.AdrienPoupa:jaudiotagger:2.2.3'
|
||||
|
||||
implementation 'com.github.ologe:scroll-helper:2.0.0-beta01'
|
||||
|
||||
implementation 'com.anjlab.android.iab.v3:library:1.1.0'
|
||||
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
||||
implementation 'com.heinrichreimersoftware:material-intro:1.6'
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package code.name.monkey.retromusic
|
||||
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||
import dev.olog.scrollhelper.ScrollHelper
|
||||
|
||||
class RetroScrollHelper(
|
||||
private val activity: FragmentActivity
|
||||
) : ScrollHelper(activity,
|
||||
true,
|
||||
false // TODO when true, scrolls both bottomsheet and bottom navigation
|
||||
) {
|
||||
|
||||
private val skipFragment = listOf(
|
||||
PlayerFragment::class.java.name
|
||||
)
|
||||
|
||||
// TODO every fragment has to have it's unique tag in order to work correctly
|
||||
// here you can decide what fragment will be processed by the library
|
||||
// probably you want to skip player fragments, ecc ..
|
||||
override fun shouldSkipFragment(fragment: Fragment): Boolean {
|
||||
return fragment::class.java.name in skipFragment
|
||||
}
|
||||
|
||||
override fun findBottomNavigation(): View? {
|
||||
return activity.findViewById(R.id.bottomNavigationView)
|
||||
}
|
||||
|
||||
override fun findBottomSheet(): View? {
|
||||
return activity.findViewById(R.id.slidingPanel)
|
||||
}
|
||||
|
||||
override fun findFab(fragment: Fragment): View? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun findRecyclerView(fragment: Fragment): RecyclerView? {
|
||||
return fragment.requireView().findViewById(R.id.recyclerView)
|
||||
}
|
||||
|
||||
override fun findToolbar(fragment: Fragment): View? {
|
||||
return fragment.requireActivity().findViewById(R.id.toolbarContainer)
|
||||
}
|
||||
|
||||
override fun findTabLayout(fragment: Fragment): View? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun findViewPager(fragment: Fragment): ViewPager2? {
|
||||
return null
|
||||
}
|
||||
|
||||
// TODO override this if you want to apply custom padding
|
||||
override fun updateRecyclerViewPadding(
|
||||
fragment: Fragment,
|
||||
recyclerView: RecyclerView,
|
||||
topPadding: Int,
|
||||
bottomPadding: Int
|
||||
) {
|
||||
super.updateRecyclerViewPadding(fragment, recyclerView, topPadding, bottomPadding)
|
||||
}
|
||||
|
||||
}
|
|
@ -55,6 +55,7 @@ import java.util.List;
|
|||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.RetroScrollHelper;
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity;
|
||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog;
|
||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
||||
|
@ -83,6 +84,7 @@ import code.name.monkey.retromusic.util.NavigationUtil;
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil;
|
||||
import code.name.monkey.retromusic.util.RetroUtil;
|
||||
import dev.olog.scrollhelper.ScrollHelper;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2020-02-19.
|
||||
|
@ -119,6 +121,9 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
private Toolbar mToolbar;
|
||||
private MaterialCardView mToolbarContainer;
|
||||
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private ScrollHelper scrollHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
setDrawUnderStatusBar();
|
||||
|
@ -151,6 +156,8 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
checkShowChangelog();
|
||||
AppRater.appLaunched(this);
|
||||
setupToolbar();
|
||||
|
||||
scrollHelper = new RetroScrollHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -111,10 +111,14 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator?.cancel() // just in case
|
||||
navigationBarColorAnimator?.cancel() // just in case
|
||||
}
|
||||
|
||||
protected fun wrapSlidingMusicPanel(@LayoutRes resId: Int): View {
|
||||
|
@ -142,7 +146,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
// necessary to make the views below clickable
|
||||
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
|
||||
|
||||
bottomNavigationView.translationY = progress * 500
|
||||
//bottomNavigationView.alpha = alpha
|
||||
}
|
||||
|
||||
|
@ -217,8 +220,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
}
|
||||
}
|
||||
|
||||
fun setBottomBarVisibility(gone: Int) {
|
||||
bottomNavigationView.visibility = gone
|
||||
fun setBottomBarVisibility(visibility: Int) {
|
||||
bottomNavigationView.visibility = visibility
|
||||
hideBottomBar(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.DimenRes
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun Context.dip(value: Int): Int = (value * resources.displayMetrics.density).toInt()
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun Context.dimen(@DimenRes resource: Int): Int = resources.getDimensionPixelSize(resource)
|
|
@ -8,17 +8,13 @@ import androidx.annotation.NonNull
|
|||
import androidx.annotation.StringRes
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.ThemedFastScroller.create
|
||||
import code.name.monkey.retromusic.views.ScrollingViewOnApplyWindowInsetsListener
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.*
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
|
||||
abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : RecyclerView.LayoutManager> :
|
||||
AbsLibraryPagerFragment(), AppBarLayout.OnOffsetChangedListener {
|
||||
AbsLibraryPagerFragment() {
|
||||
|
||||
protected var adapter: A? = null
|
||||
protected var layoutManager: LM? = null
|
||||
|
@ -31,7 +27,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mainActivity.addOnAppBarOffsetChangedListener(this)
|
||||
initLayoutManager()
|
||||
initAdapter()
|
||||
setUpRecyclerView()
|
||||
|
@ -41,13 +36,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
val fastScroller = create(recyclerView)
|
||||
recyclerView.setOnApplyWindowInsetsListener(
|
||||
ScrollingViewOnApplyWindowInsetsListener(
|
||||
recyclerView,
|
||||
fastScroller
|
||||
)
|
||||
)
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
protected open fun createFastScroller(recyclerView: RecyclerView): FastScroller {
|
||||
|
@ -60,7 +48,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
checkIsEmpty()
|
||||
checkForPadding()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -78,18 +65,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
empty.visibility = if (adapter!!.itemCount == 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
private fun checkForPadding() {
|
||||
val itemCount: Int = adapter?.itemCount ?: 0
|
||||
val params = container.layoutParams as ViewGroup.MarginLayoutParams
|
||||
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
val height = DensityUtil.dip2px(requireContext(), 104f)
|
||||
params.bottomMargin = height
|
||||
} else {
|
||||
val height = DensityUtil.dip2px(requireContext(), 52f)
|
||||
params.bottomMargin = height
|
||||
}
|
||||
}
|
||||
|
||||
private fun initLayoutManager() {
|
||||
layoutManager = createLayoutManager()
|
||||
}
|
||||
|
@ -99,25 +74,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
@NonNull
|
||||
protected abstract fun createAdapter(): A
|
||||
|
||||
override fun onOffsetChanged(p0: AppBarLayout?, i: Int) {
|
||||
container.setPadding(
|
||||
container.paddingLeft,
|
||||
container.paddingTop,
|
||||
container.paddingRight,
|
||||
mainActivity.totalAppBarScrollingRange + i
|
||||
)
|
||||
}
|
||||
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
protected fun invalidateLayoutManager() {
|
||||
initLayoutManager()
|
||||
recyclerView.layoutManager = layoutManager
|
||||
|
@ -129,11 +85,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
mainActivity.removeOnAppBarOffsetChangedListener(this)
|
||||
}
|
||||
|
||||
fun recyclerView(): RecyclerView {
|
||||
return recyclerView
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import code.name.monkey.retromusic.model.Album
|
|||
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumsView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollGridLayoutManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class AlbumsFragment :
|
||||
|
@ -51,7 +52,7 @@ class AlbumsFragment :
|
|||
get() = R.string.no_albums
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(requireActivity(), getGridSize())
|
||||
return OverScrollGridLayoutManager(requireActivity(), getGridSize())
|
||||
}
|
||||
|
||||
override fun createAdapter(): AlbumAdapter {
|
||||
|
|
|
@ -12,6 +12,7 @@ import code.name.monkey.retromusic.model.Artist
|
|||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollGridLayoutManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class ArtistsFragment :
|
||||
|
@ -63,7 +64,7 @@ class ArtistsFragment :
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(requireActivity(), getGridSize())
|
||||
return OverScrollGridLayoutManager(requireActivity(), getGridSize())
|
||||
}
|
||||
|
||||
override fun createAdapter(): ArtistAdapter {
|
||||
|
|
|
@ -42,6 +42,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollLinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.abs_playlists.*
|
||||
import kotlinx.android.synthetic.main.fragment_banner_home.*
|
||||
import kotlinx.android.synthetic.main.home_content.*
|
||||
|
@ -147,7 +148,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
homeAdapter = HomeAdapter(mainActivity, displayMetrics)
|
||||
|
||||
recyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(mainActivity)
|
||||
layoutManager = OverScrollLinearLayoutManager(mainActivity)
|
||||
adapter = homeAdapter
|
||||
}
|
||||
homePresenter.attachView(this)
|
||||
|
|
|
@ -74,6 +74,7 @@ import code.name.monkey.retromusic.util.RetroColorUtil;
|
|||
import code.name.monkey.retromusic.util.ThemedFastScroller;
|
||||
import code.name.monkey.retromusic.views.BreadCrumbLayout;
|
||||
import code.name.monkey.retromusic.views.ScrollingViewOnApplyWindowInsetsListener;
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollLinearLayoutManager;
|
||||
import me.zhanghai.android.fastscroll.FastScroller;
|
||||
|
||||
public class FoldersFragment extends AbsMainActivityFragment implements
|
||||
|
@ -478,7 +479,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
}
|
||||
|
||||
private void setUpRecyclerView() {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
recyclerView.setLayoutManager(new OverScrollLinearLayoutManager(getActivity()));
|
||||
FastScroller fastScroller = ThemedFastScroller.INSTANCE.create(recyclerView);
|
||||
recyclerView.setOnApplyWindowInsetsListener(
|
||||
new ScrollingViewOnApplyWindowInsetsListener(recyclerView, fastScroller));
|
||||
|
|
|
@ -25,6 +25,7 @@ import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
|||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenresView
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollLinearLayoutManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
|
||||
|
@ -42,7 +43,7 @@ class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearL
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): LinearLayoutManager {
|
||||
return LinearLayoutManager(activity)
|
||||
return OverScrollLinearLayoutManager(activity)
|
||||
}
|
||||
|
||||
override fun createAdapter(): GenreAdapter {
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropM
|
|||
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager
|
||||
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollLinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.activity_playing_queue.*
|
||||
|
||||
/**
|
||||
|
@ -73,7 +74,7 @@ class PlayingQueueFragment :
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): LinearLayoutManager {
|
||||
return LinearLayoutManager(requireContext())
|
||||
return OverScrollLinearLayoutManager(requireContext())
|
||||
}
|
||||
|
||||
override fun createAdapter(): PlayingQueueAdapter {
|
||||
|
|
|
@ -13,6 +13,7 @@ import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
|||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistView
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollGridLayoutManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class PlaylistsFragment :
|
||||
|
@ -40,7 +41,7 @@ class PlaylistsFragment :
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(requireContext(), 1)
|
||||
return OverScrollGridLayoutManager(requireContext(), 1)
|
||||
}
|
||||
|
||||
override fun createAdapter(): PlaylistAdapter {
|
||||
|
|
|
@ -14,6 +14,7 @@ import code.name.monkey.retromusic.model.Song
|
|||
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SongView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollGridLayoutManager
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -39,7 +40,7 @@ class SongsFragment :
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(requireActivity(), getGridSize()).apply {
|
||||
return OverScrollGridLayoutManager(requireActivity(), getGridSize()).apply {
|
||||
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int): Int {
|
||||
return if (position == 0) {
|
||||
|
|
|
@ -18,11 +18,13 @@ import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
|||
import code.name.monkey.appthemehelper.util.ColorUtil.isColorLight
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper.getPrimaryTextColor
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.dimen
|
||||
import code.name.monkey.retromusic.extensions.dip
|
||||
import code.name.monkey.retromusic.views.PopupBackground
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
import me.zhanghai.android.fastscroll.PopupStyles
|
||||
import me.zhanghai.android.fastscroll.R
|
||||
|
||||
object ThemedFastScroller {
|
||||
fun create(view: ViewGroup): FastScroller {
|
||||
|
@ -37,6 +39,13 @@ object ThemedFastScroller {
|
|||
popupText.setTextColor(textColor)
|
||||
}
|
||||
|
||||
fastScrollerBuilder.setPadding(
|
||||
0,
|
||||
view.context.dimen(R.dimen.toolbar_height) + view.context.dip(8),
|
||||
0,
|
||||
view.context.dimen(R.dimen.mini_player_height)
|
||||
)
|
||||
|
||||
fastScrollerBuilder.setThumbDrawable(
|
||||
TintHelper.createTintedDrawable(
|
||||
context,
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This 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 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software 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.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class StatusBarView extends View {
|
||||
|
||||
|
||||
public StatusBarView(@NonNull Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public StatusBarView(@NonNull Context context, @NonNull AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public StatusBarView(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public static int getStatusBarHeight(@NonNull Resources r) {
|
||||
int result = 0;
|
||||
int resourceId = r.getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = r.getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), getStatusBarHeight(getResources()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package code.name.monkey.retromusic.views
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
|
||||
class StatusBarView(
|
||||
context: Context,
|
||||
attrs: AttributeSet
|
||||
) : View(context, attrs) {
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
if (isInEditMode){
|
||||
return
|
||||
}
|
||||
setOnApplyWindowInsetsListener { _, insets ->
|
||||
val height = insets?.systemWindowInsetTop ?: 0
|
||||
setHeight(height)
|
||||
insets
|
||||
}
|
||||
}
|
||||
|
||||
private fun setHeight(px: Int) {
|
||||
val params = layoutParams ?: return
|
||||
params.height = px
|
||||
layoutParams = params
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +1,71 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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="?colorSurface"
|
||||
android:orientation="vertical">
|
||||
android:background="?colorSurface">
|
||||
|
||||
<!-- TODO in order to work, children has to be defined in reverse drawing order-->
|
||||
<!-- TODO so: first fragment_container, than toolbar, than statusbar -->
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/status_bar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/toolbarContainer"
|
||||
app:layout_constraintTop_toBottomOf="@+id/status_bar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:elevation="0dp"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<include layout="@layout/status_bar" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="0dp"
|
||||
app:elevation="0dp"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/toolbarContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:background="?attr/colorSurface"
|
||||
app:popupTheme="?attr/toolbarPopupTheme"
|
||||
app:titleTextColor="?attr/colorControlNormal"
|
||||
app:titleTextAppearance="@style/TextViewHeadline6"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/appTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="?attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextViewHeadline6" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/cab_stub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height" />
|
||||
</FrameLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:background="?attr/colorSurface"
|
||||
app:popupTheme="?attr/toolbarPopupTheme"
|
||||
app:titleTextColor="?attr/colorControlNormal"
|
||||
app:titleTextAppearance="@style/TextViewHeadline6"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/appTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="?attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextViewHeadline6" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/cab_stub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height" />
|
||||
</FrameLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<include layout="@layout/status_bar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_width="0dp"
|
||||
tools:layout_height="24dp"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -17,6 +17,7 @@
|
|||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/toolbar_height"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/toolbar_height"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -6,15 +6,16 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- TODO note that recycler view has to cover the entire screen -->
|
||||
<!-- TODO so has to be drawn under bottom navigation, toolbar, ecc, but has to be below statusbar-->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation_fall_down"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none"
|
||||
app:layout_dodgeInsetEdges="bottom"
|
||||
tools:listitem="@layout/item_list" />
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
android:id="@+id/miniPlayerFragment"
|
||||
android:name="code.name.monkey.retromusic.fragments.MiniPlayerFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_height="@dimen/mini_player_height"
|
||||
tools:layout="@layout/fragment_mini_player" />
|
||||
|
||||
</FrameLayout>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue