diff --git a/app/src/main/java/org/isoron/uhabits/helpers/ListHabitsHelper.java b/app/src/main/java/org/isoron/uhabits/helpers/ListHabitsHelper.java
index b9c871028..385cce4b7 100644
--- a/app/src/main/java/org/isoron/uhabits/helpers/ListHabitsHelper.java
+++ b/app/src/main/java/org/isoron/uhabits/helpers/ListHabitsHelper.java
@@ -21,6 +21,7 @@ package org.isoron.uhabits.helpers;
import android.content.Context;
import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -37,7 +38,8 @@ import java.util.GregorianCalendar;
public class ListHabitsHelper
{
- private int inactiveColor;
+ private final int lowContrastColor;
+ private final int mediumContrastColor;
private final Context context;
private final HabitListLoader loader;
@@ -48,7 +50,8 @@ public class ListHabitsHelper
this.context = context;
this.loader = loader;
- inactiveColor = UIHelper.getStyledColor(context, R.attr.lowContrastTextColor);
+ lowContrastColor = UIHelper.getStyledColor(context, R.attr.lowContrastTextColor);
+ mediumContrastColor = UIHelper.getStyledColor(context, R.attr.mediumContrastTextColor);
fontawesome = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
}
@@ -95,7 +98,7 @@ public class ListHabitsHelper
public int getActiveColor(Habit habit)
{
int activeColor = ColorHelper.getColor(context, habit.color);
- if(habit.isArchived()) activeColor = inactiveColor;
+ if(habit.isArchived()) activeColor = mediumContrastColor;
return activeColor;
}
@@ -129,12 +132,12 @@ public class ListHabitsHelper
if (score < Score.HALF_STAR_CUTOFF)
{
tvStar.setText(context.getString(R.string.fa_star_o));
- tvStar.setTextColor(inactiveColor);
+ tvStar.setTextColor(lowContrastColor);
}
else if (score < Score.FULL_STAR_CUTOFF)
{
tvStar.setText(context.getString(R.string.fa_star_half_o));
- tvStar.setTextColor(inactiveColor);
+ tvStar.setTextColor(lowContrastColor);
}
else
{
@@ -156,13 +159,13 @@ public class ListHabitsHelper
case 1:
tvCheck.setText(R.string.fa_check);
- tvCheck.setTextColor(inactiveColor);
+ tvCheck.setTextColor(lowContrastColor);
tvCheck.setTag(R.string.toggle_key, 1);
break;
case 0:
tvCheck.setText(R.string.fa_times);
- tvCheck.setTextColor(inactiveColor);
+ tvCheck.setTextColor(lowContrastColor);
tvCheck.setTag(R.string.toggle_key, 0);
break;
}
@@ -197,13 +200,23 @@ public class ListHabitsHelper
public void updateHabitCardBackground(View view, boolean isSelected)
{
- if (isSelected)
- view.setBackgroundResource(R.drawable.selected_box);
- else
+ if (android.os.Build.VERSION.SDK_INT >= 21)
{
- if (android.os.Build.VERSION.SDK_INT >= 21)
+ if (isSelected)
+ view.setBackgroundResource(R.drawable.selected_box);
+ else
view.setBackgroundResource(R.drawable.ripple);
- else view.setBackgroundResource(R.drawable.card_background);
+ }
+ else
+ {
+ Drawable background;
+
+ if (isSelected)
+ background = UIHelper.getStyledDrawable(context, R.attr.selectedBackground);
+ else
+ background = UIHelper.getStyledDrawable(context, R.attr.cardBackground);
+
+ view.setBackgroundDrawable(background);
}
}
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 ede9f9b3a..4c6444112 100644
--- a/app/src/main/java/org/isoron/uhabits/helpers/UIHelper.java
+++ b/app/src/main/java/org/isoron/uhabits/helpers/UIHelper.java
@@ -25,6 +25,7 @@ import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Debug;
import android.os.Looper;
@@ -187,6 +188,16 @@ public abstract class UIHelper
return color;
}
+ public static Drawable getStyledDrawable(Context context, int attrId)
+ {
+ int[] attrs = new int[]{ attrId };
+ TypedArray ta = context.obtainStyledAttributes(attrs);
+ Drawable drawable = ta.getDrawable(0);
+ ta.recycle();
+
+ return drawable;
+ }
+
public static boolean getStyledBoolean(Context context, int attrId)
{
int[] attrs = new int[]{ attrId };
diff --git a/app/src/main/res/drawable/selected_box.xml b/app/src/main/res/drawable-v21/selected_box.xml
similarity index 100%
rename from app/src/main/res/drawable/selected_box.xml
rename to app/src/main/res/drawable-v21/selected_box.xml
diff --git a/app/src/main/res/drawable/card_amoled_background.xml b/app/src/main/res/drawable/card_amoled_background.xml
new file mode 100644
index 000000000..d46bbb1e5
--- /dev/null
+++ b/app/src/main/res/drawable/card_amoled_background.xml
@@ -0,0 +1,58 @@
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/card_dark_background.xml b/app/src/main/res/drawable/card_dark_background.xml
new file mode 100644
index 000000000..7bf94a482
--- /dev/null
+++ b/app/src/main/res/drawable/card_dark_background.xml
@@ -0,0 +1,58 @@
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/card_background.xml b/app/src/main/res/drawable/card_light_background.xml
similarity index 100%
rename from app/src/main/res/drawable/card_background.xml
rename to app/src/main/res/drawable/card_light_background.xml
diff --git a/app/src/main/res/drawable/habits_list_header_amoled_background.xml b/app/src/main/res/drawable/habits_list_header_amoled_background.xml
new file mode 100644
index 000000000..b65fb29c3
--- /dev/null
+++ b/app/src/main/res/drawable/habits_list_header_amoled_background.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/habits_list_header_dark_background.xml b/app/src/main/res/drawable/habits_list_header_dark_background.xml
new file mode 100644
index 000000000..88989c254
--- /dev/null
+++ b/app/src/main/res/drawable/habits_list_header_dark_background.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/habits_list_header_background.xml b/app/src/main/res/drawable/habits_list_header_light_background.xml
similarity index 97%
rename from app/src/main/res/drawable/habits_list_header_background.xml
rename to app/src/main/res/drawable/habits_list_header_light_background.xml
index 83385eaa5..5a17ae8d5 100644
--- a/app/src/main/res/drawable/habits_list_header_background.xml
+++ b/app/src/main/res/drawable/habits_list_header_light_background.xml
@@ -20,7 +20,7 @@
- -
+
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/selected_box_dark.xml b/app/src/main/res/drawable/selected_box_dark.xml
new file mode 100644
index 000000000..ca0fb00ab
--- /dev/null
+++ b/app/src/main/res/drawable/selected_box_dark.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/selected_box_light.xml b/app/src/main/res/drawable/selected_box_light.xml
new file mode 100644
index 000000000..754676620
--- /dev/null
+++ b/app/src/main/res/drawable/selected_box_light.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index e7bb375b9..aa6965939 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -34,4 +34,9 @@
+
+
+
+
+
\ 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 fcaf40423..dd07830c7 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -22,6 +22,62 @@
+
+
+
+