diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2b9f6f5..27daecb 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,9 @@
xmlns:tools="http://schemas.android.com/tools">
+
+
+
, grantResults: IntArray) {
+ if (requestCode == REQUEST_CODE_PERMISSIONS) {
+ if (allPermissionsGranted()) {
+ // 권한이 모두 부여되었을 때 실행할 코드를 여기에 작성합니다.
+ } else {
+ Toast.makeText(requireContext(), "Permissions not granted by the user.", Toast.LENGTH_SHORT).show()
+ activity?.finish()
+ }
+ }
+ }
+
private val PICK_IMAGE_MULTIPLE = 2
private fun openGallery() {
@@ -68,13 +96,20 @@ class UploadBottomFragment(context: Context, private val viewModelType: Int) :
}
private fun createImageFile(uri: Uri): File {
- val fileName = "img_" + System.currentTimeMillis() + ".jpg"
+ val fileName = getFileName(uri)
val directory = requireContext().getExternalFilesDir(null)
val file = File(directory, fileName)
val inputStream = requireContext().contentResolver.openInputStream(uri)
+ val originalBitmap = BitmapFactory.decodeStream(inputStream)
+
+ // 이미지 리사이징
+ val newWidth = originalBitmap.width / 2
+ val newHeight = originalBitmap.height / 2
+ val resizedBitmap = Bitmap.createScaledBitmap(originalBitmap, newWidth, newHeight, true)
+
val outputStream: OutputStream = FileOutputStream(file)
- inputStream?.copyTo(outputStream)
+ resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream)
inputStream?.close()
outputStream.close()