fix: DB 마이그레이션 추가 및 연차 저장/다크모드/달력 UI 개선
- DB 마이그레이션으로 기존 알람 데이터 보존 - 연차 저장 문제 수정 (원래대로/연차 설정 시 updateRemainingAnnualLeave 호출) - 달력 5행 스크롤 없이 표시 (85dp 높이) - 알람 편집/월년 선택 다크모드 지원 - 설정 앱정보 버전 동기화 표시 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
package com.example.shiftalarm
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.*
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
@Database(entities = [ShiftOverride::class, DailyMemo::class, CustomAlarm::class, AnnualLeave::class], version = 4, exportSchema = false)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
@@ -11,6 +15,23 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
@Volatile
|
||||
private var INSTANCE: AppDatabase? = null
|
||||
|
||||
// Migration from version 3 to 4: Add AnnualLeave table
|
||||
private val MIGRATION_3_4 = object : Migration(3, 4) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
// Create AnnualLeave table
|
||||
database.execSQL(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS annual_leave (
|
||||
id INTEGER PRIMARY KEY NOT NULL,
|
||||
totalDays REAL NOT NULL,
|
||||
remainingDays REAL NOT NULL,
|
||||
updatedAt INTEGER NOT NULL
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun getDatabase(context: Context): AppDatabase {
|
||||
return INSTANCE ?: synchronized(this) {
|
||||
val instance = Room.databaseBuilder(
|
||||
@@ -18,7 +39,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
AppDatabase::class.java,
|
||||
"shift_database"
|
||||
)
|
||||
.fallbackToDestructiveMigration() // Simple for now
|
||||
.addMigrations(MIGRATION_3_4)
|
||||
.build()
|
||||
INSTANCE = instance
|
||||
instance
|
||||
|
||||
@@ -93,6 +93,7 @@ class FragmentSettingsAdditional : Fragment() {
|
||||
|
||||
// Tide Switch
|
||||
binding.switchTide.isChecked = prefs.getBoolean("show_tide", false)
|
||||
loadAppVersion()
|
||||
}
|
||||
|
||||
private fun setupListeners() {
|
||||
@@ -211,6 +212,18 @@ class FragmentSettingsAdditional : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun loadAppVersion() {
|
||||
try {
|
||||
val packageInfo = requireContext().packageManager.getPackageInfo(requireContext().packageName, 0)
|
||||
val versionName = packageInfo.versionName
|
||||
binding.tvAppVersion.text = "버전 $versionName"
|
||||
} catch (e: Exception) {
|
||||
binding.tvAppVersion.text = "버전 1.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
|
||||
@@ -595,6 +595,7 @@ class MainActivity : AppCompatActivity() {
|
||||
android.widget.Toast.makeText(this, "원래 근무로 복구되었습니다.", android.widget.Toast.LENGTH_SHORT).show()
|
||||
syncAllAlarms(this)
|
||||
updateCalendar()
|
||||
repo.updateRemainingAnnualLeave()
|
||||
}
|
||||
"직접 입력" -> {
|
||||
showCustomInputDialog(date, repo, team, factory)
|
||||
@@ -620,6 +621,7 @@ class MainActivity : AppCompatActivity() {
|
||||
updateCalendar()
|
||||
syncAllAlarms(this)
|
||||
android.widget.Toast.makeText(this, "${selected}(으)로 기록되었습니다. 알람이 해제됩니다.", android.widget.Toast.LENGTH_SHORT).show()
|
||||
repo.updateRemainingAnnualLeave()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
android:text="알람 추가"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/black"
|
||||
android:textColor="@color/text_primary"
|
||||
android:layout_centerInParent="true"/>
|
||||
|
||||
<TextView
|
||||
@@ -80,7 +80,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardBackgroundColor="@color/surface"
|
||||
android:layout_marginBottom="16dp">
|
||||
|
||||
<LinearLayout
|
||||
@@ -116,7 +116,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardBackgroundColor="@color/surface"
|
||||
android:layout_marginBottom="16dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/btnSelectSound"
|
||||
@@ -162,7 +162,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardBackgroundColor="@color/surface"
|
||||
android:layout_marginBottom="16dp">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
android:text="날짜 이동"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/black"
|
||||
android:textColor="@color/text_primary"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
|
||||
|
||||
@@ -361,5 +361,17 @@
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- App Version -->
|
||||
<TextView
|
||||
android:id="@+id/tvAppVersion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="버전 1.4.0"
|
||||
android:textColor="@color/text_tertiary"
|
||||
android:textSize="12sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/dayRoot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="108dp"
|
||||
android:layout_height="85dp"
|
||||
android:background="@drawable/bg_grid_cell_v4">
|
||||
|
||||
<!-- Day Number (top-left) -->
|
||||
|
||||
Reference in New Issue
Block a user