diff --git a/app/build.gradle b/app/build.gradle index 2aed7142f..bf4bd4d53 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -117,28 +117,23 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation project(':appthemehelper') implementation 'androidx.multidex:multidex:2.0.1' - implementation "androidx.gridlayout:gridlayout:1.0.0" implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.palette:palette:1.0.0" implementation 'androidx.palette:palette-ktx:1.0.0' - implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.annotation:annotation:1.1.0' implementation 'androidx.preference:preference:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.core:core-ktx:1.1.0' - implementation 'androidx.fragment:fragment:1.2.0-rc04' - implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha01' + implementation 'androidx.fragment:fragment:1.2.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'com.google.android.material:material:1.2.0-alpha03' - implementation 'com.google.android.play:core:1.6.4' + implementation 'com.google.android.material:material:1.0.0' def retrofit_version = "2.6.2" implementation "com.squareup.retrofit2:retrofit:$retrofit_version" implementation "com.squareup.retrofit2:converter-gson:$retrofit_version" - implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' def material_dialog_version = "3.1.1" diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt index 7cec24c4a..957ee06c5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt @@ -12,8 +12,10 @@ import androidx.fragment.app.Fragment 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.extensions.doOnApplyWindowInsets import code.name.monkey.retromusic.extensions.hide import code.name.monkey.retromusic.extensions.show +import code.name.monkey.retromusic.extensions.updateMargins import code.name.monkey.retromusic.fragments.MiniPlayerFragment import code.name.monkey.retromusic.fragments.NowPlayingScreen import code.name.monkey.retromusic.fragments.NowPlayingScreen.ADAPTIVE @@ -55,6 +57,7 @@ import code.name.monkey.retromusic.views.BottomNavigationBarTinted import com.google.android.material.bottomsheet.BottomSheetBehavior import kotlinx.android.synthetic.main.sliding_music_panel_layout.bottomNavigationView import kotlinx.android.synthetic.main.sliding_music_panel_layout.dimBackground +import kotlinx.android.synthetic.main.sliding_music_panel_layout.mainContent import kotlinx.android.synthetic.main.sliding_music_panel_layout.slidingPanel abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlayerFragment.Callbacks { @@ -102,7 +105,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(createContentView()) - + mainContent.systemUiVisibility = + View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION chooseFragmentForTheme() setupSlidingUpPanel() @@ -112,6 +116,14 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY) dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f)) + + bottomNavigationView.doOnApplyWindowInsets { view, windowInsets, initialPadding -> + view.updateMargins( + bottom = initialPadding.bottom + windowInsets.systemWindowInsetBottom, + left = initialPadding.left + windowInsets.systemWindowInsetLeft, + right = initialPadding.right + windowInsets.systemWindowInsetRight + ) + } } override fun onResume() { @@ -163,7 +175,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay // restore values super.setLightStatusbar(lightStatusBar) super.setTaskDescriptionColor(taskColor) - super.setNavigationbarColor(navigationBarColor) + super.setNavigationbarColor(Color.TRANSPARENT) super.setLightNavigationBar(lightNavigationBar) @@ -194,7 +206,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay when (panelState) { BottomSheetBehavior.STATE_EXPANDED -> onPanelExpanded() BottomSheetBehavior.STATE_COLLAPSED -> onPanelCollapsed() - else -> playerFragment!!.onHide() + else -> playerFragment?.onHide() } } }) @@ -222,8 +234,13 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay slidingPanel.cardElevation = DensityUtil.dip2px(this, 10f).toFloat() bottomNavigationView.elevation = DensityUtil.dip2px(this, 10f).toFloat() bottomSheetBehavior.isHideable = false - bottomSheetBehavior.peekHeight = - if (bottomNavigationView.visibility == View.VISIBLE) heightOfBarWithTabs else heightOfBar + /*bottomSheetBehavior.peekHeight = + if (bottomNavigationView.visibility == View.VISIBLE) heightOfBarWithTabs else heightOfBar*/ + + slidingPanel.doOnApplyWindowInsets { view, windowInsets, initialPadding -> + bottomSheetBehavior.peekHeight = + windowInsets.systemWindowInsetBottom + if (bottomNavigationView.visibility == View.VISIBLE) heightOfBarWithTabs else heightOfBar + } } } } @@ -306,6 +323,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay } else if (currentNowPlayingScreen == FULL || currentNowPlayingScreen == CARD || currentNowPlayingScreen == FIT || currentNowPlayingScreen == BLUR || currentNowPlayingScreen == BLUR_CARD) { super.setLightStatusbar(false) super.setLightNavigationBar(true) + super.setNavigationbarColor(Color.TRANSPARENT) } else if (currentNowPlayingScreen == COLOR || currentNowPlayingScreen == TINY) { super.setNavigationbarColor(paletteColor) super.setLightNavigationBar(isColorLight) @@ -315,7 +333,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay ColorUtil.isColorLight( ATHUtil.resolveColor( this, - android.R.attr.windowBackground + R.attr.colorSurface ) ) ) @@ -342,7 +360,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay navigationBarColor = color if (panelState == BottomSheetBehavior.STATE_COLLAPSED) { if (navigationBarColorAnimator != null) navigationBarColorAnimator!!.cancel() - super.setNavigationbarColor(color) + //super.setNavigationbarColor(color) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/WindowExt.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/WindowExt.kt new file mode 100644 index 000000000..3f4acd889 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/WindowExt.kt @@ -0,0 +1,84 @@ +/* + * 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.extensions + +import android.view.View +import android.view.View.OnAttachStateChangeListener +import android.view.ViewGroup +import android.view.WindowInsets +import androidx.annotation.Px +import androidx.core.view.marginBottom +import androidx.core.view.marginLeft +import androidx.core.view.marginRight +import androidx.core.view.marginTop + +fun View.doOnApplyWindowInsets(f: (View, WindowInsets, InitialPadding) -> Unit) { + // Create a snapshot of the view's padding state + val initialPadding = recordInitialPaddingForView(this) + // Set an actual OnApplyWindowInsetsListener which proxies to the given + // lambda, also passing in the original padding state + setOnApplyWindowInsetsListener { v, insets -> + f(v, insets, initialPadding) + // Always return the insets, so that children can also use them + insets + } + // request some insets + requestApplyInsetsWhenAttached() +} + +fun View.requestApplyInsetsWhenAttached() { + if (isAttachedToWindow) { + // We're already attached, just request as normal + requestApplyInsets() + } else { + // We're not attached to the hierarchy, add a listener to + // request when we are + addOnAttachStateChangeListener(object : OnAttachStateChangeListener { + override fun onViewAttachedToWindow(v: View) { + v.removeOnAttachStateChangeListener(this) + v.requestApplyInsets() + } + + override fun onViewDetachedFromWindow(v: View) = Unit + }) + } +} + +data class InitialPadding( + val left: Int, + val top: Int, + val right: Int, + val bottom: Int +) + +private fun recordInitialPaddingForView(view: View) = InitialPadding( + view.paddingLeft, + view.paddingTop, + view.paddingRight, + view.paddingBottom +) + +fun View.updateMargins( + @Px left: Int = marginLeft, + @Px top: Int = marginTop, + @Px right: Int = marginRight, + @Px bottom: Int = marginBottom +) { + val params = layoutParams as ViewGroup.MarginLayoutParams + params.leftMargin = left + params.topMargin = top + params.rightMargin = right + params.bottomMargin = bottom +} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsLibraryPagerRecyclerViewFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsLibraryPagerRecyclerViewFragment.kt index dd4c3bf94..904e8d2f3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsLibraryPagerRecyclerViewFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsLibraryPagerRecyclerViewFragment.kt @@ -6,10 +6,11 @@ import android.view.View import android.view.ViewGroup import androidx.annotation.NonNull import androidx.annotation.StringRes +import androidx.core.view.updatePadding import androidx.recyclerview.widget.RecyclerView import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.doOnApplyWindowInsets 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 @@ -84,7 +85,7 @@ abstract class AbsLibraryPagerRecyclerViewFragment, } private fun checkForPadding() { - val itemCount: Int = adapter?.itemCount ?: 0 + /*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) @@ -92,6 +93,17 @@ abstract class AbsLibraryPagerRecyclerViewFragment, } else { val height = DensityUtil.dip2px(requireContext(), 52f) params.bottomMargin = height + }*/ + + val heightOfBar = resources.getDimensionPixelSize(R.dimen.mini_player_height) + val heightOfBarWithTabs = resources.getDimensionPixelSize(R.dimen.mini_player_height_expanded) + + recyclerView.doOnApplyWindowInsets { view, windowInsets, initialPadding -> + view.updatePadding( + bottom = if (MusicPlayerRemote.playingQueue.isEmpty()) (windowInsets.systemWindowInsetBottom + initialPadding.bottom) else 0, + left = initialPadding.left + windowInsets.systemWindowInsetLeft, + right = initialPadding.right + windowInsets.systemWindowInsetRight + ) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt index 7979397f0..c75d56496 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMainActivityFragment.kt @@ -18,7 +18,7 @@ abstract class AbsMainActivityFragment : AbsMusicServiceFragment() { super.onActivityCreated(savedInstanceState) setHasOptionsMenu(true) - mainActivity.setNavigationbarColorAuto() + //mainActivity.setNavigationbarColorAuto() mainActivity.setLightNavigationBar(true) mainActivity.setTaskDescriptionColorAuto() mainActivity.hideStatusBar() diff --git a/app/src/main/res/layout/fragment_blur.xml b/app/src/main/res/layout/fragment_blur.xml index 0007814e9..136be15aa 100644 --- a/app/src/main/res/layout/fragment_blur.xml +++ b/app/src/main/res/layout/fragment_blur.xml @@ -23,56 +23,53 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - + android:layout_height="match_parent"> - - - - - - - - - - - - + android:orientation="vertical"> - - + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal"> - + + - - - + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 83df48270..6cc3020b8 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -20,56 +20,54 @@ - + android:layout_height="match_parent"> - - - - - - - - - - - - - + + - + android:layout_height="wrap_content" + android:layout_weight="0"> - + + - - - + android:layout_height="wrap_content" + android:layout_weight="0"> + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-night-v27/styles.xml b/app/src/main/res/values-night-v27/styles.xml index 16bbd391e..c6c05a0b3 100644 --- a/app/src/main/res/values-night-v27/styles.xml +++ b/app/src/main/res/values-night-v27/styles.xml @@ -34,5 +34,6 @@ false @color/darkColorSurface + @color/transparent \ No newline at end of file diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index e53f21ee5..f833ff4d0 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -34,5 +34,6 @@ @color/darkColorPrimary @color/darkColorSurface + @color/transparent \ No newline at end of file diff --git a/app/src/main/res/values-v27/styles_parents.xml b/app/src/main/res/values-v27/styles_parents.xml index 0d3264478..74908b8f8 100644 --- a/app/src/main/res/values-v27/styles_parents.xml +++ b/app/src/main/res/values-v27/styles_parents.xml @@ -31,6 +31,7 @@ @drawable/rect_selector @style/Widget.ActionButton.Overflow true + @color/transparent \ No newline at end of file diff --git a/app/src/main/res/values/styles_parents.xml b/app/src/main/res/values/styles_parents.xml index 6ac2764df..daf7d208a 100644 --- a/app/src/main/res/values/styles_parents.xml +++ b/app/src/main/res/values/styles_parents.xml @@ -17,6 +17,7 @@ @drawable/round_selector @drawable/rect_selector @style/Widget.ActionButton.Overflow + @color/transparent