mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
add hundredths to voice-recorder elapsed-time-display
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user