diff --git a/res/drawable-ldrtl-hdpi/ic_keyboard_arrow_left_grey600_24dp.png b/res/drawable-ldrtl-hdpi/ic_keyboard_arrow_left_grey600_24dp.png new file mode 100644 index 0000000000..1a14d39de9 Binary files /dev/null and b/res/drawable-ldrtl-hdpi/ic_keyboard_arrow_left_grey600_24dp.png differ diff --git a/res/drawable-ldrtl-xhdpi/ic_keyboard_arrow_left_grey600_24dp.png b/res/drawable-ldrtl-xhdpi/ic_keyboard_arrow_left_grey600_24dp.png new file mode 100644 index 0000000000..f5f0f219d7 Binary files /dev/null and b/res/drawable-ldrtl-xhdpi/ic_keyboard_arrow_left_grey600_24dp.png differ diff --git a/res/drawable-ldrtl-xxhdpi/ic_keyboard_arrow_left_grey600_24dp.png b/res/drawable-ldrtl-xxhdpi/ic_keyboard_arrow_left_grey600_24dp.png new file mode 100644 index 0000000000..67676b203e Binary files /dev/null and b/res/drawable-ldrtl-xxhdpi/ic_keyboard_arrow_left_grey600_24dp.png differ diff --git a/res/drawable-ldrtl-xxxhdpi/ic_keyboard_arrow_left_grey600_24dp.png b/res/drawable-ldrtl-xxxhdpi/ic_keyboard_arrow_left_grey600_24dp.png new file mode 100644 index 0000000000..b1a9cf4c6b Binary files /dev/null and b/res/drawable-ldrtl-xxxhdpi/ic_keyboard_arrow_left_grey600_24dp.png differ diff --git a/res/layout/conversation_input_panel.xml b/res/layout/conversation_input_panel.xml index 305cd216bc..537d5f9818 100644 --- a/res/layout/conversation_input_panel.xml +++ b/res/layout/conversation_input_panel.xml @@ -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"/> diff --git a/src/org/thoughtcrime/securesms/components/InputPanel.java b/src/org/thoughtcrime/securesms/components/InputPanel.java index f7a07c88ee..eff26a35f8 100644 --- a/src/org/thoughtcrime/securesms/components/InputPanel.java +++ b/src/org/thoughtcrime/securesms/components/InputPanel.java @@ -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 hide(float x) { final SettableFuture 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 { diff --git a/src/org/thoughtcrime/securesms/components/MicrophoneRecorderView.java b/src/org/thoughtcrime/securesms/components/MicrophoneRecorderView.java index 7615902605..7346f96122 100644 --- a/src/org/thoughtcrime/securesms/components/MicrophoneRecorderView.java +++ b/src/org/thoughtcrime/securesms/components/MicrophoneRecorderView.java @@ -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; + } + } }