From a6b30fb92f5f640a4ee7b72a8dc7b3735cb99952 Mon Sep 17 00:00:00 2001 From: krimin_killr21 Date: Fri, 11 Sep 2015 17:08:51 -0400 Subject: [PATCH] Version 4.0.1 - Fixed flipped indicator bug affecting APIs 14-. - Fixed no indicator colour bug affecting all APIs. - Fixed indicator not fading bug affecting APIs 14-. --- app/build.gradle | 4 +-- lib/build.gradle | 6 ++-- .../materialscrollbar/MaterialScrollBar.java | 20 ++++++++++--- lib/src/main/res/drawable-v12/indicator.xml | 30 +++++++++++++++++++ lib/src/main/res/drawable/indicator.xml | 7 +++-- 5 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 lib/src/main/res/drawable-v12/indicator.xml diff --git a/app/build.gradle b/app/build.gradle index 987c69a..fd696af 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,9 +6,9 @@ android { defaultConfig { applicationId "com.turingtechnologies.materialscrollbardemo" - minSdkVersion 11 + minSdkVersion 9 targetSdkVersion 23 - versionCode 1 + versionCode 2 versionName "2.0" } buildTypes { diff --git a/lib/build.gradle b/lib/build.gradle index 8dc0895..be6fd4f 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -13,7 +13,7 @@ ext { siteUrl = 'https://github.com/krimin-killr21/MaterialScrollBar' gitUrl = 'https://github.com/krimin-killr21/MaterialScrollBar.git' - libraryVersion = '4.0.0' + libraryVersion = '4.0.1' developerId = 'krimin-killr21' developerName = 'Turing Technologies' @@ -31,8 +31,8 @@ android { defaultConfig { minSdkVersion 7 targetSdkVersion 23 - versionCode 6 - versionName "4.0.0" + versionCode 7 + versionName "4.0.1" } } diff --git a/lib/src/main/java/com/turingtechnologies/materialscrollbar/MaterialScrollBar.java b/lib/src/main/java/com/turingtechnologies/materialscrollbar/MaterialScrollBar.java index 7ea3fec..47f7d27 100644 --- a/lib/src/main/java/com/turingtechnologies/materialscrollbar/MaterialScrollBar.java +++ b/lib/src/main/java/com/turingtechnologies/materialscrollbar/MaterialScrollBar.java @@ -20,9 +20,12 @@ import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; +import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Color; +import android.graphics.drawable.GradientDrawable; import android.os.Build; +import android.support.v4.content.ContextCompat; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.TypedValue; @@ -168,6 +171,9 @@ public boolean onTouch(View v, MotionEvent event) { fadeIn(); } else { if(indicator != null && indicator.getVisibility() == VISIBLE){ + if(Build.VERSION.SDK_INT <= 12){ + indicator.clearAnimation(); + } indicator.setVisibility(INVISIBLE); } @@ -200,9 +206,10 @@ public MaterialScrollBar setHideDuration(int duration){ * @param colour to set the handle. */ public MaterialScrollBar setHandleColour(String colour){ - handleColour = Color.parseColor(colour); + handleColour = ContextCompat.getColor(getContext(), Color.parseColor(colour)); + ((GradientDrawable) indicator.getBackground()).setColor(Color.parseColor(colour)); if(!lightOnTouch) { - handle.setBackgroundColor(Color.parseColor(colour)); + ((GradientDrawable)indicator.getBackground()).setColor(Color.parseColor(colour)); } return this; } @@ -212,9 +219,14 @@ public MaterialScrollBar setHandleColour(String colour){ * @param colour to set the handle. */ public MaterialScrollBar setHandleColour(int colour){ - handleColour = getResources().getColor(colour); + try{ + handleColour = ContextCompat.getColor(getContext(), getResources().getColor(colour)); + } catch (Resources.NotFoundException e){ + handleColour = colour; + } + ((GradientDrawable)indicator.getBackground()).setColor(handleColour); if(!lightOnTouch){ - handle.setBackgroundColor(getResources().getColor(colour)); + handle.setBackgroundColor(handleColour); } return this; } diff --git a/lib/src/main/res/drawable-v12/indicator.xml b/lib/src/main/res/drawable-v12/indicator.xml new file mode 100644 index 0000000..09c7229 --- /dev/null +++ b/lib/src/main/res/drawable-v12/indicator.xml @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/lib/src/main/res/drawable/indicator.xml b/lib/src/main/res/drawable/indicator.xml index 09c7229..d83133b 100644 --- a/lib/src/main/res/drawable/indicator.xml +++ b/lib/src/main/res/drawable/indicator.xml @@ -21,10 +21,13 @@ + + android:bottomRightRadius="100dp" /> \ No newline at end of file