Add search view extension for incognito keyboards.
This commit is contained in:
parent
5c3ea712fe
commit
99ae7c5961
2 changed files with 16 additions and 1 deletions
|
@ -320,6 +320,7 @@ import org.thoughtcrime.securesms.util.hasNonTextSlide
|
||||||
import org.thoughtcrime.securesms.util.isValidReactionTarget
|
import org.thoughtcrime.securesms.util.isValidReactionTarget
|
||||||
import org.thoughtcrime.securesms.util.padding
|
import org.thoughtcrime.securesms.util.padding
|
||||||
import org.thoughtcrime.securesms.util.savedStateViewModel
|
import org.thoughtcrime.securesms.util.savedStateViewModel
|
||||||
|
import org.thoughtcrime.securesms.util.setIncognitoKeyboardEnabled
|
||||||
import org.thoughtcrime.securesms.util.toMillis
|
import org.thoughtcrime.securesms.util.toMillis
|
||||||
import org.thoughtcrime.securesms.util.viewModel
|
import org.thoughtcrime.securesms.util.viewModel
|
||||||
import org.thoughtcrime.securesms.util.views.Stub
|
import org.thoughtcrime.securesms.util.views.Stub
|
||||||
|
@ -3255,6 +3256,7 @@ class ConversationFragment :
|
||||||
|
|
||||||
searchMenuItem!!.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
searchMenuItem!!.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
|
||||||
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
|
||||||
|
searchView.setIncognitoKeyboardEnabled(TextSecurePreferences.isIncognitoKeyboardEnabled(requireContext()))
|
||||||
searchView.setOnQueryTextListener(queryListener)
|
searchView.setOnQueryTextListener(queryListener)
|
||||||
isSearchRequested = true
|
isSearchRequested = true
|
||||||
searchViewModel.onSearchOpened()
|
searchViewModel.onSearchOpened()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.thoughtcrime.securesms.util
|
package org.thoughtcrime.securesms.util
|
||||||
|
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
|
import androidx.appcompat.widget.SearchView
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since this value is only supported on API26+ we hard-code it here
|
* 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.
|
* be respected by all IMEs.
|
||||||
*/
|
*/
|
||||||
fun EditText.setIncognitoKeyboardEnabled(isIncognitoKeyboardEnabled: Boolean) {
|
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
|
imeOptions or INCOGNITO_KEYBOARD
|
||||||
} else {
|
} else {
|
||||||
imeOptions and INCOGNITO_KEYBOARD.inv()
|
imeOptions and INCOGNITO_KEYBOARD.inv()
|
||||||
|
|
Loading…
Add table
Reference in a new issue