mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Allow checkmark widget to be resized to very small sizes
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.Context;
|
|||||||
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;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
@@ -40,7 +41,6 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|||||||
@Nullable
|
@Nullable
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private RingView ring;
|
private RingView ring;
|
||||||
private TextView label;
|
private TextView label;
|
||||||
private int checkmarkValue;
|
private int checkmarkValue;
|
||||||
@@ -147,8 +147,22 @@ public class CheckmarkWidgetView extends HabitWidgetView implements HabitDataVie
|
|||||||
w *= scale;
|
w *= scale;
|
||||||
h *= scale;
|
h *= scale;
|
||||||
|
|
||||||
|
if(h < getResources().getDimension(R.dimen.checkmarkWidget_heightBreakpoint))
|
||||||
|
ring.setVisibility(GONE);
|
||||||
|
else
|
||||||
|
ring.setVisibility(VISIBLE);
|
||||||
|
|
||||||
widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) w, MeasureSpec.EXACTLY);
|
widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) w, MeasureSpec.EXACTLY);
|
||||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) h, MeasureSpec.EXACTLY);
|
heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) h, MeasureSpec.EXACTLY);
|
||||||
|
|
||||||
|
float textSize = 0.15f * h;
|
||||||
|
float maxTextSize = getResources().getDimension(R.dimen.smallerTextSize);
|
||||||
|
textSize = Math.min(textSize, maxTextSize);
|
||||||
|
|
||||||
|
label.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
||||||
|
ring.setTextSize(textSize);
|
||||||
|
ring.setThickness(0.15f * textSize);
|
||||||
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,11 @@ public class RingView extends View
|
|||||||
postInvalidate();
|
postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTextSize(float textSize)
|
||||||
|
{
|
||||||
|
this.textSize = textSize;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBackgroundColor(int backgroundColor)
|
public void setBackgroundColor(int backgroundColor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,9 @@
|
|||||||
<dimen name="history_max_font_size">@dimen/regularTextSize</dimen>
|
<dimen name="history_max_font_size">@dimen/regularTextSize</dimen>
|
||||||
<dimen name="regularTextSize">16sp</dimen>
|
<dimen name="regularTextSize">16sp</dimen>
|
||||||
<dimen name="smallTextSize">14sp</dimen>
|
<dimen name="smallTextSize">14sp</dimen>
|
||||||
|
<dimen name="smallerTextSize">12sp</dimen>
|
||||||
<dimen name="tinyTextSize">10sp</dimen>
|
<dimen name="tinyTextSize">10sp</dimen>
|
||||||
<dimen name="habitNameWidth">160dp</dimen>
|
<dimen name="habitNameWidth">160dp</dimen>
|
||||||
<dimen name="progressbarOffset">-10dp</dimen>
|
<dimen name="progressbarOffset">-10dp</dimen>
|
||||||
|
<dimen name="checkmarkWidget_heightBreakpoint">55dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user