mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Add search view extension for incognito keyboards.
This commit is contained in:
committed by
Cody Henthorne
parent
5c3ea712fe
commit
99ae7c5961
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import android.widget.EditText
|
||||
import androidx.appcompat.widget.SearchView
|
||||
|
||||
/**
|
||||
* Since this value is only supported on API26+ we hard-code it here
|
||||
@@ -14,7 +15,19 @@ private const val INCOGNITO_KEYBOARD = 16777216
|
||||
* be respected by all IMEs.
|
||||
*/
|
||||
fun EditText.setIncognitoKeyboardEnabled(isIncognitoKeyboardEnabled: Boolean) {
|
||||
imeOptions = if (isIncognitoKeyboardEnabled) {
|
||||
imeOptions = setIncognitoFlag(imeOptions, isIncognitoKeyboardEnabled)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables incognito-mode for the keyboard. Note that this might not
|
||||
* be respected by all IMEs.
|
||||
*/
|
||||
fun SearchView.setIncognitoKeyboardEnabled(isIncognitoKeyboardEnabled: Boolean) {
|
||||
imeOptions = setIncognitoFlag(imeOptions, isIncognitoKeyboardEnabled)
|
||||
}
|
||||
|
||||
private fun setIncognitoFlag(imeOptions: Int, isIncognitoKeyboardEnabled: Boolean): Int {
|
||||
return if (isIncognitoKeyboardEnabled) {
|
||||
imeOptions or INCOGNITO_KEYBOARD
|
||||
} else {
|
||||
imeOptions and INCOGNITO_KEYBOARD.inv()
|
||||
|
||||
Reference in New Issue
Block a user