|
|
@ -20,7 +20,6 @@
|
|
|
|
package org.isoron.uhabits.views;
|
|
|
|
package org.isoron.uhabits.views;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.util.AttributeSet;
|
|
|
@ -28,6 +27,7 @@ import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
|
|
import org.isoron.uhabits.R;
|
|
|
|
import org.isoron.uhabits.R;
|
|
|
|
import org.isoron.uhabits.helpers.ColorHelper;
|
|
|
|
import org.isoron.uhabits.helpers.ColorHelper;
|
|
|
|
|
|
|
|
import org.isoron.uhabits.helpers.UIHelper;
|
|
|
|
import org.isoron.uhabits.models.Checkmark;
|
|
|
|
import org.isoron.uhabits.models.Checkmark;
|
|
|
|
import org.isoron.uhabits.models.Habit;
|
|
|
|
import org.isoron.uhabits.models.Habit;
|
|
|
|
import org.isoron.uhabits.models.Score;
|
|
|
|
import org.isoron.uhabits.models.Score;
|
|
|
@ -44,7 +44,6 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|
|
|
private RingView ring;
|
|
|
|
private RingView ring;
|
|
|
|
private TextView label;
|
|
|
|
private TextView label;
|
|
|
|
private int checkmarkValue;
|
|
|
|
private int checkmarkValue;
|
|
|
|
private int inactiveColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CheckmarkWidgetView(Context context)
|
|
|
|
public CheckmarkWidgetView(Context context)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -63,8 +62,6 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|
|
|
ring = (RingView) findViewById(R.id.scoreRing);
|
|
|
|
ring = (RingView) findViewById(R.id.scoreRing);
|
|
|
|
label = (TextView) findViewById(R.id.label);
|
|
|
|
label = (TextView) findViewById(R.id.label);
|
|
|
|
|
|
|
|
|
|
|
|
inactiveColor = ColorHelper.CSV_PALETTE[11];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isInEditMode())
|
|
|
|
if(isInEditMode())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
percentage = 0.75f;
|
|
|
|
percentage = 0.75f;
|
|
|
@ -80,7 +77,7 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|
|
|
{
|
|
|
|
{
|
|
|
|
super.setHabit(habit);
|
|
|
|
super.setHabit(habit);
|
|
|
|
this.name = habit.name;
|
|
|
|
this.name = habit.name;
|
|
|
|
this.activeColor = ColorHelper.CSV_PALETTE[habit.color];
|
|
|
|
this.activeColor = ColorHelper.getColor(getContext(), habit.color);
|
|
|
|
refresh();
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -88,40 +85,41 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (backgroundPaint == null || frame == null || ring == null) return;
|
|
|
|
if (backgroundPaint == null || frame == null || ring == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Context context = getContext();
|
|
|
|
|
|
|
|
|
|
|
|
String text;
|
|
|
|
String text;
|
|
|
|
int backgroundColor;
|
|
|
|
int backgroundColor;
|
|
|
|
int foregroundColor;
|
|
|
|
int foregroundColor;
|
|
|
|
float alpha;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (checkmarkValue)
|
|
|
|
switch (checkmarkValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case Checkmark.CHECKED_EXPLICITLY:
|
|
|
|
case Checkmark.CHECKED_EXPLICITLY:
|
|
|
|
text = getResources().getString(R.string.fa_check);
|
|
|
|
text = getResources().getString(R.string.fa_check);
|
|
|
|
backgroundColor = activeColor;
|
|
|
|
backgroundColor = activeColor;
|
|
|
|
foregroundColor = Color.WHITE;
|
|
|
|
foregroundColor =
|
|
|
|
alpha = 1.0f;
|
|
|
|
UIHelper.getStyledColor(context, R.attr.highContrastReverseTextColor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setShadowAlpha(0x4f);
|
|
|
|
|
|
|
|
rebuildBackground();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backgroundPaint.setColor(backgroundColor);
|
|
|
|
|
|
|
|
frame.setBackgroundDrawable(background);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Checkmark.CHECKED_IMPLICITLY:
|
|
|
|
case Checkmark.CHECKED_IMPLICITLY:
|
|
|
|
text = getResources().getString(R.string.fa_check);
|
|
|
|
text = getResources().getString(R.string.fa_check);
|
|
|
|
backgroundColor = inactiveColor;
|
|
|
|
backgroundColor = UIHelper.getStyledColor(context, R.attr.cardBackgroundColor);
|
|
|
|
foregroundColor = ColorHelper.CSV_PALETTE[12];
|
|
|
|
foregroundColor = UIHelper.getStyledColor(context, R.attr.mediumContrastTextColor);
|
|
|
|
alpha = 0.5f;
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Checkmark.UNCHECKED:
|
|
|
|
case Checkmark.UNCHECKED:
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
text = getResources().getString(R.string.fa_times);
|
|
|
|
text = getResources().getString(R.string.fa_times);
|
|
|
|
backgroundColor = inactiveColor;
|
|
|
|
backgroundColor = UIHelper.getStyledColor(context, R.attr.cardBackgroundColor);
|
|
|
|
foregroundColor = ColorHelper.CSV_PALETTE[12];
|
|
|
|
foregroundColor = UIHelper.getStyledColor(context, R.attr.mediumContrastTextColor);
|
|
|
|
alpha = 0.5f;
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
backgroundPaint.setColor(backgroundColor);
|
|
|
|
|
|
|
|
frame.setBackgroundDrawable(background);
|
|
|
|
|
|
|
|
setAlpha(alpha);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ring.setPercentage(percentage);
|
|
|
|
ring.setPercentage(percentage);
|
|
|
|
ring.setPrecision(0.125f);
|
|
|
|
ring.setPrecision(0.125f);
|
|
|
|
ring.setColor(foregroundColor);
|
|
|
|
ring.setColor(foregroundColor);
|
|
|
@ -167,10 +165,4 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return R.layout.widget_checkmark;
|
|
|
|
return R.layout.widget_checkmark;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected int getShadowAlpha()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0x4f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|