Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ android {
buildConfigField("String", "KAKAO_REST_API_KEY", "\"${properties["kakao_rest_api_key"]}\"")

manifestPlaceholders["KAKAO_NATIVE_KEY"] = properties["kakao_manifest_native_key"].toString()
manifestPlaceholders["NAVER_MAP_ID"] = properties["naver_map_id"].toString()
}

buildTypes {
Expand Down Expand Up @@ -130,6 +131,4 @@ dependencies {

implementation ("com.airbnb.android:lottie:6.5.2")
implementation(kotlin("script-runtime"))


}
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<!-- Android 12(API 32) 이하에서 이미지를 읽기 위한 권한 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />



<application
android:name=".presentation.KustaurantApplication"
android:allowBackup="true"
Expand Down Expand Up @@ -120,7 +119,7 @@
android:exported="false" />
<meta-data
android:name="com.naver.maps.map.CLIENT_ID"
android:value="dyfgbjtlqu" />
android:value="${NAVER_MAP_ID}"/>

<activity
android:name=".presentation.ui.detail.DetailActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.kust.kustaurant.presentation.ui.community

import android.annotation.SuppressLint
import android.os.Bundle
import android.content.Intent
import android.content.pm.PackageManager
import android.content.res.ColorStateList
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.OpenableColumns
import android.webkit.JavascriptInterface
import android.webkit.WebView
Expand All @@ -15,18 +13,17 @@ import android.widget.LinearLayout
import android.widget.PopupWindow
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.widget.addTextChangedListener
import androidx.lifecycle.lifecycleScope
import com.kust.kustaurant.R
import com.kust.kustaurant.databinding.ActivityCommunityPostWriteBinding
import com.kust.kustaurant.databinding.PopupCommuPostWriteSortBinding
import com.kust.kustaurant.presentation.model.CommunityPostIntent
import com.kust.kustaurant.presentation.ui.detail.EvaluateActivity.Companion.REQ_GALLERY
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
Expand All @@ -36,9 +33,9 @@ import kotlinx.coroutines.launch
class CommunityPostWriteActivity : AppCompatActivity() {
private lateinit var binding: ActivityCommunityPostWriteBinding
private val viewModel: CommunityPostWriteViewModel by viewModels()
private lateinit var photoPickerLauncher: ActivityResultLauncher<Intent>
private var textChangeJob: Job? = null
private var postId : Int? = null
private lateinit var pickMedia: ActivityResultLauncher<PickVisualMediaRequest>

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -164,20 +161,16 @@ class CommunityPostWriteActivity : AppCompatActivity() {

// Fragment에서 ViewModel에서 반환된 HTML 값을 직접 설정하고 커서 위치 재확인
private fun initPhotoPicker() {
photoPickerLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == RESULT_OK) {
result.data?.data?.let { uri ->
lifecycleScope.launch {
val imageUrl =
viewModel.uploadImageAndGetUrl(uri, getFileNameFromUri(uri))
imageUrl?.let {
insertImageAtCursor(it)
}
}
pickMedia = registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
if (uri != null) {
lifecycleScope.launch {
val imageUrl = viewModel.uploadImageAndGetUrl(uri, getFileNameFromUri(uri))
imageUrl?.let {
insertImageAtCursor(it)
}
}
}
}
}

private fun insertImageAtCursor(imageUrl: String) {
Expand All @@ -186,32 +179,7 @@ class CommunityPostWriteActivity : AppCompatActivity() {
}

private fun selectGallery() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
// Android 13 이상 Photo Picker
val intent = Intent(android.provider.MediaStore.ACTION_PICK_IMAGES)
photoPickerLauncher.launch(intent)
} else {
// Android 13 미만 기존 갤러리 + 권한 체크
if (ContextCompat.checkSelfPermission(
this,
android.Manifest.permission.READ_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_DENIED
) {
ActivityCompat.requestPermissions(
this,
arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE),
REQ_GALLERY
)
} else {
openGallery()
}
}
}

private fun openGallery() {
val intent = Intent(Intent.ACTION_PICK)
intent.type = "image/*"
photoPickerLauncher.launch(intent)
pickMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
}

private fun showPopupWindow() {
Expand Down Expand Up @@ -243,17 +211,6 @@ class CommunityPostWriteActivity : AppCompatActivity() {
popupWindow.dismiss()
}

override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == REQ_GALLERY && grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
openGallery()
}
}

private fun getFileNameFromUri(uri: Uri): String {
var fileName: String? = null
val cursor = contentResolver?.query(uri, null, null, null, null)
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/layout/activity_community_post_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
android:id="@+id/community_iv_user_icon"
android:layout_width="16dp"
android:layout_height="16dp"
android:contentDescription="유저 아이콘 입니다."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Externalizing contentDescription strings to strings.xml for consistency and localization.

The PR adds contentDescription attributes to three ImageViews (lines 131, 282, 309) as accessibility improvements, which is good. However, the implementation is inconsistent: some ImageViews in this file reference string resources (e.g., line 45: @string/back_btn_info, line 151: @string/community_post_img_info), while the new ones use inline Korean strings.

For consistency and to support localization, move these inline contentDescription strings to strings.xml:

<!-- In strings.xml -->
<string name="community_user_icon_info">유저 아이콘 입니다.</string>
<string name="community_like_icon_info">좋아요 아이콘 입니다.</string>
<string name="community_scrap_icon_info">스크랩 아이콘입니다.</string>

Then update the layout:

- android:contentDescription="유저 아이콘 입니다."
+ android:contentDescription="@string/community_user_icon_info"

- android:contentDescription="좋아요 아이콘 입니다."
+ android:contentDescription="@string/community_like_icon_info"

- android:contentDescription="스크랩 아이콘입니다."
+ android:contentDescription="@string/community_scrap_icon_info"

Also applies to: 282-282, 309-309

🤖 Prompt for AI Agents
In app/src/main/res/layout/activity_community_post_detail.xml at lines 131, 282
and 309, three ImageView contentDescription attributes use inline Korean strings
which breaks consistency with other entries and prevents localization; move
those inline strings into app/src/main/res/values/strings.xml using resource
names like community_user_icon_info, community_like_icon_info and
community_scrap_icon_info (with the provided Korean values), then replace the
inline contentDescription values in the layout with references to
@string/community_user_icon_info, @string/community_like_icon_info and
@string/community_scrap_icon_info respectively so all contentDescription
attributes consistently use string resources and support localization.

android:src="@drawable/ic_baby_cow" />

<TextView
Expand Down Expand Up @@ -278,6 +279,7 @@
android:id="@+id/community_iv_btn_post_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="좋아요 아이콘 입니다."
android:src="@drawable/ic_like_true" />

<TextView
Expand All @@ -304,6 +306,7 @@
android:id="@+id/community_iv_btn_scrap_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="스크랩 아이콘입니다."
android:src="@drawable/ic_scrap" />

<TextView
Expand Down Expand Up @@ -365,7 +368,7 @@
android:paddingHorizontal="16dp"
android:paddingVertical="14dp"
android:textColorHint="@color/cement_4"
android:textSize="14dp"
android:textSize="14sp"
app:layout_constraintEnd_toStartOf="@id/community_cl_comment_confirm"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand All @@ -386,6 +389,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="댓글 입력 확인 버튼"
android:paddingEnd="3dp"
android:paddingStart="0dp"
android:src="@drawable/ic_confirm"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/fragment_community_post_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@

<Button
android:id="@+id/commu_btn_write_post"
android:layout_width="104dp"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:layout_marginBottom="22dp"
android:background="@drawable/all_radius_30_signature_1"
Expand All @@ -152,6 +152,8 @@
android:textColor="@color/white"
android:textSize="15sp"
android:textStyle="bold"
android:singleLine="true"
android:maxLines="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/community_gl_end" />
</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ converterGson = "2.11.0"
loggingInterceptor = "5.0.0-alpha.14"
okhttp = "5.0.0-alpha.14"
okhttpUrlconnection = "5.0.0-alpha.14"
naverMaps = "3.17.0"
naverMaps = "3.23.0"
databindingCompiler = "8.5.1"
materialVersion = "1.13.0-alpha01"
oauth = "5.9.1"
Expand Down