131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki/* 231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Copyright (C) 2015 The Android Open Source Project 331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * 431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Licensed under the Apache License, Version 2.0 (the "License"); 531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * you may not use this file except in compliance with the License. 631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * You may obtain a copy of the License at 731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * 831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * http://www.apache.org/licenses/LICENSE-2.0 931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * 1031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Unless required by applicable law or agreed to in writing, software 1131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * distributed under the License is distributed on an "AS IS" BASIS, 1231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * See the License for the specific language governing permissions and 1431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * limitations under the License. 1531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki */ 1631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 1731a49efe2adb59e31611f6871895a3243d835127Yuichi Arakipackage android.support.v4.widget; 1831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 19cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanuimport static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP; 20cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 2131a49efe2adb59e31611f6871895a3243d835127Yuichi Arakiimport android.graphics.drawable.Drawable; 2231a49efe2adb59e31611f6871895a3243d835127Yuichi Arakiimport android.os.Build; 2339e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikovimport android.support.annotation.DrawableRes; 24cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanuimport android.support.annotation.IntDef; 2531a49efe2adb59e31611f6871895a3243d835127Yuichi Arakiimport android.support.annotation.NonNull; 2631a49efe2adb59e31611f6871895a3243d835127Yuichi Arakiimport android.support.annotation.Nullable; 27cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanuimport android.support.annotation.RequiresApi; 28cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanuimport android.support.annotation.RestrictTo; 2939e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikovimport android.support.annotation.StyleRes; 30744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikasimport android.util.Log; 31cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanuimport android.util.TypedValue; 32744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikasimport android.view.View; 3331a49efe2adb59e31611f6871895a3243d835127Yuichi Arakiimport android.widget.TextView; 3431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 35cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanuimport java.lang.annotation.Retention; 36cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanuimport java.lang.annotation.RetentionPolicy; 37744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikasimport java.lang.reflect.Field; 38744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas 3931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki/** 40744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas * Helper for accessing features in {@link TextView} in a backwards compatible fashion. 4131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki */ 42c5847d13e40f5d52459f5c0dab32dc08f1a9a683Chris Banespublic final class TextViewCompat { 4331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 44cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 45cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * The TextView does not auto-size text (default). 46cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 47cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static final int AUTO_SIZE_TEXT_TYPE_NONE = 0; 48cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 49cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 50cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * The TextView scales text size both horizontally and vertically to fit within the 51cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * container. 52cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 53cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static final int AUTO_SIZE_TEXT_TYPE_UNIFORM = 1; 54cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 55cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** @hide */ 56cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @RestrictTo(LIBRARY_GROUP) 57cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @IntDef({AUTO_SIZE_TEXT_TYPE_NONE, AUTO_SIZE_TEXT_TYPE_UNIFORM}) 58cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @Retention(RetentionPolicy.SOURCE) 59cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public @interface AutoSizeTextType {} 60cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 6131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki // Hide constructor 62092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes private TextViewCompat() {} 6331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 64744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas static class TextViewCompatBaseImpl { 65744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static final String LOG_TAG = "TextViewCompatBase"; 66744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static final int LINES = 1; 67744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas 68744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static Field sMaximumField; 69744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static boolean sMaximumFieldFetched; 70744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static Field sMaxModeField; 71744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static boolean sMaxModeFieldFetched; 72744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas 73744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static Field sMinimumField; 74744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static boolean sMinimumFieldFetched; 75744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static Field sMinModeField; 76744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static boolean sMinModeFieldFetched; 7731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 7831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelative(@NonNull TextView textView, 7931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, 8031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable bottom) { 8131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki textView.setCompoundDrawables(start, top, end, bottom); 8231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 8331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 8431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView, 8531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, 8631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable bottom) { 8731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki textView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom); 8831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 8931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 9031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView, 9139e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, 9239e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov @DrawableRes int bottom) { 9331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki textView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom); 9431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 9531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 96744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static Field retrieveField(String fieldName) { 97744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas Field field = null; 98744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas try { 99744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas field = TextView.class.getDeclaredField(fieldName); 100744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas field.setAccessible(true); 101744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } catch (NoSuchFieldException e) { 102744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas Log.e(LOG_TAG, "Could not retrieve " + fieldName + " field."); 103744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 104744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return field; 105092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes } 106092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes 107744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas private static int retrieveIntFromField(Field field, TextView textView) { 108744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas try { 109744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return field.getInt(textView); 110744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } catch (IllegalAccessException e) { 111744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas Log.d(LOG_TAG, "Could not retrieve value of " + field.getName() + " field."); 112744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 113744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return -1; 114092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes } 1150bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov 116744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas public int getMaxLines(TextView textView) { 117744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (!sMaxModeFieldFetched) { 118744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas sMaxModeField = retrieveField("mMaxMode"); 119744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas sMaxModeFieldFetched = true; 120744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 121744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (sMaxModeField != null && retrieveIntFromField(sMaxModeField, textView) == LINES) { 122744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas // If the max mode is using lines, we can grab the maximum value 123744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (!sMaximumFieldFetched) { 124744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas sMaximumField = retrieveField("mMaximum"); 125744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas sMaximumFieldFetched = true; 126744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 127744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (sMaximumField != null) { 128744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return retrieveIntFromField(sMaximumField, textView); 129744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 130744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 131744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return -1; 132744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 133744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas 134744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas public int getMinLines(TextView textView) { 135744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (!sMinModeFieldFetched) { 136744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas sMinModeField = retrieveField("mMinMode"); 137744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas sMinModeFieldFetched = true; 138744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 139744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (sMinModeField != null && retrieveIntFromField(sMinModeField, textView) == LINES) { 140744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas // If the min mode is using lines, we can grab the maximum value 141744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (!sMinimumFieldFetched) { 142744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas sMinimumField = retrieveField("mMinimum"); 143744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas sMinimumFieldFetched = true; 144744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 145744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (sMinimumField != null) { 146744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return retrieveIntFromField(sMinimumField, textView); 147744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 148744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 149744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return -1; 150744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 151744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas 152744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas @SuppressWarnings("deprecation") 15339e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov public void setTextAppearance(TextView textView, @StyleRes int resId) { 154744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas textView.setTextAppearance(textView.getContext(), resId); 1550bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov } 156ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes 157ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes public Drawable[] getCompoundDrawablesRelative(@NonNull TextView textView) { 158744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return textView.getCompoundDrawables(); 159ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes } 160cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 161cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public void setAutoSizeTextTypeWithDefaults(TextView textView, int autoSizeTextType) { 162cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (textView instanceof AutoSizeableTextView) { 163cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu ((AutoSizeableTextView) textView).setAutoSizeTextTypeWithDefaults(autoSizeTextType); 164cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 165cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 166cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 167cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public void setAutoSizeTextTypeUniformWithConfiguration( 168cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu TextView textView, 169cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeMinTextSize, 170cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeMaxTextSize, 171cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeStepGranularity, 172cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int unit) throws IllegalArgumentException { 173cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (textView instanceof AutoSizeableTextView) { 174cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu ((AutoSizeableTextView) textView).setAutoSizeTextTypeUniformWithConfiguration( 175cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu autoSizeMinTextSize, autoSizeMaxTextSize, autoSizeStepGranularity, unit); 176cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 177cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 178cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 179cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public void setAutoSizeTextTypeUniformWithPresetSizes(TextView textView, 180cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @NonNull int[] presetSizes, int unit) throws IllegalArgumentException { 181cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (textView instanceof AutoSizeableTextView) { 182cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu ((AutoSizeableTextView) textView).setAutoSizeTextTypeUniformWithPresetSizes( 183cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu presetSizes, unit); 184cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 185cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 186cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 187cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int getAutoSizeTextType(TextView textView) { 188cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (textView instanceof AutoSizeableTextView) { 189cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return ((AutoSizeableTextView) textView).getAutoSizeTextType(); 190cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 191cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return AUTO_SIZE_TEXT_TYPE_NONE; 192cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 193cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 194cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int getAutoSizeStepGranularity(TextView textView) { 195cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (textView instanceof AutoSizeableTextView) { 196cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return ((AutoSizeableTextView) textView).getAutoSizeStepGranularity(); 197cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 198cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return -1; 199cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 200cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 201cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int getAutoSizeMinTextSize(TextView textView) { 202cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (textView instanceof AutoSizeableTextView) { 203cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return ((AutoSizeableTextView) textView).getAutoSizeMinTextSize(); 204cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 205cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return -1; 206cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 207cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 208cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int getAutoSizeMaxTextSize(TextView textView) { 209cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (textView instanceof AutoSizeableTextView) { 210cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return ((AutoSizeableTextView) textView).getAutoSizeMaxTextSize(); 211cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 212cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return -1; 213cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 214cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 215cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int[] getAutoSizeTextAvailableSizes(TextView textView) { 216cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (textView instanceof AutoSizeableTextView) { 217cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return ((AutoSizeableTextView) textView).getAutoSizeTextAvailableSizes(); 218cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 219cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return new int[0]; 220cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 22131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 22231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 223c69882cb9b130902c1554ef5d3e3b06d776cd796Alan Viverette @RequiresApi(16) 224744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas static class TextViewCompatApi16Impl extends TextViewCompatBaseImpl { 225092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes @Override 226092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes public int getMaxLines(TextView textView) { 227744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return textView.getMaxLines(); 228092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes } 22931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 23031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Override 231092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes public int getMinLines(TextView textView) { 232744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return textView.getMinLines(); 233092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes } 234092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes } 235092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes 236c69882cb9b130902c1554ef5d3e3b06d776cd796Alan Viverette @RequiresApi(17) 237744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas static class TextViewCompatApi17Impl extends TextViewCompatApi16Impl { 238092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes @Override 23931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelative(@NonNull TextView textView, 24031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, 24131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable bottom) { 242744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas boolean rtl = textView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; 243744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas textView.setCompoundDrawables(rtl ? end : start, top, rtl ? start : end, bottom); 24431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 24531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 24631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Override 24731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView, 24831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, 24931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable bottom) { 250744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas boolean rtl = textView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; 251744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas textView.setCompoundDrawablesWithIntrinsicBounds(rtl ? end : start, top, 252744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas rtl ? start : end, bottom); 25331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 25431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 25531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Override 25631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView, 25739e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, 25839e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov @DrawableRes int bottom) { 259744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas boolean rtl = textView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; 260744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas textView.setCompoundDrawablesWithIntrinsicBounds(rtl ? end : start, top, 261744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas rtl ? start : end, bottom); 26231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 263ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes 264ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes @Override 265ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes public Drawable[] getCompoundDrawablesRelative(@NonNull TextView textView) { 266744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas final boolean rtl = textView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; 267744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas final Drawable[] compounds = textView.getCompoundDrawables(); 268744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas if (rtl) { 269744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas // If we're on RTL, we need to invert the horizontal result like above 270744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas final Drawable start = compounds[2]; 271744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas final Drawable end = compounds[0]; 272744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas compounds[0] = start; 273744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas compounds[2] = end; 274744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } 275744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return compounds; 276ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes } 27731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 27831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 279c69882cb9b130902c1554ef5d3e3b06d776cd796Alan Viverette @RequiresApi(18) 280744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas static class TextViewCompatApi18Impl extends TextViewCompatApi17Impl { 28131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Override 28231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelative(@NonNull TextView textView, 28331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, 28431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable bottom) { 285744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas textView.setCompoundDrawablesRelative(start, top, end, bottom); 28631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 28731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 28831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Override 28931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView, 29031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, 29131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable bottom) { 292744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom); 29331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 29431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 29531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Override 29631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView, 29739e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, 29839e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov @DrawableRes int bottom) { 299744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom); 30031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 30172c39bd1626ba13fc7dbf8f8d8ed097915c7eedbChris Banes 30272c39bd1626ba13fc7dbf8f8d8ed097915c7eedbChris Banes @Override 30372c39bd1626ba13fc7dbf8f8d8ed097915c7eedbChris Banes public Drawable[] getCompoundDrawablesRelative(@NonNull TextView textView) { 304744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas return textView.getCompoundDrawablesRelative(); 30572c39bd1626ba13fc7dbf8f8d8ed097915c7eedbChris Banes } 30631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 30731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 308c69882cb9b130902c1554ef5d3e3b06d776cd796Alan Viverette @RequiresApi(23) 309744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas static class TextViewCompatApi23Impl extends TextViewCompatApi18Impl { 3100bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov @Override 31139e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov public void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { 312744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas textView.setTextAppearance(resId); 3130bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov } 3140bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov } 3150bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov 316cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @RequiresApi(26) 317cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu static class TextViewCompatApi26Impl extends TextViewCompatApi23Impl { 318cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @Override 319cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public void setAutoSizeTextTypeWithDefaults(TextView textView, int autoSizeTextType) { 320cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu textView.setAutoSizeTextTypeWithDefaults(autoSizeTextType); 321cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 322cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 323cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @Override 324cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public void setAutoSizeTextTypeUniformWithConfiguration( 325cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu TextView textView, 326cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeMinTextSize, 327cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeMaxTextSize, 328cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeStepGranularity, 329cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int unit) throws IllegalArgumentException { 330cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu textView.setAutoSizeTextTypeUniformWithConfiguration( 331cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu autoSizeMinTextSize, autoSizeMaxTextSize, autoSizeStepGranularity, unit); 332cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 333cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 334cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @Override 335cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public void setAutoSizeTextTypeUniformWithPresetSizes(TextView textView, 336cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @NonNull int[] presetSizes, int unit) throws IllegalArgumentException { 337cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu textView.setAutoSizeTextTypeUniformWithPresetSizes(presetSizes, unit); 338cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 339cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 3403d1439637ea0d65aeeb4ddfa8d8545fee42063b6Andrei Stingaceanu @Override 341cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int getAutoSizeTextType(TextView textView) { 342cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return textView.getAutoSizeTextType(); 343cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 344cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 345cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @Override 346cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int getAutoSizeStepGranularity(TextView textView) { 347cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return textView.getAutoSizeStepGranularity(); 348cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 349cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 350cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @Override 351cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int getAutoSizeMinTextSize(TextView textView) { 352cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return textView.getAutoSizeMinTextSize(); 353cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 354cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 355cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @Override 356cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int getAutoSizeMaxTextSize(TextView textView) { 357cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return textView.getAutoSizeMaxTextSize(); 358cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 359cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 360cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @Override 361cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public int[] getAutoSizeTextAvailableSizes(TextView textView) { 362cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return textView.getAutoSizeTextAvailableSizes(); 363cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 364cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 365cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 366744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas static final TextViewCompatBaseImpl IMPL; 36731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 36831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki static { 369cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu if (Build.VERSION.SDK_INT >= 26) { 370cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu IMPL = new TextViewCompatApi26Impl(); 371cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } else if (Build.VERSION.SDK_INT >= 23) { 372744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas IMPL = new TextViewCompatApi23Impl(); 373744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } else if (Build.VERSION.SDK_INT >= 18) { 374744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas IMPL = new TextViewCompatApi18Impl(); 375744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } else if (Build.VERSION.SDK_INT >= 17) { 376744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas IMPL = new TextViewCompatApi17Impl(); 377744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas } else if (Build.VERSION.SDK_INT >= 16) { 378744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas IMPL = new TextViewCompatApi16Impl(); 37931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } else { 380744f0b5067100b2f32d970e213cad0cc61602adcAurimas Liutikas IMPL = new TextViewCompatBaseImpl(); 38131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 38231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 38331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 38431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki /** 38531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Sets the Drawables (if any) to appear to the start of, above, to the end 38631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * of, and below the text. Use {@code null} if you do not want a Drawable 38731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * there. The Drawables must already have had {@link Drawable#setBounds} 38831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * called. 38931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * <p/> 39031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Calling this method will overwrite any Drawables previously set using 39131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * {@link TextView#setCompoundDrawables} or related methods. 39231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * 39331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * @param textView The TextView against which to invoke the method. 394929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableStart 395929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableTop 396929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableEnd 397929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableBottom 39831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki */ 39931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public static void setCompoundDrawablesRelative(@NonNull TextView textView, 40031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, 40131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable bottom) { 40231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki IMPL.setCompoundDrawablesRelative(textView, start, top, end, bottom); 40331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 40431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 40531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki /** 40631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Sets the Drawables (if any) to appear to the start of, above, to the end 40731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * of, and below the text. Use {@code null} if you do not want a Drawable 40831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * there. The Drawables' bounds will be set to their intrinsic bounds. 40931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * <p/> 41031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Calling this method will overwrite any Drawables previously set using 41131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * {@link TextView#setCompoundDrawables} or related methods. 41231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * 41331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * @param textView The TextView against which to invoke the method. 414929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableStart 415929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableTop 416929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableEnd 417929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableBottom 41831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki */ 41931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public static void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView, 42031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable start, @Nullable Drawable top, @Nullable Drawable end, 42131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki @Nullable Drawable bottom) { 42231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki IMPL.setCompoundDrawablesRelativeWithIntrinsicBounds(textView, start, top, end, bottom); 42331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 42431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 42531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki /** 42631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Sets the Drawables (if any) to appear to the start of, above, to the end 42731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * of, and below the text. Use 0 if you do not want a Drawable there. The 42831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Drawables' bounds will be set to their intrinsic bounds. 42931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * <p/> 43031a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * Calling this method will overwrite any Drawables previously set using 43131a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * {@link TextView#setCompoundDrawables} or related methods. 43231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * 43331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * @param textView The TextView against which to invoke the method. 43431a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * @param start Resource identifier of the start Drawable. 43531a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * @param top Resource identifier of the top Drawable. 43631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * @param end Resource identifier of the end Drawable. 43731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki * @param bottom Resource identifier of the bottom Drawable. 438929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableStart 439929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableTop 440929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableEnd 441929f27aab7ac7231f3734c988d5ee7201627d535Alan Viverette * @attr name android:drawableBottom 44231a49efe2adb59e31611f6871895a3243d835127Yuichi Araki */ 44331a49efe2adb59e31611f6871895a3243d835127Yuichi Araki public static void setCompoundDrawablesRelativeWithIntrinsicBounds(@NonNull TextView textView, 44439e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, 44539e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov @DrawableRes int bottom) { 44631a49efe2adb59e31611f6871895a3243d835127Yuichi Araki IMPL.setCompoundDrawablesRelativeWithIntrinsicBounds(textView, start, top, end, bottom); 44731a49efe2adb59e31611f6871895a3243d835127Yuichi Araki } 44831a49efe2adb59e31611f6871895a3243d835127Yuichi Araki 449092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes /** 450092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes * Returns the maximum number of lines displayed in the given TextView, or -1 if the maximum 451092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes * height was set in pixels instead. 452092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes */ 453092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes public static int getMaxLines(@NonNull TextView textView) { 454092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes return IMPL.getMaxLines(textView); 455092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes } 456092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes 457092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes /** 458092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes * Returns the minimum number of lines displayed in the given TextView, or -1 if the minimum 459092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes * height was set in pixels instead. 460092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes */ 461092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes public static int getMinLines(@NonNull TextView textView) { 462092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes return IMPL.getMinLines(textView); 463092bd179f5a24c29a63717ce69c6d4065e33abe6Chris Banes } 4640bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov 4650bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov /** 4660bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov * Sets the text appearance from the specified style resource. 4670bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov * <p> 4680bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov * Use a framework-defined {@code TextAppearance} style like 4699562a3b639225d406d736b64a12e2d75459259e3Alan Viverette * {@link android.R.style#TextAppearance_Material_Body1 @android:style/TextAppearance.Material.Body1}. 4700bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov * 4710bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov * @param textView The TextView against which to invoke the method. 4720bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov * @param resId The resource identifier of the style to apply. 4730bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov */ 47439e84476b45f10ed4929e307372d6f7a2103e9d5Kirill Grouchnikov public static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { 4750bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov IMPL.setTextAppearance(textView, resId); 4760bd3435d26a1c5daa0d205324c327dee4992bfbeKirill Grouchnikov } 477ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes 478ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes /** 479ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes * Returns drawables for the start, top, end, and bottom borders from the given text view. 480ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes */ 481ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes public static Drawable[] getCompoundDrawablesRelative(@NonNull TextView textView) { 482bf14265885d1cb7ecd6db9b0109a8b033181747bAndrei Stingaceanu return IMPL.getCompoundDrawablesRelative(textView); 483ddf46923b9487ac3a021f01b55d96136d811e8beChris Banes } 484cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 485cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 486cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * Specify whether this widget should automatically scale the text to try to perfectly fit 487cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * within the layout bounds by using the default auto-size configuration. 488cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 489cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @param autoSizeTextType the type of auto-size. Must be one of 490cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * {@link TextViewCompat#AUTO_SIZE_TEXT_TYPE_NONE} or 491cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * {@link TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM} 492cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 493cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeTextType 494cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 495cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static void setAutoSizeTextTypeWithDefaults(TextView textView, int autoSizeTextType) { 496cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu IMPL.setAutoSizeTextTypeWithDefaults(textView, autoSizeTextType); 497cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 498cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 499cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 500cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * Specify whether this widget should automatically scale the text to try to perfectly fit 501cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * within the layout bounds. If all the configuration params are valid the type of auto-size is 502cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * set to {@link TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM}. 503cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 504cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @param autoSizeMinTextSize the minimum text size available for auto-size 505cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @param autoSizeMaxTextSize the maximum text size available for auto-size 506cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @param autoSizeStepGranularity the auto-size step granularity. It is used in conjunction with 507cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * the minimum and maximum text size in order to build the set of 508cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * text sizes the system uses to choose from when auto-sizing 509cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @param unit the desired dimension unit for all sizes above. See {@link TypedValue} for the 510cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * possible dimension units 511cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 512cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @throws IllegalArgumentException if any of the configuration params are invalid. 513cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 514cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeTextType 515cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeTextType 516cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeMinTextSize 517cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeMaxTextSize 518cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeStepGranularity 519cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 520cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static void setAutoSizeTextTypeUniformWithConfiguration( 521cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu TextView textView, 522cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeMinTextSize, 523cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeMaxTextSize, 524cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int autoSizeStepGranularity, 525cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu int unit) throws IllegalArgumentException { 526cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu IMPL.setAutoSizeTextTypeUniformWithConfiguration(textView, autoSizeMinTextSize, 527cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu autoSizeMaxTextSize, autoSizeStepGranularity, unit); 528cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 529cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 530cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 531cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * Specify whether this widget should automatically scale the text to try to perfectly fit 532cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * within the layout bounds. If at least one value from the <code>presetSizes</code> is valid 533cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * then the type of auto-size is set to {@link TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM}. 534cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 535cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @param presetSizes an {@code int} array of sizes in pixels 536cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @param unit the desired dimension unit for the preset sizes above. See {@link TypedValue} for 537cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * the possible dimension units 538cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 539cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @throws IllegalArgumentException if all of the <code>presetSizes</code> are invalid. 540cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu *_ 541cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeTextType 542cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizePresetSizes 543cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 544cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static void setAutoSizeTextTypeUniformWithPresetSizes(TextView textView, 545cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu @NonNull int[] presetSizes, int unit) throws IllegalArgumentException { 546cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu IMPL.setAutoSizeTextTypeUniformWithPresetSizes(textView, presetSizes, unit); 547cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 548cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 549cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 550cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * Returns the type of auto-size set for this widget. 551cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 552cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @return an {@code int} corresponding to one of the auto-size types: 553cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * {@link TextViewCompat#AUTO_SIZE_TEXT_TYPE_NONE} or 554cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * {@link TextViewCompat#AUTO_SIZE_TEXT_TYPE_UNIFORM} 555cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 556cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeTextType 557cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 558cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static int getAutoSizeTextType(TextView textView) { 559cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return IMPL.getAutoSizeTextType(textView); 560cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 561cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 562cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 563cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @return the current auto-size step granularity in pixels. 564cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 565cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeStepGranularity 566cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 567cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static int getAutoSizeStepGranularity(TextView textView) { 568cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return IMPL.getAutoSizeStepGranularity(textView); 569cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 570cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 571cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 572cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @return the current auto-size minimum text size in pixels (the default is 12sp). Note that 573cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * if auto-size has not been configured this function returns {@code -1}. 574cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 575cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeMinTextSize 576cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 577cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static int getAutoSizeMinTextSize(TextView textView) { 578cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return IMPL.getAutoSizeMinTextSize(textView); 579cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 580cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 581cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 582cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @return the current auto-size maximum text size in pixels (the default is 112sp). Note that 583cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * if auto-size has not been configured this function returns {@code -1}. 584cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 585cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizeMaxTextSize 586cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 587cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static int getAutoSizeMaxTextSize(TextView textView) { 588cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return IMPL.getAutoSizeMaxTextSize(textView); 589cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 590cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu 591cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu /** 592cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @return the current auto-size {@code int} sizes array (in pixels). 593cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * 594cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu * @attr name android:autoSizePresetSizes 595cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu */ 596cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu public static int[] getAutoSizeTextAvailableSizes(TextView textView) { 597cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu return IMPL.getAutoSizeTextAvailableSizes(textView); 598cc93b432d3b66d1127b1d71cf1b95eb8a21ef319Andrei Stingaceanu } 59931a49efe2adb59e31611f6871895a3243d835127Yuichi Araki} 600