From 78a858579a630453e025f7d21f222c8fae1fa1b6 Mon Sep 17 00:00:00 2001 From: chanu Date: Wed, 15 Nov 2023 13:27:23 +0900 Subject: [PATCH 1/6] =?UTF-8?q?fix=20:=20=ED=86=B5=EA=B3=84=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=95=A1=EC=85=98=EB=B0=94=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feat/history/src/main/AndroidManifest.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/feat/history/src/main/AndroidManifest.xml b/feat/history/src/main/AndroidManifest.xml index 820d570..04f7432 100644 --- a/feat/history/src/main/AndroidManifest.xml +++ b/feat/history/src/main/AndroidManifest.xml @@ -4,7 +4,8 @@ + android:exported="false" + android:theme="@style/Theme.LiteWeight_Android.NoActionBar" /> \ No newline at end of file From 653946646925f62e0b3dbc93fb71e96f4902ebb1 Mon Sep 17 00:00:00 2001 From: chanu Date: Wed, 15 Nov 2023 13:43:26 +0900 Subject: [PATCH 2/6] =?UTF-8?q?fix=20:=20=EA=B0=9C=EC=9D=B8=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=ED=99=94=EB=A9=B4=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=EB=B7=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/drawable/imageperson.xml | 21 ++++++++++++++ .../src/main/res/layout/activity_settings.xml | 28 +++++++++++++------ 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 feat/personal/src/main/res/drawable/imageperson.xml diff --git a/feat/personal/src/main/res/drawable/imageperson.xml b/feat/personal/src/main/res/drawable/imageperson.xml new file mode 100644 index 0000000..a72fbba --- /dev/null +++ b/feat/personal/src/main/res/drawable/imageperson.xml @@ -0,0 +1,21 @@ + + + + + diff --git a/feat/personal/src/main/res/layout/activity_settings.xml b/feat/personal/src/main/res/layout/activity_settings.xml index c264cff..4c857b7 100644 --- a/feat/personal/src/main/res/layout/activity_settings.xml +++ b/feat/personal/src/main/res/layout/activity_settings.xml @@ -4,11 +4,13 @@ xmlns:tools="http://schemas.android.com/tools"> + + @@ -39,28 +41,38 @@ android:layout_height="4dp" android:layout_marginTop="20dp" android:background="@color/light_blue" + android:visibility="invisible" app:layout_constraintTop_toBottomOf="@id/iv_back_btn" /> + + + android:layout_marginTop="32dp" + android:text="나이" /> + android:layout_marginTop="32dp" + android:text="성별" /> Date: Wed, 15 Nov 2023 13:49:21 +0900 Subject: [PATCH 3/6] =?UTF-8?q?fix=20:=20=EA=B2=80=EC=83=89=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20ui=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feat/capture/src/main/res/layout/activity_search.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/feat/capture/src/main/res/layout/activity_search.xml b/feat/capture/src/main/res/layout/activity_search.xml index 135775d..8e6eb91 100644 --- a/feat/capture/src/main/res/layout/activity_search.xml +++ b/feat/capture/src/main/res/layout/activity_search.xml @@ -39,8 +39,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/btn_back" app:layout_constraintTop_toTopOf="@id/btn_back" - app:strokeColor="@color/main_blue" - app:strokeWidth="1dp"> + app:strokeColor="@color/main_blue"> From b3177f02eabfd5d5db8ceeec24dc588470fc8983 Mon Sep 17 00:00:00 2001 From: chanu Date: Wed, 15 Nov 2023 14:17:37 +0900 Subject: [PATCH 4/6] =?UTF-8?q?fix=20:=20=EA=B2=80=EC=83=89=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=ED=99=94=EB=A9=B4=20=ED=85=8C=EB=91=90=EB=A6=AC=20?= =?UTF-8?q?=EC=83=89=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/drawable/rounded_corner_shape_lightgray.xml | 12 ++++++++++++ .../src/main/res/layout/item_searched_food.xml | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 feat/capture/src/main/res/drawable/rounded_corner_shape_lightgray.xml diff --git a/feat/capture/src/main/res/drawable/rounded_corner_shape_lightgray.xml b/feat/capture/src/main/res/drawable/rounded_corner_shape_lightgray.xml new file mode 100644 index 0000000..e3841a6 --- /dev/null +++ b/feat/capture/src/main/res/drawable/rounded_corner_shape_lightgray.xml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/feat/capture/src/main/res/layout/item_searched_food.xml b/feat/capture/src/main/res/layout/item_searched_food.xml index e77cf62..654bf7c 100644 --- a/feat/capture/src/main/res/layout/item_searched_food.xml +++ b/feat/capture/src/main/res/layout/item_searched_food.xml @@ -16,8 +16,9 @@ + android:layout_marginHorizontal="28dp" + android:layout_marginVertical="14dp" + android:background="@drawable/rounded_corner_shape_lightgray"> Date: Fri, 17 Nov 2023 20:24:27 +0900 Subject: [PATCH 5/6] =?UTF-8?q?refactor:=20=EC=B9=B4=EB=A9=94=EB=9D=BC=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=EC=9A=94=EC=B2=AD=20=ED=94=8C=EB=A1=9C?= =?UTF-8?q?=EC=9A=B0=20=EC=A4=80=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/konkuk/liteweight/ui/MainActivity.kt | 37 +++++++++++++++++-- .../com/konkuk/liteweight/util/Extensions.kt | 21 +++++++++++ feat/capture/src/main/AndroidManifest.xml | 2 + .../capture/ui/capture/CaptureActivity.kt | 37 +++++++++++++------ 4 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 app/src/main/java/com/konkuk/liteweight/util/Extensions.kt diff --git a/app/src/main/java/com/konkuk/liteweight/ui/MainActivity.kt b/app/src/main/java/com/konkuk/liteweight/ui/MainActivity.kt index f7e5e6a..f2c4709 100644 --- a/app/src/main/java/com/konkuk/liteweight/ui/MainActivity.kt +++ b/app/src/main/java/com/konkuk/liteweight/ui/MainActivity.kt @@ -1,8 +1,12 @@ package com.konkuk.liteweight.ui +import android.Manifest +import android.content.pm.PackageManager import android.os.Bundle +import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle @@ -14,11 +18,20 @@ import androidx.navigation.ui.setupWithNavController import com.konkuk.capture.ui.enroll.EnrollBottomSheetDialogFragment import com.konkuk.liteweight.R import com.konkuk.liteweight.databinding.ActivityMainBinding +import com.konkuk.liteweight.util.showPermissionContextPopup import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch @AndroidEntryPoint class MainActivity : AppCompatActivity() { + private val requestPermissionLauncher = + registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted -> + if (isGranted) { + navigateCaptureDialog() + } else { + showPermissionContextPopup(Manifest.permission.CAMERA) + } + } private lateinit var appBarConfiguration: AppBarConfiguration private lateinit var binding: ActivityMainBinding @@ -58,7 +71,7 @@ class MainActivity : AppCompatActivity() { private fun handleEvent(event: Event) { when (event) { Event.CaptureClickEvent -> { - navigateCaptureDialog() + requestCameraTask() } } } @@ -73,7 +86,25 @@ class MainActivity : AppCompatActivity() { override fun onSupportNavigateUp(): Boolean { val navController = findNavController(R.id.nav_host_fragment_content_main) - return navController.navigateUp(appBarConfiguration) || - super.onSupportNavigateUp() + return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp() + } + + private fun requestCameraTask() { + when { + ContextCompat.checkSelfPermission( + this, + Manifest.permission.CAMERA, + ) == PackageManager.PERMISSION_GRANTED -> { + navigateCaptureDialog() + } + + shouldShowRequestPermissionRationale(Manifest.permission.CAMERA) -> { + showPermissionContextPopup("카메라") + } + + else -> { + requestPermissionLauncher.launch(Manifest.permission.CAMERA) + } + } } } diff --git a/app/src/main/java/com/konkuk/liteweight/util/Extensions.kt b/app/src/main/java/com/konkuk/liteweight/util/Extensions.kt new file mode 100644 index 0000000..a9fa865 --- /dev/null +++ b/app/src/main/java/com/konkuk/liteweight/util/Extensions.kt @@ -0,0 +1,21 @@ +package com.konkuk.liteweight.util + +import android.content.Intent +import android.net.Uri +import android.provider.Settings +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.app.AppCompatActivity + +fun AppCompatActivity.showPermissionContextPopup(permissionName: String) { + AlertDialog.Builder(this) + .setTitle("권한 요청") + .setMessage("해당 기능을 사용하기 위해서는\n $permissionName 권한이 필요합니다.") + .setPositiveButton("동의하기") { _, _ -> + val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) + intent.data = Uri.parse("package:$packageName") + startActivity(intent) + } + .setNegativeButton("취소하기") { _, _ -> } + .create() + .show() +} diff --git a/feat/capture/src/main/AndroidManifest.xml b/feat/capture/src/main/AndroidManifest.xml index d914c6a..aff171d 100644 --- a/feat/capture/src/main/AndroidManifest.xml +++ b/feat/capture/src/main/AndroidManifest.xml @@ -1,5 +1,7 @@ + + - bitmapPicture = bitmap - binding.ivNutritionInfo.setImageBitmap(bitmap) - processImageRecognize(InputImage.fromBitmap(bitmap, 0)) - } ?: reCapture() - } else { - reCapture() + ActivityResultContracts.TakePicture(), + ) { isSuccess -> + if (isSuccess) { + binding.ivNutritionInfo.setImageURI(uriPicture) + uriPicture?.let { uri -> + processImageRecognize( + InputImage.fromFilePath( + this@CaptureActivity, + uri, + ), + ) + } + } + } + + private fun createImageFile(): Uri? { + val now = SimpleDateFormat("yyMMdd_HHmmss").format(Date()) + val content = ContentValues().apply { + put(MediaStore.Images.Media.DISPLAY_NAME, "img_$now.jpg") + put(MediaStore.Images.Media.MIME_TYPE, "image/jpg") } + return contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, content) } private val getPictureLauncher = registerForActivityResult( @@ -70,7 +84,8 @@ class CaptureActivity : AppCompatActivity() { val getPictureIntent = Intent(Intent.ACTION_GET_CONTENT).apply { type = "image/*" } captureDialog = CaptureDialogFragment({ - takePictureLauncher.launch(takePictureIntent) + uriPicture = createImageFile() + uriPicture?.let { uri -> takePictureLauncher.launch(uri) } }, { getPictureLauncher.launch(getPictureIntent) }, { From 0062bae9837456c5c71a31c0306349cd93923eca Mon Sep 17 00:00:00 2001 From: yonghanJu Date: Fri, 17 Nov 2023 20:32:10 +0900 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20=EB=A6=AC=EC=86=8C=EC=8A=A4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/res/drawable/camera3x.png | Bin 0 -> 2495 bytes common/src/main/res/drawable/ic_search.xml | 9 +++++++++ common/src/main/res/drawable/pen_pressed.xml | 9 +++++++++ common/src/main/res/drawable/selector_camera.xml | 7 +++++++ common/src/main/res/drawable/selector_pen.xml | 7 +++++++ 5 files changed, 32 insertions(+) create mode 100644 common/src/main/res/drawable/camera3x.png create mode 100644 common/src/main/res/drawable/ic_search.xml create mode 100644 common/src/main/res/drawable/pen_pressed.xml create mode 100644 common/src/main/res/drawable/selector_camera.xml create mode 100644 common/src/main/res/drawable/selector_pen.xml diff --git a/common/src/main/res/drawable/camera3x.png b/common/src/main/res/drawable/camera3x.png new file mode 100644 index 0000000000000000000000000000000000000000..696ad6183e908e7c293207113df7cd3b07e2ff45 GIT binary patch literal 2495 zcmV;w2|)IVP)K zPur67VEBe20BhiXOMri}dkN7~&k^&`b56tFk1IX6Al{p>x$kycz~Lc2Ac&ZQA01{-619S&*wEkv-8aNSQ zpJ7w;9H%XTFP(K<`t?FAhRMb8OAZ|ae}E-mP4_v2PxEaSq(vW}%^%$g=$Uap$n9~& zjV0{!wO0=v$vW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`xM4TCfGDOiG?8fJL+G*Uss zK)o&R5_moU)B!7mnZZwF>;W{7mM*+iW=4ImLfFJ{K?^A9{Ks`C1KR8KWp3Tua8X8~ z;F8g7kD6hRFx2REk#egnh2Vi9dX&9FvTDTB|qDe7q?8I&2iHXMGtc9@aD zXH(Q8l*LL6l&pXSSS5^VSxMB}w-KbEYhttiA-j!5Imx=E@61FirsP7TeZKa~g-1@BIOaO;Q7$FPkb*2W=M^M1%#6E@$i%w{ zC_Pe2UWn{CQtV@xzwBI3oTz&>1;Zvt!H9vw$bb^r;h!^Sioy=^2QoN1!H$xo#i@56qNJ&g0OD;^V6@ zOY&720Nj*VvgCS=()wM@w4vPR6iv-o+NLDpJ#d-mz8KF=FEBnS>E2 zK+1tVuUh(!X2(Xt`ISeqH!Uj>sHIc+Obhik8U?=`UKde@F?LCRB?9LV#u7$QvAYi4%GG0x1xWD6EuBiEVSLd=BTZ=HCXth;2gw9i z?9L}z&FWl)nNUWpz;@4&JjsG-TKJZf8MNI0px6K<+?^-z`#%w@r&)NhslxyO002ov JPDHLkV1oG?wn_j1 literal 0 HcmV?d00001 diff --git a/common/src/main/res/drawable/ic_search.xml b/common/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..d727517 --- /dev/null +++ b/common/src/main/res/drawable/ic_search.xml @@ -0,0 +1,9 @@ + + + diff --git a/common/src/main/res/drawable/pen_pressed.xml b/common/src/main/res/drawable/pen_pressed.xml new file mode 100644 index 0000000..78a6d4f --- /dev/null +++ b/common/src/main/res/drawable/pen_pressed.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/selector_camera.xml b/common/src/main/res/drawable/selector_camera.xml new file mode 100644 index 0000000..00dbc18 --- /dev/null +++ b/common/src/main/res/drawable/selector_camera.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/selector_pen.xml b/common/src/main/res/drawable/selector_pen.xml new file mode 100644 index 0000000..e2ae96b --- /dev/null +++ b/common/src/main/res/drawable/selector_pen.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file