From ebb22f6cc7130a208beb2bcfcf5456a81cf04cb5 Mon Sep 17 00:00:00 2001 From: Hemanth S Date: Thu, 14 May 2020 19:07:15 +0530 Subject: [PATCH] Code refactor with ConstraintLayout --- .../adapter/artist/ArtistAdapter.kt | 8 +- .../drawable/artist_card_gradient_effect.xml | 2 +- .../main/res/layout-xlarge/item_artist.xml | 36 ------- app/src/main/res/layout-xlarge/item_image.xml | 36 ------- app/src/main/res/layout-xlarge/pager_item.xml | 62 ----------- app/src/main/res/layout/item_album_card.xml | 25 +++-- app/src/main/res/layout/item_artist.xml | 39 ++++--- app/src/main/res/layout/item_artist_card.xml | 4 +- .../main/res/layout/item_artist_square.xml | 25 +++-- app/src/main/res/layout/item_card.xml | 81 +++++++------- app/src/main/res/layout/item_card_color.xml | 81 +++++++------- .../res/layout/item_contributor_header.xml | 53 +++++---- .../main/res/layout/item_donation_option.xml | 42 +++++--- app/src/main/res/layout/item_grid.xml | 78 ++++++++------ app/src/main/res/layout/item_grid_circle.xml | 101 ++++++++---------- app/src/main/res/layout/item_image.xml | 16 ++- .../main/res/layout/item_image_gradient.xml | 65 +++++------ app/src/main/res/layout/item_song.xml | 2 - app/src/main/res/values/colors.xml | 2 +- 19 files changed, 316 insertions(+), 442 deletions(-) delete mode 100644 app/src/main/res/layout-xlarge/item_artist.xml delete mode 100644 app/src/main/res/layout-xlarge/item_image.xml delete mode 100644 app/src/main/res/layout-xlarge/pager_item.xml diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt index 19c8cf37..173a096c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt @@ -2,7 +2,6 @@ package code.name.monkey.retromusic.adapter.artist import android.app.ActivityOptions import android.content.res.ColorStateList -import android.graphics.drawable.Drawable import android.view.LayoutInflater import android.view.MenuItem import android.view.View @@ -66,12 +65,12 @@ class ArtistAdapter( } fun setColors(processor: MediaNotificationProcessor, holder: ViewHolder) { + holder.mask?.backgroundTintList = ColorStateList.valueOf(processor.primaryTextColor) if (holder.paletteColorContainer != null) { holder.paletteColorContainer?.setBackgroundColor(processor.backgroundColor) holder.title?.setTextColor(processor.primaryTextColor) } holder.imageContainerCard?.setCardBackgroundColor(processor.backgroundColor) - holder.mask?.backgroundTintList = ColorStateList.valueOf(processor.backgroundColor) } private fun loadArtistImage(artist: Artist, holder: ViewHolder) { @@ -82,11 +81,6 @@ class ArtistAdapter( .generatePalette(activity) .build() .into(object : RetroMusicColoredTarget(holder.image!!) { - override fun onLoadCleared(placeholder: Drawable?) { - super.onLoadCleared(placeholder) - //setColors(defaultFooterColor, holder) - } - override fun onColorReady(colors: MediaNotificationProcessor) { setColors(colors, holder) } diff --git a/app/src/main/res/drawable/artist_card_gradient_effect.xml b/app/src/main/res/drawable/artist_card_gradient_effect.xml index 0264f2f1..2804ee8b 100644 --- a/app/src/main/res/drawable/artist_card_gradient_effect.xml +++ b/app/src/main/res/drawable/artist_card_gradient_effect.xml @@ -17,5 +17,5 @@ + android:startColor="#80000000" /> \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/item_artist.xml b/app/src/main/res/layout-xlarge/item_artist.xml deleted file mode 100644 index b74317cb..00000000 --- a/app/src/main/res/layout-xlarge/item_artist.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/item_image.xml b/app/src/main/res/layout-xlarge/item_image.xml deleted file mode 100644 index 0252ce12..00000000 --- a/app/src/main/res/layout-xlarge/item_image.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/pager_item.xml b/app/src/main/res/layout-xlarge/pager_item.xml deleted file mode 100644 index d5e02625..00000000 --- a/app/src/main/res/layout-xlarge/pager_item.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/item_album_card.xml b/app/src/main/res/layout/item_album_card.xml index a3d8e3aa..c631d15c 100644 --- a/app/src/main/res/layout/item_album_card.xml +++ b/app/src/main/res/layout/item_album_card.xml @@ -1,5 +1,5 @@ - + app:cardElevation="4dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_artist.xml b/app/src/main/res/layout/item_artist.xml index 2c9d3e83..50562d8c 100644 --- a/app/src/main/res/layout/item_artist.xml +++ b/app/src/main/res/layout/item_artist.xml @@ -1,21 +1,32 @@ - + android:orientation="vertical" + android:padding="4dp"> - + android:layout_height="112dp" + app:cardCornerRadius="56dp" + app:cardElevation="4dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_artist_card.xml b/app/src/main/res/layout/item_artist_card.xml index 96acc95b..f0558b04 100644 --- a/app/src/main/res/layout/item_artist_card.xml +++ b/app/src/main/res/layout/item_artist_card.xml @@ -16,7 +16,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="128dp" android:layout_height="128dp" - android:layout_margin="4dp" app:cardCornerRadius="16dp"> @@ -24,7 +23,8 @@ android:id="@+id/paletteColorContainer" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@drawable/artist_card_gradient_effect"> + android:background="@drawable/artist_card_gradient_effect" + tools:backgroundTint="@color/md_red_500"> + app:cardCornerRadius="8dp" + app:cardElevation="4dp"> - + android:layout_height="wrap_content"> + android:layout_width="0dp" + android:layout_height="wrap_content" + android:padding="8dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/image"> - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_card.xml b/app/src/main/res/layout/item_card.xml index 5f3ce430..0a6f10ba 100644 --- a/app/src/main/res/layout/item_card.xml +++ b/app/src/main/res/layout/item_card.xml @@ -4,65 +4,64 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="2dp" android:background="?attr/rectSelector" android:clickable="true" - android:focusable="true" - tools:ignore="MissingPrefix"> + android:focusable="true"> - - + - - - - + android:paddingHorizontal="8dp" + android:paddingTop="8dp" + android:paddingBottom="4dp" + android:singleLine="true" + android:textAppearance="@style/TextViewSubtitle1" + android:textStyle="bold" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/image" + tools:text="@string/bug_report_summary" /> - + - - - - + - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_card_color.xml b/app/src/main/res/layout/item_card_color.xml index c298e78a..aaca9e3a 100644 --- a/app/src/main/res/layout/item_card_color.xml +++ b/app/src/main/res/layout/item_card_color.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="2dp" + android:layout_margin="4dp" android:background="?attr/rectSelector" android:clickable="true" android:focusable="true" @@ -14,56 +14,53 @@ android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="8dp" - app:cardUseCompatPadding="true" tools:ignore="MissingPrefix"> - + android:layout_height="wrap_content"> - + - - - - + android:paddingHorizontal="8dp" + android:paddingTop="8dp" + android:paddingBottom="4dp" + android:singleLine="true" + android:textAppearance="@style/TextViewSubtitle1" + android:textStyle="bold" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/image" + tools:text="@string/bug_report_summary" /> - + - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_contributor_header.xml b/app/src/main/res/layout/item_contributor_header.xml index de037f53..77a72283 100644 --- a/app/src/main/res/layout/item_contributor_header.xml +++ b/app/src/main/res/layout/item_contributor_header.xml @@ -11,7 +11,7 @@ ~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ~ See the GNU General Public License for more details. --> - - + android:textAppearance="@style/TextViewHeadline5" + android:textStyle="bold" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/icon" + tools:text="@tools:sample/full_names" /> - + - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_donation_option.xml b/app/src/main/res/layout/item_donation_option.xml index d0177c46..d85ce054 100644 --- a/app/src/main/res/layout/item_donation_option.xml +++ b/app/src/main/res/layout/item_donation_option.xml @@ -8,11 +8,11 @@ - + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:ignore="MissingPrefix" + tools:text="$9" /> - + - - - - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_grid.xml b/app/src/main/res/layout/item_grid.xml index 15fa9d32..7d741069 100644 --- a/app/src/main/res/layout/item_grid.xml +++ b/app/src/main/res/layout/item_grid.xml @@ -1,56 +1,64 @@ - - + - - + - + - + - - - + + diff --git a/app/src/main/res/layout/item_grid_circle.xml b/app/src/main/res/layout/item_grid_circle.xml index d881ef87..05388bc4 100644 --- a/app/src/main/res/layout/item_grid_circle.xml +++ b/app/src/main/res/layout/item_grid_circle.xml @@ -1,67 +1,58 @@ - - + + + + android:maxLines="2" + android:paddingTop="8dp" + android:paddingBottom="4dp" + android:textAppearance="@style/TextViewSubtitle1" + android:textColor="?android:attr/textColorPrimary" + android:textStyle="bold" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/image" + tools:text="@tools:sample/lorem/random" /> - + - - - - - - - - - - - - + diff --git a/app/src/main/res/layout/item_image.xml b/app/src/main/res/layout/item_image.xml index f816b986..7ca624c5 100644 --- a/app/src/main/res/layout/item_image.xml +++ b/app/src/main/res/layout/item_image.xml @@ -1,5 +1,5 @@ - + app:cardElevation="8dp" + app:cardPreventCornerOverlap="true" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_image_gradient.xml b/app/src/main/res/layout/item_image_gradient.xml index bb9cbc35..f8ab7cf5 100644 --- a/app/src/main/res/layout/item_image_gradient.xml +++ b/app/src/main/res/layout/item_image_gradient.xml @@ -1,57 +1,41 @@ - + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintDimensionRatio="1:1" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - - - - - - - - - - - + android:scaleType="centerCrop" + android:transitionName="@string/transition_album_art" + tools:ignore="ContentDescription" + tools:src="@tools:sample/avatars" /> + - - + tools:text="@tools:sample/full_names" /> - \ No newline at end of file + - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_song.xml b/app/src/main/res/layout/item_song.xml index dbf9e841..df284995 100755 --- a/app/src/main/res/layout/item_song.xml +++ b/app/src/main/res/layout/item_song.xml @@ -54,8 +54,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" - - android:padding="8dp" android:textColor="?android:attr/textColorSecondary" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f76e1cb2..1f03fffa 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -34,7 +34,7 @@ #000000 #00000000 - #40000000 + #20000000 #ffffff #d4d4d4