diff --git a/app/src/main/java/com/hippo/drawable/AddDeleteDrawable.java b/app/src/main/java/com/hippo/drawable/AddDeleteDrawable.java index 0700fa23f..80c6daeae 100644 --- a/app/src/main/java/com/hippo/drawable/AddDeleteDrawable.java +++ b/app/src/main/java/com/hippo/drawable/AddDeleteDrawable.java @@ -46,13 +46,13 @@ public class AddDeleteDrawable extends Drawable { /** * @param context used to get the configuration for the drawable from */ - public AddDeleteDrawable(Context context) { + public AddDeleteDrawable(Context context, int color) { Resources resources = context.getResources(); mSize = resources.getDimensionPixelSize(R.dimen.add_size); float barThickness = Math.round(resources.getDimension(R.dimen.add_thickness)); - mPaint.setColor(resources.getColor(R.color.primary_drawable_light)); + mPaint.setColor(color); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.MITER); mPaint.setStrokeCap(Paint.Cap.BUTT); diff --git a/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java b/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java index e7b429bb9..65a518847 100644 --- a/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java +++ b/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java @@ -28,6 +28,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; +import android.support.annotation.ColorInt; import com.hippo.ehviewer.R; import com.hippo.yorozuya.MathUtils; @@ -66,11 +67,11 @@ public class DrawerArrowDrawable extends Drawable { /** * @param context used to get the configuration for the drawable from */ - public DrawerArrowDrawable(Context context) { + public DrawerArrowDrawable(Context context, int color) { Resources resources = context.getResources(); mPaint.setAntiAlias(true); - mPaint.setColor(resources.getColor(R.color.primary_drawable_light)); + mPaint.setColor(color); mSize = resources.getDimensionPixelSize(R.dimen.dad_drawable_size); // round this because having this floating may cause bad measurements mBarSize = Math.round(resources.getDimension(R.dimen.dad_bar_size)); @@ -144,6 +145,11 @@ public class DrawerArrowDrawable extends Drawable { canvas.restore(); } + public void setColor(@ColorInt int color) { + mPaint.setColor(color); + invalidateSelf(); + } + @Override public void setAlpha(int i) { mPaint.setAlpha(i); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java index adfeb0357..6b59bf53a 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java @@ -49,6 +49,7 @@ import android.widget.TextView; import com.github.amlcurran.showcaseview.ShowcaseView; import com.github.amlcurran.showcaseview.SimpleShowcaseEventListener; import com.github.amlcurran.showcaseview.targets.PointTarget; +import com.hippo.android.resource.AttrResources; import com.hippo.annotation.Implemented; import com.hippo.drawable.DrawerArrowDrawable; import com.hippo.easyrecyclerview.EasyRecyclerView; @@ -273,7 +274,7 @@ public class FavoritesScene extends BaseScene implements refreshLayout.setHeaderTranslationY(paddingTopSB); - mLeftDrawable = new DrawerArrowDrawable(context); + mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.colorPrimaryDrawable)); mSearchBar.setLeftDrawable(mLeftDrawable); mSearchBar.setRightDrawable(DrawableManager.getDrawable(context, R.drawable.v_magnify_x24)); mSearchBar.setHelper(this); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java index 59fe97e5e..d2f3e93cd 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java @@ -49,10 +49,10 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; - import com.github.amlcurran.showcaseview.ShowcaseView; import com.github.amlcurran.showcaseview.SimpleShowcaseEventListener; import com.github.amlcurran.showcaseview.targets.PointTarget; +import com.hippo.android.resource.AttrResources; import com.hippo.app.CheckBoxDialogBuilder; import com.hippo.app.EditTextDialogBuilder; import com.hippo.drawable.AddDeleteDrawable; @@ -92,13 +92,11 @@ import com.hippo.yorozuya.MathUtils; import com.hippo.yorozuya.SimpleAnimatorListener; import com.hippo.yorozuya.StringUtils; import com.hippo.yorozuya.ViewUtils; - -import junit.framework.Assert; - import java.io.File; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; +import junit.framework.Assert; public final class GalleryListScene extends BaseScene implements EasyRecyclerView.OnItemClickListener, EasyRecyclerView.OnItemLongClickListener, @@ -427,8 +425,8 @@ public final class GalleryListScene extends BaseScene refreshLayout.setHeaderTranslationY(paddingTopSB); - mLeftDrawable = new DrawerArrowDrawable(context); - mRightDrawable = new AddDeleteDrawable(context); + mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.colorPrimaryDrawable)); + mRightDrawable = new AddDeleteDrawable(context, AttrResources.getAttrColor(context, R.attr.colorPrimaryDrawable)); mSearchBar.setLeftDrawable(mLeftDrawable); mSearchBar.setRightDrawable(mRightDrawable); mSearchBar.setHelper(this); @@ -446,8 +444,7 @@ public final class GalleryListScene extends BaseScene mFabLayout.setOnExpandListener(this); addAboveSnackView(mFabLayout); - mActionFabDrawable = new AddDeleteDrawable(context); - mActionFabDrawable.setColor(resources.getColor(R.color.primary_drawable_dark)); + mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark)); mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable); mSearchFab.setOnClickListener(this); diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index b2da3c88c..0a9a30298 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -20,6 +20,10 @@ + + + + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 329980047..c38610074 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -29,6 +29,7 @@ @color/divider_light @color/colorPrimary + @color/primary_drawable_light