Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
12 commits
Select commit Hold shift + click to select a range
09a7bc5
[feat] #71 : ๋งˆ์ดํŽ˜์ด์ง€ - ๋‹‰๋„ค์ž„, ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ ๋ณ€๊ฒฝ
nasohee Aug 7, 2025
37a835a
[feat]#71 : ๋งˆ์ดํŽ˜์ด์ง€-๋ฌธ์˜ํ•˜๊ธฐ ui
nasohee Aug 7, 2025
1309bb4
[feat] #71 :๋งˆ์ดํŽ˜์ด์ง€ - ๋ฌธ์˜ํ•˜๊ธฐ
nasohee Aug 7, 2025
57d728e
[feat] #71 :๋งˆ์ดํŽ˜์ด์ง€ - ๋กœ๊ทธ์•„์›ƒ ํŒ์—…
nasohee Aug 7, 2025
798b12d
[feat] #71 :๋งˆ์ดํŽ˜์ด์ง€ - ํšŒ์›ํƒˆํ‡ด ํŒ์—…
nasohee Aug 7, 2025
f5a9125
[feat] #71 : ๋งˆ์ดํŽ˜์ด์ง€ - ๋ฌธ์˜ํ•˜๊ธฐ ๊ฒฝ๊ณ  ๋ฉ”์‹œ์ง€ ๋„์šฐ๊ธฐ
nasohee Aug 7, 2025
a12c184
[feat] #71 : ๋งˆ์ดํŽ˜์ด์ง€ - ๋‹‰๋„ค์ž„ ์˜ค๋ฅ˜ ํŒŒ๋ฒ• ๋„์šฐ๊ธฐ
nasohee Aug 10, 2025
cf17be9
[feat]#71 : ๋งˆ์ดํŽ˜์ด์ง€ ๋ฌธ์˜ํ•˜๊ธฐ - stroke ์ƒ‰ ์„œ ใ„น์ •
nasohee Aug 12, 2025
7e11d98
[feat]#71 : ๋งˆ์ดํŽ˜์ด์ง€ - ๋ฒ„์ „ ์ •๋ณด
nasohee Aug 12, 2025
7188274
[feat] #71: ๊ฐค๋Ÿฌ๋ฆฌ ๋Ÿฐ์ฒ˜ ์ ‘๊ทผ
nasohee Aug 14, 2025
b767cfa
[feat] #71: ๋งˆ์ดํŽ˜์ด์ง€-์•Œ๋ฆผํ† ๊ธ€
nasohee Aug 14, 2025
e286c3d
[refactor] #71 : binding์ถ”๊ฐ€, ๊ฒน์น˜๋Š” ํ•จ์ˆ˜ ์‚ญ์ œ
nasohee Aug 18, 2025
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
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

147 changes: 104 additions & 43 deletions app/src/main/java/com/example/findu/presentation/ui/my/MyFragment.kt
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
package com.example.findu.presentation.ui.my

import android.Manifest
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.isVisible
import androidx.core.widget.addTextChangedListener
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.fragment.findNavController
import com.example.findu.BuildConfig
import com.example.findu.R
import com.example.findu.databinding.FragmentMyBinding
import com.example.findu.presentation.ui.login.LoginActivity
import com.example.findu.presentation.ui.my.dialog.MyLogoutDialog
import com.example.findu.presentation.ui.my.dialog.MyNicknameDialog
import com.example.findu.presentation.ui.my.dialog.MyProfileImageDialog
import com.example.findu.presentation.ui.my.dialog.MyWithdrawalDialog
import com.example.findu.presentation.util.PermissionUtils.hasCameraPermission
import com.example.findu.presentation.util.PermissionUtils.hasLocationPermission
import com.example.findu.presentation.util.PermissionUtils.requestLocationPermission
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

Expand All @@ -34,25 +37,27 @@ class MyFragment : Fragment() {
private val binding get() = _binding!!
private val myViewModel by viewModels<MyViewModel>()

private lateinit var requestPermissionLauncher: ActivityResultLauncher<String>
private lateinit var pickMedia: ActivityResultLauncher<PickVisualMediaRequest>
private var myProfileImageDialog: MyProfileImageDialog? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

requestPermissionLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
if (isGranted) {
Toast.makeText(requireContext(), "๊ถŒํ•œ์ด ํ—ˆ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.", Toast.LENGTH_SHORT).show()
} else {
findNavController().popBackStack()
}
pickMedia = registerForActivityResult(
ActivityResultContracts.PickVisualMedia()
) { uri: Uri? ->
if (uri != null) {
myProfileImageDialog?.setGalleryImage(uri)
} else {
Toast.makeText(requireContext(), "์ด๋ฏธ์ง€๊ฐ€ ์„ ํƒ๋˜์ง€ ์•Š์•˜์–ด์š”.", Toast.LENGTH_SHORT).show()
}
}
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
savedInstanceState: Bundle?,
): View {
_binding = FragmentMyBinding.inflate(inflater, container, false)

Expand All @@ -63,18 +68,32 @@ class MyFragment : Fragment() {
}

private fun initListener() {

with(binding) {
llMyNickname.setOnClickListener {
llMyNickname.visibility = View.INVISIBLE
llMyEditNickname.visibility = View.VISIBLE
MyNicknameDialog(
context = requireContext(),
onNicknameChange = { newNickname ->
myViewModel.updateNickName(newNickname)
}
).show()
}

btnMyDoneEdit.setOnClickListener {
llMyNickname.visibility = View.VISIBLE
llMyEditNickname.visibility = View.INVISIBLE

myViewModel.updateNickName(etMyNickname.text.toString())
clMyProflieImage.setOnClickListener {
myProfileImageDialog = MyProfileImageDialog(
context = requireContext(),
onDrawableSelected = { resId ->
myViewModel.updateProfileImage(resId)
},
onGallerySelected = { uri ->
myViewModel.updateProfileImageFromGallery(uri)
},
launchGallery = {
pickMedia.launch(
PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)
)
}
)
myProfileImageDialog?.show()
}

etMyNickname.addTextChangedListener { text ->
Expand All @@ -93,35 +112,40 @@ class MyFragment : Fragment() {
findNavController().navigate(R.id.action_fragment_my_to_fragment_my_keep_animals)
}

clMyCameraPermission.setOnClickListener {
if (hasCameraPermission(requireContext())) {
Toast.makeText(requireContext(), "์นด๋ฉ”๋ผ ๊ถŒํ•œ์ด ์ด๋ฏธ ํ—ˆ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.", Toast.LENGTH_SHORT)
.show()
} else {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
clMyInquire.setOnClickListener {
findNavController().navigate(R.id.action_fragment_my_to_fragment_inquire)
}

clMyLocationPermission.setOnClickListener {
if (hasLocationPermission(requireContext())) {
Toast.makeText(requireContext(), "์œ„์น˜ ๊ถŒํ•œ์ด ์ด๋ฏธ ํ—ˆ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.", Toast.LENGTH_SHORT)
.show()
} else {
requestLocationPermission(requireActivity())
}
}

clMyLogout.setOnClickListener {
val logoutClickListener = View.OnClickListener {
MyLogoutDialog(
context = requireContext(),
onLogoutClick = {
with(requireActivity()) {
startActivity(
Intent(requireContext(), LoginActivity::class.java)
)
startActivity(Intent(requireContext(), LoginActivity::class.java))
finish()
}
}).show()
}
).show()
}

clMyLogout.setOnClickListener(logoutClickListener)
tvMyVersionInfo.setOnClickListener(logoutClickListener)
chipMyVersion.setOnClickListener(logoutClickListener)

Comment on lines +131 to +134
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

๋ฒ„์ „ ์ •๋ณด/์นฉ์ด '๋กœ๊ทธ์•„์›ƒ'์œผ๋กœ ์—ฐ๊ฒฐ๋˜๋Š” ๋ฒ„๊ทธ ์ˆ˜์ • ํ•„์š”

tvMyVersionInfo, chipMyVersion์— logoutClickListener๊ฐ€ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ์–ด, ์‚ฌ์šฉ์ž๊ฐ€ ๋ฒ„์ „ ๊ด€๋ จ UI๋ฅผ ํƒญํ•˜๋ฉด ๋กœ๊ทธ์•„์›ƒ ํŒ์—…์ด ๋– ๋ฒ„๋ฆฝ๋‹ˆ๋‹ค. clMyGotoUpdate์— ์ด๋ฏธ ์—…๋ฐ์ดํŠธ ์ด๋™ ๋กœ์ง์ด ์žˆ์œผ๋ฏ€๋กœ ๋‘ ์ปดํฌ๋„ŒํŠธ์˜ ํด๋ฆญ ๋ฆฌ์Šค๋„ˆ๋Š” ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด ๋งž์Šต๋‹ˆ๋‹ค.

์•„๋ž˜์ฒ˜๋Ÿผ ์ •๋ฆฌํ•ด ์ฃผ์„ธ์š”:

-            clMyLogout.setOnClickListener(logoutClickListener)
-            tvMyVersionInfo.setOnClickListener(logoutClickListener)
-            chipMyVersion.setOnClickListener(logoutClickListener)
+            clMyLogout.setOnClickListener(logoutClickListener)
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
clMyLogout.setOnClickListener(logoutClickListener)
tvMyVersionInfo.setOnClickListener(logoutClickListener)
chipMyVersion.setOnClickListener(logoutClickListener)
clMyLogout.setOnClickListener(logoutClickListener)
๐Ÿค– Prompt for AI Agents
In app/src/main/java/com/example/findu/presentation/ui/my/MyFragment.kt around
lines 131-134, tvMyVersionInfo and chipMyVersion are incorrectly wired to
logoutClickListener causing the logout popup when users tap version-related UI;
remove the logoutClickListener assignments for these two views (leave
clMyLogout.setOnClickListener(logoutClickListener) intact) so version taps no
longer trigger logout, and ensure navigation to updates remains handled by
clMyGotoUpdate's existing click logic.

clMyGotoUpdate.setOnClickListener {
val pkg = requireContext().packageName
try {
startActivity(
Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$pkg"))
)
} catch (e: ActivityNotFoundException) {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=$pkg")
)
)
}
}

clMyWithdrawal.setOnClickListener {
Expand All @@ -137,9 +161,25 @@ class MyFragment : Fragment() {
}
}).show()
}

clMyAlarmSetting.setOnClickListener {
myViewModel.toggleAlarmSetting()
}

setupVersion()
}
}

private fun setupVersion() = with(binding) {
val currentVersion = BuildConfig.VERSION_NAME
val latest = "1.0"
tvMyVersionInfo.text = "๋ฒ„์ „ ์ •๋ณด $currentVersion"

val isLatest = currentVersion.replace(".", "").toInt() >= latest.replace(".", "").toInt()
clMyVersionChip.isVisible = isLatest
clMyGotoUpdate.isVisible = !isLatest
}
Comment on lines +173 to +181
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

๋ฒ„์ „ ๋น„๊ต ๋กœ์ง์ด ์ทจ์•ฝํ•ฉ๋‹ˆ๋‹ค (๋ฌธ์ž ํฌํ•จ/์„ธ๊ทธ๋จผํŠธ ์ˆ˜ ๋ถˆ์ผ์น˜ ์‹œ NFE ์œ„ํ—˜)

"." ์ œ๊ฑฐ ํ›„ toInt ๋น„๊ต๋Š” "1.0.0-alpha" ๊ฐ™์€ ๋ฒ„์ „์—์„œ NumberFormatException์„ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์„ธ๊ทธ๋จผํŠธ ๋‹จ์œ„ ๋น„๊ต๋กœ ๊ต์ฒดํ•ด์ฃผ์„ธ์š”.

     private fun setupVersion() = with(binding) {
         val currentVersion = BuildConfig.VERSION_NAME
         val latest = "1.0"
         tvMyVersionInfo.text = "๋ฒ„์ „ ์ •๋ณด $currentVersion"
 
-        val isLatest = currentVersion.replace(".", "").toInt() >= latest.replace(".", "").toInt()
+        val isLatest = compareVersionNames(currentVersion, latest) >= 0
         clMyVersionChip.isVisible = isLatest
         clMyGotoUpdate.isVisible = !isLatest
     }

์•„๋ž˜ ์œ ํ‹ธ ํ•จ์ˆ˜๋ฅผ ๋ณธ ํŒŒ์ผ ํ•˜๋‹จ(ํด๋ž˜์Šค ์•ˆ) ์–ด๋”˜๊ฐ€์— ์ถ”๊ฐ€ํ•ด ์ฃผ์„ธ์š”:

private fun compareVersionNames(a: String, b: String): Int {
    fun parse(v: String): List<Int> =
        v.split('.', '-', '_')
            .map { seg -> seg.filter { it.isDigit() } }
            .filter { it.isNotEmpty() }
            .map { it.toIntOrNull() ?: 0 }

    val av = parse(a)
    val bv = parse(b)
    val max = maxOf(av.size, bv.size)
    for (i in 0 until max) {
        val ai = av.getOrElse(i) { 0 }
        val bi = bv.getOrElse(i) { 0 }
        if (ai != bi) return ai.compareTo(bi)
    }
    return 0
}

๋˜ํ•œ, latest๋ฅผ ํ•˜๋“œ์ฝ”๋”ฉํ•˜๊ธฐ๋ณด๋‹ค ์›๊ฒฉ ๊ตฌ์„ฑ(Remote Config) ๋˜๋Š” ๋ฐฑ์—”๋“œ์—์„œ ์ตœ์‹  ๋ฒ„์ „์„ ๋‚ด๋ ค๋ฐ›๋Š” ๊ตฌ์กฐ๋กœ ๋ฐ”๊พธ๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

๐Ÿค– Prompt for AI Agents
In app/src/main/java/com/example/findu/presentation/ui/my/MyFragment.kt around
lines 173-181, the version-comparison removes dots then parses to Int which can
throw NumberFormatException for pre-release or non-numeric segments; replace
that logic by adding the provided compareVersionNames(a,b) helper as a private
function inside the class (near the file bottom) and change setupVersion() to
call compareVersionNames(currentVersion, latest) to determine isLatest (>= 0
means current is latest); additionally remove the hardcoded latest value and
wire it to a Remote Config / backend value when available.


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand Down Expand Up @@ -171,6 +211,27 @@ class MyFragment : Fragment() {
}
}
}
launch {
myViewModel.selectedImageResId.collect { resId ->
resId?.let {
binding.ivMyIllust.setImageResource(it)
}
}
}
launch {
myViewModel.selectedProfileImageUri.collect { uri ->
uri?.let {
binding.ivMyIllust.setImageURI(it)
}
}
}
launch {
myViewModel.alarmEnabled.collect { enabled ->
binding.ivMyAlarmIcon.setImageResource(
if (enabled) R.drawable.img_my_alarm_on else R.drawable.img_my_alarm_off
)
}
}
}
}
}
Expand All @@ -179,4 +240,4 @@ class MyFragment : Fragment() {
super.onDestroyView()
_binding = null
}
}
}
Loading