Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
h4h13
8af8cd727b Added translucent 2020-02-01 20:15:41 +05:30
h4h13
b8d9a3e768 WIP for window insets 2020-01-29 23:33:31 +05:30
11 changed files with 229 additions and 107 deletions

View file

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

View file

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

View file

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

View file

@ -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<A : RecyclerView.Adapter<*>,
}
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<A : RecyclerView.Adapter<*>,
} 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
)
}
}

View file

@ -18,7 +18,7 @@ abstract class AbsMainActivityFragment : AbsMusicServiceFragment() {
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
mainActivity.setNavigationbarColorAuto()
//mainActivity.setNavigationbarColorAuto()
mainActivity.setLightNavigationBar(true)
mainActivity.setTaskDescriptionColorAuto()
mainActivity.hideStatusBar()

View file

@ -23,56 +23,53 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
<code.name.monkey.retromusic.views.StatusBarMarginFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/status_bar" />
</FrameLayout>
<code.name.monkey.retromusic.views.WidthFitSquareLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<fragment
android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_album_cover" />
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
<FrameLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
tools:background="@color/md_white_1000">
android:orientation="vertical">
<fragment
android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.fragments.player.blur.BlurPlaybackControlsFragment"
<code.name.monkey.retromusic.views.WidthFitSquareLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0">
<fragment
android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_album_cover" />
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
style="@style/Toolbar"
android:layout_height="48dp"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
tools:background="@color/md_white_1000">
<fragment
android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.fragments.player.blur.BlurPlaybackControlsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
style="@style/Toolbar"
android:layout_height="48dp"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
</FrameLayout>
</LinearLayout>
</code.name.monkey.retromusic.views.StatusBarMarginFrameLayout>
</FrameLayout>

View file

@ -20,56 +20,54 @@
<include layout="@layout/shadow_statusbar_toolbar" />
<LinearLayout
<code.name.monkey.retromusic.views.StatusBarMarginFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
<FrameLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/status_bar" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
style="@style/Toolbar"
android:layout_gravity="bottom"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
</FrameLayout>
<code.name.monkey.retromusic.views.WidthFitSquareLayout
android:id="@+id/playerAlbumCoverContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0">
<fragment
android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_album_cover" />
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
android:layout_height="wrap_content"
android:layout_weight="0">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/playerToolbar"
style="@style/Toolbar"
android:layout_gravity="bottom"
android:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp"
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black_24dp" />
</FrameLayout>
<fragment
android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.fragments.player.normal.PlayerPlaybackControlsFragment"
<code.name.monkey.retromusic.views.WidthFitSquareLayout
android:id="@+id/playerAlbumCoverContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_player_playback_controls" />
</FrameLayout>
</LinearLayout>
android:layout_height="wrap_content"
android:layout_weight="0">
<fragment
android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_album_cover" />
</code.name.monkey.retromusic.views.WidthFitSquareLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<fragment
android:id="@+id/playbackControlsFragment"
android:name="code.name.monkey.retromusic.fragments.player.normal.PlayerPlaybackControlsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_player_playback_controls" />
</FrameLayout>
</LinearLayout>
</code.name.monkey.retromusic.views.StatusBarMarginFrameLayout>
</FrameLayout>

View file

@ -34,5 +34,7 @@
<item name="android:windowLightNavigationBar">false</item>
<!--Manual setting colors-->
<item name="colorSurface">@color/darkColorSurface</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>

View file

@ -34,5 +34,7 @@
<!--Manual setting colors-->
<item name="colorPrimary">@color/darkColorPrimary</item>
<item name="colorSurface">@color/darkColorSurface</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>

View file

@ -31,6 +31,8 @@
<item name="rectSelector">@drawable/rect_selector</item>
<item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>
<item name="android:windowLightNavigationBar">true</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar">
@ -55,6 +57,8 @@
<item name="android:windowLightNavigationBar">false</item>
<!--Manual setting colors-->
<item name="colorSurface">@color/darkColorSurface</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
@ -76,5 +80,7 @@
<item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
<item name="materialButtonStyle">@style/MaterialButtonTheme</item>
<item name="android:windowLightNavigationBar">false</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>

View file

@ -17,6 +17,8 @@
<item name="roundSelector">@drawable/round_selector</item>
<item name="rectSelector">@drawable/rect_selector</item>
<item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar">
@ -41,6 +43,8 @@
<!--Manual setting colors-->
<item name="colorSurface">@color/darkColorSurface</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="Theme.RetroMusic.Base.Black" parent="Theme.MaterialComponents.NoActionBar">
@ -61,6 +65,8 @@
<item name="colorOnBackground">@color/blackColorSurface</item>
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
<item name="mcab_popup_theme">@style/ThemeOverlay.AppCompat.Dark</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
@ -81,6 +87,8 @@
<item name="windowActionBar">false</item>
<item name="materialAlertDialogTheme">@style/MaterialAlertDialogTheme</item>
<item name="materialButtonStyle">@style/MaterialButtonTheme</item>
<item name="android:navigationBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>