Better icons and colors

pull/610/head
KristianTashkov 5 years ago
parent d4e451e27b
commit 6f39551202

@ -369,8 +369,6 @@ public class HistoryChart extends ScrollableChart
GregorianCalendar date, GregorianCalendar date,
int checkmarkOffset) int checkmarkOffset)
{ {
boolean drawCross = false;
boolean drawDash = false;
if (checkmarkOffset >= checkmarks.length) pSquareBg.setColor(colors[0]); if (checkmarkOffset >= checkmarks.length) pSquareBg.setColor(colors[0]);
else else
{ {
@ -381,13 +379,6 @@ public class HistoryChart extends ScrollableChart
pSquareBg.setColor(isNumerical ? textColor : colors[1]); pSquareBg.setColor(isNumerical ? textColor : colors[1]);
} }
else pSquareBg.setColor(colors[2]); else pSquareBg.setColor(colors[2]);
if (!isNumerical)
{
if (checkmark == FAILED_EXPLICITLY_UNNECESSARY ||
checkmark == FAILED_EXPLICITLY_NECESSARY) drawCross = true;
if (checkmark == SKIPPED_EXPLICITLY) drawDash = true;
}
} }
pSquareFg.setColor(reverseTextColor); pSquareFg.setColor(reverseTextColor);
@ -396,28 +387,6 @@ public class HistoryChart extends ScrollableChart
String text = Integer.toString(date.get(Calendar.DAY_OF_MONTH)); String text = Integer.toString(date.get(Calendar.DAY_OF_MONTH));
canvas.drawText(text, location.centerX(), canvas.drawText(text, location.centerX(),
location.centerY() + squareTextOffset, pSquareFg); location.centerY() + squareTextOffset, pSquareFg);
if (drawCross)
{
for (int thickness = -1; thickness < 2; thickness ++)
{
canvas.drawLine(
location.left + thickness, location.bottom,
location.right - thickness, location.top, pSquareFg);
canvas.drawLine(
location.right - thickness, location.bottom,
location.left + thickness, location.top, pSquareFg);
}
}
if (drawDash)
{
for (int thickness = -1; thickness < 2; thickness ++)
{
canvas.drawLine(
location.left, location.centerY() + thickness + squareTextOffset / 2,
location.right,location.centerY() + thickness + squareTextOffset / 2,
pSquareFg);
}
}
} }
private float getWeekdayLabelWidth() private float getWeekdayLabelWidth()
@ -449,16 +418,13 @@ public class HistoryChart extends ScrollableChart
if (isBackgroundTransparent) if (isBackgroundTransparent)
primaryColor = ColorUtils.setMinValue(primaryColor, 0.75f); primaryColor = ColorUtils.setMinValue(primaryColor, 0.75f);
int lighterPrimaryColor = ColorUtils.setAlpha(primaryColor, 0.5f);
int red = Color.red(primaryColor);
int green = Color.green(primaryColor);
int blue = Color.blue(primaryColor);
if (isBackgroundTransparent) if (isBackgroundTransparent)
{ {
colors = new int[3]; colors = new int[3];
colors[0] = Color.argb(16, 255, 255, 255); colors[0] = Color.argb(16, 255, 255, 255);
colors[1] = Color.argb(128, red, green, blue); colors[1] = lighterPrimaryColor;
colors[2] = primaryColor; colors[2] = primaryColor;
textColor = Color.WHITE; textColor = Color.WHITE;
reverseTextColor = Color.WHITE; reverseTextColor = Color.WHITE;
@ -467,7 +433,7 @@ public class HistoryChart extends ScrollableChart
{ {
colors = new int[3]; colors = new int[3];
colors[0] = res.getColor(R.attr.lowContrastTextColor); colors[0] = res.getColor(R.attr.lowContrastTextColor);
colors[1] = Color.argb(127, red, green, blue); colors[1] = lighterPrimaryColor;
colors[2] = primaryColor; colors[2] = primaryColor;
textColor = res.getColor(R.attr.mediumContrastTextColor); textColor = res.getColor(R.attr.mediumContrastTextColor);
reverseTextColor = reverseTextColor =

@ -26,6 +26,7 @@ import android.view.*
import android.view.View.MeasureSpec.* import android.view.View.MeasureSpec.*
import com.google.auto.factory.* import com.google.auto.factory.*
import org.isoron.androidbase.activities.* import org.isoron.androidbase.activities.*
import org.isoron.androidbase.utils.ColorUtils
import org.isoron.uhabits.* import org.isoron.uhabits.*
import org.isoron.uhabits.core.models.Checkmark.* import org.isoron.uhabits.core.models.Checkmark.*
import org.isoron.uhabits.core.preferences.* import org.isoron.uhabits.core.preferences.*
@ -105,9 +106,6 @@ class CheckmarkButtonView(
private inner class Drawer { private inner class Drawer {
private val rect = RectF() private val rect = RectF()
private val lowContrastColor = sres.getColor(R.attr.lowContrastTextColor) private val lowContrastColor = sres.getColor(R.attr.lowContrastTextColor)
private val mediumContrastTextColor = sres.getColor(R.attr.mediumContrastTextColor)
private val paint = TextPaint().apply { private val paint = TextPaint().apply {
typeface = getFontAwesome() typeface = getFontAwesome()
@ -117,18 +115,25 @@ class CheckmarkButtonView(
} }
fun draw(canvas: Canvas) { fun draw(canvas: Canvas) {
val lighterColor = ColorUtils.setAlpha(color, 0.5f)
paint.color = when (value) { paint.color = when (value) {
CHECKED_EXPLICITLY -> color CHECKED_EXPLICITLY -> color
FAILED_EXPLICITLY_UNNECESSARY -> mediumContrastTextColor FAILED_EXPLICITLY_NECESSARY -> lowContrastColor
SKIPPED_EXPLICITLY -> mediumContrastTextColor UNCHECKED -> lowContrastColor
FAILED_EXPLICITLY_NECESSARY -> mediumContrastTextColor else -> lighterColor
else -> lowContrastColor }
var unchecked_symbol = R.string.fa_times
var implicitCheckedSymbol = R.string.fa_check
if (preferences.isAdvancedCheckmarksEnabled) {
unchecked_symbol = R.string.fa_question
implicitCheckedSymbol = R.string.fa_question
} }
val id = when (value) { val id = when (value) {
SKIPPED_EXPLICITLY -> R.string.fa_skipped SKIPPED_EXPLICITLY -> R.string.fa_skipped
UNCHECKED -> R.string.fa_times UNCHECKED -> unchecked_symbol
FAILED_EXPLICITLY_NECESSARY -> R.string.fa_times FAILED_EXPLICITLY_NECESSARY -> R.string.fa_times
FAILED_EXPLICITLY_UNNECESSARY -> R.string.fa_check CHECKED_IMPLICITLY -> implicitCheckedSymbol
else -> R.string.fa_check else -> R.string.fa_check
} }
val label = resources.getString(id) val label = resources.getString(id)
@ -140,3 +145,4 @@ class CheckmarkButtonView(
} }
} }
} }

@ -20,6 +20,7 @@
package org.isoron.uhabits.widgets.views; package org.isoron.uhabits.widgets.views;
import android.content.*; import android.content.*;
import android.graphics.Color;
import android.util.*; import android.util.*;
import android.widget.*; import android.widget.*;
@ -73,24 +74,27 @@ public class CheckmarkWidgetView extends HabitWidgetView {
int bgColor; int bgColor;
int fgColor; int fgColor;
int lighterActiveColor = ColorUtils.setAlpha(activeColor, 0.5f);
switch (checkmarkState) { switch (checkmarkState) {
case Checkmark.CHECKED_EXPLICITLY: case Checkmark.CHECKED_EXPLICITLY:
bgColor = activeColor; bgColor = activeColor;
fgColor = res.getColor(R.attr.highContrastReverseTextColor); fgColor = res.getColor(R.attr.highContrastReverseTextColor);
setShadowAlpha(0x4f); setShadowAlpha(0x4f);
backgroundPaint.setColor(bgColor);
frame.setBackgroundDrawable(background); frame.setBackgroundDrawable(background);
break; break;
case Checkmark.FAILED_EXPLICITLY_NECESSARY: case Checkmark.FAILED_EXPLICITLY_NECESSARY:
case Checkmark.FAILED_EXPLICITLY_UNNECESSARY:
case Checkmark.SKIPPED_EXPLICITLY:
bgColor = res.getColor(R.attr.highlightedBackgroundColor); bgColor = res.getColor(R.attr.highlightedBackgroundColor);
fgColor = res.getColor(R.attr.mediumContrastTextColor); fgColor = res.getColor(R.attr.highContrastReverseTextColor);
setShadowAlpha(0x4f); setShadowAlpha(0x4f);
break; break;
case Checkmark.SKIPPED_EXPLICITLY:
case Checkmark.CHECKED_IMPLICITLY: case Checkmark.CHECKED_IMPLICITLY:
case Checkmark.FAILED_EXPLICITLY_UNNECESSARY:
bgColor = lighterActiveColor;
fgColor = res.getColor(R.attr.highContrastReverseTextColor);
setShadowAlpha(0x4f);
break;
case Checkmark.UNCHECKED: case Checkmark.UNCHECKED:
default: default:
bgColor = res.getColor(R.attr.cardBgColor); bgColor = res.getColor(R.attr.cardBgColor);
@ -99,6 +103,7 @@ public class CheckmarkWidgetView extends HabitWidgetView {
break; break;
} }
backgroundPaint.setColor(bgColor);
ring.setPercentage(percentage); ring.setPercentage(percentage);
ring.setColor(fgColor); ring.setColor(fgColor);
ring.setBackgroundColor(bgColor); ring.setBackgroundColor(bgColor);
@ -118,18 +123,29 @@ public class CheckmarkWidgetView extends HabitWidgetView {
protected String getText() protected String getText()
{ {
HabitsApplication app =
(HabitsApplication) getContext().getApplicationContext();
int uncheckedSymbol = R.string.fa_times;
int implicitCheckedSymbol = R.string.fa_check;
if (app.getComponent().getPreferences().isAdvancedCheckmarksEnabled())
{
uncheckedSymbol = R.string.fa_question;
implicitCheckedSymbol = R.string.fa_question;
}
if (isNumerical) return NumberButtonViewKt.toShortString(checkmarkValue / 1000.0); if (isNumerical) return NumberButtonViewKt.toShortString(checkmarkValue / 1000.0);
switch (checkmarkState) { switch (checkmarkState) {
case Checkmark.CHECKED_EXPLICITLY: case Checkmark.CHECKED_EXPLICITLY:
case Checkmark.CHECKED_IMPLICITLY:
case Checkmark.FAILED_EXPLICITLY_UNNECESSARY: case Checkmark.FAILED_EXPLICITLY_UNNECESSARY:
return getResources().getString(R.string.fa_check); return getResources().getString(R.string.fa_check);
case Checkmark.CHECKED_IMPLICITLY:
return getResources().getString(implicitCheckedSymbol);
case Checkmark.SKIPPED_EXPLICITLY: case Checkmark.SKIPPED_EXPLICITLY:
return getResources().getString(R.string.fa_skipped); return getResources().getString(R.string.fa_skipped);
case Checkmark.UNCHECKED:
case Checkmark.FAILED_EXPLICITLY_NECESSARY: case Checkmark.FAILED_EXPLICITLY_NECESSARY:
default:
return getResources().getString(R.string.fa_times); return getResources().getString(R.string.fa_times);
case Checkmark.UNCHECKED:
default:
return getResources().getString(uncheckedSymbol);
} }
} }

@ -21,9 +21,11 @@
<resources> <resources>
<string translatable="false" name="fa_star_half_o">&#xf123;</string> <string translatable="false" name="fa_star_half_o">&#xf123;</string>
<string translatable="false" name="fa_arrow_circle_up">&#xf0aa;</string> <string translatable="false" name="fa_arrow_circle_up">&#xf0aa;</string>
<string translatable="false" name="fa_skipped">&#xf068;</string>
<string translatable="false" name="fa_check">&#xf00c;</string> <string translatable="false" name="fa_check">&#xf00c;</string>
<string translatable="false" name="fa_times">&#xf00d;</string> <string translatable="false" name="fa_times">&#xf00d;</string>
<string translatable="false" name="fa_skipped">&#xf068;</string>
<string translatable="false" name="fa_question">&#xf128;</string>
<string translatable="false" name="fa_archive">&#xf187;</string>
<string translatable="false" name="fa_bell_o">&#xf0a2;</string> <string translatable="false" name="fa_bell_o">&#xf0a2;</string>
<string translatable="false" name="fa_calendar">&#xf073;</string> <string translatable="false" name="fa_calendar">&#xf073;</string>

Loading…
Cancel
Save