summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurice Lam <yukl@google.com>2015-03-19 17:28:42 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-19 17:28:42 +0000
commit9a551bde9a5f3cae7475bd4f1f9b3c20b7c8e159 (patch)
tree474355889d9bead3df62e8750e730d5497fc7da0
parent20a4f1ac5bd26e02563fd9ea85fc25e2d1d27d3b (diff)
parenta722cfbd655876203db00e86ab6749a1e4d2eeb5 (diff)
downloadandroid_frameworks_opt_setupwizard-9a551bde9a5f3cae7475bd4f1f9b3c20b7c8e159.tar.gz
android_frameworks_opt_setupwizard-9a551bde9a5f3cae7475bd4f1f9b3c20b7c8e159.tar.bz2
android_frameworks_opt_setupwizard-9a551bde9a5f3cae7475bd4f1f9b3c20b7c8e159.zip
am a722cfbd: [SetupWizardLib] Flip Illustration for RTL on JB
* commit 'a722cfbd655876203db00e86ab6749a1e4d2eeb5': [SetupWizardLib] Flip Illustration for RTL on JB
-rw-r--r--library/main/src/com/android/setupwizardlib/view/Illustration.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/library/main/src/com/android/setupwizardlib/view/Illustration.java b/library/main/src/com/android/setupwizardlib/view/Illustration.java
index fd976bc..18c79b8 100644
--- a/library/main/src/com/android/setupwizardlib/view/Illustration.java
+++ b/library/main/src/com/android/setupwizardlib/view/Illustration.java
@@ -17,6 +17,7 @@
package com.android.setupwizardlib.view;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -157,24 +158,20 @@ public class Illustration extends FrameLayout {
canvas.translate(0, mIllustrationBounds.height());
// Scale the background so its size matches the foreground
canvas.scale(mScale, mScale, 0, 0);
- if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
- if (layoutDirection == LayoutDirection.RTL && mBackground.isAutoMirrored()) {
- // Flip the illustration for RTL layouts
- canvas.scale(-1, 1);
- canvas.translate(-mBackground.getBounds().width(), 0);
- }
+ if (shouldMirrorIllustration(layoutDirection)) {
+ // Flip the illustration for RTL layouts
+ canvas.scale(-1, 1);
+ canvas.translate(-mBackground.getBounds().width(), 0);
}
mBackground.draw(canvas);
canvas.restore();
}
if (mIllustration != null) {
canvas.save();
- if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
- if (layoutDirection == LayoutDirection.RTL && mIllustration.isAutoMirrored()) {
- // Flip the illustration for RTL layouts
- canvas.scale(-1, 1);
- canvas.translate(-mIllustrationBounds.width(), 0);
- }
+ if (shouldMirrorIllustration(layoutDirection)) {
+ // Flip the illustration for RTL layouts
+ canvas.scale(-1, 1);
+ canvas.translate(-mIllustrationBounds.width(), 0);
}
// Draw the illustration
mIllustration.draw(canvas);
@@ -182,4 +179,16 @@ public class Illustration extends FrameLayout {
}
super.onDraw(canvas);
}
+
+ private boolean shouldMirrorIllustration(int layoutDirection) {
+ if (layoutDirection == LayoutDirection.RTL) {
+ if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
+ return mIllustration.isAutoMirrored();
+ } else if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
+ final int flags = getContext().getApplicationInfo().flags;
+ return (flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0;
+ }
+ }
+ return false;
+ }
}