mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
View tests: create wrapper for getDimension; other fixes
This commit is contained in:
@@ -25,6 +25,7 @@ import android.content.res.*;
|
||||
import android.os.*;
|
||||
import android.support.annotation.*;
|
||||
import android.support.test.*;
|
||||
import android.util.*;
|
||||
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.isoron.uhabits.preferences.*;
|
||||
@@ -78,8 +79,8 @@ public class BaseAndroidTest
|
||||
targetContext = InstrumentationRegistry.getTargetContext();
|
||||
testContext = InstrumentationRegistry.getContext();
|
||||
|
||||
InterfaceUtils.setFixedResolution(2.0f);
|
||||
DateUtils.setFixedLocalTime(FIXED_LOCAL_TIME);
|
||||
setResolution(2.0f);
|
||||
setTheme(R.style.AppBaseTheme);
|
||||
setLocale("en", "US");
|
||||
|
||||
@@ -127,6 +128,14 @@ public class BaseAndroidTest
|
||||
config.setLocale(locale);
|
||||
}
|
||||
|
||||
protected void setResolution(float r)
|
||||
{
|
||||
DisplayMetrics dm = targetContext.getResources().getDisplayMetrics();
|
||||
dm.density = r;
|
||||
dm.scaledDensity = r;
|
||||
InterfaceUtils.setFixedResolution(r);
|
||||
}
|
||||
|
||||
protected void setTheme(@StyleRes int themeId)
|
||||
{
|
||||
targetContext.setTheme(themeId);
|
||||
|
||||
@@ -36,7 +36,7 @@ import static junit.framework.Assert.*;
|
||||
|
||||
public class BaseViewTest extends BaseAndroidTest
|
||||
{
|
||||
double similarityCutoff = 0.0005;
|
||||
double similarityCutoff = 0.00075;
|
||||
|
||||
@Override
|
||||
public void setUp()
|
||||
@@ -48,42 +48,31 @@ public class BaseViewTest extends BaseAndroidTest
|
||||
throws IOException
|
||||
{
|
||||
expectedImagePath = getVersionedPath(expectedImagePath);
|
||||
Bitmap actual = renderView(view);
|
||||
if(actual == null) throw new IllegalStateException("actual is null");
|
||||
|
||||
if (view.isLayoutRequested()) measureView(view, view.getMeasuredWidth(),
|
||||
view.getMeasuredHeight());
|
||||
view.setDrawingCacheEnabled(true);
|
||||
view.buildDrawingCache();
|
||||
|
||||
Bitmap expected = null;
|
||||
Bitmap actual = view.getDrawingCache();
|
||||
try
|
||||
{
|
||||
expected = getBitmapFromAssets(expectedImagePath);
|
||||
Bitmap expected = getBitmapFromAssets(expectedImagePath);
|
||||
double distance = distance(actual, expected);
|
||||
if (distance > similarityCutoff)
|
||||
{
|
||||
saveBitmap(expectedImagePath, ".expected", expected);
|
||||
String path = saveBitmap(expectedImagePath, "", actual);
|
||||
fail(String.format("Image differs from expected " +
|
||||
"(distance=%f). Actual rendered " +
|
||||
"image saved to %s", distance, path));
|
||||
}
|
||||
|
||||
expected.recycle();
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (IOException e)
|
||||
{
|
||||
String path = saveBitmap(expectedImagePath, "", actual);
|
||||
fail(String.format("Could not open expected image. Actual " +
|
||||
"rendered image saved to %s", path));
|
||||
throw e;
|
||||
}
|
||||
|
||||
int width = actual.getWidth();
|
||||
int height = actual.getHeight();
|
||||
Bitmap scaledExpected =
|
||||
Bitmap.createScaledBitmap(expected, width, height, true);
|
||||
|
||||
double distance = distance(actual, scaledExpected);
|
||||
if (distance > similarityCutoff)
|
||||
{
|
||||
saveBitmap(expectedImagePath, ".expected", scaledExpected);
|
||||
String path = saveBitmap(expectedImagePath, "", actual);
|
||||
fail(String.format("Image differs from expected " +
|
||||
"(distance=%f). Actual rendered " +
|
||||
"image saved to %s", distance, path));
|
||||
}
|
||||
|
||||
expected.recycle();
|
||||
scaledExpected.recycle();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -110,8 +99,7 @@ public class BaseViewTest extends BaseAndroidTest
|
||||
int specWidth = makeMeasureSpec((int) width, View.MeasureSpec.EXACTLY);
|
||||
int specHeight = makeMeasureSpec((int) height, View.MeasureSpec.EXACTLY);
|
||||
|
||||
view.setLayoutParams(
|
||||
new ViewGroup.LayoutParams((int) width, (int) height));
|
||||
view.setLayoutParams(new ViewGroup.LayoutParams((int) width, (int) height));
|
||||
view.measure(specWidth, specHeight);
|
||||
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
|
||||
}
|
||||
@@ -198,4 +186,17 @@ public class BaseViewTest extends BaseAndroidTest
|
||||
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
public Bitmap renderView(View view)
|
||||
{
|
||||
int width = view.getMeasuredWidth();
|
||||
int height = view.getMeasuredHeight();
|
||||
if(view.isLayoutRequested())
|
||||
measureView(view, width, height);
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
view.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ import org.isoron.uhabits.models.*;
|
||||
import org.isoron.uhabits.tasks.*;
|
||||
import org.isoron.uhabits.utils.*;
|
||||
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||
|
||||
public class HistoryEditorDialog extends AppCompatDialogFragment
|
||||
implements DialogInterface.OnClickListener, ModelObservable.Listener
|
||||
{
|
||||
@@ -83,7 +85,7 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
|
||||
}
|
||||
|
||||
int padding =
|
||||
(int) getResources().getDimension(R.dimen.history_editor_padding);
|
||||
(int) getDimension(getContext(), R.dimen.history_editor_padding);
|
||||
|
||||
historyChart.setPadding(padding, 0, padding, 0);
|
||||
historyChart.setIsEditable(true);
|
||||
|
||||
@@ -239,7 +239,7 @@ public class BarChart extends ScrollableChart
|
||||
{
|
||||
if (height < 9) height = 200;
|
||||
|
||||
float maxTextSize = getResources().getDimension(R.dimen.tinyTextSize);
|
||||
float maxTextSize = getDimension(getContext(), R.dimen.tinyTextSize);
|
||||
float textSize = height * 0.06f;
|
||||
pText.setTextSize(Math.min(textSize, maxTextSize));
|
||||
em = pText.getFontSpacing();
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
import static org.isoron.uhabits.models.Checkmark.*;
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||
|
||||
public class HistoryChart extends ScrollableChart
|
||||
{
|
||||
@@ -251,9 +252,8 @@ public class HistoryChart extends ScrollableChart
|
||||
float baseSize = height / 8.0f;
|
||||
setScrollerBucketSize((int) baseSize);
|
||||
|
||||
squareSpacing = InterfaceUtils.dpToPixels(getContext(), 1.0f);
|
||||
float maxTextSize =
|
||||
getResources().getDimension(R.dimen.regularTextSize);
|
||||
squareSpacing = dpToPixels(getContext(), 1.0f);
|
||||
float maxTextSize = getDimension(getContext(), R.dimen.regularTextSize);
|
||||
float textSize = height * 0.06f;
|
||||
textSize = Math.min(textSize, maxTextSize);
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class RingView extends View
|
||||
color = ColorUtils.getAndroidTestColor(0);
|
||||
thickness = dpToPixels(getContext(), 2);
|
||||
text = "";
|
||||
textSize = context.getResources().getDimension(R.dimen.smallTextSize);
|
||||
textSize = getDimension(context, R.dimen.smallTextSize);
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -98,14 +98,13 @@ public class RingView extends View
|
||||
thickness = getFloatAttribute(ctx, attrs, "thickness", 0);
|
||||
thickness = dpToPixels(ctx, thickness);
|
||||
|
||||
float defaultTextSize =
|
||||
ctx.getResources().getDimension(R.dimen.smallTextSize);
|
||||
float defaultTextSize = getDimension(ctx, R.dimen.smallTextSize);
|
||||
textSize = getFloatAttribute(ctx, attrs, "textSize", defaultTextSize);
|
||||
textSize = spToPixels(ctx, textSize);
|
||||
text = AttributeSetUtils.getAttribute(ctx, attrs, "text", "");
|
||||
text = getAttribute(ctx, attrs, "text", "");
|
||||
|
||||
enableFontAwesome = AttributeSetUtils.getBooleanAttribute(ctx, attrs,
|
||||
"enableFontAwesome", false);
|
||||
enableFontAwesome =
|
||||
getBooleanAttribute(ctx, attrs, "enableFontAwesome", false);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ public class ScoreChart extends ScrollableChart
|
||||
{
|
||||
if (height < 9) height = 200;
|
||||
|
||||
float maxTextSize = getResources().getDimension(R.dimen.tinyTextSize);
|
||||
float maxTextSize = getDimension(getContext(), R.dimen.tinyTextSize);
|
||||
float textSize = height * 0.06f;
|
||||
pText.setTextSize(Math.min(textSize, maxTextSize));
|
||||
em = pText.getFontSpacing();
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
import static android.view.View.MeasureSpec.*;
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.getDimension;
|
||||
|
||||
public class StreakChart extends View
|
||||
{
|
||||
@@ -170,9 +171,9 @@ public class StreakChart extends View
|
||||
{
|
||||
this.width = width;
|
||||
|
||||
float minTextSize = getResources().getDimension(R.dimen.tinyTextSize);
|
||||
float maxTextSize =
|
||||
getResources().getDimension(R.dimen.regularTextSize);
|
||||
Context context = getContext();
|
||||
float minTextSize = getDimension(context, R.dimen.tinyTextSize);
|
||||
float maxTextSize = getDimension(context, R.dimen.regularTextSize);
|
||||
float textSize = baseSize * 0.5f;
|
||||
|
||||
paint.setTextSize(
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.isoron.uhabits.activities.habits.list;
|
||||
|
||||
import android.content.*;
|
||||
import android.content.res.*;
|
||||
import android.support.annotation.*;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.*;
|
||||
@@ -40,6 +39,8 @@ import javax.inject.*;
|
||||
|
||||
import butterknife.*;
|
||||
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||
|
||||
@ActivityScope
|
||||
public class ListHabitsRootView extends BaseRootView
|
||||
implements ModelObservable.Listener, TaskRunner.Listener
|
||||
@@ -171,9 +172,9 @@ public class ListHabitsRootView extends BaseRootView
|
||||
|
||||
private int getCheckmarkCount()
|
||||
{
|
||||
Resources res = getResources();
|
||||
float labelWidth = Math.max(getMeasuredWidth() / 3, res.getDimension(R.dimen.habitNameWidth));
|
||||
float buttonWidth = res.getDimension(R.dimen.checkmarkWidth);
|
||||
float nameWidth = getDimension(getContext(), R.dimen.habitNameWidth);
|
||||
float labelWidth = Math.max(getMeasuredWidth() / 3, nameWidth);
|
||||
float buttonWidth = getDimension(getContext(), R.dimen.checkmarkWidth);
|
||||
return Math.min(MAX_CHECKMARK_COUNT, Math.max(0,
|
||||
(int) ((getMeasuredWidth() - labelWidth) / buttonWidth)));
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ import org.isoron.uhabits.utils.*;
|
||||
import static android.view.View.MeasureSpec.*;
|
||||
import static org.isoron.uhabits.models.Checkmark.*;
|
||||
import static org.isoron.uhabits.utils.AttributeSetUtils.*;
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.getDimension;
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.getFontAwesome;
|
||||
|
||||
public class CheckmarkButtonView extends View
|
||||
{
|
||||
@@ -128,14 +130,13 @@ public class CheckmarkButtonView extends View
|
||||
{
|
||||
setFocusable(false);
|
||||
|
||||
Resources res = getResources();
|
||||
styledRes = new StyledResources(getContext());
|
||||
|
||||
paint = new TextPaint();
|
||||
paint.setTypeface(InterfaceUtils.getFontAwesome(getContext()));
|
||||
paint.setTypeface(getFontAwesome(getContext()));
|
||||
paint.setAntiAlias(true);
|
||||
paint.setTextAlign(Paint.Align.CENTER);
|
||||
paint.setTextSize(res.getDimension(R.dimen.smallTextSize));
|
||||
paint.setTextSize(getDimension(getContext(), R.dimen.smallTextSize));
|
||||
|
||||
rect = new RectF();
|
||||
color = Color.BLACK;
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.*;
|
||||
import static android.view.View.MeasureSpec.*;
|
||||
import static org.isoron.uhabits.utils.AttributeSetUtils.*;
|
||||
import static org.isoron.uhabits.utils.ColorUtils.*;
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.getDimension;
|
||||
|
||||
public class CheckmarkPanelView extends LinearLayout
|
||||
implements Preferences.Listener
|
||||
@@ -154,9 +155,8 @@ public class CheckmarkPanelView extends LinearLayout
|
||||
@Override
|
||||
protected void onMeasure(int widthSpec, int heightSpec)
|
||||
{
|
||||
float buttonWidth = getResources().getDimension(R.dimen.checkmarkWidth);
|
||||
float buttonHeight =
|
||||
getResources().getDimension(R.dimen.checkmarkHeight);
|
||||
float buttonWidth = getDimension(getContext(), R.dimen.checkmarkWidth);
|
||||
float buttonHeight = getDimension(getContext(), R.dimen.checkmarkHeight);
|
||||
|
||||
float width = buttonWidth * nButtons;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.isoron.uhabits.activities.habits.list.views;
|
||||
|
||||
import android.content.*;
|
||||
import android.content.res.*;
|
||||
import android.graphics.*;
|
||||
import android.support.annotation.*;
|
||||
import android.text.*;
|
||||
@@ -34,6 +33,8 @@ import org.isoron.uhabits.utils.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||
|
||||
public class HeaderView extends ScrollableChart
|
||||
implements Preferences.Listener, MidnightTimer.MidnightListener
|
||||
{
|
||||
@@ -123,9 +124,8 @@ public class HeaderView extends ScrollableChart
|
||||
super.onDraw(canvas);
|
||||
|
||||
GregorianCalendar day = DateUtils.getStartOfTodayCalendar();
|
||||
Resources res = getContext().getResources();
|
||||
float width = res.getDimension(R.dimen.checkmarkWidth);
|
||||
float height = res.getDimension(R.dimen.checkmarkHeight);
|
||||
float width = getDimension(getContext(), R.dimen.checkmarkWidth);
|
||||
float height = getDimension(getContext(), R.dimen.checkmarkHeight);
|
||||
boolean reverse = shouldReverseCheckmarks();
|
||||
boolean isRtl = InterfaceUtils.isLayoutRtl(this);
|
||||
|
||||
@@ -159,22 +159,20 @@ public class HeaderView extends ScrollableChart
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
||||
{
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int height = (int) getContext()
|
||||
.getResources()
|
||||
.getDimension(R.dimen.checkmarkHeight);
|
||||
int height = (int) getDimension(getContext(), R.dimen.checkmarkHeight);
|
||||
setMeasuredDimension(width, height);
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
Resources res = getContext().getResources();
|
||||
setScrollerBucketSize((int) res.getDimension(R.dimen.checkmarkWidth));
|
||||
setScrollerBucketSize(
|
||||
(int) getDimension(getContext(), R.dimen.checkmarkWidth));
|
||||
|
||||
StyledResources sr = new StyledResources(getContext());
|
||||
paint = new TextPaint();
|
||||
paint.setColor(Color.BLACK);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setTextSize(getResources().getDimension(R.dimen.tinyTextSize));
|
||||
paint.setTextSize(getDimension(getContext(), R.dimen.tinyTextSize));
|
||||
paint.setTextAlign(Paint.Align.CENTER);
|
||||
paint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
paint.setColor(sr.getColor(R.attr.mediumContrastTextColor));
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.isoron.uhabits.activities.habits.list.views;
|
||||
|
||||
import android.content.*;
|
||||
import android.content.res.*;
|
||||
import android.graphics.*;
|
||||
import android.support.annotation.*;
|
||||
import android.text.*;
|
||||
@@ -35,6 +34,7 @@ import java.text.*;
|
||||
|
||||
import static org.isoron.uhabits.utils.AttributeSetUtils.*;
|
||||
import static org.isoron.uhabits.utils.ColorUtils.*;
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||
|
||||
public class NumberButtonView extends View
|
||||
{
|
||||
@@ -56,8 +56,6 @@ public class NumberButtonView extends View
|
||||
|
||||
private TextPaint pRegular;
|
||||
|
||||
private Resources res;
|
||||
|
||||
private TextPaint pBold;
|
||||
|
||||
private int lightGrey;
|
||||
@@ -164,25 +162,25 @@ public class NumberButtonView extends View
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
||||
{
|
||||
int width = (int) res.getDimension(R.dimen.checkmarkWidth);
|
||||
int height = (int) res.getDimension(R.dimen.checkmarkHeight);
|
||||
int width = (int) getDimension(getContext(), R.dimen.checkmarkWidth);
|
||||
int height = (int) getDimension(getContext(), R.dimen.checkmarkHeight);
|
||||
setMeasuredDimension(width, height);
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
StyledResources sr = new StyledResources(getContext());
|
||||
res = getContext().getResources();
|
||||
|
||||
rect = new RectF();
|
||||
pRegular = new TextPaint();
|
||||
pRegular.setTextSize(res.getDimension(R.dimen.smallerTextSize));
|
||||
pRegular.setTextSize(
|
||||
getDimension(getContext(), R.dimen.smallerTextSize));
|
||||
pRegular.setTypeface(NORMAL_TYPEFACE);
|
||||
pRegular.setAntiAlias(true);
|
||||
pRegular.setTextAlign(Paint.Align.CENTER);
|
||||
|
||||
pBold = new TextPaint();
|
||||
pBold.setTextSize(res.getDimension(R.dimen.smallTextSize));
|
||||
pBold.setTextSize(getDimension(getContext(), R.dimen.smallTextSize));
|
||||
pBold.setTypeface(BOLD_TYPEFACE);
|
||||
pBold.setAntiAlias(true);
|
||||
pBold.setTextAlign(Paint.Align.CENTER);
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.util.*;
|
||||
import static android.view.View.MeasureSpec.*;
|
||||
import static org.isoron.uhabits.utils.AttributeSetUtils.*;
|
||||
import static org.isoron.uhabits.utils.ColorUtils.*;
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.*;
|
||||
|
||||
public class NumberPanelView extends LinearLayout
|
||||
implements Preferences.Listener
|
||||
@@ -178,9 +179,9 @@ public class NumberPanelView extends LinearLayout
|
||||
@Override
|
||||
protected void onMeasure(int widthSpec, int heightSpec)
|
||||
{
|
||||
float buttonWidth = getResources().getDimension(R.dimen.checkmarkWidth);
|
||||
float buttonHeight =
|
||||
getResources().getDimension(R.dimen.checkmarkHeight);
|
||||
Context context = getContext();
|
||||
float buttonWidth = getDimension(context, R.dimen.checkmarkWidth);
|
||||
float buttonHeight = getDimension(context, R.dimen.checkmarkHeight);
|
||||
|
||||
float width = buttonWidth * nButtons;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class InterfaceUtils
|
||||
@Nullable
|
||||
private static Float fixedResolution = null;
|
||||
|
||||
public static void setFixedResolution(@Nullable Float f)
|
||||
public static void setFixedResolution(@NonNull Float f)
|
||||
{
|
||||
fixedResolution = f;
|
||||
}
|
||||
@@ -67,6 +67,18 @@ public abstract class InterfaceUtils
|
||||
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, metrics);
|
||||
}
|
||||
|
||||
public static float getDimension(Context context, int id)
|
||||
{
|
||||
float dim = context.getResources().getDimension(id);
|
||||
if (fixedResolution == null) return dim;
|
||||
else
|
||||
{
|
||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
float actualDensity = dm.density;
|
||||
return dim / actualDensity * fixedResolution;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupEditorAction(@NonNull ViewGroup parent,
|
||||
@NonNull TextView.OnEditorActionListener listener)
|
||||
{
|
||||
|
||||
@@ -149,14 +149,13 @@ public abstract class BaseWidget
|
||||
private Bitmap getBitmapFromView(View view)
|
||||
{
|
||||
view.invalidate();
|
||||
view.setDrawingCacheEnabled(true);
|
||||
view.buildDrawingCache(true);
|
||||
Bitmap drawingCache = view.getDrawingCache();
|
||||
int width = view.getMeasuredWidth();
|
||||
int height = view.getMeasuredHeight();
|
||||
|
||||
if(drawingCache == null)
|
||||
throw new IllegalStateException("bitmap is null");
|
||||
|
||||
return drawingCache;
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
view.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -29,6 +29,8 @@ import org.isoron.uhabits.models.*;
|
||||
import org.isoron.uhabits.activities.common.views.*;
|
||||
import org.isoron.uhabits.utils.*;
|
||||
|
||||
import static org.isoron.uhabits.utils.InterfaceUtils.getDimension;
|
||||
|
||||
public class CheckmarkWidgetView extends HabitWidgetView
|
||||
{
|
||||
private int activeColor;
|
||||
@@ -154,9 +156,10 @@ public class CheckmarkWidgetView extends HabitWidgetView
|
||||
w *= scale;
|
||||
h *= scale;
|
||||
|
||||
if (h < getResources().getDimension(
|
||||
R.dimen.checkmarkWidget_heightBreakpoint)) ring.setVisibility(GONE);
|
||||
else ring.setVisibility(VISIBLE);
|
||||
if (h < getDimension(getContext(), R.dimen.checkmarkWidget_heightBreakpoint))
|
||||
ring.setVisibility(GONE);
|
||||
else
|
||||
ring.setVisibility(VISIBLE);
|
||||
|
||||
widthMeasureSpec =
|
||||
MeasureSpec.makeMeasureSpec((int) w, MeasureSpec.EXACTLY);
|
||||
@@ -164,8 +167,7 @@ public class CheckmarkWidgetView extends HabitWidgetView
|
||||
MeasureSpec.makeMeasureSpec((int) h, MeasureSpec.EXACTLY);
|
||||
|
||||
float textSize = 0.15f * h;
|
||||
float maxTextSize =
|
||||
getResources().getDimension(R.dimen.smallerTextSize);
|
||||
float maxTextSize = getDimension(getContext(), R.dimen.smallerTextSize);
|
||||
textSize = Math.min(textSize, maxTextSize);
|
||||
|
||||
label.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
||||
|
||||
Reference in New Issue
Block a user