# EmojiTextViewHelper

# EmojiTextViewHelper

Artifact:[androidx.emoji:emoji](https://developer.android.com/jetpack/androidx/releases/emoji)  
[View Source](https://cs.android.com/search?q=file:androidx/emoji/widget/EmojiTextViewHelper.java+class:androidx.emoji.widget.EmojiTextViewHelper)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/emoji/widget/EmojiTextViewHelper "View this page in Java")

<br />

```
class EmojiTextViewHelper
```

<br />

*** ** * ** ***

Utility class to enhance custom TextView widgets with[EmojiCompat](https://developer.android.com/reference/kotlin/androidx/emoji/text/EmojiCompat).  

```kotlin
public class MyEmojiTextView extends TextView {
    public MyEmojiTextView(Context context) {
        super(context);
        init();
    }
    // ..
    private void init() {
        getEmojiTextViewHelper().updateTransformationMethod();
    }

    @Override
    public void setFilters(InputFilter[] filters) {
        super.setFilters(getEmojiTextViewHelper().getFilters(filters));
    }

    @Override
    public void setAllCaps(boolean allCaps) {
        super.setAllCaps(allCaps);
        getEmojiTextViewHelper().setAllCaps(allCaps);
    }

    private EmojiTextViewHelper getEmojiTextViewHelper() {
        if (mEmojiTextViewHelper == null) {
            mEmojiTextViewHelper = new EmojiTextViewHelper(this);
        }
        return mEmojiTextViewHelper;
    }
}
```

## Summary

|                                                                                                                              ### Public constructors                                                                                                                              |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [EmojiTextViewHelper](https://developer.android.com/reference/kotlin/androidx/emoji/widget/EmojiTextViewHelper#EmojiTextViewHelper(android.widget.TextView))`(textView: `[TextView](https://developer.android.com/reference/android/widget/TextView.html)`)` Default constructor. |

|                                                                            ### Public functions                                                                            |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[InputFilter](https://developer.android.com/reference/android/text/InputFilter.html)`!>` | [getFilters](https://developer.android.com/reference/kotlin/androidx/emoji/widget/EmojiTextViewHelper#getFilters(android.text.InputFilter[]))`(filters: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[InputFilter](https://developer.android.com/reference/android/text/InputFilter.html)`!>)` Appends EmojiCompat InputFilters to the widget InputFilters.                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                              | [setAllCaps](https://developer.android.com/reference/kotlin/androidx/emoji/widget/EmojiTextViewHelper#setAllCaps(boolean))`(allCaps: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Call when allCaps is set on TextView.                                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                              | [updateTransformationMethod](https://developer.android.com/reference/kotlin/androidx/emoji/widget/EmojiTextViewHelper#updateTransformationMethod())`()` Updates widget's TransformationMethod so that the transformed text can be processed.                                                                                                                                                                            |
| [TransformationMethod](https://developer.android.com/reference/android/text/method/TransformationMethod.html)`?`                                                           | [wrapTransformationMethod](https://developer.android.com/reference/kotlin/androidx/emoji/widget/EmojiTextViewHelper#wrapTransformationMethod(android.text.method.TransformationMethod))`(transformationMethod: `[TransformationMethod](https://developer.android.com/reference/android/text/method/TransformationMethod.html)`?)` Returns transformation method that can update the transformed text to display emojis. |

## Public constructors

### EmojiTextViewHelper

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
EmojiTextViewHelper(textView: TextView)
```

Default constructor.  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|-------------------|
| `textView: `[TextView](https://developer.android.com/reference/android/widget/TextView.html) | TextView instance |

## Public functions

### getFilters

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun getFilters(filters: Array<InputFilter!>): Array<InputFilter!>
```

Appends EmojiCompat InputFilters to the widget InputFilters. Should be called by[setFilters](https://developer.android.com/reference/android/widget/TextView.html#setFilters(android.text.InputFilter[]))to update the InputFilters. When used on devices running API 18 or below, this method returns`filters`that is given as a parameter.  

|                                                                                      Parameters                                                                                       |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `filters: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[InputFilter](https://developer.android.com/reference/android/text/InputFilter.html)`!>` | InputFilter array passed to[setFilters](https://developer.android.com/reference/android/widget/TextView.html#setFilters(android.text.InputFilter[])) |

|                                                                                  Returns                                                                                   |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[InputFilter](https://developer.android.com/reference/android/text/InputFilter.html)`!>` | same copy if the array already contains EmojiCompat InputFilter. A new array copy if not. |

### setAllCaps

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun setAllCaps(allCaps: Boolean): Unit
```

Call when allCaps is set on TextView. When used on devices running API 18 or below, this method does nothing.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `allCaps: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | allCaps parameter passed to[setAllCaps](https://developer.android.com/reference/android/widget/TextView.html#setAllCaps(boolean)) |

### updateTransformationMethod

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun updateTransformationMethod(): Unit
```

Updates widget's TransformationMethod so that the transformed text can be processed. Should be called in the widget constructor. When used on devices running API 18 or below, this method does nothing.  

|                                                                                        See also                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [wrapTransformationMethod](https://developer.android.com/reference/kotlin/androidx/emoji/widget/EmojiTextViewHelper#wrapTransformationMethod(android.text.method.TransformationMethod)) |   |

### wrapTransformationMethod

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/emoji#1.0.0)  

```
fun wrapTransformationMethod(transformationMethod: TransformationMethod?): TransformationMethod?
```

Returns transformation method that can update the transformed text to display emojis. When used on devices running API 18 or below, this method returns`transformationMethod`that is given as a parameter.  

|                                                                Parameters                                                                |
|------------------------------------------------------------------------------------------------------------------------------------------|------------------------|
| `transformationMethod: `[TransformationMethod](https://developer.android.com/reference/android/text/method/TransformationMethod.html)`?` | instance to be wrapped |