summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryueg <yueg@google.com>2017-12-19 16:05:47 -0800
committerEric Erfanian <erfanian@google.com>2017-12-22 08:50:44 -0800
commit07e323c0c61e2a9fc48bf91a02de6b19d2de1ece (patch)
tree496a106883c81f567caa15e2dfaeed11a4ead578
parentc35c7580d48516eb8fedaad1142a40428c780946 (diff)
Bubble v2 RTL language fixes.
- Always use LTR layout direction for root view to avoid jank animation. - Set menu button icon position (left or right) according to default locale. - Set bubble default showing position (left or right) according to default locale. Bug: 67605985 Test: NewBubbleIntegrationTest PiperOrigin-RevId: 179616379 Change-Id: If418cbbf4747c2b655bc83d7c06fc0139979d94b
-rw-r--r--java/com/android/newbubble/NewBubble.java17
-rw-r--r--java/com/android/newbubble/res/layout/new_bubble_base.xml1
2 files changed, 16 insertions, 2 deletions
diff --git a/java/com/android/newbubble/NewBubble.java b/java/com/android/newbubble/NewBubble.java
index 3378ad81a..469c15d71 100644
--- a/java/com/android/newbubble/NewBubble.java
+++ b/java/com/android/newbubble/NewBubble.java
@@ -39,6 +39,7 @@ import android.support.annotation.VisibleForTesting;
import android.support.v4.graphics.ColorUtils;
import android.support.v4.os.BuildCompat;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
+import android.text.TextUtils;
import android.transition.TransitionManager;
import android.transition.TransitionValues;
import android.view.ContextThemeWrapper;
@@ -70,6 +71,7 @@ import com.android.newbubble.NewBubbleInfo.Action;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
+import java.util.Locale;
/**
* Creates and manages a bubble window from information in a {@link NewBubbleInfo}. Before creating,
@@ -406,6 +408,8 @@ public class NewBubble {
hideAfterText = false;
+ boolean isRtl =
+ TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
if (windowParams == null) {
// Apps targeting O+ must use TYPE_APPLICATION_OVERLAY, which is not available prior to O.
@SuppressWarnings("deprecation")
@@ -423,7 +427,7 @@ public class NewBubble {
| LayoutParams.FLAG_NOT_FOCUSABLE
| LayoutParams.FLAG_LAYOUT_NO_LIMITS,
PixelFormat.TRANSLUCENT);
- windowParams.gravity = Gravity.TOP | Gravity.LEFT;
+ windowParams.gravity = Gravity.TOP | (isRtl ? Gravity.RIGHT : Gravity.LEFT);
windowParams.x = leftBoundary;
windowParams.y = currentInfo.getStartingYPosition();
windowParams.height = LayoutParams.WRAP_CONTENT;
@@ -441,6 +445,9 @@ public class NewBubble {
viewHolder.getPrimaryButton().setScaleY(0);
viewHolder.getPrimaryAvatar().setAlpha(0f);
viewHolder.getPrimaryIcon().setAlpha(0f);
+ if (isRtl) {
+ onLeftRightSwitch(true);
+ }
}
viewHolder.setChildClickable(true);
@@ -795,7 +802,13 @@ public class NewBubble {
}
private void configureButton(Action action, NewCheckableButton button) {
- button.setCompoundDrawablesWithIntrinsicBounds(action.getIconDrawable(), null, null, null);
+ boolean isRtl =
+ TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
+ if (isRtl) {
+ button.setCompoundDrawablesWithIntrinsicBounds(null, null, action.getIconDrawable(), null);
+ } else {
+ button.setCompoundDrawablesWithIntrinsicBounds(action.getIconDrawable(), null, null, null);
+ }
button.setChecked(action.isChecked());
button.setEnabled(action.isEnabled());
button.setText(action.getName());
diff --git a/java/com/android/newbubble/res/layout/new_bubble_base.xml b/java/com/android/newbubble/res/layout/new_bubble_base.xml
index f83b75395..f6ce26dd1 100644
--- a/java/com/android/newbubble/res/layout/new_bubble_base.xml
+++ b/java/com/android/newbubble/res/layout/new_bubble_base.xml
@@ -21,6 +21,7 @@
android:layout_height="wrap_content"
android:clipChildren="true"
android:clipToPadding="false"
+ android:layoutDirection="ltr"
tools:theme="@style/Theme.AppCompat">
<RelativeLayout
android:id="@+id/bubble_primary_container"