Add red flashing voice note microphone.
This commit is contained in:
parent
652306edd0
commit
621ac62c7e
2 changed files with 51 additions and 8 deletions
|
@ -11,18 +11,32 @@
|
|||
tools:visibility="visible"
|
||||
tools:showIn="@layout/conversation_input_panel">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/microphone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="14dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="?quick_mic_icon"
|
||||
android:tint="@color/red_500"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/record_time"
|
||||
style="@style/Signal.Text.Body"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:ellipsize="none"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/core_grey_60"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/microphone"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="00:00"
|
||||
tools:visibility="visible" />
|
||||
|
@ -36,9 +50,10 @@
|
|||
android:layout_marginEnd="8dp"
|
||||
android:ellipsize="none"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="4dp"
|
||||
android:text="@string/conversation_input_panel__cancel"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/red_A700"
|
||||
android:textColor="@color/red_500"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.view.View;
|
|||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationSet;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
@ -99,6 +100,7 @@ public class InputPanel extends LinearLayout
|
|||
this.microphoneRecorderView = findViewById(R.id.recorder_view);
|
||||
this.microphoneRecorderView.setListener(this);
|
||||
this.recordTime = new RecordTime(findViewById(R.id.record_time),
|
||||
findViewById(R.id.microphone),
|
||||
TimeUnit.HOURS.toSeconds(1),
|
||||
() -> microphoneRecorderView.cancelAction());
|
||||
|
||||
|
@ -359,13 +361,15 @@ public class InputPanel extends LinearLayout
|
|||
|
||||
private static class RecordTime implements Runnable {
|
||||
|
||||
private final TextView recordTimeView;
|
||||
private final long limitSeconds;
|
||||
private final Runnable onLimitHit;
|
||||
private long startTime;
|
||||
private final @NonNull TextView recordTimeView;
|
||||
private final @NonNull View microphone;
|
||||
private final @NonNull Runnable onLimitHit;
|
||||
private final long limitSeconds;
|
||||
private long startTime;
|
||||
|
||||
private RecordTime(TextView recordTimeView, long limitSeconds, Runnable onLimitHit) {
|
||||
private RecordTime(@NonNull TextView recordTimeView, @NonNull View microphone, long limitSeconds, @NonNull Runnable onLimitHit) {
|
||||
this.recordTimeView = recordTimeView;
|
||||
this.microphone = microphone;
|
||||
this.limitSeconds = limitSeconds;
|
||||
this.onLimitHit = onLimitHit;
|
||||
}
|
||||
|
@ -376,6 +380,8 @@ public class InputPanel extends LinearLayout
|
|||
this.recordTimeView.setText(DateUtils.formatElapsedTime(0));
|
||||
ViewUtil.fadeIn(this.recordTimeView, FADE_TIME);
|
||||
Util.runOnMainDelayed(this, TimeUnit.SECONDS.toMillis(1));
|
||||
microphone.setVisibility(View.VISIBLE);
|
||||
microphone.startAnimation(pulseAnimation());
|
||||
}
|
||||
|
||||
@MainThread
|
||||
|
@ -383,6 +389,8 @@ public class InputPanel extends LinearLayout
|
|||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
this.startTime = 0;
|
||||
ViewUtil.fadeOut(this.recordTimeView, FADE_TIME, View.INVISIBLE);
|
||||
microphone.clearAnimation();
|
||||
ViewUtil.fadeOut(this.microphone, FADE_TIME, View.INVISIBLE);
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
|
@ -401,6 +409,26 @@ public class InputPanel extends LinearLayout
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Animation pulseAnimation() {
|
||||
AlphaAnimation animation = new AlphaAnimation(0, 1);
|
||||
|
||||
animation.setInterpolator(pulseInterpolator());
|
||||
animation.setRepeatCount(Animation.INFINITE);
|
||||
animation.setDuration(1000);
|
||||
|
||||
return animation;
|
||||
}
|
||||
|
||||
private static Interpolator pulseInterpolator() {
|
||||
return input -> {
|
||||
input *= 5;
|
||||
if (input > 1) {
|
||||
input = 4 - input;
|
||||
}
|
||||
return Math.max(0, Math.min(1, input));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public interface MediaListener {
|
||||
|
|
Loading…
Add table
Reference in a new issue