fix: 휴가관리 UI 정리 및 자동 저장 기능 추가

- 중복된 '연차: -1일 / 반년: -0.5일 차감' 텍스트 제거
- 중복된 Spinner/NumberPicker 뷰 정리
- 저장 버튼 제거하고 Spinner 선택 시 자동 저장되도록 개선
- 버전 업데이트 v1.4.6 (1146)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-03-13 00:27:42 +09:00
parent 608109e437
commit f586d74759
3 changed files with 40 additions and 48 deletions

View File

@@ -4,16 +4,19 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.example.shiftalarm.databinding.FragmentSettingsLabBinding
import kotlinx.coroutines.launch
import kotlinx.coroutines.delay
class FragmentSettingsLab : Fragment() {
private var _binding: FragmentSettingsLabBinding? = null
private val binding get() = _binding!!
private var isInitialLoad = true
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
@@ -28,7 +31,6 @@ class FragmentSettingsLab : Fragment() {
setupSpinner()
loadAnnualLeave()
setupSaveButton()
}
private fun setupSpinner() {
@@ -37,10 +39,25 @@ class FragmentSettingsLab : Fragment() {
val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, daysList)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
binding.spinnerTotalDays.adapter = adapter
// 선택 시 자동 저장
binding.spinnerTotalDays.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
if (!isInitialLoad) {
val totalDays = position + 1 // 0-indexed to actual days
saveAnnualLeave(totalDays)
}
}
override fun onNothingSelected(parent: AdapterView<*>?) {
// Do nothing
}
}
}
private fun loadAnnualLeave() {
lifecycleScope.launch {
isInitialLoad = true
val repo = ShiftRepository(requireContext())
val annualLeave = repo.getAnnualLeave()
@@ -53,24 +70,23 @@ class FragmentSettingsLab : Fragment() {
binding.spinnerTotalDays.setSelection(14)
binding.tvRemainingDays.text = "15"
}
// 초기 로드 완료 후 플래그 변경 (약간의 딜레이로 초기 선택 이벤트 방지)
delay(300)
isInitialLoad = false
}
}
private fun setupSaveButton() {
binding.btnSaveAnnualLeave.setOnClickListener {
val selectedPosition = binding.spinnerTotalDays.selectedItemPosition
val totalDays = selectedPosition + 1 // 0-indexed to actual days
private fun saveAnnualLeave(totalDays: Int) {
lifecycleScope.launch {
val repo = ShiftRepository(requireContext())
lifecycleScope.launch {
val repo = ShiftRepository(requireContext())
repo.recalculateAndSaveAnnualLeave(totalDays.toFloat())
val updated = repo.getAnnualLeave()
updated?.let {
binding.tvRemainingDays.text = formatRemainingDays(it.remainingDays)
showCustomToast(requireContext(), "총 연차 ${totalDays}일로 저장되었습니다 (남은 연차: ${formatRemainingDays(it.remainingDays)}일)")
}
repo.recalculateAndSaveAnnualLeave(totalDays.toFloat())
val updated = repo.getAnnualLeave()
updated?.let {
binding.tvRemainingDays.text = formatRemainingDays(it.remainingDays)
showCustomToast(requireContext(), "총 연차 ${totalDays}일로 저장되었습니다 (남은 연차: ${formatRemainingDays(it.remainingDays)}일)")
}
}
}

View File

@@ -15,13 +15,13 @@
android:textSize="18sp"
android:textStyle="bold"
android:textColor="@color/text_primary"
android:layout_marginBottom="16dp"/>
android:layout_marginBottom="24dp"/>
<!-- Total Annual Leave Setting -->
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="12dp"
app:cardElevation="2dp"
app:cardBackgroundColor="@color/surface">
@@ -30,7 +30,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="12dp"
android:padding="16dp"
android:gravity="center_vertical">
<TextView
@@ -51,9 +51,6 @@
android:id="@+id/spinnerTotalDays"
android:layout_width="80dp"
android:layout_height="48dp"/>
android:id="@+id/npTotalDays"
android:layout_width="60dp"
android:layout_height="100dp"/>
<TextView
android:layout_width="wrap_content"
@@ -70,7 +67,7 @@
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="12dp"
app:cardElevation="2dp"
app:cardBackgroundColor="@color/surface">
@@ -79,7 +76,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="12dp"
android:padding="16dp"
android:gravity="center_vertical">
<TextView
@@ -116,16 +113,6 @@
</LinearLayout>
</androidx.cardview.widget.CardView>
<!-- Calculation Info -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="※ 연차: -1일 / 반년: -0.5일 차감"
android:textSize="12sp"
android:textColor="@color/text_tertiary"
android:layout_marginBottom="8dp"
android:gravity="center"/>
<!-- Calculation Info -->
<TextView
android:layout_width="wrap_content"
@@ -136,15 +123,4 @@
android:layout_marginBottom="24dp"
android:gravity="center"/>
<!-- Save Button -->
<com.google.android.material.button.MaterialButton
android:id="@+id/btnSaveAnnualLeave"
android:layout_width="match_parent"
android:layout_height="56dp"
android:text="저장"
android:textSize="16sp"
android:textStyle="bold"
app:cornerRadius="12dp"
android:backgroundTint="@color/primary"/>
</LinearLayout>

View File

@@ -1,7 +1,7 @@
{
"versionCode": 1145,
"versionName": "1.4.5",
"apkUrl": "https://git.webpluss.net/attachments/aeb7b079-f81b-4c77-b8ee-b8fde90a530e",
"changelog": "v1.4.5: 연차 최초적용 수정, 휴가관리 Spinner 변경, 동그라미 크기 확대",
"versionCode": 1146,
"versionName": "1.4.6",
"apkUrl": "https://git.webpluss.net/attachments/94d91eff-db0f-44af-b043-b03918cba243",
"changelog": "v1.4.6: 휴가관리 중복 텍스트 제거, 자동 저장 기능 추가",
"forceUpdate": false
}