Hide Incognito Keyboard setting on unsupported devices

This commit is contained in:
Tomáš Beňo 2022-09-25 14:56:20 +02:00
parent e5cf431cc7
commit 079a2f5351
3 changed files with 18 additions and 1 deletions

View File

@ -1536,7 +1536,9 @@ class TimelineFragment :
observerUserTyping()
composerEditText.setUseIncognitoKeyboard(vectorPreferences.useIncognitoKeyboard())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
composerEditText.setUseIncognitoKeyboard(vectorPreferences.useIncognitoKeyboard())
}
composerEditText.setSendMessageWithEnter(vectorPreferences.sendMessageWithEnter())
composerEditText.setOnEditorActionListener { v, actionId, keyEvent ->

View File

@ -20,10 +20,12 @@ package im.vector.app.features.home.room.detail.composer
import android.content.ClipData
import android.content.Context
import android.net.Uri
import android.os.Build
import android.text.Editable
import android.util.AttributeSet
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputConnection
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.AppCompatEditText
import androidx.core.view.OnReceiveContentListener
import androidx.core.view.ViewCompat
@ -80,6 +82,7 @@ class ComposerEditText @JvmOverloads constructor(
}
/** Set whether the keyboard should disable personalized learning. */
@RequiresApi(Build.VERSION_CODES.O)
fun setUseIncognitoKeyboard(useIncognitoKeyboard: Boolean) {
imeOptions = if (useIncognitoKeyboard) {
imeOptions or EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING

View File

@ -20,6 +20,7 @@ package im.vector.app.features.settings
import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -160,6 +161,10 @@ class VectorSettingsSecurityPrivacyFragment :
findPreference<VectorSwitchPreference>("SETTINGS_USER_ANALYTICS_CONSENT_KEY")!!
}
private val incognitoKeyboardPref by lazy {
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_SECURITY_INCOGNITO_KEYBOARD_PREFERENCE_KEY)!!
}
override fun onCreateRecyclerView(inflater: LayoutInflater, parent: ViewGroup, savedInstanceState: Bundle?): RecyclerView {
return super.onCreateRecyclerView(inflater, parent, savedInstanceState).also {
// Insert animation are really annoying the first time the list is shown
@ -275,6 +280,9 @@ class VectorSettingsSecurityPrivacyFragment :
// Analytics
setUpAnalytics()
// Incognito Keyboard
setUpIncognitoKeyboard()
// Pin code
openPinCodeSettingsPref.setOnPreferenceClickListener {
openPinCodePreferenceScreen()
@ -337,6 +345,10 @@ class VectorSettingsSecurityPrivacyFragment :
}
}
private fun setUpIncognitoKeyboard() {
incognitoKeyboardPref.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
}
// Todo this should be refactored and use same state as 4S section
private fun refreshXSigningStatus() {
val crossSigningKeys = session.cryptoService().crossSigningService().getMyCrossSigningKeys()