13ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov/* 23ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Copyright (C) 2016 The Android Open Source Project 33ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * 43ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Licensed under the Apache License, Version 2.0 (the "License"); 53ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * you may not use this file except in compliance with the License. 63ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * You may obtain a copy of the License at 73ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * 83ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * http://www.apache.org/licenses/LICENSE-2.0 93ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * 103ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Unless required by applicable law or agreed to in writing, software 113ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * distributed under the License is distributed on an "AS IS" BASIS, 123ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * See the License for the specific language governing permissions and 143ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * limitations under the License. 153ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov */ 163ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 173ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikovpackage android.support.v4.testutils; 183ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 199dede51868bbbe16aadcd65e04860bea8ea50e05Aurimas Liutikasimport static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom; 209dede51868bbbe16aadcd65e04860bea8ea50e05Aurimas Liutikas 213ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikovimport android.graphics.drawable.Drawable; 229dede51868bbbe16aadcd65e04860bea8ea50e05Aurimas Liutikasimport android.support.test.espresso.UiController; 239dede51868bbbe16aadcd65e04860bea8ea50e05Aurimas Liutikasimport android.support.test.espresso.ViewAction; 249dede51868bbbe16aadcd65e04860bea8ea50e05Aurimas Liutikasimport android.view.View; 259dede51868bbbe16aadcd65e04860bea8ea50e05Aurimas Liutikasimport android.widget.TextView; 269dede51868bbbe16aadcd65e04860bea8ea50e05Aurimas Liutikas 27ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.DrawableRes; 28ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.Nullable; 29ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.StringRes; 30ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.StyleRes; 31ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.core.widget.TextViewCompat; 323ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 339dede51868bbbe16aadcd65e04860bea8ea50e05Aurimas Liutikasimport org.hamcrest.Matcher; 343ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 353ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikovpublic class TextViewActions { 363ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov /** 373ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Sets max lines count on <code>TextView</code>. 383ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov */ 393ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public static ViewAction setMaxLines(final int maxLines) { 403ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return new ViewAction() { 413ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 423ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public Matcher<View> getConstraints() { 433ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return isAssignableFrom(TextView.class); 443ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 453ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 463ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 473ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public String getDescription() { 483ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return "TextView set max lines"; 493ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 503ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 513ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 523ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public void perform(UiController uiController, View view) { 533ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 543ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 553ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextView textView = (TextView) view; 563ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov textView.setMaxLines(maxLines); 573ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 583ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 593ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 603ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov }; 613ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 623ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 633ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov /** 643ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Sets min lines count on <code>TextView</code>. 653ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov */ 663ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public static ViewAction setMinLines(final int minLines) { 673ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return new ViewAction() { 683ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 693ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public Matcher<View> getConstraints() { 703ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return isAssignableFrom(TextView.class); 713ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 723ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 733ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 743ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public String getDescription() { 753ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return "TextView set min lines"; 763ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 773ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 783ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 793ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public void perform(UiController uiController, View view) { 803ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 813ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 823ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextView textView = (TextView) view; 833ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov textView.setMinLines(minLines); 843ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 853ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 863ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 873ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov }; 883ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 893ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 903ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov /** 913ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Sets text content on <code>TextView</code>. 923ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov */ 933ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public static ViewAction setText(final @StringRes int stringResId) { 943ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return new ViewAction() { 953ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 963ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public Matcher<View> getConstraints() { 973ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return isAssignableFrom(TextView.class); 983ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 993ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1003ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1013ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public String getDescription() { 1023ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return "TextView set text"; 1033ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1043ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1053ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1063ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public void perform(UiController uiController, View view) { 1073ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 1083ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1093ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextView textView = (TextView) view; 1103ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov textView.setText(stringResId); 1113ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1123ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 1133ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1143ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov }; 1153ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1163ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1173ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov /** 1183ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Sets text appearance on <code>TextView</code>. 1193ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov */ 1203ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public static ViewAction setTextAppearance(final @StyleRes int styleResId) { 1213ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return new ViewAction() { 1223ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1233ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public Matcher<View> getConstraints() { 1243ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return isAssignableFrom(TextView.class); 1253ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1263ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1273ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1283ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public String getDescription() { 1293ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return "TextView set text appearance"; 1303ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1313ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1323ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1333ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public void perform(UiController uiController, View view) { 1343ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 1353ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1363ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextView textView = (TextView) view; 1373ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextViewCompat.setTextAppearance(textView, styleResId); 1383ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1393ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 1403ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1413ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov }; 1423ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1433ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1443ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov /** 1453ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Sets compound drawables on <code>TextView</code>. 1463ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov */ 1473ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public static ViewAction setCompoundDrawablesRelative(final @Nullable Drawable start, 1483ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov final @Nullable Drawable top, final @Nullable Drawable end, 1493ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov final @Nullable Drawable bottom) { 1503ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return new ViewAction() { 1513ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1523ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public Matcher<View> getConstraints() { 1533ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return isAssignableFrom(TextView.class); 1543ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1553ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1563ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1573ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public String getDescription() { 1583ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return "TextView set compound drawables"; 1593ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1603ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1613ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1623ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public void perform(UiController uiController, View view) { 1633ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 1643ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1653ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextView textView = (TextView) view; 1663ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextViewCompat.setCompoundDrawablesRelative(textView, start, top, end, bottom); 1673ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1683ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 1693ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1703ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov }; 1713ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1723ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1733ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov /** 1743ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Sets compound drawables on <code>TextView</code>. 1753ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov */ 1763ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public static ViewAction setCompoundDrawablesRelativeWithIntrinsicBounds( 1773ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov final @Nullable Drawable start, final @Nullable Drawable top, 1783ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov final @Nullable Drawable end, final @Nullable Drawable bottom) { 1793ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return new ViewAction() { 1803ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1813ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public Matcher<View> getConstraints() { 1823ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return isAssignableFrom(TextView.class); 1833ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1843ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1853ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1863ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public String getDescription() { 1873ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return "TextView set compound drawables"; 1883ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 1893ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1903ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 1913ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public void perform(UiController uiController, View view) { 1923ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 1933ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1943ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextView textView = (TextView) view; 1953ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds( 1963ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov textView, start, top, end, bottom); 1973ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 1983ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 1993ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 2003ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov }; 2013ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 2023ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 2033ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov /** 2043ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov * Sets compound drawables on <code>TextView</code>. 2053ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov */ 2063ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public static ViewAction setCompoundDrawablesRelativeWithIntrinsicBounds( 2073ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov final @DrawableRes int start, final @DrawableRes int top, final @DrawableRes int end, 2083ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov final @DrawableRes int bottom) { 2093ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return new ViewAction() { 2103ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 2113ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public Matcher<View> getConstraints() { 2123ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return isAssignableFrom(TextView.class); 2133ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 2143ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 2153ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 2163ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public String getDescription() { 2173ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov return "TextView set compound drawables"; 2183ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 2193ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 2203ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov @Override 2213ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov public void perform(UiController uiController, View view) { 2223ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 2233ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 2243ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextView textView = (TextView) view; 2253ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds( 2263ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov textView, start, top, end, bottom); 2273ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov 2283ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov uiController.loopMainThreadUntilIdle(); 2293ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 2303ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov }; 2313ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov } 2323ac77bf186f87ecad4bf0063b2f6c4384efbd56aKirill Grouchnikov} 233