|
80 | 80 | import androidx.annotation.NonNull; |
81 | 81 | import androidx.annotation.Nullable; |
82 | 82 | import androidx.annotation.VisibleForTesting; |
| 83 | +import androidx.core.content.ContextCompat; |
83 | 84 | import androidx.core.graphics.drawable.DrawableCompat; |
84 | 85 | import androidx.core.view.ViewCompat; |
85 | 86 | import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; |
@@ -250,6 +251,7 @@ abstract class BaseOverlaySlider< |
250 | 251 |
|
251 | 252 | @NonNull private final Paint inactiveTrackPaint; |
252 | 253 | @NonNull private final Paint inactiveTrackPaintUnder; |
| 254 | + @NonNull private final Paint inactiveTrackPaintUnderOverlay; |
253 | 255 | @NonNull private final Paint activeTrackPaint; |
254 | 256 | @NonNull private final Paint thumbPaint; |
255 | 257 | @NonNull private final Paint haloPaint; |
@@ -363,8 +365,13 @@ public BaseOverlaySlider( |
363 | 365 | inactiveTrackPaintUnder = new Paint(); |
364 | 366 | inactiveTrackPaintUnder.setStyle(Style.STROKE); |
365 | 367 | inactiveTrackPaintUnder.setStrokeCap(Cap.ROUND); |
366 | | - inactiveTrackPaintUnder.setColor(Color.parseColor("#80FFFFFF")); |
367 | | - inactiveTrackPaintUnder.setXfermode(new PorterDuffXfermode(Mode.OVERLAY)); |
| 368 | + inactiveTrackPaintUnder.setColor(ContextCompat.getColor(context, org.akanework.gramophone.R.color.contrast_colorSecondaryBackOverlayActivated)); |
| 369 | + |
| 370 | + inactiveTrackPaintUnderOverlay = new Paint(); |
| 371 | + inactiveTrackPaintUnderOverlay.setStyle(Style.STROKE); |
| 372 | + inactiveTrackPaintUnderOverlay.setStrokeCap(Cap.ROUND); |
| 373 | + inactiveTrackPaintUnderOverlay.setXfermode(new PorterDuffXfermode(Mode.OVERLAY)); |
| 374 | + inactiveTrackPaintUnderOverlay.setColor(ContextCompat.getColor(context, org.akanework.gramophone.R.color.contrast_colorSecondaryTopOverlayActivated)); |
368 | 375 |
|
369 | 376 | inactiveTrackPaint = new Paint(); |
370 | 377 | inactiveTrackPaint.setStyle(Style.STROKE); |
@@ -1788,9 +1795,11 @@ protected void onDraw(@NonNull Canvas canvas) { |
1788 | 1795 |
|
1789 | 1796 | int yCenter = calculateTrackCenter(); |
1790 | 1797 |
|
| 1798 | + drawBottomTrackOverlay(canvas, trackWidth, yCenter); |
| 1799 | + |
1791 | 1800 | drawBottomTrack(canvas, trackWidth, yCenter); |
1792 | 1801 |
|
1793 | | - drawInactiveTrack(canvas, trackWidth, yCenter); |
| 1802 | + // drawInactiveTrack(canvas, trackWidth, yCenter); |
1794 | 1803 | if (max(getValues()) > valueFrom) { |
1795 | 1804 | drawActiveTrack(canvas, trackWidth, yCenter); |
1796 | 1805 | } |
@@ -1849,6 +1858,16 @@ private void drawBottomTrack(@NonNull Canvas canvas, int width, int yCenter) { |
1849 | 1858 | ); |
1850 | 1859 | } |
1851 | 1860 |
|
| 1861 | + private void drawBottomTrackOverlay(@NonNull Canvas canvas, int width, int yCenter) { |
| 1862 | + canvas.drawLine( |
| 1863 | + trackSidePadding, |
| 1864 | + yCenter, |
| 1865 | + trackSidePadding + width, |
| 1866 | + yCenter, |
| 1867 | + inactiveTrackPaintUnderOverlay |
| 1868 | + ); |
| 1869 | + } |
| 1870 | + |
1852 | 1871 | /** |
1853 | 1872 | * Returns a number between 0 and 1 indicating where on the track this value should sit with 0 |
1854 | 1873 | * being on the far left, and 1 on the far right. |
@@ -2040,6 +2059,11 @@ public void updateBottomTrackColor(int color) { |
2040 | 2059 | postInvalidate(); |
2041 | 2060 | } |
2042 | 2061 |
|
| 2062 | + public void updateBottomTrackOverlayColor(int color) { |
| 2063 | + inactiveTrackPaintUnderOverlay.setColor(color); |
| 2064 | + postInvalidate(); |
| 2065 | + } |
| 2066 | + |
2043 | 2067 | /** |
2044 | 2068 | * Calculates the index the closest tick coordinates that the thumb should snap to. |
2045 | 2069 | * |
@@ -2351,9 +2375,10 @@ private void setValueForLabel(TooltipDrawable label, float value) { |
2351 | 2375 | } |
2352 | 2376 |
|
2353 | 2377 | private void invalidateTrack() { |
2354 | | - inactiveTrackPaint.setStrokeWidth(trackHeight); |
| 2378 | + // inactiveTrackPaint.setStrokeWidth(trackHeight); |
2355 | 2379 | activeTrackPaint.setStrokeWidth(trackHeight); |
2356 | 2380 | inactiveTrackPaintUnder.setStrokeWidth(trackHeight); |
| 2381 | + inactiveTrackPaintUnderOverlay.setStrokeWidth(trackHeight); |
2357 | 2382 | } |
2358 | 2383 |
|
2359 | 2384 | /** |
|
0 commit comments