From 437f73b1dcf0da59554e9016cd0af37ca1e8ebf3 Mon Sep 17 00:00:00 2001 From: h4h13 Date: Mon, 24 Feb 2020 11:12:09 +0530 Subject: [PATCH] Added Material Design ShapeableImageView for Circular ImageView --- .../retromusic/activities/MainActivity.java | 2 +- .../views/RetroShapeableImageView.kt | 39 +++++++++++++++++++ .../res/layout-land/fragment_banner_home.xml | 11 +++--- .../main/res/layout-land/fragment_home.xml | 11 +++--- .../main/res/layout-xlarge/item_artist.xml | 3 +- .../main/res/layout/fragment_banner_home.xml | 9 +++-- app/src/main/res/layout/fragment_home.xml | 3 +- .../layout/fragment_player_album_cover.xml | 3 +- app/src/main/res/layout/item_artist.xml | 5 ++- app/src/main/res/layout/item_artist_card.xml | 11 +++--- app/src/main/res/layout/item_contributor.xml | 9 +++-- .../res/layout/item_contributor_header.xml | 9 +++-- .../main/res/values/shapeable_imageview.xml | 19 +++++++++ app/src/main/res/values/styles.xml | 15 +++++++ 14 files changed, 116 insertions(+), 33 deletions(-) create mode 100644 app/src/main/java/code/name/monkey/retromusic/views/RetroShapeableImageView.kt create mode 100644 app/src/main/res/values/shapeable_imageview.xml diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.java index f6e2c86ae..fab4dd45f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.java @@ -143,7 +143,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity }); if (savedInstanceState == null) { - setMusicChooser(PreferenceUtil.getInstance(this).getLastMusicChooser()); + selectedFragment(PreferenceUtil.getInstance(this).getLastPage()); } else { restoreCurrentFragment(); } diff --git a/app/src/main/java/code/name/monkey/retromusic/views/RetroShapeableImageView.kt b/app/src/main/java/code/name/monkey/retromusic/views/RetroShapeableImageView.kt new file mode 100644 index 000000000..79371a4a1 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/views/RetroShapeableImageView.kt @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 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.util.AttributeSet +import code.name.monkey.retromusic.R +import com.google.android.material.imageview.ExperimentalImageView +import com.google.android.material.imageview.ShapeableImageView +import com.google.android.material.shape.CornerFamily +import com.google.android.material.shape.ShapeAppearanceModel + +@ExperimentalImageView +class RetroShapeableImageView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyle: Int = -1 +) : ShapeableImageView(context, attrs, defStyle) { + + init { + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.RetroShapeableImageView, defStyle, -1) + val cornerSize = typedArray.getDimension(R.styleable.RetroShapeableImageView_retroCornerSize, 0f); + shapeAppearanceModel = ShapeAppearanceModel.Builder() + .setAllCorners(CornerFamily.ROUNDED, cornerSize) + .build() + typedArray.recycle() + } +} \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_banner_home.xml b/app/src/main/res/layout-land/fragment_banner_home.xml index 99f27ab40..3227e823e 100644 --- a/app/src/main/res/layout-land/fragment_banner_home.xml +++ b/app/src/main/res/layout-land/fragment_banner_home.xml @@ -12,14 +12,14 @@ ~ See the GNU General Public License for more details. --> - - - - - diff --git a/app/src/main/res/layout/fragment_banner_home.xml b/app/src/main/res/layout/fragment_banner_home.xml index e1f77e532..b704c7916 100644 --- a/app/src/main/res/layout/fragment_banner_home.xml +++ b/app/src/main/res/layout/fragment_banner_home.xml @@ -11,10 +11,10 @@ ~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ~ See the GNU General Public License for more details. --> - @@ -55,15 +55,16 @@ android:background="@drawable/shadow_up" app:layout_constraintBottom_toBottomOf="parent" /> - - + android:layout_height="match_parent" + android:overScrollMode="never" /> \ 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 2c66d2361..de221b6a8 100644 --- a/app/src/main/res/layout/item_artist.xml +++ b/app/src/main/res/layout/item_artist.xml @@ -2,7 +2,7 @@ - diff --git a/app/src/main/res/layout/item_artist_card.xml b/app/src/main/res/layout/item_artist_card.xml index decd26f9f..303f616bc 100644 --- a/app/src/main/res/layout/item_artist_card.xml +++ b/app/src/main/res/layout/item_artist_card.xml @@ -25,24 +25,25 @@ android:layout_height="match_parent" android:background="@drawable/artist_card_gradient_effect"> - - diff --git a/app/src/main/res/layout/item_contributor_header.xml b/app/src/main/res/layout/item_contributor_header.xml index 7fd443d59..6125eed68 100644 --- a/app/src/main/res/layout/item_contributor_header.xml +++ b/app/src/main/res/layout/item_contributor_header.xml @@ -23,13 +23,14 @@ android:paddingBottom="24dp" tools:ignore="PrivateResource"> - @@ -38,10 +39,10 @@ android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" - android:paddingStart="16dp" - android:paddingTop="8dp" + android:paddingBottom="8dp" android:paddingEnd="16dp" - android:paddingBottom="8dp"> + android:paddingStart="16dp" + android:paddingTop="8dp"> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6a4338d28..e37c44b3c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -183,4 +183,19 @@ @drawable/splash @android:color/transparent + + + + + +