mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 06:08:51 +00:00
TripsGallery: Add horizontal padding to the time labels of the grid.
This commit is contained in:
parent
68726e3b3a
commit
9a5408b468
1 changed files with 7 additions and 5 deletions
|
@ -53,6 +53,7 @@ public class TripsGallery extends Gallery {
|
||||||
private final Paint currenttimeLabelTextPaint = new Paint();
|
private final Paint currenttimeLabelTextPaint = new Paint();
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
private final int paddingHorizontal;
|
||||||
private final float density;
|
private final float density;
|
||||||
private final java.text.DateFormat timeFormat;
|
private final java.text.DateFormat timeFormat;
|
||||||
|
|
||||||
|
@ -74,6 +75,7 @@ public class TripsGallery extends Gallery {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
|
paddingHorizontal = res.getDimensionPixelSize(R.dimen.list_entry_padding_horizontal);
|
||||||
density = res.getDisplayMetrics().density;
|
density = res.getDisplayMetrics().density;
|
||||||
final float strokeWidth = res.getDimension(R.dimen.trips_overview_stroke_width);
|
final float strokeWidth = res.getDimension(R.dimen.trips_overview_stroke_width);
|
||||||
final int colorSignificant = res.getColor(R.color.fg_significant);
|
final int colorSignificant = res.getColor(R.color.fg_significant);
|
||||||
|
@ -285,10 +287,10 @@ public class TripsGallery extends Gallery {
|
||||||
}
|
}
|
||||||
|
|
||||||
gridLabelPaint.getTextBounds(labelTime.toString(), 0, labelTime.length(), bounds);
|
gridLabelPaint.getTextBounds(labelTime.toString(), 0, labelTime.length(), bounds);
|
||||||
bounds.offsetTo(0, Math.round(y) - bounds.height());
|
bounds.offsetTo(paddingHorizontal, Math.round(y) - bounds.height());
|
||||||
|
|
||||||
path.reset();
|
path.reset();
|
||||||
path.moveTo(bounds.right, y);
|
path.moveTo(bounds.right + paddingHorizontal, y);
|
||||||
path.lineTo(width, y);
|
path.lineTo(width, y);
|
||||||
// can't use drawLine here because of
|
// can't use drawLine here because of
|
||||||
// https://code.google.com/p/android/issues/detail?id=29944
|
// https://code.google.com/p/android/issues/detail?id=29944
|
||||||
|
@ -306,7 +308,7 @@ public class TripsGallery extends Gallery {
|
||||||
.append(Formats.formatDate(context, now, firstGrid));
|
.append(Formats.formatDate(context, now, firstGrid));
|
||||||
|
|
||||||
gridLabelPaint.getTextBounds(labelTime.toString(), 0, labelTime.length(), bounds);
|
gridLabelPaint.getTextBounds(labelTime.toString(), 0, labelTime.length(), bounds);
|
||||||
bounds.offsetTo(0, Math.round(adapter.timeToCoord(firstGrid, height)) - bounds.height());
|
bounds.offsetTo(paddingHorizontal, Math.round(adapter.timeToCoord(firstGrid, height)) - bounds.height());
|
||||||
|
|
||||||
canvas.drawText(labelTime, 0, labelTime.length(), bounds.centerX(), bounds.bottom, gridLabelPaint);
|
canvas.drawText(labelTime, 0, labelTime.length(), bounds.centerX(), bounds.bottom, gridLabelPaint);
|
||||||
}
|
}
|
||||||
|
@ -319,9 +321,9 @@ public class TripsGallery extends Gallery {
|
||||||
currenttimeLabelTextPaint.getTextBounds(label, 0, label.length(), bounds);
|
currenttimeLabelTextPaint.getTextBounds(label, 0, label.length(), bounds);
|
||||||
final int inset = Math.round(2 * density);
|
final int inset = Math.round(2 * density);
|
||||||
bounds.inset(-inset, -inset);
|
bounds.inset(-inset, -inset);
|
||||||
bounds.offsetTo(0, Math.round(y) - bounds.height());
|
bounds.offsetTo(paddingHorizontal, Math.round(y) - bounds.height());
|
||||||
|
|
||||||
canvas.drawLine(bounds.right, y, width, y, currenttimePaint);
|
canvas.drawLine(bounds.right + paddingHorizontal, y, width, y, currenttimePaint);
|
||||||
final float roundRadius = 3 * density;
|
final float roundRadius = 3 * density;
|
||||||
boundsF.set(bounds);
|
boundsF.set(bounds);
|
||||||
canvas.drawRoundRect(boundsF, roundRadius, roundRadius, currenttimeLabelBackgroundPaint);
|
canvas.drawRoundRect(boundsF, roundRadius, roundRadius, currenttimeLabelBackgroundPaint);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue