<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dmytro Batyuk on Medium]]></title>
        <description><![CDATA[Stories by Dmytro Batyuk on Medium]]></description>
        <link>https://medium.com/@dimabatyuk?source=rss-23adb288c911------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yi25_YSsReuM71tggNlHYA.jpeg</url>
            <title>Stories by Dmytro Batyuk on Medium</title>
            <link>https://medium.com/@dimabatyuk?source=rss-23adb288c911------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:39:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dimabatyuk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sharing private data with other apps on Android]]></title>
            <link>https://medium.com/@dimabatyuk/sharing-private-data-with-other-apps-on-android-718d7598c447?source=rss-23adb288c911------2</link>
            <guid isPermaLink="false">https://medium.com/p/718d7598c447</guid>
            <category><![CDATA[document-preview]]></category>
            <category><![CDATA[contentprovider]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[fileprovider]]></category>
            <dc:creator><![CDATA[Dmytro Batyuk]]></dc:creator>
            <pubDate>Fri, 19 Apr 2019 15:25:47 GMT</pubDate>
            <atom:updated>2019-04-19T15:25:47.581Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post consists of two parts:</p><ol><li>short overview of why and how to cache files in an app (you could skip that part if you familiar with it)</li><li>share private cached files with other apps</li></ol><h3>Short overview of why and how to cache files in an app (you could skip that part if you familiar with it)</h3><h4>Why do we need cache files</h4><p>Good practice for Android apps is to cache files locally instead of loading it from network every time app needs them. This approach decreases network usage, battery draining and speedup showing results to the user.</p><h4>How could we cache files</h4><p>All files could be cached:</p><ol><li>in public (not sensitive data):</li></ol><ul><li>downloaded photos and documents from public access</li><li>application assets</li></ul><p>2. private (sensitive data):</p><ul><li>private photos and documents</li><li>HIPAA compliance files</li></ul><p>Android system provides mechanism to save public data in <a href="https://developer.android.com/guide/topics/data/data-storage#filesExternal">external storage</a> and private data in <a href="https://developer.android.com/guide/topics/data/data-storage#filesInternal">internal storage</a>.</p><h4>What we can do with cached files</h4><p>Cached files could be used in app like playing audio, placing raw data into UI like OpenGL data etc.</p><p>Also it could be the case when external preview app is required to preview files like doc, pdf, xls.</p><p>For that case file should be shared with another app. If the file is stored in external (public) storage it won’t be a problem because it’s public accessible. But if the file is cached in internal (private) storage it requires some additional work to do and we are coming to second part of the post.</p><h3>Share private cached files with other apps</h3><p>Private files are shared within <a href="https://developer.android.com/reference/android/support/v4/content/FileProvider.html">FileProvider</a>. We will use default implementation but if you need to add additional logic FileProvider class could be extended and <em>openFile </em>method could be overridden for that purpose.</p><p>To do that we need to complete few steps:</p><p>1.Adding default FileProvider to the manifest file where:</p><ul><li>applicationId<em> — </em>is going to be replaced to package name automatically</li><li>androidx.core.content.FileProvider — default FileProvider implementation (if you want to use our own FileProvider — use pass it here instead of default)</li><li>meta-data — contains path to resource file where access permissions are described and it’ll be next step</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9131b7f139e5d111ad3bb5f54c32225/href">https://medium.com/media/a9131b7f139e5d111ad3bb5f54c32225/href</a></iframe><p>2.Adding <em>file_paths</em><strong> </strong>file to res/xml folder with described permissions where:</p><ul><li>files-path — means to use internal (private) storage</li><li>name — represent alias which will be used in generated Uri</li><li>path — folder name which is placed in root of internal storage ( “.” could be used if want to use rood folder instead)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89304fdf01bbc9df9d5bffde0123064e/href">https://medium.com/media/89304fdf01bbc9df9d5bffde0123064e/href</a></iframe><p>3.Performing preview or send the file via email with supported app, where:</p><ul><li>previewFile — method is called to preview the file</li><li>sendFile — method is used to send file via email</li><li>line#52 — “.fileprovider” matches with authorities in line#16 in Manifest file</li><li>line#58 — “attachments” matches with line#3 in file_paths.xml file</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d7b74a51d0b069013b889829ad076fb/href">https://medium.com/media/4d7b74a51d0b069013b889829ad076fb/href</a></iframe><p>Hope you enjoy this reading and have a nice day!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5qpN3kFEICfhTBhQ" /><figcaption>Photo by <a href="https://unsplash.com/@shaka?utm_source=medium&amp;utm_medium=referral">Justin Young</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=718d7598c447" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding clear button to EditText]]></title>
            <link>https://medium.com/@dimabatyuk/adding-clear-button-to-edittext-9655e9dbb721?source=rss-23adb288c911------2</link>
            <guid isPermaLink="false">https://medium.com/p/9655e9dbb721</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[material-design]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Dmytro Batyuk]]></dc:creator>
            <pubDate>Mon, 02 Jul 2018 14:25:41 GMT</pubDate>
            <atom:updated>2019-04-25T10:26:14.297Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post I’m going to show you how to add clear button to EditText.<br>In result we will have next functionality:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*OVVtHLX_P6YEOQ56KQArbQ.gif" /></figure><h3>Starting with simple project</h3><p>Let’s start from creating layout with <a href="https://github.com/DmytroBatyuk/Clearable-EditText-Implementation/blob/EditText_without_clear_button/app/src/main/res/layout/activity_main.xml">two simple EditText fields</a>. Creating two EditText fields which are username and password inputs:</p><pre><em>&lt;?</em>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;<em>?&gt;<br></em>&lt;ScrollView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    android:fillViewport=&quot;true&quot;&gt;<br><br>    &lt;android.support.constraint.ConstraintLayout<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;wrap_content&quot;&gt;<br><br>        &lt;android.support.v7.widget.AppCompatTextView<br>            android:id=&quot;@+id/title&quot;<br>            android:layout_width=&quot;wrap_content&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginEnd=&quot;8dp&quot;<br>            android:layout_marginStart=&quot;8dp&quot;<br>            android:text=&quot;Login form&quot;<br>            android:textSize=&quot;26dp&quot;<br>            app:layout_constraintBottom_toTopOf=&quot;@+id/username_input_layout&quot;<br>            app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>            app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>            app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;<br><br>        &lt;android.support.design.widget.TextInputLayout<br>            android:id=&quot;@+id/username_input_layout&quot;<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginEnd=&quot;8dp&quot;<br>            android:layout_marginStart=&quot;8dp&quot;<br>            app:layout_constraintBottom_toTopOf=&quot;@+id/password_input_layout&quot;<br>            app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>            app:layout_constraintHorizontal_bias=&quot;0.0&quot;<br>            app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>            app:layout_constraintTop_toBottomOf=&quot;@+id/title&quot;&gt;<br><br>            <strong>&lt;android.support.v7.widget.AppCompatEditText<br>                android:id=&quot;@+id/username_text&quot;<br>                android:layout_width=&quot;match_parent&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                android:hint=&quot;Username&quot; /&gt;</strong><br>        &lt;/android.support.design.widget.TextInputLayout&gt;<br><br>        &lt;android.support.design.widget.TextInputLayout<br>            android:id=&quot;@+id/password_input_layout&quot;<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginEnd=&quot;8dp&quot;<br>            android:layout_marginStart=&quot;8dp&quot;<br>            app:layout_constraintBottom_toTopOf=&quot;@+id/loginButton&quot;<br>            app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>            app:layout_constraintHorizontal_bias=&quot;0.0&quot;<br>            app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>            app:layout_constraintTop_toBottomOf=&quot;@+id/username_input_layout&quot;&gt;<br><br>            <strong>&lt;android.support.v7.widget.AppCompatEditText<br>                android:id=&quot;@+id/password_text&quot;<br>                android:layout_width=&quot;match_parent&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                android:inputType=&quot;textPassword&quot;<br>                android:hint=&quot;Password&quot; /&gt;</strong><br>        &lt;/android.support.design.widget.TextInputLayout&gt;<br><br>        &lt;android.support.v7.widget.AppCompatButton<br>            android:id=&quot;@+id/loginButton&quot;<br>            android:layout_width=&quot;0dp&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginEnd=&quot;8dp&quot;<br>            android:layout_marginStart=&quot;8dp&quot;<br>            android:text=&quot;Login&quot;<br>            app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>            app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>            app:layout_constraintHorizontal_bias=&quot;0.0&quot;<br>            app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>            app:layout_constraintTop_toBottomOf=&quot;@+id/password_input_layout&quot; /&gt;<br><br>    &lt;/android.support.constraint.ConstraintLayout&gt;<br>&lt;/ScrollView&gt;</pre><p>In result we will see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*fuBN4uOxFMx6IRcwoN11Yg.gif" /></figure><h3>Adding vector drawable to the project</h3><p>Fist of all we need to add clear icon to Android project. Fortunately <a href="https://developer.android.com/studio/write/vector-asset-studio#running">Android Studio provides out of the box functionality to do that</a>.</p><p>Find <strong>cancel</strong> icon in search. You could change color on vector icon you are going to add but don’t forget to change icon name suffix from black to color you have selected ;)</p><h3>Adding right icon to EditText</h3><p>Android SDK allows us to add <a href="https://developer.android.com/reference/android/widget/TextView#setCompoundDrawables(android.graphics.drawable.Drawable,%20android.graphics.drawable.Drawable,%20android.graphics.drawable.Drawable,%20android.graphics.drawable.Drawable)">compound drawables</a> to left, right, top and bottom to TextView. EditText is TextView inheritor which means we can use compounds drawables with first also.</p><p>There are two ways to add right drawable: inside xml layout and within code. Lets look detail to both of them:</p><ul><li>inside xml layout file:</li></ul><pre><em>&lt;?</em>xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;<em>?&gt;<br></em>&lt;ScrollView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    android:fillViewport=&quot;true&quot;&gt;<br><br>    &lt;android.support.constraint.ConstraintLayout<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;wrap_content&quot;&gt;<br><br>        &lt;android.support.v7.widget.AppCompatTextView<br>            android:id=&quot;@+id/title&quot;<br>            android:layout_width=&quot;wrap_content&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginEnd=&quot;8dp&quot;<br>            android:layout_marginStart=&quot;8dp&quot;<br>            android:text=&quot;Login form&quot;<br>            android:textSize=&quot;26dp&quot;<br>            app:layout_constraintBottom_toTopOf=&quot;@+id/username_input_layout&quot;<br>            app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>            app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>            app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;<br><br>        &lt;android.support.design.widget.TextInputLayout<br>            android:id=&quot;@+id/username_input_layout&quot;<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginEnd=&quot;8dp&quot;<br>            android:layout_marginStart=&quot;8dp&quot;<br>            app:layout_constraintBottom_toTopOf=&quot;@+id/password_input_layout&quot;<br>            app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>            app:layout_constraintHorizontal_bias=&quot;0.0&quot;<br>            app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>            app:layout_constraintTop_toBottomOf=&quot;@+id/title&quot;&gt;<br><br>            &lt;android.support.v7.widget.AppCompatEditText<br>                android:id=&quot;@+id/username_text&quot;<br>                android:layout_width=&quot;match_parent&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                <strong>android:drawableRight=&quot;@drawable/ic_cancel_black_24dp&quot;</strong><br>                android:hint=&quot;Username&quot; /&gt;<br>        &lt;/android.support.design.widget.TextInputLayout&gt;<br><br>        &lt;android.support.design.widget.TextInputLayout<br>            android:id=&quot;@+id/password_input_layout&quot;<br>            android:layout_width=&quot;match_parent&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginEnd=&quot;8dp&quot;<br>            android:layout_marginStart=&quot;8dp&quot;<br>            app:layout_constraintBottom_toTopOf=&quot;@+id/loginButton&quot;<br>            app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>            app:layout_constraintHorizontal_bias=&quot;0.0&quot;<br>            app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>            app:layout_constraintTop_toBottomOf=&quot;@+id/username_input_layout&quot;&gt;<br><br>            &lt;android.support.v7.widget.AppCompatEditText<br>                android:id=&quot;@+id/password_text&quot;<br>                android:layout_width=&quot;match_parent&quot;<br>                android:layout_height=&quot;wrap_content&quot;<br>                <strong>android:drawableRight=&quot;@drawable/ic_cancel_black_24dp&quot;</strong><br>                android:hint=&quot;Password&quot;<br>                android:inputType=&quot;textPassword&quot; /&gt;<br>        &lt;/android.support.design.widget.TextInputLayout&gt;<br><br>        &lt;android.support.v7.widget.AppCompatButton<br>            android:id=&quot;@+id/loginButton&quot;<br>            android:layout_width=&quot;0dp&quot;<br>            android:layout_height=&quot;wrap_content&quot;<br>            android:layout_marginEnd=&quot;8dp&quot;<br>            android:layout_marginStart=&quot;8dp&quot;<br>            android:text=&quot;Login&quot;<br>            app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>            app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>            app:layout_constraintHorizontal_bias=&quot;0.0&quot;<br>            app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>            app:layout_constraintTop_toBottomOf=&quot;@+id/password_input_layout&quot; /&gt;<br><br>    &lt;/android.support.constraint.ConstraintLayout&gt;<br>&lt;/ScrollView&gt;</pre><ul><li>inside native code with introducing method for that named <strong>addRightCancelDrawable</strong>:</li></ul><pre>class MainActivity : AppCompatActivity() {<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.<em>activity_main</em>)<br><br>        <strong>addRightCancelDrawable(findViewById(R.id.<em>username_text</em>))<br>        addRightCancelDrawable(findViewById(R.id.<em>password_text</em>))</strong><br>    }<br><br>    <strong>private fun addRightCancelDrawable(editText: EditText) {<br>        val cancel = ContextCompat.getDrawable(this, R.drawable.<em>ic_cancel_black_24dp</em>)<br>        cancel?.setBounds(0,0, cancel.<em>intrinsicWidth</em>, cancel.<em>intrinsicHeight</em>)<br>        editText.setCompoundDrawables(null, null, cancel, null)<br>    }</strong><br>}</pre><h3>Add interactivity to clear drawable</h3><p>Kotlin is a great language where each class could be extended with new methods. Lets introduce new method for EditText class which will catch clicks to right drawable. For that I create separate <a href="https://github.com/DmytroBatyuk/Clearable-EditText-Implementation/blob/master/app/src/main/java/ua/batyuk/dmytro/clearableedittextimplementation/EditText.kt">Kotlin file</a> with that method:</p><pre>fun EditText.<strong>onRightDrawableClicked</strong>(onClicked: (view: EditText) -&gt; Unit) {<br>    this.setOnTouchListener { v, event -&gt;<br>        var hasConsumed = false<br>        if (v is EditText) {<br>            if (event.x &gt;= v.width - v.totalPaddingRight) {<br>                if (event.action == MotionEvent.ACTION_UP) {<br>                    onClicked(this)<br>                }<br>                hasConsumed = true<br>            }<br>        }<br>        hasConsumed<br>    }<br>}</pre><p>You can see it takes callback function as argument which is called when user clicks to right drawable.</p><p>Lets use that method for username and password EditText views and clear input:</p><pre>class MainActivity : AppCompatActivity() {<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.<em>activity_main</em>)<br><br>        val <strong>username</strong> = findViewById&lt;EditText&gt;(R.id.<em>username_text</em>)<br>        <strong>username.<em>onRightDrawableClicked </em>{<br>            it.<em>text</em>.clear()<br>        }</strong><br><br>        val <strong>password</strong> = findViewById&lt;EditText&gt;(R.id.<em>password_text</em>)<br>        <strong>password.<em>onRightDrawableClicked </em>{<br>            it.<em>text</em>.clear()<br>        }</strong><br>        ...<br>    }<br>    ...<br>}</pre><p>In result we should see that input is cleared when right clear button is clicked:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*VSdbR8zLFDp2_k1S_TVWSA.gif" /></figure><p>Would be better if clear icon disappears when input is empty. Let’s add this.</p><h3>Managing show\hide clear button regarding empty input</h3><p>To do that let’s continue extending EditText class with new function called <strong>makeClearableEditText </strong>which manages showing, hiding clear button. To get more details look at <a href="https://github.com/DmytroBatyuk/Clearable-EditText-Implementation/blob/master/app/src/main/java/ua/batyuk/dmytro/clearableedittextimplementation/EditText.kt#L70">code</a></p><pre>fun EditText.<strong>makeClearableEditText</strong>(<br>    onIsNotEmpty: (() -&gt; Unit)?,<br>    onClear: (() -&gt; Unit)?,<br>    clearDrawable: Drawable<br>) {<br>    val updateRightDrawable = {<br>        this.setCompoundDrawables(null, null,<br>            if (<em>text</em>.<em>isNotEmpty</em>()) clearDrawable else null,<br>            null)<br>    }<br>    updateRightDrawable()<br><br>    this.<em>afterTextChanged </em>{<br>        if (it.<em>isNotEmpty</em>()) {<br>            onIsNotEmpty?.invoke()<br>        }<br>        updateRightDrawable()<br>    }<br>    this.<em>onRightDrawableClicked </em>{<br>        this.<em>text</em>.clear()<br>        this.setCompoundDrawables(null, null, null, null)<br>        onClear?.invoke()<br>        <strong>this.requestFocus()</strong><br>    }<br>}<br><br>private const val <em>COMPOUND_DRAWABLE_RIGHT_INDEX </em>= 2<br><em><br></em>fun EditText.<strong>makeClearableEditText</strong>(onIsNotEmpty: (() -&gt; Unit)?, onCleared: (() -&gt; Unit)?) {<br>    <em>compoundDrawables</em>[<em>COMPOUND_DRAWABLE_RIGHT_INDEX</em>]?.<em>let </em>{ clearDrawable -&gt;<br>        <em>makeClearableEditText</em>(onIsNotEmpty, onCleared, clearDrawable)<br>    }<br>}</pre><p>There is function overriding. First one with <strong>clearDrawable</strong> argument uses that drawable as clear drawable. Second function implementation finds right compound drawable and use it as clearDrawable if drawable exists.</p><p>Both functions have <strong>onIsNotEmpty</strong> and <strong>onCleared</strong> callbacks which are called when input is not empty and when input is cleared with clear button regardlessly. They are not used in that post but might be useful in future :).</p><p>Also you can find that <strong>this.requestFocus </strong>has been added. It request focus of EditText when user clicks to clear icon — it makes user interaction more clear.</p><p>Also some changes are required in activity class:</p><pre>class MainActivity : AppCompatActivity() {<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.activity_main)<br><br>        val username = findViewById&lt;EditText&gt;(R.id.username_text)<br><em>//        username.onRightDrawableClicked {<br>//            it.text.clear()<br>//        }</em><br>        username.<strong>makeClearableEditText</strong>(null, null)<br><br>        val password = findViewById&lt;EditText&gt;(R.id.password_text)<br><em>//        password.onRightDrawableClicked {<br>//            it.text.clear()<br>//        }</em><br>        password.<strong>makeClearableEditText</strong>(null, null)<br>        ...<em><br>    </em>}<br><br>    ...<br>}</pre><p><strong>onRightDrawableClicked </strong>methods are replaced with <strong>makeClearableEditText </strong>methods.</p><h3>Summary</h3><p>It’s not hard to add clear text button to EditText. Also that code could be reused in any place easily with Kotlin class extension functionality.</p><p>Hope you enjoy that article and don’t forget applaud if it was useful for you :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9655e9dbb721" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>