GetStream / stream-chat-android

:speech_balloon: Android Chat SDK ➜ Stream Chat API. UI component libraries for chat apps. Kotlin & Jetpack Compose messaging SDK for Android chat
https://getstream.io/chat/sdk/android/
Other
1.38k stars 260 forks source link

enableEdgeToEdge hides EditText/TextField on MessagesScreen [Compose] #5304

Open mtali opened 1 week ago

mtali commented 1 week ago

Describe the bug
When edgeToEdge is enabled, the keyboard hides the input EditText/TextField in MessageActivity, making it difficult for users to see what they are typing.

SDK version

To Reproduce
Steps to reproduce the behavior:

  1. Go to MessageActivity.
  2. Enable edgeToEdge in the onCreate method.
  3. Focus on the EditText/TextField to bring up the keyboard.
  4. Observe that the keyboard hides the input field.

Expected behavior
When the keyboard is displayed, the EditText/TextField should remain visible, adjusting the layout so that users can see what they are typing.

Device:

Code Snippet

class MessageActivity : ComponentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    enableEdgeToEdge() // <------------------- REMOVING THIS FIXES THE ISSUE BUT I NEED IT
    val extras = checkNotNull(intent.extras)
    val channelId = extras.getString(CHANNEL_ID_KEY) ?: error("Null channelId")

    setContent {
      ChatTheme {
        Scaffold { innerPadding ->
          Box(modifier = Modifier.padding(innerPadding)) {
            MessagesScreen(
              viewModelFactory = MessagesViewModelFactory(
                context = this@MessageActivity,
                channelId = channelId,
                messageLimit = 30,
              ),
              onBackPressed = { onBackPressedDispatcher.onBackPressed() },
            )
          }
        }
      }
    }
  }

  companion object {
    private const val CHANNEL_ID_KEY = "channelId"

    fun launch(context: Context, channelId: String) {
      val intent = Intent(context, MessageActivity::class.java)
      intent.putExtra(CHANNEL_ID_KEY, channelId)
      context.startActivity(intent)
    }
  }
}

AndroidManifest.xml

<activity
  android:name=".chat.MessageActivity"
  android:exported="false"
  android:windowSoftInputMode="adjustResize"
/>

Build Configuration

const val COMPILE_SDK = 34
const val TARGET_SDK = 34
const val MIN_SDK = 27

Screenshots

WhatsApp Image 2024-06-23 at 23 45 52

WhatsApp Image 2024-06-23 at 23 49 29

mtali commented 1 week ago

I have also tried adding enableEdgeToEdge() on BaseConnectedActivity here stream-chat-android-compose-sample, same thing happens

aleksandar-apostolov commented 6 days ago

Hey @mtali thank you for the report, we already looking into this, will keep you posted.

mtali commented 4 days ago

Hello @aleksandar-apostolov , thanks for your response. After some digging I found out that the solution is to add .imePadding() on MessageInput. I also think a good idea to add some safe padding on MessageInput (Maybe)

MessageInput(
        modifier = Modifier
          .fillMaxWidth()
          .imePadding()
          .weight(7f)
          .padding(start = 8.dp)