mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Fix right-to-left language support for voice recording
Bug: fixes #5999 // FREEBIE
This commit is contained in:
parent
49e78d16ba
commit
4dae4444bc
BIN
res/drawable-ldrtl-hdpi/ic_keyboard_arrow_left_grey600_24dp.png
Normal file
BIN
res/drawable-ldrtl-hdpi/ic_keyboard_arrow_left_grey600_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 284 B |
BIN
res/drawable-ldrtl-xhdpi/ic_keyboard_arrow_left_grey600_24dp.png
Normal file
BIN
res/drawable-ldrtl-xhdpi/ic_keyboard_arrow_left_grey600_24dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 341 B |
Binary file not shown.
After Width: | Height: | Size: 386 B |
Binary file not shown.
After Width: | Height: | Size: 353 B |
@ -110,6 +110,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="none"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:text="00:00"
|
||||
android:textColor="#61737b"
|
||||
android:textSize="20dp"
|
||||
@ -126,6 +127,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:drawableLeft="@drawable/ic_keyboard_arrow_left_grey600_24dp"
|
||||
android:drawableStart="@drawable/ic_keyboard_arrow_left_grey600_24dp"
|
||||
android:text="@string/conversation_input_panel__slide_to_cancel"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="#61737b"
|
||||
@ -133,6 +135,7 @@
|
||||
android:ellipsize="none"
|
||||
android:singleLine="true"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingStart="20dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.components;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@ -113,9 +114,12 @@ public class MicrophoneRecorderView extends FrameLayout implements View.OnTouchL
|
||||
|
||||
recordButtonFab.setVisibility(View.VISIBLE);
|
||||
|
||||
float translation = ViewCompat.getLayoutDirection(recordButtonFab) ==
|
||||
ViewCompat.LAYOUT_DIRECTION_LTR ? -.25f : .25f;
|
||||
|
||||
AnimationSet animation = new AnimationSet(true);
|
||||
animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, -.25f,
|
||||
Animation.RELATIVE_TO_SELF, -.25f,
|
||||
animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, translation,
|
||||
Animation.RELATIVE_TO_SELF, translation,
|
||||
Animation.RELATIVE_TO_SELF, -.25f,
|
||||
Animation.RELATIVE_TO_SELF, -.25f));
|
||||
|
||||
@ -134,8 +138,8 @@ public class MicrophoneRecorderView extends FrameLayout implements View.OnTouchL
|
||||
public void moveTo(float x) {
|
||||
this.lastPositionX = x;
|
||||
|
||||
float offset = -Math.max(0, this.startPositionX - x);
|
||||
int widthAdjustment = -(recordButtonFab.getWidth() / 4);
|
||||
float offset = getOffset(x);
|
||||
int widthAdjustment = getWidthAdjustment();
|
||||
|
||||
Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, widthAdjustment + offset,
|
||||
Animation.ABSOLUTE, widthAdjustment + offset,
|
||||
@ -152,8 +156,8 @@ public class MicrophoneRecorderView extends FrameLayout implements View.OnTouchL
|
||||
public void hide(float x) {
|
||||
this.lastPositionX = x;
|
||||
|
||||
float offset = -Math.max(0, this.startPositionX - x);
|
||||
int widthAdjustment = -(recordButtonFab.getWidth() / 4);
|
||||
float offset = getOffset(x);
|
||||
int widthAdjustment = getWidthAdjustment();
|
||||
|
||||
AnimationSet animation = new AnimationSet(false);
|
||||
Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
|
||||
@ -179,6 +183,16 @@ public class MicrophoneRecorderView extends FrameLayout implements View.OnTouchL
|
||||
recordButtonFab.startAnimation(animation);
|
||||
}
|
||||
|
||||
private float getOffset(float x) {
|
||||
return ViewCompat.getLayoutDirection(recordButtonFab) == ViewCompat.LAYOUT_DIRECTION_LTR ?
|
||||
-Math.max(0, this.startPositionX - x) : Math.max(0, x - this.startPositionX);
|
||||
}
|
||||
|
||||
private int getWidthAdjustment() {
|
||||
int width = recordButtonFab.getWidth() / 4;
|
||||
return ViewCompat.getLayoutDirection(recordButtonFab) == ViewCompat.LAYOUT_DIRECTION_LTR ? -width : width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user