diff options
author | yueg <yueg@google.com> | 2017-12-19 16:05:47 -0800 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-12-22 08:50:44 -0800 |
commit | 07e323c0c61e2a9fc48bf91a02de6b19d2de1ece (patch) | |
tree | 496a106883c81f567caa15e2dfaeed11a4ead578 /java/com/android/newbubble/NewBubble.java | |
parent | c35c7580d48516eb8fedaad1142a40428c780946 (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
Diffstat (limited to 'java/com/android/newbubble/NewBubble.java')
-rw-r--r-- | java/com/android/newbubble/NewBubble.java | 17 |
1 files changed, 15 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()); |