mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 00:01:08 +01:00
Fix gradle format task.
This commit is contained in:
committed by
Alex Hart
parent
9cefe0bc04
commit
b48b1f031e
@@ -5,7 +5,6 @@ import androidx.camera.compose.CameraXViewfinder
|
||||
import androidx.camera.core.SurfaceRequest
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider
|
||||
import androidx.camera.viewfinder.compose.MutableCoordinateTransformer
|
||||
import androidx.camera.core.Preview as CameraPreview
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.Spring
|
||||
@@ -45,6 +44,7 @@ import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.signal.core.ui.compose.Previews
|
||||
import androidx.camera.core.Preview as CameraPreview
|
||||
|
||||
/**
|
||||
* A camera screen that handles core camera functionality, such as:
|
||||
|
||||
@@ -43,4 +43,4 @@ sealed interface CameraScreenEvents {
|
||||
|
||||
/** Indicates the capture error has been handled and can be cleared. */
|
||||
data object ClearCaptureError : CameraScreenEvents
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,3 @@ enum class FlashMode(val cameraxMode: Int) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.signal.camera
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.ContextWrapper
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Matrix
|
||||
import android.os.Build
|
||||
@@ -81,7 +81,7 @@ class CameraScreenViewModel : ViewModel() {
|
||||
private var orientationListener: OrientationEventListener? = null
|
||||
|
||||
private val _qrCodeDetected = MutableSharedFlow<String>(extraBufferCapacity = 1)
|
||||
|
||||
|
||||
/**
|
||||
* Flow of detected QR codes. Observers can collect from this flow to receive QR code detections.
|
||||
* The flow filters consecutive duplicates and is throttled to avoid rapid-fire detections.
|
||||
@@ -133,7 +133,7 @@ class CameraScreenViewModel : ViewModel() {
|
||||
@androidx.annotation.OptIn(markerClass = [androidx.camera.core.ExperimentalGetImage::class])
|
||||
fun capturePhoto(
|
||||
context: Context,
|
||||
onPhotoCaptured: (Bitmap) -> Unit,
|
||||
onPhotoCaptured: (Bitmap) -> Unit
|
||||
) {
|
||||
val state = _state.value
|
||||
val capture = imageCapture ?: run {
|
||||
|
||||
@@ -13,7 +13,7 @@ sealed class VideoOutput {
|
||||
* The consumer is responsible for creating the file and managing its lifecycle.
|
||||
*/
|
||||
data class FileOutput(val file: File) : VideoOutput()
|
||||
|
||||
|
||||
/**
|
||||
* Save video to a file descriptor.
|
||||
* The consumer provides the file descriptor and is responsible for closing it.
|
||||
@@ -35,7 +35,7 @@ sealed class VideoCaptureResult {
|
||||
val outputFile: File? = null,
|
||||
val fileDescriptor: ParcelFileDescriptor? = null
|
||||
) : VideoCaptureResult()
|
||||
|
||||
|
||||
/**
|
||||
* Video capture failed.
|
||||
* @param fileDescriptor The file descriptor that was being used (for cleanup)
|
||||
|
||||
@@ -22,12 +22,12 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.StrokeCap
|
||||
import androidx.compose.ui.graphics.drawscope.DrawScope
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
||||
@@ -32,14 +32,14 @@ import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.DpSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.signal.glide.compose.GlideImage
|
||||
import org.signal.glide.compose.GlideImageScaleType
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
/**
|
||||
* A button that displays a thumbnail of the most recent image or video from the gallery.
|
||||
* Shows a circular thumbnail with a white border that opens the gallery when clicked.
|
||||
*
|
||||
*
|
||||
* @param modifier Modifier to apply to the button
|
||||
* @param onClick Callback when the button is clicked
|
||||
*/
|
||||
@@ -50,12 +50,12 @@ fun GalleryThumbnailButton(
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
var thumbnailUri by remember { mutableStateOf<Uri?>(null) }
|
||||
|
||||
|
||||
// Load the most recent media item
|
||||
LaunchedEffect(Unit) {
|
||||
thumbnailUri = getLatestMediaUri(context)
|
||||
}
|
||||
|
||||
|
||||
Box(
|
||||
modifier = modifier
|
||||
.size(52.dp)
|
||||
@@ -93,7 +93,7 @@ private suspend fun getLatestMediaUri(context: Context): Uri? = withContext(Disp
|
||||
try {
|
||||
val imageUri = getLatestImageUri(context)
|
||||
val videoUri = getLatestVideoUri(context)
|
||||
|
||||
|
||||
// Compare timestamps if both exist, otherwise return whichever is available
|
||||
when {
|
||||
imageUri != null && videoUri != null -> {
|
||||
@@ -122,9 +122,9 @@ private fun getLatestImageUri(context: Context): Uri? {
|
||||
MediaStore.Images.Media._ID,
|
||||
MediaStore.Images.Media.DATE_ADDED
|
||||
)
|
||||
|
||||
|
||||
val sortOrder = "${MediaStore.Images.Media.DATE_ADDED} DESC"
|
||||
|
||||
|
||||
context.contentResolver.query(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
projection,
|
||||
@@ -141,7 +141,7 @@ private fun getLatestImageUri(context: Context): Uri? {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -153,9 +153,9 @@ private fun getLatestVideoUri(context: Context): Uri? {
|
||||
MediaStore.Video.Media._ID,
|
||||
MediaStore.Video.Media.DATE_ADDED
|
||||
)
|
||||
|
||||
|
||||
val sortOrder = "${MediaStore.Video.Media.DATE_ADDED} DESC"
|
||||
|
||||
|
||||
context.contentResolver.query(
|
||||
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
|
||||
projection,
|
||||
@@ -172,7 +172,7 @@ private fun getLatestVideoUri(context: Context): Uri? {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ private fun getLatestVideoUri(context: Context): Uri? {
|
||||
*/
|
||||
private fun getMediaTimestamp(context: Context, uri: Uri): Long? {
|
||||
val projection = arrayOf(MediaStore.MediaColumns.DATE_ADDED)
|
||||
|
||||
|
||||
context.contentResolver.query(
|
||||
uri,
|
||||
projection,
|
||||
@@ -194,7 +194,7 @@ private fun getMediaTimestamp(context: Context, uri: Uri): Long? {
|
||||
return cursor.getLong(dateColumn)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ fun hasMediaPermissions(context: Context): Boolean {
|
||||
// Android 13+
|
||||
context.checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) ==
|
||||
PackageManager.PERMISSION_GRANTED ||
|
||||
context.checkSelfPermission(Manifest.permission.READ_MEDIA_VIDEO) ==
|
||||
context.checkSelfPermission(Manifest.permission.READ_MEDIA_VIDEO) ==
|
||||
PackageManager.PERMISSION_GRANTED
|
||||
} else {
|
||||
// Older Android versions
|
||||
|
||||
@@ -413,7 +413,7 @@ private fun MediaCountIndicator(
|
||||
.padding(horizontal = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
val size = with (LocalDensity.current) {
|
||||
val size = with(LocalDensity.current) {
|
||||
22.sp.toDp()
|
||||
}
|
||||
Box(
|
||||
|
||||
Reference in New Issue
Block a user