Created
April 22, 2019 08:39
-
-
Save tizisdeepan/319eabc8d8112e79ebd9d9f4c351db40 to your computer and use it in GitHub Desktop.
EditText that ignores GIF support from Google Keypad.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import androidx.core.view.inputmethod.EditorInfoCompat | |
import androidx.core.view.inputmethod.InputConnectionCompat | |
import androidx.appcompat.widget.AppCompatEditText | |
import android.util.AttributeSet | |
import android.view.inputmethod.EditorInfo | |
import android.view.inputmethod.InputConnection | |
import android.widget.Toast | |
import com.zoho.zohosocial.utils.RunOnUiThread | |
class NoGifEditText @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle) : AppCompatEditText(context, attrs, defStyleAttr) { | |
override fun onCreateInputConnection(editorInfo: EditorInfo): InputConnection { | |
val ic = super.onCreateInputConnection(editorInfo) | |
EditorInfoCompat.setContentMimeTypes(editorInfo, arrayOf("image/*", "image/png", "image/jpeg")) | |
return InputConnectionCompat.createWrapper(ic, editorInfo) { inputContentInfo, flags, opt -> | |
Toast.makeText(context, "This media is not supported.", Toast.LENGTH_SHORT).show() | |
true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment