mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Small tweaks to CheckmarkWidget padding and aspect ratio
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 20 KiB |
@@ -39,6 +39,7 @@ import org.isoron.uhabits.utils.PaletteUtils.getAndroidTestColor
|
||||
import org.isoron.uhabits.utils.StyledResources
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class CheckmarkWidgetView : HabitWidgetView {
|
||||
var activeColor: Int = 0
|
||||
@@ -118,19 +119,25 @@ class CheckmarkWidgetView : HabitWidgetView {
|
||||
get() = R.layout.widget_checkmark
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
val width = MeasureSpec.getSize(widthMeasureSpec)
|
||||
val height = MeasureSpec.getSize(heightMeasureSpec)
|
||||
var textSize = 0.15f * height
|
||||
val maxTextSize = getDimension(context, R.dimen.smallerTextSize)
|
||||
textSize = min(textSize, maxTextSize)
|
||||
var width = MeasureSpec.getSize(widthMeasureSpec)
|
||||
var height = MeasureSpec.getSize(heightMeasureSpec)
|
||||
if (height >= width) {
|
||||
height = min(height, (width * 1.5).roundToInt())
|
||||
} else {
|
||||
width = min(width, height)
|
||||
}
|
||||
val textSize = min(0.2f * width, getDimension(context, R.dimen.smallerTextSize))
|
||||
label.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||
if (isNumerical) {
|
||||
ring.setTextSize(textSize * 0.75f)
|
||||
ring.setTextSize(textSize * 0.9f)
|
||||
} else {
|
||||
ring.setTextSize(textSize)
|
||||
}
|
||||
ring.setThickness(0.15f * textSize)
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
ring.setThickness(0.03f * width)
|
||||
super.onMeasure(
|
||||
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)
|
||||
)
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
|
||||
@@ -31,19 +31,19 @@
|
||||
android:id="@+id/scoreRing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="0.9"
|
||||
habit:thickness="2"
|
||||
habit:textSize="16"
|
||||
habit:enableFontAwesome="true"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp"/>
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:layout_weight="0.1"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/white"
|
||||
android:layout_marginLeft="6dp"
|
||||
|
||||
Reference in New Issue
Block a user