mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 22:08:49 +00:00
TripsGallery: Make current time label easier to read.
This commit is contained in:
parent
6320480304
commit
f4f902af6b
1 changed files with 14 additions and 8 deletions
|
@ -27,6 +27,7 @@ import android.graphics.Paint.Align;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
@ -53,7 +54,8 @@ 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 int paddingHorizontal, paddingHorizontalCram;
|
||||||
|
private final int currentTimeLabelPaddingHorizontal, currentTimeLabelPaddingVertical;
|
||||||
private final float density;
|
private final float density;
|
||||||
private final java.text.DateFormat timeFormat;
|
private final java.text.DateFormat timeFormat;
|
||||||
|
|
||||||
|
@ -76,6 +78,9 @@ public class TripsGallery extends Gallery {
|
||||||
|
|
||||||
final Resources res = getResources();
|
final Resources res = getResources();
|
||||||
paddingHorizontal = res.getDimensionPixelSize(R.dimen.text_padding_horizontal);
|
paddingHorizontal = res.getDimensionPixelSize(R.dimen.text_padding_horizontal);
|
||||||
|
paddingHorizontalCram = res.getDimensionPixelSize(R.dimen.text_padding_horizontal_cram);
|
||||||
|
currentTimeLabelPaddingHorizontal = res.getDimensionPixelSize(R.dimen.text_padding_horizontal);
|
||||||
|
currentTimeLabelPaddingVertical = res.getDimensionPixelSize(R.dimen.text_padding_vertical);
|
||||||
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);
|
||||||
|
@ -104,7 +109,8 @@ public class TripsGallery extends Gallery {
|
||||||
|
|
||||||
currenttimeLabelTextPaint.setColor(Color.BLACK);
|
currenttimeLabelTextPaint.setColor(Color.BLACK);
|
||||||
currenttimeLabelTextPaint.setAntiAlias(true);
|
currenttimeLabelTextPaint.setAntiAlias(true);
|
||||||
currenttimeLabelTextPaint.setTextSize(res.getDimension(R.dimen.font_size_small));
|
currenttimeLabelTextPaint.setTextSize(res.getDimension(R.dimen.font_size_normal));
|
||||||
|
currenttimeLabelTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
currenttimeLabelTextPaint.setTextAlign(Align.CENTER);
|
currenttimeLabelTextPaint.setTextAlign(Align.CENTER);
|
||||||
|
|
||||||
timeFormat = DateFormat.getTimeFormat(context);
|
timeFormat = DateFormat.getTimeFormat(context);
|
||||||
|
@ -319,15 +325,15 @@ public class TripsGallery extends Gallery {
|
||||||
final String label = timeFormat.format(now);
|
final String label = timeFormat.format(now);
|
||||||
|
|
||||||
currenttimeLabelTextPaint.getTextBounds(label, 0, label.length(), bounds);
|
currenttimeLabelTextPaint.getTextBounds(label, 0, label.length(), bounds);
|
||||||
final int inset = Math.round(2 * density);
|
bounds.inset(-currentTimeLabelPaddingHorizontal, -currentTimeLabelPaddingVertical);
|
||||||
bounds.inset(-inset, -inset);
|
bounds.offsetTo(paddingHorizontalCram, Math.round(y) - bounds.height());
|
||||||
bounds.offsetTo(paddingHorizontal, Math.round(y) - bounds.height());
|
|
||||||
|
|
||||||
canvas.drawLine(bounds.right + paddingHorizontal, y, width, y, currenttimePaint);
|
canvas.drawLine(bounds.right + paddingHorizontalCram, y, width, y, currenttimePaint);
|
||||||
final float roundRadius = 3 * density;
|
final float roundRadius = Math.min(currentTimeLabelPaddingHorizontal, currentTimeLabelPaddingVertical);
|
||||||
boundsF.set(bounds);
|
boundsF.set(bounds);
|
||||||
canvas.drawRoundRect(boundsF, roundRadius, roundRadius, currenttimeLabelBackgroundPaint);
|
canvas.drawRoundRect(boundsF, roundRadius, roundRadius, currenttimeLabelBackgroundPaint);
|
||||||
canvas.drawText(label, bounds.centerX(), bounds.bottom - inset, currenttimeLabelTextPaint);
|
canvas.drawText(label, bounds.centerX(), bounds.bottom - currentTimeLabelPaddingVertical,
|
||||||
|
currenttimeLabelTextPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnScrollListener {
|
public interface OnScrollListener {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue