First version of dark theme

This commit is contained in:
2016-04-08 17:15:14 -04:00
parent de8018af7d
commit f0701f7b35
17 changed files with 117 additions and 44 deletions

View File

@@ -20,7 +20,6 @@
package org.isoron.uhabits.helpers;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
@@ -37,8 +36,7 @@ import java.util.GregorianCalendar;
public class ListHabitsHelper
{
public static final int INACTIVE_COLOR = Color.rgb(200, 200, 200);
public static final int INACTIVE_CHECKMARK_COLOR = Color.rgb(230, 230, 230);
private int inactiveColor;
private final Context context;
private final HabitListLoader loader;
@@ -49,6 +47,7 @@ public class ListHabitsHelper
this.context = context;
this.loader = loader;
inactiveColor = UIHelper.getStyledColor(context, R.attr.inactiveCheckmarkColor);
fontawesome = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
}
@@ -95,7 +94,7 @@ public class ListHabitsHelper
public int getActiveColor(Habit habit)
{
int activeColor = habit.color;
if(habit.isArchived()) activeColor = INACTIVE_COLOR;
if(habit.isArchived()) activeColor = inactiveColor;
return activeColor;
}
@@ -129,12 +128,12 @@ public class ListHabitsHelper
if (score < Score.HALF_STAR_CUTOFF)
{
tvStar.setText(context.getString(R.string.fa_star_o));
tvStar.setTextColor(INACTIVE_COLOR);
tvStar.setTextColor(inactiveColor);
}
else if (score < Score.FULL_STAR_CUTOFF)
{
tvStar.setText(context.getString(R.string.fa_star_half_o));
tvStar.setTextColor(INACTIVE_COLOR);
tvStar.setTextColor(inactiveColor);
}
else
{
@@ -156,13 +155,13 @@ public class ListHabitsHelper
case 1:
tvCheck.setText(R.string.fa_check);
tvCheck.setTextColor(INACTIVE_CHECKMARK_COLOR);
tvCheck.setTextColor(inactiveColor);
tvCheck.setTag(R.string.toggle_key, 1);
break;
case 0:
tvCheck.setText(R.string.fa_times);
tvCheck.setTextColor(INACTIVE_CHECKMARK_COLOR);
tvCheck.setTextColor(inactiveColor);
tvCheck.setTag(R.string.toggle_key, 0);
break;
}
@@ -175,7 +174,7 @@ public class ListHabitsHelper
else
{
if (android.os.Build.VERSION.SDK_INT >= 21)
view.setBackgroundResource(R.drawable.ripple_white);
view.setBackgroundResource(R.drawable.ripple);
else view.setBackgroundResource(R.drawable.card_background);
}
}

View File

@@ -22,6 +22,7 @@ package org.isoron.uhabits.helpers;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Debug;
@@ -170,4 +171,14 @@ public abstract class UIHelper
return context.getResources().getDisplayMetrics().widthPixels;
}
public static int getStyledColor(Context context, int attrId)
{
int[] attrs = new int[]{ attrId };
TypedArray ta = context.obtainStyledAttributes(attrs);
int color = ta.getColor(0, 0);
ta.recycle();
return color;
}
}

View File

@@ -32,6 +32,7 @@ import android.util.AttributeSet;
import org.isoron.uhabits.R;
import org.isoron.uhabits.helpers.ColorHelper;
import org.isoron.uhabits.helpers.DateHelper;
import org.isoron.uhabits.helpers.UIHelper;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.models.Score;
@@ -74,6 +75,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
private boolean isBackgroundTransparent;
private int bucketSize = 7;
private int footerHeight;
private int backgroundColor;
public HabitScoreView(Context context)
{
@@ -123,7 +125,8 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
else
{
textColor = Color.argb(64, 0, 0, 0);
dimmedTextColor = Color.argb(16, 0, 0, 0);
dimmedTextColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
backgroundColor = UIHelper.getStyledColor(getContext(), R.attr.cardBackgroundColor);
}
}
@@ -345,7 +348,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
private void drawMarker(Canvas canvas, RectF rect)
{
rect.inset(baseSize * 0.15f, baseSize * 0.15f);
setModeOrColor(pGraph, XFERMODE_CLEAR, Color.WHITE);
setModeOrColor(pGraph, XFERMODE_CLEAR, backgroundColor);
canvas.drawOval(rect, pGraph);
rect.inset(baseSize * 0.1f, baseSize * 0.1f);
@@ -353,7 +356,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
canvas.drawOval(rect, pGraph);
rect.inset(baseSize * 0.1f, baseSize * 0.1f);
setModeOrColor(pGraph, XFERMODE_CLEAR, Color.WHITE);
setModeOrColor(pGraph, XFERMODE_CLEAR, backgroundColor);
canvas.drawOval(rect, pGraph);
if(isBackgroundTransparent)

View File

@@ -29,6 +29,7 @@ import android.view.View;
import org.isoron.uhabits.R;
import org.isoron.uhabits.helpers.ColorHelper;
import org.isoron.uhabits.helpers.UIHelper;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.models.Streak;
@@ -150,7 +151,7 @@ public class HabitStreakView extends View implements HabitDataView
colors[2] = Color.argb(192, red, green, blue);
colors[1] = Color.argb(96, red, green, blue);
colors[0] = Color.argb(32, 0, 0, 0);
textColor = Color.argb(64, 0, 0, 0);
textColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
}
}

View File

@@ -51,6 +51,7 @@ public class RingView extends View
private float maxDiameter;
private float textSize;
private int fadedTextColor;
private int backgroundColor;
public RingView(Context context)
{
@@ -97,7 +98,8 @@ public class RingView extends View
pRing.setColor(color);
pRing.setTextAlign(Paint.Align.CENTER);
fadedTextColor = getResources().getColor(R.color.fadedTextColor);
backgroundColor = UIHelper.getStyledColor(getContext(), R.attr.cardBackgroundColor);
fadedTextColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
textSize = getResources().getDimension(R.dimen.smallTextSize);
rect = new RectF();
@@ -139,7 +141,7 @@ public class RingView extends View
pRing.setColor(Color.argb(255, 230, 230, 230));
canvas.drawArc(rect, 360 * percentage - 90 + 2, 360 * (1 - percentage) - 4, true, pRing);
pRing.setColor(Color.WHITE);
pRing.setColor(backgroundColor);
rect.inset(thickness, thickness);
canvas.drawArc(rect, -90, 360, true, pRing);