mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-31 12:33:12 +01:00
Fix right-to-left language support for voice recording
Bug: fixes #5999 // FREEBIE
This commit is contained in:
committed by
Moxie Marlinspike
parent
49e78d16ba
commit
4dae4444bc
@@ -7,6 +7,7 @@ import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -21,7 +22,6 @@ import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
@@ -146,7 +146,12 @@ public class InputPanel extends LinearLayout
|
||||
public void onRecordMoved(float x, float absoluteX) {
|
||||
slideToCancel.moveTo(x);
|
||||
|
||||
if (absoluteX / recordingContainer.getWidth() <= 0.5) {
|
||||
int direction = ViewCompat.getLayoutDirection(this);
|
||||
float position = absoluteX / recordingContainer.getWidth();
|
||||
|
||||
if (direction == ViewCompat.LAYOUT_DIRECTION_LTR && position <= 0.5 ||
|
||||
direction == ViewCompat.LAYOUT_DIRECTION_RTL && position >= 0.6)
|
||||
{
|
||||
this.microphoneRecorderView.cancelAction();
|
||||
}
|
||||
}
|
||||
@@ -225,7 +230,7 @@ public class InputPanel extends LinearLayout
|
||||
|
||||
public ListenableFuture<Void> hide(float x) {
|
||||
final SettableFuture<Void> future = new SettableFuture<>();
|
||||
float offset = -Math.max(0, this.startPositionX - x);
|
||||
float offset = getOffset(x);
|
||||
|
||||
AnimationSet animation = new AnimationSet(true);
|
||||
animation.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, offset,
|
||||
@@ -255,7 +260,7 @@ public class InputPanel extends LinearLayout
|
||||
}
|
||||
|
||||
public void moveTo(float x) {
|
||||
float offset = -Math.max(0, this.startPositionX - x);
|
||||
float offset = getOffset(x);
|
||||
Animation animation = new TranslateAnimation(Animation.ABSOLUTE, offset,
|
||||
Animation.ABSOLUTE, offset,
|
||||
Animation.RELATIVE_TO_SELF, 0,
|
||||
@@ -268,6 +273,11 @@ public class InputPanel extends LinearLayout
|
||||
slideToCancelView.startAnimation(animation);
|
||||
}
|
||||
|
||||
private float getOffset(float x) {
|
||||
return ViewCompat.getLayoutDirection(slideToCancelView) == ViewCompat.LAYOUT_DIRECTION_LTR ?
|
||||
-Math.max(0, this.startPositionX - x) : Math.max(0, x - this.startPositionX);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class RecordTime implements Runnable {
|
||||
|
||||
Reference in New Issue
Block a user