mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Move next button up on new message fragment
This commit is contained in:
parent
2a73e944e7
commit
8c9ff9840c
@ -9,7 +9,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
@ -30,7 +30,6 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
import kotlinx.coroutines.flow.filterIsInstance
|
||||
@ -59,7 +58,6 @@ import org.thoughtcrime.securesms.ui.components.SessionOutlinedTextField
|
||||
import org.thoughtcrime.securesms.ui.components.SessionTabRow
|
||||
import org.thoughtcrime.securesms.ui.contentDescription
|
||||
|
||||
@AndroidEntryPoint
|
||||
class NewMessageFragment : Fragment() {
|
||||
|
||||
val viewModel: NewMessageViewModel by viewModels()
|
||||
@ -149,9 +147,9 @@ fun EnterAccountId(
|
||||
onHelp: () -> Unit = {}
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(12.dp),
|
||||
modifier = Modifier.padding(horizontal = 12.dp, vertical = 16.dp).fillMaxHeight(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
SessionOutlinedTextField(
|
||||
text = state.newMessageIdOrOns,
|
||||
@ -169,12 +167,10 @@ fun EnterAccountId(
|
||||
) { onHelp() }
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
OutlineButton(
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterHorizontally)
|
||||
.padding(horizontal = 64.dp, vertical = 20.dp)
|
||||
.padding(horizontal = 64.dp)
|
||||
.width(200.dp)
|
||||
.contentDescription(R.string.next),
|
||||
onClick = { callbacks.onContinue() }
|
||||
|
@ -7,6 +7,7 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewGroup.LayoutParams
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.commit
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
@ -15,6 +16,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.utilities.Address
|
||||
import org.session.libsession.utilities.modifyLayoutParams
|
||||
import org.thoughtcrime.securesms.conversation.new.NewMessageFragment
|
||||
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||
import org.thoughtcrime.securesms.groups.CreateGroupFragment
|
||||
@ -40,21 +42,18 @@ class NewConversationFragment : BottomSheetDialogFragment(), NewConversationDele
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = BottomSheetDialog(requireContext(), R.style.Theme_Session_BottomSheet)
|
||||
dialog.setOnShowListener {
|
||||
val bottomSheetDialog = it as BottomSheetDialog
|
||||
val parentLayout = bottomSheetDialog.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)
|
||||
parentLayout?.let {
|
||||
val behaviour = BottomSheetBehavior.from(it)
|
||||
val layoutParams = it.layoutParams
|
||||
layoutParams.height = defaultPeekHeight
|
||||
it.layoutParams = layoutParams
|
||||
behaviour.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
|
||||
BottomSheetDialog(requireContext(), R.style.Theme_Session_BottomSheet).apply {
|
||||
setOnShowListener { _ ->
|
||||
findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)?.let {
|
||||
it.modifyLayoutParams<LayoutParams> { height = defaultPeekHeight }
|
||||
BottomSheetBehavior.from(it).apply {
|
||||
skipCollapsed = true
|
||||
state = BottomSheetBehavior.STATE_EXPANDED
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onNewMessageSelected() {
|
||||
replaceFragment(NewMessageFragment().also { it.delegate = this })
|
||||
|
@ -8,6 +8,7 @@ import android.provider.Settings
|
||||
import androidx.camera.core.CameraSelector
|
||||
import androidx.camera.core.ImageAnalysis
|
||||
import androidx.camera.core.ImageProxy
|
||||
import androidx.camera.core.Preview
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider
|
||||
import androidx.camera.view.PreviewView
|
||||
import androidx.compose.foundation.background
|
||||
@ -49,19 +50,13 @@ import com.google.mlkit.vision.barcode.BarcodeScannerOptions
|
||||
import com.google.mlkit.vision.barcode.BarcodeScanning
|
||||
import com.google.mlkit.vision.barcode.common.Barcode
|
||||
import com.google.mlkit.vision.common.InputImage
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.buffer
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsignal.utilities.Log
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
typealias CameraPreview = androidx.camera.core.Preview
|
||||
|
||||
private const val TAG = "NewMessageFragment"
|
||||
|
||||
@ -76,16 +71,16 @@ fun MaybeScanQrCode(
|
||||
} },
|
||||
onScan: (String) -> Unit
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
.background(MaterialTheme.colors.surface)
|
||||
) {
|
||||
LocalSoftwareKeyboardController.current?.hide()
|
||||
|
||||
val cameraPermissionState = rememberPermissionState(Manifest.permission.CAMERA)
|
||||
|
||||
if (cameraPermissionState.status.isGranted) {
|
||||
ScanQrCode(errors) {
|
||||
Log.d("QR", "scan: $it")
|
||||
onScan(it)
|
||||
}
|
||||
ScanQrCode(errors, onScan)
|
||||
} else if (cameraPermissionState.status.shouldShowRationale) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@ -115,13 +110,12 @@ fun MaybeScanQrCode(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(FlowPreview::class)
|
||||
@Composable
|
||||
fun ScanQrCode(errors: Flow<String>, onScan: (String) -> Unit) {
|
||||
val localContext = LocalContext.current
|
||||
val cameraProvider = remember { ProcessCameraProvider.getInstance(localContext) }
|
||||
|
||||
val preview = androidx.camera.core.Preview.Builder().build()
|
||||
val preview = Preview.Builder().build()
|
||||
val selector = CameraSelector.Builder()
|
||||
.requireLensFacing(CameraSelector.LENS_FACING_BACK)
|
||||
.build()
|
||||
@ -142,7 +136,7 @@ fun ScanQrCode(errors: Flow<String>, onScan: (String) -> Unit) {
|
||||
)
|
||||
}.onFailure { Log.e(TAG, "error binding camera", it) }
|
||||
|
||||
DisposableEffect(key1 = cameraProvider) {
|
||||
DisposableEffect(cameraProvider) {
|
||||
onDispose {
|
||||
cameraProvider.get().unbindAll()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user