diff --git a/app/src/main/java/com/vincent_falzon/discreetlauncher/ViewClock.java b/app/src/main/java/com/vincent_falzon/discreetlauncher/ViewClock.java index 3b5699d0..67876685 100644 --- a/app/src/main/java/com/vincent_falzon/discreetlauncher/ViewClock.java +++ b/app/src/main/java/com/vincent_falzon/discreetlauncher/ViewClock.java @@ -247,7 +247,7 @@ protected void onDraw(Canvas canvas) while((rect_date.width() > (view_width - 2 * padding)) && (date_text_size_factor > 0)) { // Progressively lower the size of the date text size - date_text_size_factor -= 0.01 ; + date_text_size_factor -= 0.01f ; textClock.setTextSize(time_text_size * date_text_size_factor) ; textClock.getTextBounds(date_text, 0, date_text.length(), rect_date) ; } @@ -265,7 +265,7 @@ protected void onDraw(Canvas canvas) // Draw the time text textClock.setFakeBoldText(false) ; textClock.setTextSize(time_text_size) ; - canvas.drawText(time_text, offset_x, offset_y, textClock) ; + canvas.drawText(time_text, offset_x - rect_time.left, offset_y, textClock) ; rect_time.offset(Math.round(offset_x), Math.round(offset_y)) ; // Define the horizontal offset of the date text @@ -276,7 +276,7 @@ protected void onDraw(Canvas canvas) // Draw the date text textClock.setFakeBoldText(true) ; textClock.setTextSize(time_text_size * date_text_size_factor) ; - canvas.drawText(date_text, offset_x, offset_y + 0.5f * padding + rect_date.height(), textClock) ; + canvas.drawText(date_text, offset_x - rect_date.left, offset_y + 0.5f * padding + rect_date.height(), textClock) ; rect_date.offset(Math.round(offset_x), Math.round(offset_y + 0.5f * padding + rect_date.height())) ; } else if(clock_format.startsWith("date")) @@ -294,7 +294,7 @@ else if(clock_format.startsWith("date")) while((rect_date.width() > (view_width - 2 * padding)) && (date_text_size_factor > 0)) { // Progressively lower the size of the date text size - date_text_size_factor -= 0.01 ; + date_text_size_factor -= 0.01f ; textClock.setTextSize(time_text_size * date_text_size_factor) ; textClock.getTextBounds(date_text, 0, date_text.length(), rect_date) ; } @@ -312,7 +312,7 @@ else if(clock_format.startsWith("date")) // Draw the date text textClock.setFakeBoldText(true) ; textClock.setTextSize(time_text_size * date_text_size_factor) ; - canvas.drawText(date_text, offset_x, offset_y, textClock) ; + canvas.drawText(date_text, offset_x - rect_date.left, offset_y, textClock) ; rect_date.offset(Math.round(offset_x), Math.round(offset_y)) ; } else @@ -342,7 +342,7 @@ else if(clock_format.startsWith("date")) else offset_x = view_width / 2f - rect_time.width() / 2f ; // Draw the time text - canvas.drawText(time_text, offset_x, offset_y, textClock) ; + canvas.drawText(time_text, offset_x - rect_time.left, offset_y, textClock) ; rect_time.offset(Math.round(offset_x), Math.round(offset_y)) ; } }