Convert ContactFilterView to compose.

This commit is contained in:
jeffrey-signal
2025-10-27 17:58:19 -04:00
committed by GitHub
parent c316381159
commit 963a72a660
7 changed files with 262 additions and 69 deletions

View File

@@ -27,9 +27,10 @@ import org.thoughtcrime.securesms.util.ViewUtil;
/**
* A search input field for finding recipients.
* <p>
* In compose, use RecipientSearchField instead.
*
* @deprecated Use the RecipientSearchBar composable instead.
*/
@Deprecated
public final class ContactFilterView extends FrameLayout {
private OnFilterChangedListener listener;

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2025 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.components.compose
import android.os.Build
import android.view.inputmethod.EditorInfo
import androidx.compose.runtime.Composable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.platform.InterceptPlatformTextInput
import androidx.compose.ui.platform.PlatformTextInputMethodRequest
/**
* When [enabled]=true, this function sets the [EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING] flag for all text fields within its content to enable the
* incognito keyboard.
*
* This workaround is needed until it's possible to configure granular IME options for a [TextField].
* https://issuetracker.google.com/issues/359257538
*/
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun ProvideIncognitoKeyboard(
enabled: Boolean,
content: @Composable () -> Unit
) {
if (enabled) {
InterceptPlatformTextInput(
interceptor = { request, nextHandler ->
val modifiedRequest = PlatformTextInputMethodRequest { outAttributes ->
request.createInputConnection(outAttributes).also {
if (Build.VERSION.SDK_INT >= 26) {
outAttributes.imeOptions = outAttributes.imeOptions or EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING
}
}
}
nextHandler.startInputMethod(modifiedRequest)
}
) {
content()
}
} else {
content()
}
}