TextViewCompat - fix #getCompoundDrawablesRelative

TextViewCompat#getCompoundDrawablesRelative makes a wrong call to
TextView#getCompoundDrawables() which makes it return the drawableLeft
and drawableRight (in the Drawable[] array) instead of expected
drawableStart and drawableEnd.

Test: instrumentation test attached
Bug: 31590009
Change-Id: I916d711fa7c368ccadf196c8fef59169f17eb83b
diff --git a/compat/java/android/support/v4/widget/TextViewCompat.java b/compat/java/android/support/v4/widget/TextViewCompat.java
index acee54b..6c96ef3 100644
--- a/compat/java/android/support/v4/widget/TextViewCompat.java
+++ b/compat/java/android/support/v4/widget/TextViewCompat.java
@@ -282,6 +282,6 @@
      * Returns drawables for the start, top, end, and bottom borders from the given text view.
      */
     public static Drawable[] getCompoundDrawablesRelative(@NonNull TextView textView) {
-        return textView.getCompoundDrawables();
+        return IMPL.getCompoundDrawablesRelative(textView);
     }
 }
diff --git a/compat/tests/java/android/support/v4/widget/TextViewCompatTest.java b/compat/tests/java/android/support/v4/widget/TextViewCompatTest.java
index 27a85ef..19242cb 100644
--- a/compat/tests/java/android/support/v4/widget/TextViewCompatTest.java
+++ b/compat/tests/java/android/support/v4/widget/TextViewCompatTest.java
@@ -387,4 +387,29 @@
                 drawablesAbsolute[3].getBounds().height(),
                 res.getDimensionPixelSize(R.dimen.drawable_small_size));
     }
+
+    @Test
+    @SmallTest
+    public void testCompoundDrawablesRelativeGetterAndSetter() {
+        final Drawable drawableStart = new TestDrawable(0xFFFF0000, 20, 20);
+        final Drawable drawableTop = new TestDrawable(0xFFFFFF00, 20, 20);
+        final Drawable drawableEnd = new TestDrawable(0xFF0000FF, 20, 20);
+        final Drawable drawableBottom = new TestDrawable(0xFF00FF00, 20, 20);
+
+        onView(withId(R.id.text_view)).perform(setLayoutDirection(ViewCompat.LAYOUT_DIRECTION_RTL));
+        onView(withId(R.id.text_view)).perform(setCompoundDrawablesRelative(drawableStart,
+                drawableTop, drawableEnd, drawableBottom));
+
+        // Check to see whether our text view is under RTL mode
+        if (ViewCompat.getLayoutDirection(mTextView) != ViewCompat.LAYOUT_DIRECTION_RTL) {
+            // This will happen on v17- devices
+            return;
+        }
+
+        final Drawable[] drawablesRelative = TextViewCompat.getCompoundDrawablesRelative(mTextView);
+        assertEquals(drawableStart, drawablesRelative[0]);
+        assertEquals(drawableTop, drawablesRelative[1]);
+        assertEquals(drawableEnd, drawablesRelative[2]);
+        assertEquals(drawableBottom, drawablesRelative[3]);
+    }
 }