mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-24 23:45:19 +00:00
@@ -1,12 +1,15 @@
|
|||||||
package com.bitchat.android
|
package com.bitchat.android
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
@@ -65,6 +68,12 @@ class MainActivity : ComponentActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
// Enable edge-to-edge display for modern Android look
|
||||||
|
enableEdgeToEdge()
|
||||||
|
|
||||||
|
// Make status bar transparent and content can extend behind it
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
|
|
||||||
// Initialize permission management
|
// Initialize permission management
|
||||||
permissionManager = PermissionManager(this)
|
permissionManager = PermissionManager(this)
|
||||||
// Initialize core mesh service first
|
// Initialize core mesh service first
|
||||||
|
|||||||
@@ -70,18 +70,26 @@ fun ChatScreen(viewModel: ChatViewModel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use WindowInsets to handle keyboard properly
|
// Use WindowInsets to handle keyboard properly
|
||||||
Box(modifier = Modifier.fillMaxSize()) {
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(colorScheme.background) // Extend background to fill entire screen including status bar
|
||||||
|
) {
|
||||||
val headerHeight = 42.dp
|
val headerHeight = 42.dp
|
||||||
|
|
||||||
// Main content area that responds to keyboard/window insets
|
// Main content area that responds to keyboard/window insets
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.background(colorScheme.background)
|
|
||||||
.windowInsetsPadding(WindowInsets.ime) // This handles keyboard insets
|
.windowInsetsPadding(WindowInsets.ime) // This handles keyboard insets
|
||||||
|
.windowInsetsPadding(WindowInsets.navigationBars) // Add bottom padding when keyboard is not expanded
|
||||||
) {
|
) {
|
||||||
// Header spacer - creates space for the floating header
|
// Header spacer - creates exact space for the floating header (status bar + compact header)
|
||||||
Spacer(modifier = Modifier.height(headerHeight))
|
Spacer(
|
||||||
|
modifier = Modifier
|
||||||
|
.windowInsetsPadding(WindowInsets.statusBars)
|
||||||
|
.height(headerHeight)
|
||||||
|
)
|
||||||
|
|
||||||
// Messages area - takes up available space, will compress when keyboard appears
|
// Messages area - takes up available space, will compress when keyboard appears
|
||||||
MessagesList(
|
MessagesList(
|
||||||
@@ -180,6 +188,16 @@ fun ChatScreen(viewModel: ChatViewModel) {
|
|||||||
onLocationChannelsClick = { showLocationChannelsSheet = true }
|
onLocationChannelsClick = { showLocationChannelsSheet = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Divider under header - positioned after status bar + header height
|
||||||
|
HorizontalDivider(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.windowInsetsPadding(WindowInsets.statusBars)
|
||||||
|
.offset(y = headerHeight)
|
||||||
|
.zIndex(1f),
|
||||||
|
color = colorScheme.outline.copy(alpha = 0.3f)
|
||||||
|
)
|
||||||
|
|
||||||
val alpha by animateFloatAsState(
|
val alpha by animateFloatAsState(
|
||||||
targetValue = if (showSidebar) 0.5f else 0f,
|
targetValue = if (showSidebar) 0.5f else 0f,
|
||||||
animationSpec = tween(
|
animationSpec = tween(
|
||||||
@@ -267,8 +285,7 @@ private fun ChatInputSection(
|
|||||||
) {
|
) {
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
color = colorScheme.background,
|
color = colorScheme.background
|
||||||
shadowElevation = 8.dp
|
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
HorizontalDivider(color = colorScheme.outline.copy(alpha = 0.3f))
|
HorizontalDivider(color = colorScheme.outline.copy(alpha = 0.3f))
|
||||||
@@ -324,11 +341,9 @@ private fun ChatFloatingHeader(
|
|||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(headerHeight)
|
|
||||||
.zIndex(1f)
|
.zIndex(1f)
|
||||||
.windowInsetsPadding(WindowInsets.statusBars), // Only respond to status bar
|
.windowInsetsPadding(WindowInsets.statusBars), // Extend into status bar area
|
||||||
color = colorScheme.background.copy(alpha = 0.95f),
|
color = colorScheme.background // Solid background color extending into status bar
|
||||||
shadowElevation = 8.dp
|
|
||||||
) {
|
) {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = {
|
title = {
|
||||||
@@ -351,18 +366,10 @@ private fun ChatFloatingHeader(
|
|||||||
},
|
},
|
||||||
colors = TopAppBarDefaults.topAppBarColors(
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
containerColor = Color.Transparent
|
containerColor = Color.Transparent
|
||||||
)
|
),
|
||||||
|
modifier = Modifier.height(headerHeight) // Ensure compact header height
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Divider under header
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.offset(y = headerHeight)
|
|
||||||
.zIndex(1f),
|
|
||||||
color = colorScheme.outline.copy(alpha = 0.3f)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Dark theme -->
|
||||||
|
<style name="Theme.BitchatAndroid" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||||
|
<!-- Enable edge-to-edge content -->
|
||||||
|
<item name="android:windowTranslucentStatus">false</item>
|
||||||
|
<item name="android:windowTranslucentNavigation">false</item>
|
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:windowLightStatusBar" tools:targetApi="23">false</item>
|
||||||
|
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
|
||||||
|
<!-- Ensure smooth transitions -->
|
||||||
|
<item name="android:windowActivityTransitions">true</item>
|
||||||
|
<item name="android:windowContentTransitions">true</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -2,6 +2,15 @@
|
|||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<!-- Base application theme -->
|
<!-- Base application theme -->
|
||||||
<style name="Theme.BitchatAndroid" parent="Theme.AppCompat.DayNight.NoActionBar">
|
<style name="Theme.BitchatAndroid" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||||
<!-- Customize your theme here. -->
|
<!-- Enable edge-to-edge content -->
|
||||||
|
<item name="android:windowTranslucentStatus">false</item>
|
||||||
|
<item name="android:windowTranslucentNavigation">false</item>
|
||||||
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
|
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
|
||||||
|
<item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
|
||||||
|
<!-- Ensure smooth transitions -->
|
||||||
|
<item name="android:windowActivityTransitions">true</item>
|
||||||
|
<item name="android:windowContentTransitions">true</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user