|
|
|
@ -19,7 +19,6 @@
|
|
|
|
|
|
|
|
|
|
package org.isoron.uhabits.widgets.views;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.*;
|
|
|
|
|
import android.util.*;
|
|
|
|
|
import android.widget.*;
|
|
|
|
@ -36,9 +35,6 @@ import org.isoron.uhabits.utils.*;
|
|
|
|
|
|
|
|
|
|
import static org.isoron.androidbase.utils.InterfaceUtils.getDimension;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class CheckmarkWidgetView extends HabitWidgetView {
|
|
|
|
|
protected int activeColor;
|
|
|
|
|
|
|
|
|
@ -57,20 +53,20 @@ public class CheckmarkWidgetView extends HabitWidgetView {
|
|
|
|
|
|
|
|
|
|
protected boolean isNumerical;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CheckmarkWidgetView(Context context) {
|
|
|
|
|
public CheckmarkWidgetView(Context context)
|
|
|
|
|
{
|
|
|
|
|
super(context);
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CheckmarkWidgetView(Context context, AttributeSet attrs) {
|
|
|
|
|
public CheckmarkWidgetView(Context context, AttributeSet attrs)
|
|
|
|
|
{
|
|
|
|
|
super(context, attrs);
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void refresh() {
|
|
|
|
|
public void refresh()
|
|
|
|
|
{
|
|
|
|
|
if (backgroundPaint == null || frame == null || ring == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -95,29 +91,22 @@ public class CheckmarkWidgetView extends HabitWidgetView {
|
|
|
|
|
ring.setPercentage(percentage);
|
|
|
|
|
ring.setColor(fgColor);
|
|
|
|
|
ring.setBackgroundColor(bgColor);
|
|
|
|
|
ring.setText(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getText());
|
|
|
|
|
ring.setText(getText());
|
|
|
|
|
|
|
|
|
|
label.setText(name);
|
|
|
|
|
label.setTextColor(fgColor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requestLayout();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
postInvalidate();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setCheckmarkState(CheckmarkState checkmarkState) {
|
|
|
|
|
public void setCheckmarkState(CheckmarkState checkmarkState)
|
|
|
|
|
{
|
|
|
|
|
this.checkmarkState = checkmarkState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected String getText() {
|
|
|
|
|
protected String getText()
|
|
|
|
|
{
|
|
|
|
|
if (isNumerical) {
|
|
|
|
|
return NumberButtonViewKt.toShortString(checkmarkState.getValue() / 1000.0);
|
|
|
|
|
}
|
|
|
|
@ -132,36 +121,36 @@ public class CheckmarkWidgetView extends HabitWidgetView {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setActiveColor(int activeColor) {
|
|
|
|
|
public void setActiveColor(int activeColor)
|
|
|
|
|
{
|
|
|
|
|
this.activeColor = activeColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setName(@NonNull String name) {
|
|
|
|
|
public void setName(@NonNull String name)
|
|
|
|
|
{
|
|
|
|
|
this.name = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setPercentage(float percentage) {
|
|
|
|
|
public void setPercentage(float percentage)
|
|
|
|
|
{
|
|
|
|
|
this.percentage = percentage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setNumerical(boolean isNumerical) {
|
|
|
|
|
public void setNumerical(boolean isNumerical)
|
|
|
|
|
{
|
|
|
|
|
this.isNumerical = isNumerical;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@NonNull
|
|
|
|
|
protected Integer getInnerLayoutId() {
|
|
|
|
|
protected Integer getInnerLayoutId()
|
|
|
|
|
{
|
|
|
|
|
return R.layout.widget_checkmark;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
|
|
|
|
{
|
|
|
|
|
int width = MeasureSpec.getSize(widthMeasureSpec);
|
|
|
|
|
int height = MeasureSpec.getSize(heightMeasureSpec);
|
|
|
|
|
|
|
|
|
@ -194,8 +183,8 @@ public class CheckmarkWidgetView extends HabitWidgetView {
|
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void init() {
|
|
|
|
|
private void init()
|
|
|
|
|
{
|
|
|
|
|
ring = (RingView) findViewById(R.id.scoreRing);
|
|
|
|
|
label = (TextView) findViewById(R.id.label);
|
|
|
|
|
|
|
|
|
|