From d14e59afaef2712dd4768caaaba5c06565bd3519 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 4 Jan 2019 17:06:31 +0100 Subject: [PATCH] add hundredths to voice-recorder elapsed-time-display --- res/layout/conversation_input_panel.xml | 2 +- .../securesms/components/InputPanel.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/res/layout/conversation_input_panel.xml b/res/layout/conversation_input_panel.xml index b7fe3cf10..eac64bf9d 100644 --- a/res/layout/conversation_input_panel.xml +++ b/res/layout/conversation_input_panel.xml @@ -156,7 +156,7 @@ android:layout_height="wrap_content" android:ellipsize="none" style="@style/Signal.Text.Body" - android:text="00:00" + android:text="00:00.00" android:textColor="?conversation_item_outgoing_text_primary_color" android:singleLine="true" android:visibility="gone" diff --git a/src/org/thoughtcrime/securesms/components/InputPanel.java b/src/org/thoughtcrime/securesms/components/InputPanel.java index fbcfec34f..d89430a31 100644 --- a/src/org/thoughtcrime/securesms/components/InputPanel.java +++ b/src/org/thoughtcrime/securesms/components/InputPanel.java @@ -309,6 +309,7 @@ public class InputPanel extends LinearLayout private final TextView recordTimeView; private final AtomicLong startTime = new AtomicLong(0); + private final int UPDATE_EVERY_MS = 137; private RecordTime(TextView recordTimeView) { this.recordTimeView = recordTimeView; @@ -316,9 +317,9 @@ public class InputPanel extends LinearLayout public void display() { this.startTime.set(System.currentTimeMillis()); - this.recordTimeView.setText(DateUtils.formatElapsedTime(0)); + this.recordTimeView.setText(formatElapsedTime(0)); ViewUtil.fadeIn(this.recordTimeView, FADE_TIME); - Util.runOnMainDelayed(this, TimeUnit.SECONDS.toMillis(1)); + Util.runOnMainDelayed(this, UPDATE_EVERY_MS); } public long hide() { @@ -333,10 +334,17 @@ public class InputPanel extends LinearLayout long localStartTime = startTime.get(); if (localStartTime > 0) { long elapsedTime = System.currentTimeMillis() - localStartTime; - recordTimeView.setText(DateUtils.formatElapsedTime(TimeUnit.MILLISECONDS.toSeconds(elapsedTime))); - Util.runOnMainDelayed(this, TimeUnit.SECONDS.toMillis(1)); + recordTimeView.setText(formatElapsedTime(elapsedTime)); + Util.runOnMainDelayed(this, UPDATE_EVERY_MS); } } + + private String formatElapsedTime(long ms) + { + return DateUtils.formatElapsedTime(TimeUnit.MILLISECONDS.toSeconds(ms)) + + String.format(".%02d", ((ms/10)%100)); + + } } public interface MediaListener {