diff --git a/app/src/main/java/org/isoron/uhabits/helpers/ColorHelper.java b/app/src/main/java/org/isoron/uhabits/helpers/ColorHelper.java index 975d9a774..df27d7add 100644 --- a/app/src/main/java/org/isoron/uhabits/helpers/ColorHelper.java +++ b/app/src/main/java/org/isoron/uhabits/helpers/ColorHelper.java @@ -20,9 +20,7 @@ package org.isoron.uhabits.helpers; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Color; -import android.util.Log; import org.isoron.uhabits.R; @@ -57,16 +55,8 @@ public class ColorHelper public static int[] getPalette(Context context) { - int[] attr = new int[] { R.attr.palette }; - TypedArray array = context.obtainStyledAttributes(attr); - int resourceId = array.getResourceId(0, -1); - array.recycle(); - - if(resourceId < 0) - { - Log.w("ColorHelper", "could not find palette resource. Returning CSV palette"); - return CSV_PALETTE; - } + int resourceId = UIHelper.getStyleResource(context, R.attr.palette); + if(resourceId < 0) return CSV_PALETTE; return context.getResources().getIntArray(resourceId); } diff --git a/app/src/main/java/org/isoron/uhabits/helpers/UIHelper.java b/app/src/main/java/org/isoron/uhabits/helpers/UIHelper.java index 4c6444112..92bfe5620 100644 --- a/app/src/main/java/org/isoron/uhabits/helpers/UIHelper.java +++ b/app/src/main/java/org/isoron/uhabits/helpers/UIHelper.java @@ -208,6 +208,16 @@ public abstract class UIHelper return bool; } + static int getStyleResource(Context context, int attrId) + { + int[] attr = new int[] { attrId }; + TypedArray array = context.obtainStyledAttributes(attr); + int resourceId = array.getResourceId(0, -1); + array.recycle(); + + return resourceId; + } + public static void applyCurrentTheme(Activity activity) { switch(getCurrentTheme())