Merge "[WifiSetup] Use framework AutoMirrored" into lmp-dev
diff --git a/res/drawable-nodpi/setup_illustration_wifi.jpg b/res/drawable-nodpi/setup_illustration_wifi_image.jpg
similarity index 100%
rename from res/drawable-nodpi/setup_illustration_wifi.jpg
rename to res/drawable-nodpi/setup_illustration_wifi_image.jpg
Binary files differ
diff --git a/res/drawable-nodpi/setup_illustration_wifi_wide.jpg b/res/drawable-nodpi/setup_illustration_wifi_wide_image.jpg
similarity index 100%
rename from res/drawable-nodpi/setup_illustration_wifi_wide.jpg
rename to res/drawable-nodpi/setup_illustration_wifi_wide_image.jpg
Binary files differ
diff --git a/res/drawable/setup_illustration_wifi.xml b/res/drawable/setup_illustration_wifi.xml
new file mode 100644
index 0000000..9db2f13
--- /dev/null
+++ b/res/drawable/setup_illustration_wifi.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+    android:autoMirrored="true"
+    android:src="@drawable/setup_illustration_wifi_image" />
diff --git a/res/drawable/setup_illustration_wifi_wide.xml b/res/drawable/setup_illustration_wifi_wide.xml
new file mode 100644
index 0000000..3af3561
--- /dev/null
+++ b/res/drawable/setup_illustration_wifi_wide.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+    android:autoMirrored="true"
+    android:src="@drawable/setup_illustration_wifi_wide_image" />
diff --git a/res/layout-sw600dp-land/setup_preference.xml b/res/layout-sw600dp-land/setup_preference.xml
index 1c39405..0943817 100644
--- a/res/layout-sw600dp-land/setup_preference.xml
+++ b/res/layout-sw600dp-land/setup_preference.xml
@@ -16,7 +16,6 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
     android:id="@+id/fragment"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -27,8 +26,7 @@
         android:layout_height="match_parent"
         android:layout_weight="1"
         android:foreground="@drawable/setup_illustration_wifi_wide"
-        android:background="@drawable/setup_illustration_bg"
-        settings:autoMirrored="true">
+        android:background="@drawable/setup_illustration_bg">
 
         <LinearLayout
             android:layout_width="match_parent"
diff --git a/res/layout/setup_wizard_header.xml b/res/layout/setup_wizard_header.xml
index 90818cd..2409fb4 100644
--- a/res/layout/setup_wizard_header.xml
+++ b/res/layout/setup_wizard_header.xml
@@ -24,8 +24,7 @@
     android:background="@drawable/setup_illustration_bg"
     android:foreground="@drawable/setup_illustration_wifi"
     android:tag="stickyContainer"
-    settings:aspectRatio="2.0"
-    settings:autoMirrored="true">
+    settings:aspectRatio="2.0">
 
     <TextView
         android:id="@+id/title"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 8d17a28..1fe36d6 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -24,7 +24,6 @@
 
     <declare-styleable name="SetupWizardIllustration">
         <attr name="aspectRatio" format="float" />
-        <attr name="autoMirrored" format="boolean" />
     </declare-styleable>
 
     <declare-styleable name="BatteryHistoryChart">
diff --git a/src/com/android/settings/widget/SetupWizardIllustration.java b/src/com/android/settings/widget/SetupWizardIllustration.java
index 8a9d507..fa8dd80 100644
--- a/src/com/android/settings/widget/SetupWizardIllustration.java
+++ b/src/com/android/settings/widget/SetupWizardIllustration.java
@@ -22,7 +22,6 @@
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
-import android.util.LayoutDirection;
 import android.util.Log;
 import android.widget.FrameLayout;
 
@@ -46,7 +45,6 @@
     private int mForegroundHeight = 0;
     private float mScale = 1.0f;
     private float mAspectRatio = 0.0f;
-    private boolean mAutoMirrored;
 
     public SetupWizardIllustration(Context context) {
         this(context, null);
@@ -67,8 +65,6 @@
             TypedArray a = context.obtainStyledAttributes(attrs,
                     R.styleable.SetupWizardIllustration, 0, 0);
             mAspectRatio = a.getFloat(R.styleable.SetupWizardIllustration_aspectRatio, 0.0f);
-            // TODO: Use framework autoMirrored supported in drawables instead b/17047609
-            mAutoMirrored = a.getBoolean(R.styleable.SetupWizardIllustration_autoMirrored, false);
             a.recycle();
         }
         // Number of pixels of the 8dp baseline grid as defined in material design specs
@@ -95,6 +91,12 @@
     }
 
     @Override
+    public void onResolveDrawables(int layoutDirection) {
+        mBackground.setLayoutDirection(layoutDirection);
+        mForeground.setLayoutDirection(layoutDirection);
+    }
+
+    @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         if (mAspectRatio != 0.0f) {
             int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
@@ -136,10 +138,6 @@
     @Override
     public void onDraw(Canvas canvas) {
         canvas.save();
-        if (mAutoMirrored && getLayoutDirection() == LayoutDirection.RTL) {
-            canvas.scale(-1, 1);
-            canvas.translate(-canvas.getWidth(), 0);
-        }
         if (mBackground != null) {
             canvas.save();
             // Draw the background filling parts not covered by the illustration