add hundredths to voice-recorder elapsed-time-display

This commit is contained in:
B. Petersen
2019-01-04 17:06:31 +01:00
parent 5dfc44b1dc
commit d14e59afae
2 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -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"
@@ -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 {