mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Convert ContactFilterView to compose.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user