From 2b96064830d46523c44247d368c51dc5a95f6a0f Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 18 Dec 2015 17:46:26 -0800 Subject: Start of my own basic CardView since support version doesn't play nice with SquareImageView --- .../github/daneren2005/dsub/view/CardView.java | 50 +++++++++++++++++ app/src/main/res/drawable/card_rounded_corners.xml | 6 ++ app/src/main/res/layout/basic_cell_item.xml | 65 ++++++++++++---------- app/src/main/res/values/dimens.xml | 1 + 4 files changed, 92 insertions(+), 30 deletions(-) create mode 100644 app/src/main/java/github/daneren2005/dsub/view/CardView.java create mode 100644 app/src/main/res/drawable/card_rounded_corners.xml (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/view/CardView.java b/app/src/main/java/github/daneren2005/dsub/view/CardView.java new file mode 100644 index 00000000..ba6b66a4 --- /dev/null +++ b/app/src/main/java/github/daneren2005/dsub/view/CardView.java @@ -0,0 +1,50 @@ +package github.daneren2005.dsub.view; + +import android.annotation.TargetApi; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Canvas; +import android.graphics.Path; +import android.graphics.RectF; +import android.os.Build; +import android.util.AttributeSet; +import android.widget.FrameLayout; + +import github.daneren2005.dsub.R; + +public class CardView extends FrameLayout{ + public CardView(Context context) { + super(context); + this.setClipChildren(true); + this.setBackgroundResource(R.drawable.card_rounded_corners); + } + + public CardView(Context context, AttributeSet attrs) { + super(context, attrs); + this.setClipChildren(true); + this.setBackgroundResource(R.drawable.card_rounded_corners); + } + + public CardView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.setClipChildren(true); + this.setBackgroundResource(R.drawable.card_rounded_corners); + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + public CardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + this.setClipChildren(true); + this.setBackgroundResource(R.drawable.card_rounded_corners); + } + + @Override + public void onDraw(Canvas canvas) { + Path clipPath = new Path(); + + float roundedDp = getResources().getDimension(R.dimen.Card_Radius); + clipPath.addRoundRect(new RectF(canvas.getClipBounds()), roundedDp, roundedDp, Path.Direction.CW); + canvas.clipPath(clipPath); + super.onDraw(canvas); + } +} diff --git a/app/src/main/res/drawable/card_rounded_corners.xml b/app/src/main/res/drawable/card_rounded_corners.xml new file mode 100644 index 00000000..5475c3d6 --- /dev/null +++ b/app/src/main/res/drawable/card_rounded_corners.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/basic_cell_item.xml b/app/src/main/res/layout/basic_cell_item.xml index f522b196..0ccf78bd 100644 --- a/app/src/main/res/layout/basic_cell_item.xml +++ b/app/src/main/res/layout/basic_cell_item.xml @@ -1,39 +1,44 @@ - - - + android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/selectableItemBackground"> - + - + android:orientation="horizontal" + android:paddingTop="4dp" + android:paddingLeft="2dp"> + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 23a3f4a3..c63976f4 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,4 +6,5 @@ 78dip 120dip 20dp + 4dp \ No newline at end of file -- cgit v1.2.3 From e1260eafd3b6053fd51663b2eff5b97fabf51c4e Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 18 Dec 2015 17:48:44 -0800 Subject: Use card view for albums as well --- app/src/main/res/layout/album_cell_item.xml | 141 ++++++++++++++-------------- 1 file changed, 73 insertions(+), 68 deletions(-) (limited to 'app') diff --git a/app/src/main/res/layout/album_cell_item.xml b/app/src/main/res/layout/album_cell_item.xml index f6693a7f..da872273 100644 --- a/app/src/main/res/layout/album_cell_item.xml +++ b/app/src/main/res/layout/album_cell_item.xml @@ -1,90 +1,95 @@ - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:background="?attr/selectableItemBackground"> - + android:layout_height="0dp" + android:layout_weight="1"> - - + - + + - - + android:orientation="horizontal" + android:paddingTop="4dp" + android:paddingLeft="2dp"> + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="vertical"> + android:ellipsize="marquee" + android:text="@string/search.albums" + android:textColor="?android:textColorPrimary"/> + + - + + + + + + - - - \ No newline at end of file + \ No newline at end of file -- cgit v1.2.3 From 2f459f8c3f082a9f3adfc546deffe554e625c28b Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 20 Dec 2015 11:05:35 -0800 Subject: Add a bit of padding to text in cards --- app/src/main/res/layout/album_cell_item.xml | 7 +++++-- app/src/main/res/layout/basic_cell_item.xml | 3 ++- app/src/main/res/values/dimens.xml | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/src/main/res/layout/album_cell_item.xml b/app/src/main/res/layout/album_cell_item.xml index da872273..b352a5f1 100644 --- a/app/src/main/res/layout/album_cell_item.xml +++ b/app/src/main/res/layout/album_cell_item.xml @@ -36,6 +36,7 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:paddingTop="4dp" + android:paddingBottom="4dp" android:paddingLeft="2dp"> + android:textColor="?android:textColorPrimary" + android:paddingLeft="@dimen/Card.TextLeftPadding"/> + android:text="@string/search.artists" + android:paddingLeft="@dimen/Card.TextLeftPadding"/> + android:textColor="?android:textColorPrimary" + android:paddingLeft="@dimen/Card.TextLeftPadding"/> 120dip 20dp 4dp + 8dp \ No newline at end of file -- cgit v1.2.3 From 7643d4fb60b91f8cc87510f5f09d841993ec2917 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 20 Dec 2015 13:04:33 -0800 Subject: Fix headers screwing up GridSpacingDecoration --- .../github/daneren2005/dsub/view/GridSpacingDecoration.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java b/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java index b59e7157..c6d3dbb1 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java +++ b/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java @@ -18,10 +18,12 @@ package github.daneren2005.dsub.view; import android.graphics.Rect; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.util.TypedValue; import android.view.View; public class GridSpacingDecoration extends RecyclerView.ItemDecoration { + private static final String TAG = GridSpacingDecoration.class.getSimpleName(); public static final int SPACING = 10; @Override @@ -39,6 +41,16 @@ public class GridSpacingDecoration extends RecyclerView.ItemDecoration { } int spanCount = getTotalSpan(view, parent); int spanIndex = childIndex % spanCount; + + // If we can, use the SpanSizeLookup since headers screw up the index calculation + RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); + if(layoutManager instanceof GridLayoutManager) { + GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager; + GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup(); + if(spanSizeLookup != null) { + spanIndex = spanSizeLookup.getSpanIndex(childIndex, spanCount); + } + } int spanSize = getSpanSize(parent, childIndex); /* INVALID SPAN */ -- cgit v1.2.3 From b3cab61a025e1d828785b930e59721c4dbe62a08 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 20 Dec 2015 14:12:37 -0800 Subject: Add some small shadow to cards --- .../github/daneren2005/dsub/view/CardView.java | 22 +++++++++------ .../dsub/view/GridSpacingDecoration.java | 33 ++++++++++++++++------ app/src/main/res/layout/album_cell_item.xml | 3 +- app/src/main/res/layout/basic_cell_item.xml | 3 +- app/src/main/res/values/dimens.xml | 1 + 5 files changed, 43 insertions(+), 19 deletions(-) (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/view/CardView.java b/app/src/main/java/github/daneren2005/dsub/view/CardView.java index ba6b66a4..973e63fa 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/CardView.java +++ b/app/src/main/java/github/daneren2005/dsub/view/CardView.java @@ -2,12 +2,12 @@ package github.daneren2005.dsub.view; import android.annotation.TargetApi; import android.content.Context; -import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.RectF; import android.os.Build; import android.util.AttributeSet; +import android.util.Log; import android.widget.FrameLayout; import github.daneren2005.dsub.R; @@ -15,27 +15,23 @@ import github.daneren2005.dsub.R; public class CardView extends FrameLayout{ public CardView(Context context) { super(context); - this.setClipChildren(true); - this.setBackgroundResource(R.drawable.card_rounded_corners); + init(context); } public CardView(Context context, AttributeSet attrs) { super(context, attrs); - this.setClipChildren(true); - this.setBackgroundResource(R.drawable.card_rounded_corners); + init(context); } public CardView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - this.setClipChildren(true); - this.setBackgroundResource(R.drawable.card_rounded_corners); + init(context); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public CardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - this.setClipChildren(true); - this.setBackgroundResource(R.drawable.card_rounded_corners); + init(context); } @Override @@ -47,4 +43,12 @@ public class CardView extends FrameLayout{ canvas.clipPath(clipPath); super.onDraw(canvas); } + + private void init(Context context) { + setClipChildren(true); + setBackgroundResource(R.drawable.card_rounded_corners); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + setElevation(10.0f); + } + } } diff --git a/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java b/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java index c6d3dbb1..a33746c4 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java +++ b/app/src/main/java/github/daneren2005/dsub/view/GridSpacingDecoration.java @@ -21,6 +21,11 @@ import android.support.v7.widget.RecyclerView; import android.util.Log; import android.util.TypedValue; import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.LinearLayout; + +import static android.widget.LinearLayout.*; public class GridSpacingDecoration extends RecyclerView.ItemDecoration { private static final String TAG = GridSpacingDecoration.class.getSimpleName(); @@ -56,25 +61,37 @@ public class GridSpacingDecoration extends RecyclerView.ItemDecoration { /* INVALID SPAN */ if (spanCount < 1 || spanSize > 1) return; - outRect.top = halfSpacing; - outRect.bottom = halfSpacing; - outRect.left = halfSpacing; - outRect.right = halfSpacing; + int margins = 0; + if(view instanceof UpdateView) { + View firstChild = ((ViewGroup) view).getChildAt(0); + ViewGroup.LayoutParams layoutParams = firstChild.getLayoutParams(); + if (layoutParams instanceof LinearLayout.LayoutParams) { + margins = ((LinearLayout.LayoutParams) layoutParams).bottomMargin; + } else if (layoutParams instanceof FrameLayout.LayoutParams) { + margins = ((FrameLayout.LayoutParams) layoutParams).bottomMargin; + } + } + int doubleMargins = margins * 2; + + outRect.top = halfSpacing - margins; + outRect.bottom = halfSpacing - margins; + outRect.left = halfSpacing - margins; + outRect.right = halfSpacing - margins; if (isTopEdge(childIndex, spanCount)) { - outRect.top = spacing; + outRect.top = spacing - doubleMargins; } if (isLeftEdge(spanIndex, spanCount)) { - outRect.left = spacing; + outRect.left = spacing - doubleMargins; } if (isRightEdge(spanIndex, spanCount)) { - outRect.right = spacing; + outRect.right = spacing - doubleMargins; } if (isBottomEdge(childIndex, childCount, spanCount)) { - outRect.bottom = spacing; + outRect.bottom = spacing - doubleMargins; } } diff --git a/app/src/main/res/layout/album_cell_item.xml b/app/src/main/res/layout/album_cell_item.xml index b352a5f1..524727a0 100644 --- a/app/src/main/res/layout/album_cell_item.xml +++ b/app/src/main/res/layout/album_cell_item.xml @@ -1,7 +1,8 @@ + android:layout_height="match_parent" + android:layout_margin="2dp"> + android:layout_height="match_parent" + android:layout_margin="2dp"> 20dp 4dp 8dp + 2dp \ No newline at end of file -- cgit v1.2.3 From 7eafff0b9a5c389aa9575235821a85dd5487ac7d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 20 Dec 2015 14:19:04 -0800 Subject: Tweak the FastScroller for more room to grab --- app/src/main/java/github/daneren2005/dsub/view/FastScroller.java | 2 +- app/src/main/res/layout/abstract_recycler_fragment.xml | 3 ++- app/src/main/res/layout/fast_scroller.xml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java b/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java index 7cb29835..d3eacefc 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java +++ b/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java @@ -95,7 +95,7 @@ public class FastScroller extends LinearLayout { switch(action) { case MotionEvent.ACTION_DOWN: - if(event.getX() < (handle.getX() - 20)) { + if(event.getX() < (handle.getX() - 30)) { return false; } diff --git a/app/src/main/res/layout/abstract_recycler_fragment.xml b/app/src/main/res/layout/abstract_recycler_fragment.xml index 0e0c87f4..2537d222 100644 --- a/app/src/main/res/layout/abstract_recycler_fragment.xml +++ b/app/src/main/res/layout/abstract_recycler_fragment.xml @@ -19,7 +19,8 @@ android:id="@+id/fragment_recycler" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:scrollbars="vertical"/> + android:scrollbars="vertical" + android:paddingRight="6dp"/> \ No newline at end of file -- cgit v1.2.3 From c9b500569cd4c9ae9213b268b45d049f59b751e5 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 20 Dec 2015 14:21:20 -0800 Subject: Lower the list item rightPadding since we added padding to all --- app/src/main/res/values/styles.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0b45b69e..ea6eb0d1 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -38,7 +38,7 @@