A fork of Simple Time Tracker with WearOS support. (Now integrated upstream)
0

Configure Feed

Select the types of activity you want to include in your feed.

add duration view padding and legend color

razeeman (Jan 16, 2021, 4:50 PM +0300) 7ae6a392 6609ddfd

+33 -8
+9
core/src/main/res/drawable/backspace.xml
··· 1 + <vector xmlns:android="http://schemas.android.com/apk/res/android" 2 + android:width="24dp" 3 + android:height="24dp" 4 + android:viewportWidth="24" 5 + android:viewportHeight="24"> 6 + <path 7 + android:fillColor="#FF000000" 8 + android:pathData="M22,3L7,3c-0.69,0 -1.23,0.35 -1.59,0.88L0,12l5.41,8.11c0.36,0.53 0.9,0.89 1.59,0.89h15c1.1,0 2,-0.9 2,-2L24,5c0,-1.1 -0.9,-2 -2,-2zM19,15.59L17.59,17 14,13.41 10.41,17 9,15.59 12.59,12 9,8.41 10.41,7 14,10.59 17.59,7 19,8.41 15.41,12 19,15.59z"/> 9 + </vector>
+3 -1
feature_dialogs/src/main/res/layout/duration_dialog_fragment.xml
··· 23 23 android:layout_marginStart="8dp" 24 24 android:layout_marginEnd="16dp" 25 25 app:durationLegendTextSize="32sp" 26 + app:durationLegendTextColor="?appTextHintColor" 27 + app:durationLegendPadding="16dp" 26 28 app:durationTextColor="?appTextPrimaryColor" 27 29 app:layout_constraintBottom_toTopOf="@id/guidelineDurationPicker" 28 30 app:layout_constraintEnd_toStartOf="@id/ivDurationPickerDelete" ··· 35 37 android:layout_height="32dp" 36 38 android:layout_marginEnd="16dp" 37 39 android:background="?selectableItemBackgroundBorderless" 38 - android:src="@drawable/delete" 40 + android:src="@drawable/backspace" 39 41 android:tint="?appTextPrimaryColor" 40 42 app:layout_constraintBottom_toBottomOf="@id/viewDurationPickerValue" 41 43 app:layout_constraintEnd_toEndOf="parent"
+2
feature_dialogs/src/main/res/values/attrs.xml
··· 2 2 <resources> 3 3 <declare-styleable name="DurationView"> 4 4 <attr name="durationTextColor" format="color" /> 5 + <attr name="durationLegendTextColor" format="color" /> 5 6 <attr name="durationLegendTextSize" format="dimension" /> 7 + <attr name="durationLegendPadding" format="dimension" /> 6 8 </declare-styleable> 7 9 8 10 <declare-styleable name="NumberKeyboardView">
+19 -7
feature_dialogs/src/main/java/com/example/util/simpletimetracker/feature_dialogs/duration/customView/DurationView.kt
··· 22 22 23 23 // Attrs 24 24 private var textColor: Int = 0 25 + private var legendTextColor: Int = 0 26 + private var legendTextSize: Float = 0f 27 + private var legendPadding: Float = 0f 25 28 // End of attrs 26 29 27 30 private var data: ViewData = ViewData() 28 31 private val textPaint: Paint = Paint() 29 32 private val legendTextPaint: Paint = Paint() 30 - private var legendTextSize: Float = 0f 31 33 private var textStartHorizontal: Float = 0f 32 34 private var textStartVertical: Float = 0f 33 35 private val bounds: Rect = Rect() ··· 73 75 textColor = getColor( 74 76 R.styleable.DurationView_durationTextColor, Color.BLACK 75 77 ) 78 + legendTextColor = getColor( 79 + R.styleable.DurationView_durationLegendTextColor, Color.BLACK 80 + ) 76 81 legendTextSize = getDimensionPixelSize( 77 82 R.styleable.DurationView_durationLegendTextSize, 14 83 + ).toFloat() 84 + legendPadding = getDimensionPixelSize( 85 + R.styleable.DurationView_durationLegendPadding, 0 78 86 ).toFloat() 79 87 80 88 recycle() ··· 88 96 } 89 97 legendTextPaint.apply { 90 98 isAntiAlias = true 91 - color = textColor 99 + color = legendTextColor 92 100 textSize = legendTextSize 93 101 } 94 102 } 95 103 96 104 private fun calculateDimensions(w: Float, h: Float) { 97 - val legendsTextWidth = listOf("h", "m", "s").map(legendTextPaint::measureText).sum() 98 - val desiredSegmentWidth = min((w - legendsTextWidth) / 3, h) 99 - textStartHorizontal = (w - desiredSegmentWidth * 3 - legendsTextWidth) / 2 105 + val legendsTextWidth = 106 + listOf("h", "m", "s").map(legendTextPaint::measureText).sum() 107 + val desiredSegmentWidth = 108 + min((w - legendsTextWidth - 2 * legendPadding) / 3, h) 109 + textStartHorizontal = 110 + (w - desiredSegmentWidth * 3 - legendsTextWidth - 2 * legendPadding) / 2 111 + 100 112 setTextSizeForWidth(textPaint, desiredSegmentWidth) 101 113 textPaint.getTextBounds("0", 0, 1, bounds) 102 114 val textHeight = bounds.height() ··· 113 125 canvas.drawText(format(data.hours), 0f, 0f, textPaint) 114 126 canvas.translate(textPaint.measureText(text), 0f) 115 127 canvas.drawText("h", 0f, 0f, legendTextPaint) 116 - canvas.translate(legendTextPaint.measureText("h"), 0f) 128 + canvas.translate(legendTextPaint.measureText("h") + legendPadding, 0f) 117 129 118 130 text = format(data.minutes) 119 131 canvas.drawText(format(data.minutes), 0f, 0f, textPaint) 120 132 canvas.translate(textPaint.measureText(text), 0f) 121 133 canvas.drawText("m", 0f, 0f, legendTextPaint) 122 - canvas.translate(legendTextPaint.measureText("m"), 0f) 134 + canvas.translate(legendTextPaint.measureText("m") + legendPadding, 0f) 123 135 124 136 text = format(data.hours) 125 137 canvas.drawText(format(data.seconds), 0f, 0f, textPaint)