Improve destauration on Color shortcut

main
h4h13 2019-10-10 23:23:41 +05:30
commit 694e78e92e
22 changed files with 90 additions and 35 deletions

View File

@ -14,6 +14,8 @@ import code.name.monkey.retromusic.util.PreferenceUtil
import javax.inject.Inject
open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(), AlbumsView {
@Inject
lateinit var albumsPresenter: AlbumsPresenter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -37,14 +39,10 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
albumsPresenter.detachView()
}
override fun albums(albums: java.util.ArrayList<Album>) {
adapter?.swapDataSet(albums)
}
@Inject
lateinit var albumsPresenter: AlbumsPresenter
override val emptyMessage: Int
get() = R.string.no_albums

View File

@ -126,8 +126,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
NavigationUtil.goToPlaylistNew(requireActivity(), HistoryPlaylist(requireActivity()))
}
contentContainer.setBackgroundColor(ATHUtil.resolveColor(requireContext(), R.attr.colorPrimary))
setupToolbar()
checkPadding()

View File

@ -23,6 +23,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R
class ColorIconsImageView : AppCompatImageView {
constructor(context: Context) : super(context) {
@ -40,14 +41,16 @@ class ColorIconsImageView : AppCompatImageView {
private fun init(context: Context, attrs: AttributeSet?) {
// Load the styled attributes and set their properties
val attributes = context.obtainStyledAttributes(attrs, R.styleable.ColorIconsImageView, 0, 0)
setIconBackgroundColor(attributes.getColor(R.styleable.ColorIconsImageView_iconBackgroundColor, Color.RED))
val color = attributes.getColor(R.styleable.ColorIconsImageView_iconBackgroundColor, Color.RED);
setIconBackgroundColor(color)
attributes.recycle()
}
private fun setIconBackgroundColor(color: Int) {
setBackgroundResource(R.drawable.color_circle_gradient)
if (ATHUtil.isWindowBackgroundDark(context)) {
backgroundTintList = ColorStateList.valueOf(ColorUtil.adjustAlpha(color, 0.72f))
val desaturatedColor = desaturateColor(color, 0.4f)
backgroundTintList = ColorStateList.valueOf(desaturatedColor)
imageTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, R.attr.colorPrimary))
} else {
backgroundTintList = ColorStateList.valueOf(ColorUtil.adjustAlpha(color, 0.22f))
@ -56,4 +59,13 @@ class ColorIconsImageView : AppCompatImageView {
requestLayout()
invalidate()
}
private fun desaturateColor(color: Int, ratio: Float): Int {
val hsv = FloatArray(3)
Color.colorToHSV(color, hsv)
hsv[1] = hsv[1] / 1 * ratio + 0.2f * (1.0f - ratio)
return Color.HSVToColor(hsv)
}
}

View File

@ -74,9 +74,9 @@
android:id="@+id/toolbarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="58dp"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginTop="@dimen/toolbar_margin_vertical"
android:layout_marginEnd="58dp"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
android:layout_marginBottom="@dimen/toolbar_margin_vertical"
app:cardCornerRadius="8dp"
app:cardElevation="6dp"
@ -105,8 +105,8 @@
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="64dp"
android:layout_marginEnd="64dp"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
android:elevation="@dimen/card_elevation"
app:behavior_overlapTop="72dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

View File

@ -71,6 +71,8 @@
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include layout="@layout/home_content" />

View File

@ -19,10 +19,11 @@
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
android:background="@android:color/transparent"
android:elevation="0dp"
app:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
@ -57,7 +58,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="16dp"
app:cardElevation="0dp">
app:cardElevation="0dp"
app:cardPreventCornerOverlap="true">
<LinearLayout
android:layout_width="match_parent"

View File

@ -17,7 +17,9 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
android:background="@android:color/transparent"
android:elevation="0dp"
app:elevation="0dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"

View File

@ -27,9 +27,7 @@
<com.google.android.material.appbar.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.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
@ -111,8 +109,8 @@
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="128dp"
android:layout_marginEnd="128dp"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:cardCornerRadius="12dp">
<include layout="@layout/home_content" />

View File

@ -71,6 +71,8 @@
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include layout="@layout/home_content" />

View File

@ -71,6 +71,7 @@
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_centerInParent="true"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/color_circle_gradient"
android:elevation="4dp"
@ -78,7 +79,8 @@
app:layout_constraintBottom_toTopOf="@+id/volumeFragmentContainer"
app:layout_constraintStart_toEndOf="@id/previousButton"
app:layout_constraintTop_toBottomOf="@+id/text"
app:srcCompat="@drawable/ic_play_arrow_white_32dp" />
app:srcCompat="@drawable/ic_play_arrow_white_32dp"
tools:tint="@color/md_black_1000" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/nextButton"

View File

@ -15,21 +15,19 @@
<LinearLayout 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:id="@+id/main_fragment_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?colorPrimary">
<com.google.android.material.appbar.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.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
@ -111,8 +109,9 @@
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="64dp"
android:layout_marginEnd="64dp"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
app:cardBackgroundColor="?colorPrimary"
app:cardCornerRadius="12dp">
<include layout="@layout/home_content" />

View File

@ -72,10 +72,9 @@
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="64dp"
android:layout_marginEnd="64dp"
android:layout_marginStart="@dimen/toolbar_margin_horizontal"
android:layout_marginEnd="@dimen/toolbar_margin_horizontal"
android:layout_weight="1"
android:background="@color/md_white_1000"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include layout="@layout/home_content" />

View File

@ -51,6 +51,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintEnd_toStartOf="@+id/lastAdded"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"

View File

@ -16,7 +16,7 @@
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:layout_height="match_parent" >
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"

View File

@ -16,6 +16,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="?colorPrimary"
android:layout_height="match_parent"
android:orientation="vertical">

View File

@ -18,7 +18,7 @@
<LinearLayout 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:id="@+id/contentContainer"
android:background="?colorPrimary"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"

View File

@ -73,6 +73,7 @@
android:layout_margin="0dp"
android:layout_weight="0"
android:rotation="90"
android:layout_gravity="center"
app:tint="?colorOnSecondary"
tools:visibility="visible" />
</LinearLayout>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<resources>
<bool name="is_dark_mode">true</bool>
</resources>

View File

@ -1,5 +1,5 @@
<resources>
<dimen name="toolbar_margin_horizontal">128dp</dimen>
<dimen name="toolbar_margin_horizontal">64dp</dimen>
<dimen name="toolbar_height">64dp</dimen>
<dimen name="toolbar_margin_vertical">16dp</dimen>
<dimen name="item_song_height">64dp</dimen>

View File

@ -36,6 +36,7 @@
</declare-styleable>
<declare-styleable name="ColorIconsImageView">
<attr name="iconBackgroundColor" format="color" />
<attr name="colorIconColor" format="color" />
<attr name="icon" format="reference" />
</declare-styleable>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ 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.
-->
<resources>
<bool name="is_dark_mode">false</bool>
</resources>

View File

@ -3,6 +3,7 @@
<!-- Red -->
<color name="md_red_200">#EF9A9A</color>
<color name="md_red_400">#EF5350</color>
<color name="md_red_500">#F44336</color>
<color name="md_red_A700">#D50000</color>
@ -41,6 +42,7 @@
<!-- Blue -->
<color name="md_blue_200">#90CAF9</color>
<color name="md_blue_500">#2196F3</color>
<color name="md_blue_A200">#448AFF</color>
<color name="md_blue_A400">#2979FF</color>