Skip to content

Commit

Permalink
Merge pull request #12 from bibbi-team/dev
Browse files Browse the repository at this point in the history
[DEV->RELEASE/1.2.0] 릴리즈 관련 패치 추가 #2
  • Loading branch information
CChuYong authored May 31, 2024
2 parents 8d979ac + ea3c741 commit 4d0db41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.no5ing.bbibbi.presentation.feature.view.main.calendar

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -15,6 +16,7 @@ import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand Down Expand Up @@ -182,6 +184,14 @@ fun MainCalendarPage(
}
}

} else {
Box(
modifier = Modifier
.padding(horizontal = 20.dp)
.fillMaxWidth()
.background(MaterialTheme.bbibbiScheme.backgroundSecondary, RoundedCornerShape(24.dp))
.aspectRatio(335.0f/220)
)
}
Spacer(modifier = Modifier.height(24.dp))
StaticCalendar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fun UploadMissionCamera(
val coroutineScope = rememberCoroutineScope()
val torchState = remember { mutableStateOf(false) }
val isPermissionGranted = remember { mutableStateOf(false) }
val cameraDirection = remember { mutableStateOf(CameraSelector.DEFAULT_FRONT_CAMERA) }
val cameraDirection = remember { mutableStateOf(CameraSelector.DEFAULT_BACK_CAMERA) }
val cameraState = remember { mutableStateOf<Camera?>(null) }
val captureState = remember { mutableStateOf(ImageCapture.Builder().build()) }
var isCapturing by remember { mutableStateOf(false) }
Expand Down
73 changes: 1 addition & 72 deletions app/src/main/java/com/no5ing/bbibbi/util/KotlinExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,43 +93,6 @@ suspend fun Context.getCameraProvider(): ProcessCameraProvider =
}
}

suspend fun ImageCapture.takePhoto(context: Context): Uri? =
suspendCoroutine { continuation ->
val name = "${System.currentTimeMillis()}.jpg"
val contentValues = ContentValues().apply {
put(MediaStore.MediaColumns.DISPLAY_NAME, name)
put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg")
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
put(MediaStore.Images.Media.RELATIVE_PATH, "Pictures/BBiBBi-Image")
}
}

val outputOptions = ImageCapture.OutputFileOptions
.Builder(
context.contentResolver,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues
)
.build()

this.takePicture(
outputOptions,
ContextCompat.getMainExecutor(context),
object : ImageCapture.OnImageSavedCallback {
override fun onError(e: ImageCaptureException) {
Timber.e("[CameraView] photo capture failed", e)
continuation.resume(null)
}

override fun onImageSaved(
output: ImageCapture.OutputFileResults
) {
Timber.d("onImageSaved: ${output.savedUri}")
continuation.resume(output.savedUri)
}
}
)
}

suspend fun ImageCapture.takePhotoWithImage(context: Context, requiredFlip: Boolean): Uri? =
suspendCoroutine { continuation ->
this.takePicture(
Expand All @@ -149,7 +112,7 @@ suspend fun ImageCapture.takePhotoWithImage(context: Context, requiredFlip: Bool
else
image.toBitmap()
.rotateWithCropCenterRecycle(image.imageInfo.rotationDegrees).flip()
bitmap.compress(Bitmap.CompressFormat.PNG, 100, faos)
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, faos)
faos.close()
continuation.resume(Uri.fromFile(context.getFileStreamPath(fileName)))
}
Expand All @@ -174,26 +137,6 @@ suspend fun ImageCapture.takePhotoTemporary(context: Context): ImageProxy? =
)
}

fun ImageProxy.toRequestBody(
contentType: MediaType? = null,
offset: Int = 0,
): RequestBody {
val baos = ByteArrayOutputStream()
val actualBitmap = toBitmap().rotateWithCropCenter(imageInfo.rotationDegrees)
actualBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos)
return object : RequestBody() {
override fun contentType() = contentType

override fun contentLength() = baos.size().toLong()

override fun writeTo(sink: BufferedSink) {
baos.use {
sink.write(it.toByteArray(), offset, it.size())
}
}
}
}

fun Bitmap.rotateWithCropCenter(degrees: Int): Bitmap {
val matrix = Matrix().apply { postRotate(degrees.toFloat()) }
val newBitMap = if (width >= height) {
Expand Down Expand Up @@ -255,12 +198,6 @@ fun Modifier.customDialogModifier(pos: CustomDialogPosition) = layout { measurab
}
}

@Composable
fun getDialogWindow(): Window? = (LocalView.current.parent as? DialogWindowProvider)?.window

@Composable
fun getActivityWindow(): Window? = LocalView.current.context.getActivityWindow()

private tailrec fun Context.getActivityWindow(): Window? =
when (this) {
is Activity -> window
Expand All @@ -282,14 +219,6 @@ fun getScreenSize(): Pair<Dp, Dp> {
}
}

fun Context.findAndroidActivity(): Activity? {
var context = this
while (context is ContextWrapper) {
if (context is Activity) return context
context = context.baseContext
}
return null
}

fun getLinkIdFromUrl(url: String): String {
return url.split("/").last()
Expand Down

0 comments on commit 4d0db41

Please sign in to comment.