Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30d2fb26c7 | ||
|
|
2d237cb532 |
No files matched your search
@@ -1,5 +1,20 @@
|
||||
# 변경 기록
|
||||
|
||||
## 0.12.0 · 2026년 11월 21일
|
||||
|
||||
- 주 시작을 월요일 또는 일요일로 선택합니다.
|
||||
- 앱과 웹 달력 및 월간·두 주 위젯에 같은 배치를 적용합니다.
|
||||
- 회원의 선택을 서버에 보관하며 구버전이 값을 생략해도 기존 선택을 유지합니다.
|
||||
- 근무 순서와 기준일 및 실제 요일의 색상은 그대로 유지합니다.
|
||||
|
||||
## 0.11.0 · 2026년 11월 21일
|
||||
|
||||
- 홈 화면 위젯을 4×4 월간 달력과 4×2 두 주 달력 및 2×4 근무 목록과 2×2 오늘 근무로 나눴습니다.
|
||||
- 앱의 위젯 추가에서도 가로×세로 기준으로 크기를 고릅니다.
|
||||
- 작은 위젯은 크기에 맞는 별도 배치를 사용합니다. 가로형은 14일씩 이동하고 세로형은 7일씩 이동합니다.
|
||||
- 투명도와 색상 및 글자 크기를 종류에 관계없이 위젯마다 저장합니다.
|
||||
- 기존 월간 위젯과 개인 일정 및 회원 설정은 유지합니다.
|
||||
|
||||
## 0.10.0 · 2026년 11월 20일
|
||||
|
||||
- 위젯별 배경 투명도 0~100%와 밝은·어두운 모양을 추가했습니다.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 당직근무
|
||||
|
||||
제작자 블리어 (이창현) · 미리보기 0.10.0 · Android 8.0 이상
|
||||
제작자 블리어 (이창현) · 미리보기 0.12.0 · Android 8.0 이상
|
||||
|
||||
당직과 교대근무를 달력으로 확인하고 홈 화면에 계속 놓아두는 앱입니다. 본인의 근무표는 로그인 없이 사용할 수 있습니다. 서버가 잠시 멈춰도 기기에 저장한 근무와 일정 및 기념일은 그대로 사용합니다.
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
| --- | --- |
|
||||
| 일당직과 교대근무 | 2~366당직과 대표 근무 배열 12개. 직접 반복 배열 수정 |
|
||||
| 토요일 근무 | 주 5일·6일제와 당직일 평일색 및 비번 빨간색 선택 |
|
||||
| 홈 화면 달력 | 월 이동과 오늘 이동. 위젯별 투명도·색상·글자 크기·표시 항목 |
|
||||
| 홈 화면 위젯 | 4×4 월간 달력 · 4×2 두 주 달력 · 2×4 근무 목록 · 2×2 오늘 근무 |
|
||||
| 위젯 꾸미기 | 위젯별 투명도·색상·글자 크기·표시 항목 |
|
||||
| 개인 일정과 알바 | 여러 일정과 매일·매주·매월·매년 반복. 자정을 넘는 근무 |
|
||||
| 기념일 | 생일과 개인 기념일. 양력·음력 및 윤달 선택 |
|
||||
| 공휴일과 음력 | 한국 공휴일 자동 확인과 정상 자료 보관. 음력 날짜 선택 표시 |
|
||||
|
||||
@@ -10,8 +10,8 @@ android {
|
||||
applicationId = "kr.co.itosm.dutycalendar"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 14
|
||||
versionName = "0.10.0"
|
||||
versionCode = 16
|
||||
versionName = "0.12.0"
|
||||
testInstrumentationRunner = "kr.co.itosm.dutycalendar.StorageSyncCheck"
|
||||
}
|
||||
// 빌드 도구는 JDK 21로 실행하지만 앱의 Java와 Kotlin 바이트코드 대상은 17로 통일한다.
|
||||
|
||||
@@ -18,6 +18,10 @@ object WidgetAppearanceCheck {
|
||||
val app=checker.targetContext
|
||||
val prefs=app.getSharedPreferences("widget_style",0)
|
||||
val original=prefs.all.toMap()
|
||||
val positions=app.getSharedPreferences("widget",0)
|
||||
val originalPositions=positions.all.toMap()
|
||||
val schedulePrefs=app.getSharedPreferences("schedule",0)
|
||||
val originalWeekStart=schedulePrefs.all["weekStart"]
|
||||
var success=false
|
||||
var message=""
|
||||
try {
|
||||
@@ -26,6 +30,16 @@ object WidgetAppearanceCheck {
|
||||
WidgetStyle.save(app,99002,WidgetStyle(transparency=40,detail="FULL"))
|
||||
check(WidgetStyle.load(app,99001)==dark)
|
||||
check(WidgetStyle.load(app,99002).transparency==40)
|
||||
val manager=AppWidgetManager.getInstance(app)
|
||||
val registered=manager.installedProviders.filter{it.provider.packageName==app.packageName}
|
||||
check(registered.map{it.provider.className}.toSet()==WidgetKind.entries.map{it.receiver.name}.toSet()) { "위젯 목록에 네 종류가 모두 등록되지 않았습니다." }
|
||||
if(android.os.Build.VERSION.SDK_INT>=31) {
|
||||
val expected=listOf(4 to 4,4 to 2,2 to 4,2 to 2)
|
||||
WidgetKind.entries.forEachIndexed{index,kind->
|
||||
val info=registered.single{it.provider==kind.component(app)}
|
||||
check(info.targetCellWidth==expected[index].first&&info.targetCellHeight==expected[index].second)
|
||||
}
|
||||
}
|
||||
var failure:Throwable?=null
|
||||
checker.runOnMainSync {
|
||||
try {
|
||||
@@ -47,16 +61,64 @@ object WidgetAppearanceCheck {
|
||||
check(WidgetStyle.load(app,99001)==WidgetStyle())
|
||||
check(render(99001,250).findViewById<TextView>(R.id.day_0).maxLines==2)
|
||||
check(render(99001,500).findViewById<TextView>(R.id.day_0).maxLines==7)
|
||||
// 주 시작이 달라지면 머리글과 날짜가 함께 이동해야 한다. 주말 색은 실제 요일에 둔다.
|
||||
for(start in 0..1) {
|
||||
val current=ScheduleStore.load(app)
|
||||
ScheduleStore.saveDisplay(app,current.dutyAsWeekday,current.showLunar,current.offAsHoliday,start,fromSync=true)
|
||||
check(ScheduleStore.load(app).weekStart==start)
|
||||
val month=render(99001,500)
|
||||
check(month.findViewById<TextView>(R.id.widget_sun).text==if(start==1)"월" else "일")
|
||||
check(month.findViewById<TextView>(R.id.widget_saturday).text==if(start==1)"일" else "토")
|
||||
val first=calendarDays(java.time.YearMonth.now(),start).first()
|
||||
check(month.findViewById<TextView>(R.id.day_0).contentDescription.startsWith("${first.monthValue}월 ${first.dayOfMonth}일"))
|
||||
positions.edit().remove("offset_99003").commit()
|
||||
check(CompactWidgetViews.start(app,99003,WidgetKind.WIDE).dayOfWeek.value==if(start==1)1 else 7)
|
||||
val sunHeader=month.findViewById<TextView>(if(start==1)R.id.widget_saturday else R.id.widget_sun)
|
||||
check(sunHeader.currentTextColor==WidgetStyle().color(0xFFBD5163.toInt()))
|
||||
}
|
||||
// 제공자 등록만 확인하지 않고 최소 크기의 실제 글줄이 영역 안에 들어오는지도 확인한다.
|
||||
val density=app.resources.displayMetrics.density
|
||||
for(kind in WidgetKind.entries.filter{it!=WidgetKind.MONTH}) {
|
||||
for(scale in listOf(80,100,120)) {
|
||||
WidgetStyle.save(app,99003,WidgetStyle(transparency=50,scale=scale))
|
||||
val options=Bundle().apply {
|
||||
putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,kind.width);putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,kind.width)
|
||||
putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,kind.height);putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,kind.height)
|
||||
}
|
||||
val root=DutyWidget.buildViews(app,99003,options,kind).apply(app,FrameLayout(app))
|
||||
root.measure(View.MeasureSpec.makeMeasureSpec((kind.width*density).toInt(),View.MeasureSpec.EXACTLY),View.MeasureSpec.makeMeasureSpec((kind.height*density).toInt(),View.MeasureSpec.EXACTLY))
|
||||
root.layout(0,0,root.measuredWidth,root.measuredHeight)
|
||||
val cell=root.findViewById<TextView>(if(kind==WidgetKind.TODAY)R.id.compact_shift else R.id.compact_day_0)
|
||||
check(cell.layout!=null&&cell.layout.height<=cell.height) { "${kind.title} 배율 $scale 글자 높이 초과: ${cell.layout.height}/${cell.height}" }
|
||||
check(Color.alpha((root.background as ColorDrawable).color)==128)
|
||||
}
|
||||
}
|
||||
// 실제 홈 화면에 배치된 새 종류는 자신의 날짜 범위만 이동하고 오늘로 돌아와야 한다.
|
||||
for(kind in listOf(WidgetKind.WIDE,WidgetKind.TALL)) {
|
||||
val id=manager.getAppWidgetIds(kind.component(app)).firstOrNull()?:continue
|
||||
positions.edit().remove("offset_$id").commit()
|
||||
val receiver=kind.receiver.getDeclaredConstructor().newInstance()
|
||||
receiver.onReceive(app,android.content.Intent(DutyWidget.NEXT).putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,id))
|
||||
check(positions.getInt("offset_$id",0)==if(kind==WidgetKind.WIDE)14 else 7)
|
||||
receiver.onReceive(app,android.content.Intent(DutyWidget.TODAY).putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,id))
|
||||
check(!positions.contains("offset_$id"))
|
||||
}
|
||||
} catch(error:Throwable){failure=error}
|
||||
}
|
||||
failure?.let{throw it}
|
||||
success=true
|
||||
message="위젯별 설정 분리와 전체 적용 및 투명도 100%·40% 확인. 실제 RemoteViews의 색상과 간단·자세한 배치 및 크기 자동 전환 확인."
|
||||
message="월요일·일요일 시작 저장과 월간 머리글·첫 날짜 및 두 주 위젯의 시작과 일요일 색상 확인. 네 위젯의 기본 칸 수와 최소 글자 높이 및 기간 이동과 개별 설정 확인."
|
||||
} catch(error:Throwable) {message=error.stackTraceToString()}
|
||||
finally {
|
||||
val scheduleRestore=schedulePrefs.edit()
|
||||
if(originalWeekStart is Int)scheduleRestore.putInt("weekStart",originalWeekStart) else scheduleRestore.remove("weekStart")
|
||||
check(scheduleRestore.commit())
|
||||
val editor=prefs.edit().clear()
|
||||
original.forEach{(key,value)->editor.putString(key,value as String)}
|
||||
check(editor.commit());DutyWidget.updateAll(app)
|
||||
val restore=positions.edit().clear()
|
||||
originalPositions.forEach{(key,value)->when(value){is String->restore.putString(key,value);is Int->restore.putInt(key,value)}}
|
||||
check(restore.commit());DutyWidget.updateAll(app)
|
||||
}
|
||||
checker.finish(if(success)Activity.RESULT_OK else Activity.RESULT_CANCELED,Bundle().apply{putString("stream",message)})
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<!-- 시스템 위젯 알림과 앱이 만든 명시적 PendingIntent만 받도록 외부 일반 호출을 막는다. -->
|
||||
<receiver android:name=".DutyWidget" android:exported="false">
|
||||
<receiver android:name=".DutyWidget" android:label="@string/widget_month_name" android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
<action android:name="android.intent.action.DATE_CHANGED" />
|
||||
@@ -39,6 +39,36 @@
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.appwidget.provider" android:resource="@xml/duty_widget_info" />
|
||||
</receiver>
|
||||
<receiver android:name=".WideDutyWidget" android:label="@string/widget_wide_name" android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
<action android:name="android.intent.action.DATE_CHANGED" />
|
||||
<action android:name="android.intent.action.TIME_SET" />
|
||||
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.appwidget.provider" android:resource="@xml/duty_widget_wide_info" />
|
||||
</receiver>
|
||||
<receiver android:name=".TallDutyWidget" android:label="@string/widget_tall_name" android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
<action android:name="android.intent.action.DATE_CHANGED" />
|
||||
<action android:name="android.intent.action.TIME_SET" />
|
||||
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.appwidget.provider" android:resource="@xml/duty_widget_tall_info" />
|
||||
</receiver>
|
||||
<receiver android:name=".TodayDutyWidget" android:label="@string/widget_day_name" android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
<action android:name="android.intent.action.DATE_CHANGED" />
|
||||
<action android:name="android.intent.action.TIME_SET" />
|
||||
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.appwidget.provider" android:resource="@xml/duty_widget_today_info" />
|
||||
</receiver>
|
||||
<!-- 운영체제의 예약 관리자만 서비스를 연결할 수 있도록 전용 권한을 지정한다. -->
|
||||
<service android:name=".HolidaySyncService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" />
|
||||
<service android:name=".PlannerSyncService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true" />
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package kr.co.itosm.dutycalendar
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Typeface
|
||||
import android.net.Uri
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.util.TypedValue
|
||||
import android.widget.RemoteViews
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
|
||||
/** 작은 위젯에 월간 42칸을 그대로 축소하면 근무 글자가 잘린다.
|
||||
* 가로형은 두 주를 표시하고 세로형은 일주일의 근무 목록을 사용한다. 오늘형은 오늘과 내일에 집중한다.
|
||||
* 세 종류 모두 본문과 날짜 선택에 기존 근무 계산과 저장소를 그대로 사용한다.
|
||||
*/
|
||||
object CompactWidgetViews {
|
||||
private val cells=intArrayOf(R.id.compact_day_0,R.id.compact_day_1,R.id.compact_day_2,R.id.compact_day_3,R.id.compact_day_4,R.id.compact_day_5,R.id.compact_day_6,
|
||||
R.id.compact_day_7,R.id.compact_day_8,R.id.compact_day_9,R.id.compact_day_10,R.id.compact_day_11,R.id.compact_day_12,R.id.compact_day_13)
|
||||
fun start(context:Context,id:Int,kind:WidgetKind):LocalDate {
|
||||
val today=LocalDate.now()
|
||||
val base=if(kind==WidgetKind.WIDE)startOfWeek(today,ScheduleStore.load(context).weekStart) else today
|
||||
return base.plusDays(context.getSharedPreferences("widget",0).getInt("offset_$id",0).toLong())
|
||||
}
|
||||
private fun dateIntent(context:Context,id:Int,date:LocalDate)=PendingIntent.getActivity(context,id,
|
||||
Intent(context,MainActivity::class.java).setData(Uri.parse("dutycalendar://date/$date")).putExtra("selectedDate",date.toString()),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||
|
||||
fun build(context:Context,id:Int,kind:WidgetKind,width:Int,height:Int):RemoteViews {
|
||||
val style=WidgetStyle.load(context,id)
|
||||
val schedule=ScheduleStore.load(context)
|
||||
val today=LocalDate.now()
|
||||
val density=context.resources.displayMetrics.density
|
||||
val layout=when(kind){WidgetKind.WIDE->R.layout.duty_widget_wide;WidgetKind.TALL->R.layout.duty_widget_tall;else->R.layout.duty_widget_today}
|
||||
val views=RemoteViews(context.packageName,layout)
|
||||
views.setInt(R.id.compact_root,"setBackgroundColor",style.background)
|
||||
views.setViewPadding(R.id.compact_root,(8*density).toInt(),(6*density).toInt(),(8*density).toInt(),(6*density).toInt())
|
||||
views.setOnClickPendingIntent(R.id.compact_root,dateIntent(context,id,today))
|
||||
views.setTextColor(R.id.compact_title,style.ink)
|
||||
views.setTextColor(R.id.compact_customize,style.ink)
|
||||
views.setTextViewTextSize(R.id.compact_title,TypedValue.COMPLEX_UNIT_SP,if(kind==WidgetKind.WIDE)14f else 12f)
|
||||
val customize=Intent(context,MainActivity::class.java).setData(Uri.parse("dutycalendar://widget/$id/style")).putExtra("widgetStyleId",id)
|
||||
views.setOnClickPendingIntent(R.id.compact_customize,PendingIntent.getActivity(context,id,customize,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||
|
||||
if(kind==WidgetKind.TODAY) {
|
||||
val configured=ScheduleStore.isConfigured(context)
|
||||
views.setTextViewText(R.id.compact_title,today.format(DateTimeFormatter.ofPattern("M.d E",Locale.KOREAN)))
|
||||
views.setTextViewText(R.id.compact_shift,if(configured)schedule.shiftOn(today).title else "설정 필요")
|
||||
views.setTextColor(R.id.compact_shift,style.color(schedule.shiftColor(today)))
|
||||
val scale=style.scale/100f
|
||||
views.setTextViewTextSize(R.id.compact_shift,TypedValue.COMPLEX_UNIT_SP,(minOf((width-16)/5.3f,(height-64)/1.35f)).coerceIn(15f,26f)*scale)
|
||||
views.setInt(R.id.compact_shift,"setBackgroundColor",if(style.today)(if(style.dark)0x334A6D96 else 0x22A7B5CB) else 0)
|
||||
views.setTextViewText(R.id.compact_tomorrow,"내일 ${schedule.shiftOn(today.plusDays(1)).title}")
|
||||
views.setTextColor(R.id.compact_tomorrow,style.ink)
|
||||
views.setTextViewTextSize(R.id.compact_tomorrow,TypedValue.COMPLEX_UNIT_SP,11f*scale)
|
||||
views.setOnClickPendingIntent(R.id.compact_tomorrow,dateIntent(context,id,today.plusDays(1)))
|
||||
val details=detail(context,today,schedule,style)
|
||||
views.setTextViewText(R.id.compact_detail,details.ifBlank{"당직근무"})
|
||||
views.setTextColor(R.id.compact_detail,style.muted)
|
||||
views.setContentDescription(R.id.compact_shift,"${today} ${schedule.shiftOn(today).title}. $details")
|
||||
return views
|
||||
}
|
||||
|
||||
val first=start(context,id,kind)
|
||||
val count=if(kind==WidgetKind.WIDE)14 else 7
|
||||
val last=first.plusDays((count-1).toLong())
|
||||
views.setTextViewText(R.id.compact_title,if(kind==WidgetKind.WIDE)"${first.monthValue}.${first.dayOfMonth} – ${last.monthValue}.${last.dayOfMonth}" else "${first.monthValue}월 근무")
|
||||
for(control in listOf(R.id.compact_previous,R.id.compact_today,R.id.compact_next))views.setTextColor(control,style.ink)
|
||||
listOf(R.id.compact_previous to DutyWidget.PREVIOUS,R.id.compact_today to DutyWidget.TODAY,R.id.compact_next to DutyWidget.NEXT).forEach{(control,action)->
|
||||
val intent=Intent(context,kind.receiver).setAction(action).putExtra(android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID,id)
|
||||
views.setOnClickPendingIntent(control,PendingIntent.getBroadcast(context,id,intent,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||
}
|
||||
for(index in 0 until count) {
|
||||
val date=first.plusDays(index.toLong())
|
||||
val shift=schedule.shiftOn(date)
|
||||
val holiday=Holidays.name(context,date)
|
||||
val events=PlannerStore.eventsOn(context,date)
|
||||
val anniversaries=Anniversaries.on(context,date)
|
||||
val plus=if(style.eventMark&&(events.isNotEmpty()||anniversaries.isNotEmpty()))"+" else ""
|
||||
val dateLabel=if(kind==WidgetKind.WIDE)date.dayOfMonth.toString()+plus else date.format(DateTimeFormatter.ofPattern("M.d E",Locale.KOREAN))+plus
|
||||
val shiftLabel=if(kind==WidgetKind.WIDE)shift.shortTitle else shift.title
|
||||
val extra=if(kind==WidgetKind.TALL&&height>=380&&style.detail!="COMPACT")detail(context,date,schedule,style) else ""
|
||||
val separator=if(kind==WidgetKind.WIDE)"\n" else " "
|
||||
val text=dateLabel+separator+shiftLabel+(if(extra.isNotBlank())"\n$extra" else "")
|
||||
val styled=SpannableString(text)
|
||||
styled.setSpan(ForegroundColorSpan(style.color(schedule.dateColor(date,holiday!=null))),0,dateLabel.length,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
val shiftStart=dateLabel.length+separator.length
|
||||
styled.setSpan(ForegroundColorSpan(style.color(schedule.shiftColor(date))),shiftStart,shiftStart+shiftLabel.length,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
styled.setSpan(StyleSpan(Typeface.BOLD),shiftStart,shiftStart+shiftLabel.length,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
if(extra.isNotBlank())styled.setSpan(ForegroundColorSpan(style.muted),text.length-extra.length,text.length,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
val cell=cells[index]
|
||||
views.setTextViewText(cell,styled)
|
||||
views.setTextColor(cell,style.ink)
|
||||
val font=if(kind==WidgetKind.WIDE)minOf((height-54)/5.0f,(width-16)/7/3.0f).coerceIn(9f,15f) else minOf((width-16)/10f,(height-54)/7/2.4f).coerceIn(9f,14f)
|
||||
// 글자 확대를 선택해도 최소 높이에서 두 줄의 근무가 잘리지는 않게 상한을 둔다.
|
||||
// 위젯을 넓히거나 높이면 여유 공간만큼 선택한 배율이 그대로 드러난다.
|
||||
val lineLimit=if(kind==WidgetKind.WIDE)(height-56)/2/2.6f else (height-56)/7/2.6f
|
||||
views.setTextViewTextSize(cell,TypedValue.COMPLEX_UNIT_SP,minOf(font*style.scale/100,lineLimit.coerceAtLeast(8f)))
|
||||
views.setInt(cell,"setBackgroundColor",if(date==today&&style.today)(if(style.dark)0x554A6D96 else 0x44A7B5CB) else 0)
|
||||
views.setOnClickPendingIntent(cell,dateIntent(context,id,date))
|
||||
views.setContentDescription(cell,"${date} ${shift.title}. ${holiday.orEmpty()} 일정 ${events.size}개. 기념일 ${anniversaries.size}개. ${detail(context,date,schedule,style)}")
|
||||
}
|
||||
return views
|
||||
}
|
||||
private fun detail(context:Context,date:LocalDate,schedule:Schedule,style:WidgetStyle):String {
|
||||
val values=mutableListOf<String>()
|
||||
if(style.lunar&&schedule.showLunar)LunarDates.label(context,date)?.let{values.add(it)}
|
||||
if(style.holidays)Holidays.name(context,date)?.let{values.add(it)}
|
||||
if(style.anniversaries)Anniversaries.on(context,date).firstOrNull()?.let{values.add(it.getJSONObject("data").getString("title"))}
|
||||
if(style.people)People.onDuty(People.all(context),date).firstOrNull()?.let{values.add(it.name)}
|
||||
if(style.eventMark)PlannerStore.eventsOn(context,date).size.takeIf{it>0}?.let{values.add("일정 ${it}개")}
|
||||
return values.joinToString(" · ")
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import java.time.YearMonth
|
||||
* 월을 고르지 않은 위젯은 현재 달을 따라간다. 직접 이동한 위젯은 오늘 버튼을 누를 때까지 선택을 유지한다.
|
||||
* 날짜 변경과 부팅 알림 및 주기 갱신으로 오늘 표시를 갱신한다. 실제 전달 시점은 운영체제의 영향을 받는다.
|
||||
*/
|
||||
class DutyWidget : AppWidgetProvider() {
|
||||
open class DutyWidget : AppWidgetProvider() {
|
||||
override fun onUpdate(context: Context, manager: AppWidgetManager, ids: IntArray) {
|
||||
Holidays.schedule(context)
|
||||
SyncClient.schedule(context)
|
||||
@@ -32,7 +32,7 @@ class DutyWidget : AppWidgetProvider() {
|
||||
override fun onAppWidgetOptionsChanged(context: Context, manager: AppWidgetManager, id: Int, options: Bundle) { update(context, manager, id) }
|
||||
override fun onDeleted(context: Context, ids: IntArray) {
|
||||
val editor = context.getSharedPreferences("widget", Context.MODE_PRIVATE).edit()
|
||||
ids.forEach { editor.remove("month_$it") }
|
||||
ids.forEach { editor.remove("month_$it");editor.remove("offset_$it") }
|
||||
editor.apply()
|
||||
context.getSharedPreferences("widget_style",0).edit().apply { ids.forEach { remove("style_$it") } }.apply()
|
||||
}
|
||||
@@ -43,11 +43,16 @@ class DutyWidget : AppWidgetProvider() {
|
||||
if (action in listOf(PREVIOUS, NEXT, TODAY)) {
|
||||
val id = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1)
|
||||
// 삭제된 위젯이나 이 앱에 속하지 않은 번호로 들어온 요청은 처리하지 않는다.
|
||||
if (id !in manager.getAppWidgetIds(ComponentName(context, DutyWidget::class.java))) return
|
||||
if (manager.getAppWidgetInfo(id)?.provider != ComponentName(context,javaClass)) return
|
||||
val kind=WidgetKind.of(context,id)
|
||||
val prefs = context.getSharedPreferences("widget", Context.MODE_PRIVATE)
|
||||
val editor = prefs.edit()
|
||||
if (action == TODAY) editor.remove("month_$id")
|
||||
else editor.putString("month_$id", selectedMonth(context, id).plusMonths(if (action == NEXT) 1 else -1).toString())
|
||||
if (action == TODAY) { editor.remove("month_$id");editor.remove("offset_$id") }
|
||||
else if(kind==WidgetKind.MONTH)editor.putString("month_$id", selectedMonth(context, id).plusMonths(if (action == NEXT) 1 else -1).toString())
|
||||
else {
|
||||
val step=if(kind==WidgetKind.WIDE)14 else 7
|
||||
editor.putInt("offset_$id",(prefs.getInt("offset_$id",0)+(if(action==NEXT)step else -step)).coerceIn(-36500,36500))
|
||||
}
|
||||
editor.apply()
|
||||
update(context, manager, id)
|
||||
} else if (action in listOf(Intent.ACTION_DATE_CHANGED, Intent.ACTION_TIME_CHANGED, Intent.ACTION_TIMEZONE_CHANGED, Intent.ACTION_BOOT_COMPLETED)) {
|
||||
@@ -58,9 +63,9 @@ class DutyWidget : AppWidgetProvider() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val PREVIOUS = "kr.co.itosm.dutycalendar.PREVIOUS"
|
||||
private const val NEXT = "kr.co.itosm.dutycalendar.NEXT"
|
||||
private const val TODAY = "kr.co.itosm.dutycalendar.TODAY"
|
||||
internal const val PREVIOUS = "kr.co.itosm.dutycalendar.PREVIOUS"
|
||||
internal const val NEXT = "kr.co.itosm.dutycalendar.NEXT"
|
||||
internal const val TODAY = "kr.co.itosm.dutycalendar.TODAY"
|
||||
// 날짜 칸의 리소스 참조를 명시해 코드와 42칸 레이아웃의 순서를 맞춘다.
|
||||
// 문자열로 리소스를 찾지 않으므로 이름 변경이나 리소스 축소 때도 참조 관계를 추적할 수 있다.
|
||||
private val DAY_IDS = intArrayOf(
|
||||
@@ -78,15 +83,32 @@ class DutyWidget : AppWidgetProvider() {
|
||||
|
||||
fun updateAll(context: Context) {
|
||||
val manager = AppWidgetManager.getInstance(context)
|
||||
manager.getAppWidgetIds(ComponentName(context, DutyWidget::class.java)).forEach { update(context, manager, it) }
|
||||
WidgetKind.ids(context).forEach { update(context, manager, it) }
|
||||
}
|
||||
private fun update(context: Context, manager: AppWidgetManager, id: Int) {
|
||||
manager.updateAppWidget(id, buildViews(context,id,manager.getAppWidgetOptions(id)))
|
||||
val options=manager.getAppWidgetOptions(id)
|
||||
val kind=WidgetKind.of(context,id)
|
||||
// Android 12 이상은 홈 화면이 알려 준 각 크기별로 배치를 준비한다.
|
||||
// 방향 전환만으로도 알맞은 RemoteViews가 선택되며 작은 종류를 4칸 높이로 강제하지 않는다.
|
||||
if(android.os.Build.VERSION.SDK_INT>=31) {
|
||||
@Suppress("DEPRECATION")
|
||||
val sizes=options.getParcelableArrayList<android.util.SizeF>(AppWidgetManager.OPTION_APPWIDGET_SIZES)?.filter{it.width>0&&it.height>0}?.distinct()?.take(16)
|
||||
if(!sizes.isNullOrEmpty()) {
|
||||
manager.updateAppWidget(id,RemoteViews(sizes.associateWith{size->buildViews(context,id,Bundle(options).apply{
|
||||
putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,size.width.toInt());putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,size.width.toInt())
|
||||
putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,size.height.toInt());putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,size.height.toInt())
|
||||
},kind)}))
|
||||
return
|
||||
}
|
||||
}
|
||||
manager.updateAppWidget(id, buildViews(context,id,options,kind))
|
||||
}
|
||||
internal fun buildViews(context:Context,id:Int,options:Bundle):RemoteViews {
|
||||
internal fun buildViews(context:Context,id:Int,options:Bundle,kind:WidgetKind=WidgetKind.of(context,id)):RemoteViews {
|
||||
val style=WidgetStyle.load(context,id)
|
||||
val portrait=context.resources.configuration.orientation!=android.content.res.Configuration.ORIENTATION_LANDSCAPE
|
||||
val height=options.getInt(if(portrait)AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT else AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,420).coerceIn(250,1200)
|
||||
val height=options.getInt(if(portrait)AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT else AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,kind.height).coerceIn(90,1200)
|
||||
val width=options.getInt(if(portrait)AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH else AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,kind.width).coerceIn(90,1200)
|
||||
if(kind!=WidgetKind.MONTH)return CompactWidgetViews.build(context,id,kind,width,height)
|
||||
val compact=style.compact(height)
|
||||
val density=context.resources.displayMetrics.density
|
||||
val month = selectedMonth(context, id)
|
||||
@@ -100,8 +122,12 @@ class DutyWidget : AppWidgetProvider() {
|
||||
view.setViewPadding(R.id.widget_root,(12*density).toInt(),(10*density).toInt(),(12*density).toInt(),(10*density).toInt())
|
||||
for(control in listOf(R.id.widget_title,R.id.widget_today,R.id.widget_customize,R.id.widget_previous,R.id.widget_next))view.setTextColor(control,style.ink)
|
||||
for(control in listOf(R.id.widget_subtitle,R.id.widget_footer,R.id.widget_mon,R.id.widget_tue,R.id.widget_wed,R.id.widget_thu,R.id.widget_fri))view.setTextColor(control,style.muted)
|
||||
view.setTextColor(R.id.widget_sun,style.color(0xFFBD5163.toInt()))
|
||||
view.setTextColor(R.id.widget_saturday, style.color(schedule.saturdayColor))
|
||||
// 화면의 칸 번호와 실제 요일을 분리한다. 월요일 시작에서도 주말 색은 해당 요일에 남긴다.
|
||||
val headers = intArrayOf(R.id.widget_sun,R.id.widget_mon,R.id.widget_tue,R.id.widget_wed,R.id.widget_thu,R.id.widget_fri,R.id.widget_saturday)
|
||||
calendarWeekdays(schedule.weekStart).forEachIndexed { index, day ->
|
||||
view.setTextViewText(headers[index], listOf("일","월","화","수","목","금","토")[day])
|
||||
view.setTextColor(headers[index], when(day) { 0 -> style.color(0xFFBD5163.toInt()); 6 -> style.color(schedule.saturdayColor); else -> style.muted })
|
||||
}
|
||||
view.setTextViewTextSize(R.id.widget_title,android.util.TypedValue.COMPLEX_UNIT_SP,18f*style.scale/100)
|
||||
val customize=Intent(context,MainActivity::class.java).setData(android.net.Uri.parse("dutycalendar://widget/$id/style")).putExtra("widgetStyleId",id)
|
||||
view.setOnClickPendingIntent(R.id.widget_customize,PendingIntent.getActivity(context,id,customize,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||
@@ -116,7 +142,7 @@ class DutyWidget : AppWidgetProvider() {
|
||||
val intent = Intent(context, DutyWidget::class.java).setAction(action).putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id)
|
||||
view.setOnClickPendingIntent(control, PendingIntent.getBroadcast(context, id, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||
}
|
||||
calendarDays(month).forEachIndexed { index, date ->
|
||||
calendarDays(month, schedule.weekStart).forEachIndexed { index, date ->
|
||||
val shift = schedule.shiftOn(date)
|
||||
val holiday = Holidays.name(context, date)
|
||||
val events = PlannerStore.eventsOn(context, date)
|
||||
|
||||
@@ -150,13 +150,14 @@ class MainActivity : Activity() {
|
||||
calendar.addView(navigation)
|
||||
space(calendar, 12)
|
||||
val week = row()
|
||||
listOf("일", "월", "화", "수", "목", "금", "토").forEachIndexed { i, text ->
|
||||
week.addView(label(text, 13f, if (i == 0) 0xFFBD5163.toInt() else if (i == 6) schedule.saturdayColor else muted, true).apply { gravity = Gravity.CENTER }, LinearLayout.LayoutParams(0, dp(32), 1f))
|
||||
calendarWeekdays(schedule.weekStart).forEach { day ->
|
||||
val text = listOf("일", "월", "화", "수", "목", "금", "토")[day]
|
||||
week.addView(label(text, 13f, if (day == 0) 0xFFBD5163.toInt() else if (day == 6) schedule.saturdayColor else muted, true).apply { gravity = Gravity.CENTER }, LinearLayout.LayoutParams(0, dp(32), 1f))
|
||||
}
|
||||
calendar.addView(week)
|
||||
// 한 주를 7칸으로 나누고 같은 너비를 배정한다. 공휴일은 날짜 색상과 이름으로 함께 구분한다.
|
||||
// 앞뒤 달의 근무도 계산하지만 투명도를 낮춰 현재 보고 있는 달과 혼동하지 않게 한다.
|
||||
calendarDays(month).chunked(7).forEach { dates ->
|
||||
calendarDays(month, schedule.weekStart).chunked(7).forEach { dates ->
|
||||
val cells = row()
|
||||
dates.forEach { date ->
|
||||
val shift = schedule.shiftOn(date)
|
||||
@@ -346,7 +347,10 @@ class MainActivity : Activity() {
|
||||
if (!ScheduleStore.isConfigured(this)) { showSettings(); return }
|
||||
val manager = getSystemService(AppWidgetManager::class.java)
|
||||
if (manager.isRequestPinAppWidgetSupported) {
|
||||
manager.requestPinAppWidget(ComponentName(this, DutyWidget::class.java), null, null)
|
||||
AlertDialog.Builder(this).setTitle("위젯 크기 선택 · 가로×세로")
|
||||
.setItems(WidgetKind.entries.map{it.title}.toTypedArray()){_,index->
|
||||
manager.requestPinAppWidget(WidgetKind.entries[index].component(this),null,null)
|
||||
}.setNegativeButton("취소",null).show()
|
||||
} else {
|
||||
AlertDialog.Builder(this).setTitle("홈 화면에 추가하기").setMessage("홈 화면의 빈 곳을 길게 누른 뒤 위젯 목록에서 ‘당직근무’를 선택해 주세요.").setPositiveButton("확인", null).show()
|
||||
}
|
||||
@@ -400,6 +404,14 @@ class MainActivity : Activity() {
|
||||
form.addView(button("위젯 꾸미기 · 투명도와 크기") { WidgetStyleDialog.show(this) }, LinearLayout.LayoutParams(-1,dp(48)))
|
||||
form.addView(button("휴대폰 달력 연동") { deviceCalendar.open() }, LinearLayout.LayoutParams(-1,dp(48)))
|
||||
form.addView(label("앱과 홈 위젯에 함께 적용합니다.\n근무 순서와 기준일은 바뀌지 않습니다.", 12f, muted))
|
||||
space(form, 12)
|
||||
form.addView(label("주 시작 요일", 14f, ink, true))
|
||||
val weekStart = Spinner(this).apply {
|
||||
adapter = ArrayAdapter(this@MainActivity, android.R.layout.simple_spinner_dropdown_item, listOf("월요일 시작", "일요일 시작"))
|
||||
setSelection(if (current.weekStart == 1) 0 else 1)
|
||||
contentDescription = "주 시작 요일"
|
||||
}
|
||||
form.addView(weekStart, LinearLayout.LayoutParams(-1, dp(48)))
|
||||
fun choice(title: String, description: String, checked: Boolean): CheckBox {
|
||||
val option = CheckBox(this).apply { text = title; textSize = 14f; isChecked = checked; minHeight = dp(48) }
|
||||
space(form, 8); form.addView(option); form.addView(label(description, 12f, muted))
|
||||
@@ -412,7 +424,7 @@ class MainActivity : Activity() {
|
||||
.setNegativeButton("취소", null).setPositiveButton("저장", null).create()
|
||||
dialog.setOnShowListener {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
runCatching { ScheduleStore.saveDisplay(this, weekday.isChecked, lunar.isChecked, off.isChecked) }
|
||||
runCatching { ScheduleStore.saveDisplay(this, weekday.isChecked, lunar.isChecked, off.isChecked, if (weekStart.selectedItemPosition == 0) 1 else 0) }
|
||||
.onSuccess { render(); dialog.dismiss(); Toast.makeText(this, "표시 옵션을 저장했습니다.", Toast.LENGTH_SHORT).show() }
|
||||
.onFailure { Toast.makeText(this, it.message ?: "저장 공간을 확인해 주세요.", Toast.LENGTH_LONG).show() }
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ class PlannerDialogs(private val activity: Activity, private val changed: () ->
|
||||
if (item == null || item.optBoolean("deleted")) return "삭제된 일정"
|
||||
val data = item.getJSONObject("data")
|
||||
if (item.getString("kind") == "anniversary") return "${data.getString("title")}\n${Anniversaries.description(data)}\n${data.getString("notes")}"
|
||||
if (item.getString("kind") == "preferences") return "당직일 평일색: ${if (data.getBoolean("dutyAsWeekday")) "켜짐" else "꺼짐"}\n비번 빨간색: ${if (data.getBoolean("offAsHoliday")) "켜짐" else "꺼짐"}\n음력 표시: ${if (data.getBoolean("showLunar")) "켜짐" else "꺼짐"}"
|
||||
if (item.getString("kind") == "preferences") return "당직일 평일색: ${if (data.getBoolean("dutyAsWeekday")) "켜짐" else "꺼짐"}\n비번 빨간색: ${if (data.getBoolean("offAsHoliday")) "켜짐" else "꺼짐"}\n음력 표시: ${if (data.getBoolean("showLunar")) "켜짐" else "꺼짐"}\n주 시작: ${if (data.optInt("weekStart", 0) == 1) "월요일" else "일요일"}"
|
||||
if (item.getString("kind") == "person") return "${data.getString("name")} · ${People.colors.getValue(data.getString("color")).first}\n첫째 날: ${data.getString("anchor")}\n" + PlannerStore.listStrings(data.getJSONArray("pattern")).joinToString(" → ") { Shift.valueOf(it).title }
|
||||
if (item.getString("kind") == "rotation") return "첫째 날: ${data.getString("anchor")}\n" + (0 until data.getJSONArray("pattern").length()).joinToString(" → ") { Shift.valueOf(data.getJSONArray("pattern").getString(it)).title }
|
||||
return "${data.getString("title")}\n${data.getString("date")} ~ ${data.getString("endDate")}\n" + (if (data.getBoolean("allDay")) "하루 종일" else "${data.getString("startTime")} ~ ${data.getString("endTime")}") + "\n${categoryName(data.getString("category"))}\n${data.getString("notes")}"
|
||||
|
||||
@@ -99,21 +99,21 @@ object PlannerStore {
|
||||
preferences(context).edit().putBoolean("migrated", true).commit()
|
||||
}
|
||||
fun queueRotation(context: Context, schedule: Schedule) {
|
||||
put(context, "rotation", "rotation", JSONObject().put("anchor", schedule.anchor.toString()).put("pattern", JSONArray(schedule.pattern.map { it.name })).put("workWeek", schedule.workWeek).put("dutyAsWeekday", schedule.dutyAsWeekday).put("showLunar", schedule.showLunar).put("offAsHoliday", schedule.offAsHoliday))
|
||||
put(context, "rotation", "rotation", JSONObject().put("anchor", schedule.anchor.toString()).put("pattern", JSONArray(schedule.pattern.map { it.name })).put("workWeek", schedule.workWeek).put("dutyAsWeekday", schedule.dutyAsWeekday).put("showLunar", schedule.showLunar).put("offAsHoliday", schedule.offAsHoliday).put("weekStart", schedule.weekStart))
|
||||
}
|
||||
fun queuePreferences(context: Context, schedule: Schedule) {
|
||||
put(context, "preferences", "preferences", JSONObject().put("dutyAsWeekday", schedule.dutyAsWeekday)
|
||||
.put("showLunar", schedule.showLunar).put("offAsHoliday", schedule.offAsHoliday))
|
||||
.put("showLunar", schedule.showLunar).put("offAsHoliday", schedule.offAsHoliday).put("weekStart", schedule.weekStart))
|
||||
}
|
||||
private fun applyRotation(context: Context) {
|
||||
val items = items(context)
|
||||
val options = items.find { it.getString("kind") == "preferences" }?.getJSONObject("data")
|
||||
items.find { it.getString("kind") == "rotation" }?.getJSONObject("data")?.let { data ->
|
||||
val display = options ?: data
|
||||
ScheduleStore.save(context, Schedule(LocalDate.parse(data.getString("anchor")), strings(data.getJSONArray("pattern")).map(Shift::valueOf), data.optInt("workWeek", 6), display.optBoolean("dutyAsWeekday", false), display.optBoolean("showLunar", false), display.optBoolean("offAsHoliday", false)), fromSync = true)
|
||||
ScheduleStore.save(context, Schedule(LocalDate.parse(data.getString("anchor")), strings(data.getJSONArray("pattern")).map(Shift::valueOf), data.optInt("workWeek", 6), display.optBoolean("dutyAsWeekday", false), display.optBoolean("showLunar", false), display.optBoolean("offAsHoliday", false), display.optInt("weekStart", data.optInt("weekStart", 0))), fromSync = true)
|
||||
}
|
||||
if (options != null) {
|
||||
ScheduleStore.saveDisplay(context, options.getBoolean("dutyAsWeekday"), options.getBoolean("showLunar"), options.getBoolean("offAsHoliday"), fromSync = true)
|
||||
ScheduleStore.saveDisplay(context, options.getBoolean("dutyAsWeekday"), options.getBoolean("showLunar"), options.getBoolean("offAsHoliday"), options.optInt("weekStart", ScheduleStore.load(context).weekStart), fromSync = true)
|
||||
}
|
||||
}
|
||||
@Synchronized fun conflict(context: Context): Pair<JSONObject, JSONObject?>? {
|
||||
|
||||
@@ -27,10 +27,11 @@ enum class Shift(val title: String, val shortTitle: String, val color: Int, val
|
||||
* 날짜 차이를 사용하므로 월말과 연말 및 윤년에도 주기가 끊기지 않는다.
|
||||
* 현재는 교대 시작 시각을 계산하지 않는다. 당직과 비번은 각각 한 날짜를 차지한다.
|
||||
*/
|
||||
data class Schedule(val anchor: LocalDate, val pattern: List<Shift>, val workWeek: Int = 6, val dutyAsWeekday: Boolean = false, val showLunar: Boolean = false, val offAsHoliday: Boolean = false) {
|
||||
data class Schedule(val anchor: LocalDate, val pattern: List<Shift>, val workWeek: Int = 6, val dutyAsWeekday: Boolean = false, val showLunar: Boolean = false, val offAsHoliday: Boolean = false, val weekStart: Int = 0) {
|
||||
init {
|
||||
require(pattern.size in 1..MAX_DAYS) { "반복 일수는 1일부터 ${MAX_DAYS}일까지 지정할 수 있습니다." }
|
||||
require(workWeek == 5 || workWeek == 6) { "주5일제 또는 주6일제를 선택해 주세요." }
|
||||
require(weekStart in 0..1) { "주 시작은 일요일 또는 월요일을 선택해 주세요." }
|
||||
}
|
||||
fun shiftOn(date: LocalDate): Shift {
|
||||
// 기준일 이전 날짜도 같은 반복에 속한다. 음수 나머지를 그대로 쓰면 배열 범위를 벗어난다.
|
||||
@@ -64,12 +65,22 @@ data class Schedule(val anchor: LocalDate, val pattern: List<Shift>, val workWee
|
||||
}
|
||||
|
||||
/**
|
||||
* 일요일부터 토요일까지 6주를 반환한다. 월마다 행 수를 바꾸지 않아 위젯 높이가 흔들리지 않는다.
|
||||
* LocalDate의 요일 값은 월요일이 1이고 일요일이 7이다. 나머지 연산으로 일요일을 0으로 맞춘다.
|
||||
* 선택한 주 시작부터 6주를 반환한다. 월마다 행 수를 바꾸지 않아 위젯 높이가 흔들리지 않는다.
|
||||
* 주 시작은 일요일 0과 월요일 1로 저장한다. 과거 자료에 값이 없으면 기존 일요일 배치를 유지한다.
|
||||
* 앞뒤 달 날짜도 함께 반환한다. 화면에서만 흐리게 표시하고 근무 계산에는 실제 날짜를 사용한다.
|
||||
*/
|
||||
fun calendarDays(month: YearMonth): List<LocalDate> {
|
||||
val first = month.atDay(1)
|
||||
val start = first.minusDays((first.dayOfWeek.value % 7).toLong())
|
||||
fun calendarDays(month: YearMonth, weekStart: Int = 0): List<LocalDate> {
|
||||
val start = startOfWeek(month.atDay(1), weekStart)
|
||||
return List(42) { start.plusDays(it.toLong()) }
|
||||
}
|
||||
|
||||
/** 월간 달력과 두 주 위젯이 같은 기준을 사용한다. 일요일의 음수 차이도 이전 월요일로 맞춘다. */
|
||||
fun startOfWeek(date: LocalDate, weekStart: Int = 0): LocalDate {
|
||||
require(weekStart in 0..1)
|
||||
return date.minusDays(Math.floorMod(date.dayOfWeek.value % 7 - weekStart, 7).toLong())
|
||||
}
|
||||
|
||||
fun calendarWeekdays(weekStart: Int): List<Int> {
|
||||
require(weekStart in 0..1)
|
||||
return List(7) { (it + weekStart) % 7 }
|
||||
}
|
||||
@@ -23,17 +23,19 @@ object ScheduleStore {
|
||||
prefs.getInt("workWeek", 6),
|
||||
prefs.getBoolean("dutyAsWeekday", false),
|
||||
prefs.getBoolean("showLunar", false),
|
||||
prefs.getBoolean("offAsHoliday", false)
|
||||
prefs.getBoolean("offAsHoliday", false),
|
||||
prefs.getInt("weekStart", 0)
|
||||
)
|
||||
}.getOrElse { Schedule(LocalDate.now(), Schedule.preset(2)) }
|
||||
}
|
||||
/** 표시 선택만 먼저 저장해도 예시 근무표가 실제 근무표로 등록되지는 않게 한다.
|
||||
* 기초 설정이 있으면 최신 기준일과 순서를 그대로 복사해 옵션 세 항목만 갱신한다.
|
||||
* 기초 설정이 있으면 최신 기준일과 순서를 그대로 복사해 표시 옵션만 갱신한다.
|
||||
* 따라서 옵션 창을 연 사이에 다른 기기에서 받은 근무표를 이전 값으로 되돌리지 않는다.
|
||||
*/
|
||||
fun saveDisplay(context: Context, dutyAsWeekday: Boolean, showLunar: Boolean, offAsHoliday: Boolean, fromSync: Boolean = false) {
|
||||
fun saveDisplay(context: Context, dutyAsWeekday: Boolean, showLunar: Boolean, offAsHoliday: Boolean, weekStart: Int = load(context).weekStart, fromSync: Boolean = false) {
|
||||
require(weekStart in 0..1) { "주 시작 요일을 확인해 주세요." }
|
||||
check(preferences(context).edit().putBoolean("dutyAsWeekday", dutyAsWeekday)
|
||||
.putBoolean("showLunar", showLunar).putBoolean("offAsHoliday", offAsHoliday).commit()) { "저장 공간을 확인해 주세요." }
|
||||
.putBoolean("showLunar", showLunar).putBoolean("offAsHoliday", offAsHoliday).putInt("weekStart", weekStart).commit()) { "저장 공간을 확인해 주세요." }
|
||||
// 개인 표시 선택은 근무표와 별도 항목으로 저장한다. 회원은 근무표를 아직 만들지 않아도 복원할 수 있다.
|
||||
if (!fromSync && (isConfigured(context) || PlannerStore.calendarId(context).isNotBlank())) {
|
||||
PlannerStore.queuePreferences(context, load(context))
|
||||
@@ -51,6 +53,7 @@ object ScheduleStore {
|
||||
.putBoolean("dutyAsWeekday", schedule.dutyAsWeekday)
|
||||
.putBoolean("showLunar", schedule.showLunar)
|
||||
.putBoolean("offAsHoliday", schedule.offAsHoliday)
|
||||
.putInt("weekStart", schedule.weekStart)
|
||||
.apply()
|
||||
if (!fromSync) {
|
||||
PlannerStore.queueRotation(context, schedule)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package kr.co.itosm.dutycalendar
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
|
||||
/** 홈 화면의 위젯 목록에 크기별 항목을 실제로 등록한다.
|
||||
* 기존 수신자 이름은 그대로 남겨 업데이트 전에 배치한 월간 달력을 보존한다.
|
||||
* 위젯 번호는 시스템 전체에서 구분되므로 종류가 달라도 월 이동과 꾸미기 저장 키가 겹치지 않는다.
|
||||
*/
|
||||
enum class WidgetKind(val receiver:Class<out DutyWidget>,val title:String,val width:Int,val height:Int) {
|
||||
MONTH(DutyWidget::class.java,"월간 달력 · 4×4",250,250),
|
||||
WIDE(WideDutyWidget::class.java,"두 주 달력 · 4×2",250,110),
|
||||
TALL(TallDutyWidget::class.java,"근무 목록 · 2×4",110,250),
|
||||
TODAY(TodayDutyWidget::class.java,"오늘 근무 · 2×2",110,110);
|
||||
|
||||
fun component(context:Context)=ComponentName(context,receiver)
|
||||
companion object {
|
||||
fun of(context:Context,id:Int):WidgetKind {
|
||||
val name=AppWidgetManager.getInstance(context).getAppWidgetInfo(id)?.provider?.className
|
||||
return entries.firstOrNull{it.receiver.name==name}?:MONTH
|
||||
}
|
||||
fun ids(context:Context):IntArray {
|
||||
val manager=AppWidgetManager.getInstance(context)
|
||||
return entries.flatMap{manager.getAppWidgetIds(it.component(context)).toList()}.toIntArray()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WideDutyWidget:DutyWidget()
|
||||
class TallDutyWidget:DutyWidget()
|
||||
class TodayDutyWidget:DutyWidget()
|
||||
@@ -50,11 +50,11 @@ data class WidgetStyle(
|
||||
|
||||
object WidgetStyleDialog {
|
||||
fun show(activity:Activity,id:Int?=null) {
|
||||
val ids=AppWidgetManager.getInstance(activity).getAppWidgetIds(ComponentName(activity,DutyWidget::class.java))
|
||||
val ids=WidgetKind.ids(activity)
|
||||
if(id!=null){if(id in ids)edit(activity,id);return}
|
||||
if(ids.isEmpty()){edit(activity,null);return}
|
||||
AlertDialog.Builder(activity).setTitle("꾸밀 위젯 선택")
|
||||
.setItems((listOf("모든 위젯과 새 위젯의 기본값")+ids.mapIndexed{index,_->"위젯 ${index+1}"}).toTypedArray()){_,index->edit(activity,if(index==0)null else ids[index-1])}
|
||||
.setItems((listOf("모든 위젯과 새 위젯의 기본값")+ids.mapIndexed{index,widgetId->"${WidgetKind.of(activity,widgetId).title} · ${index+1}"}).toTypedArray()){_,index->edit(activity,if(index==0)null else ids[index-1])}
|
||||
.setNegativeButton("닫기",null).show()
|
||||
}
|
||||
private fun edit(activity:Activity,id:Int?) {
|
||||
@@ -73,7 +73,7 @@ object WidgetStyleDialog {
|
||||
val theme=spinner("배경과 글자 색상",listOf("밝은 배경 · 어두운 글자","어두운 배경 · 밝은 글자"),if(original.dark)1 else 0)
|
||||
val size=spinner("글자 크기",listOf("작게 · 80%","기본 · 100%","크게 · 120%"),listOf(80,100,120).indexOf(original.scale))
|
||||
val details=spinner("내용 배치",listOf("자동 · 위젯 크기에 맞춤","간단히 · 날짜와 근무","자세히 · 추가 정보 표시"),listOf("AUTO","COMPACT","FULL").indexOf(original.detail))
|
||||
label("위젯 전체 크기는 홈 화면에서 위젯을 길게 누른 뒤 테두리를 끌어 조절합니다. 작은 위젯은 간단한 배치가 읽기 좋습니다.")
|
||||
label("홈 화면에 추가할 때 4×4, 4×2, 2×4, 2×2를 고릅니다. 가로×세로 기준입니다. 배치 후 길게 누르고 테두리를 끌어 크기를 조절할 수 있습니다. 작은 종류는 공간에 맞는 항목만 표시합니다.")
|
||||
fun choice(title:String,value:Boolean)=CheckBox(activity).apply{text=title;isChecked=value;textSize=14f;minHeight=dp(42);form.addView(this)}
|
||||
val lunar=choice("음력 표시 · 앱의 음력 옵션을 따름",original.lunar)
|
||||
val holidays=choice("공휴일 이름 표시",original.holidays)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/widget_root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/widget_background">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="36dp" android:gravity="center_vertical">
|
||||
<TextView android:id="@+id/widget_title" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:text="@string/widget_name" android:textSize="18sp" android:textStyle="bold" android:textColor="#26364D" android:maxLines="1" />
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/compact_root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/widget_background" android:padding="6dp">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="24dp" android:gravity="center_vertical">
|
||||
<TextView android:id="@+id/compact_title" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center_vertical" android:text="@string/widget_name" android:textColor="#26364D" android:textSize="12sp" android:textStyle="bold" android:maxLines="1" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_customize" android:layout_width="34dp" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_customize" android:textSize="11sp" android:textColor="#26364D" />
|
||||
</LinearLayout>
|
||||
<TextView android:id="@+id/compact_day_0" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:text="@string/widget_list_example_0" android:textSize="12sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:text="@string/widget_list_example_1" android:textSize="12sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:text="@string/widget_list_example_2" android:textSize="12sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_3" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:text="@string/widget_list_example_3" android:textSize="12sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_4" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:text="@string/widget_list_example_4" android:textSize="12sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_5" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:text="@string/widget_list_example_5" android:textSize="12sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_6" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:text="@string/widget_list_example_6" android:textSize="12sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="20dp" android:gravity="center_vertical">
|
||||
<TextView android:id="@+id/compact_previous" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:text="@string/widget_previous" android:textSize="11sp" android:gravity="center" />
|
||||
<TextView android:id="@+id/compact_today" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:text="@string/widget_today" android:textSize="11sp" android:gravity="center" />
|
||||
<TextView android:id="@+id/compact_next" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:text="@string/widget_next" android:textSize="11sp" android:gravity="center" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/compact_root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/widget_background" android:padding="6dp">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="24dp" android:gravity="center_vertical">
|
||||
<TextView android:id="@+id/compact_title" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center_vertical" android:text="@string/widget_name" android:textColor="#26364D" android:textSize="12sp" android:textStyle="bold" android:maxLines="1" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_customize" android:layout_width="34dp" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_customize" android:textSize="11sp" android:textColor="#26364D" />
|
||||
</LinearLayout>
|
||||
<TextView android:id="@+id/compact_shift" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:text="@string/widget_duty_example" android:textColor="#AA4C2E" android:textStyle="bold" android:textSize="22sp" android:maxLines="1" android:ellipsize="end" android:includeFontPadding="false" />
|
||||
<TextView android:id="@+id/compact_tomorrow" android:layout_width="match_parent" android:layout_height="18dp" android:text="@string/widget_tomorrow_example" android:textSize="11sp" android:textColor="#26364D" android:maxLines="1" android:ellipsize="end" android:includeFontPadding="false" />
|
||||
<TextView android:id="@+id/compact_detail" android:layout_width="match_parent" android:layout_height="16dp" android:text="@string/widget_name" android:textSize="11sp" android:textColor="#64748B" android:maxLines="1" android:ellipsize="end" android:includeFontPadding="false" />
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/compact_root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/widget_background" android:padding="6dp">
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="24dp" android:gravity="center_vertical">
|
||||
<TextView android:id="@+id/compact_title" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center_vertical" android:text="@string/widget_name" android:textColor="#26364D" android:textSize="12sp" android:textStyle="bold" android:maxLines="1" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_customize" android:layout_width="34dp" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_customize" android:textSize="11sp" android:textColor="#26364D" />
|
||||
</LinearLayout>
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1">
|
||||
<TextView android:id="@+id/compact_day_0" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_0" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_1" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_1" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_2" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_2" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_3" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_3" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_4" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_4" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_5" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_5" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_6" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_6" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
</LinearLayout>
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1">
|
||||
<TextView android:id="@+id/compact_day_7" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_7" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_8" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_8" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_9" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_9" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_10" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_10" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_11" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_11" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_12" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_12" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
<TextView android:id="@+id/compact_day_13" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:gravity="center" android:text="@string/widget_example_13" android:textSize="11sp" android:textColor="#26364D" android:maxLines="2" android:includeFontPadding="false" android:ellipsize="end" />
|
||||
</LinearLayout>
|
||||
<LinearLayout android:layout_width="match_parent" android:layout_height="20dp" android:gravity="center_vertical">
|
||||
<TextView android:id="@+id/compact_previous" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:text="@string/widget_previous" android:textSize="11sp" android:gravity="center" />
|
||||
<TextView android:id="@+id/compact_today" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:text="@string/widget_today" android:textSize="11sp" android:gravity="center" />
|
||||
<TextView android:id="@+id/compact_next" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:text="@string/widget_next" android:textSize="11sp" android:gravity="center" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -12,4 +12,36 @@
|
||||
<string name="widget_previous">이전</string>
|
||||
<string name="widget_legend">당직 · 비번 · 일반근무</string>
|
||||
<string name="widget_next">다음</string>
|
||||
<string name="widget_customize">꾸미기</string>
|
||||
<string name="widget_month_name">월간 달력 · 4×4</string>
|
||||
<string name="widget_wide_name">두 주 달력 · 4×2</string>
|
||||
<string name="widget_tall_name">근무 목록 · 2×4</string>
|
||||
<string name="widget_day_name">오늘 근무 · 2×2</string>
|
||||
<string name="widget_month_description">한 달의 당직과 일정. 가로 4칸과 세로 4칸.</string>
|
||||
<string name="widget_wide_description">이번 주와 다음 주 근무. 가로 4칸과 세로 2칸.</string>
|
||||
<string name="widget_tall_description">다가오는 일주일 근무. 가로 2칸과 세로 4칸.</string>
|
||||
<string name="widget_day_description">오늘과 내일 근무. 가로 2칸과 세로 2칸.</string>
|
||||
<string name="widget_duty_example">당직</string>
|
||||
<string name="widget_tomorrow_example">내일 비번</string>
|
||||
<string name="widget_example_0">15\n일반</string>
|
||||
<string name="widget_example_1">16\n당직</string>
|
||||
<string name="widget_example_2">17\n비번</string>
|
||||
<string name="widget_example_3">18\n일반</string>
|
||||
<string name="widget_example_4">19\n당직</string>
|
||||
<string name="widget_example_5">20\n비번</string>
|
||||
<string name="widget_example_6">21\n일반</string>
|
||||
<string name="widget_example_7">22\n당직</string>
|
||||
<string name="widget_example_8">23\n비번</string>
|
||||
<string name="widget_example_9">24\n일반</string>
|
||||
<string name="widget_example_10">25\n당직</string>
|
||||
<string name="widget_example_11">26\n비번</string>
|
||||
<string name="widget_example_12">27\n일반</string>
|
||||
<string name="widget_example_13">28\n당직</string>
|
||||
<string name="widget_list_example_0">11.21 당직</string>
|
||||
<string name="widget_list_example_1">11.22 비번</string>
|
||||
<string name="widget_list_example_2">11.23 일반</string>
|
||||
<string name="widget_list_example_3">11.24 당직</string>
|
||||
<string name="widget_list_example_4">11.25 비번</string>
|
||||
<string name="widget_list_example_5">11.26 일반</string>
|
||||
<string name="widget_list_example_6">11.27 당직</string>
|
||||
</resources>
|
||||
@@ -3,7 +3,7 @@
|
||||
android:minResizeWidth="250dp" android:minResizeHeight="250dp"
|
||||
android:targetCellWidth="4" android:targetCellHeight="4"
|
||||
android:initialLayout="@layout/duty_widget"
|
||||
android:previewLayout="@layout/duty_widget_preview"
|
||||
android:previewLayout="@layout/duty_widget_preview" android:description="@string/widget_month_description"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen"
|
||||
android:updatePeriodMillis="1800000" />
|
||||
@@ -0,0 +1,7 @@
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="110dp" android:minHeight="250dp"
|
||||
android:minResizeWidth="110dp" android:minResizeHeight="250dp"
|
||||
android:initialLayout="@layout/duty_widget_tall"
|
||||
android:resizeMode="horizontal|vertical" android:widgetCategory="home_screen" android:updatePeriodMillis="1800000"
|
||||
android:targetCellWidth="2" android:targetCellHeight="4"
|
||||
android:previewLayout="@layout/duty_widget_tall" android:description="@string/widget_tall_description" />
|
||||
@@ -0,0 +1,7 @@
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="110dp" android:minHeight="110dp"
|
||||
android:minResizeWidth="110dp" android:minResizeHeight="110dp"
|
||||
android:initialLayout="@layout/duty_widget_today"
|
||||
android:resizeMode="horizontal|vertical" android:widgetCategory="home_screen" android:updatePeriodMillis="1800000"
|
||||
android:targetCellWidth="2" android:targetCellHeight="2"
|
||||
android:previewLayout="@layout/duty_widget_today" android:description="@string/widget_day_description" />
|
||||
@@ -0,0 +1,7 @@
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="250dp" android:minHeight="110dp"
|
||||
android:minResizeWidth="250dp" android:minResizeHeight="110dp"
|
||||
android:initialLayout="@layout/duty_widget_wide"
|
||||
android:resizeMode="horizontal|vertical" android:widgetCategory="home_screen" android:updatePeriodMillis="1800000"
|
||||
android:targetCellWidth="4" android:targetCellHeight="2"
|
||||
android:previewLayout="@layout/duty_widget_wide" android:description="@string/widget_wide_description" />
|
||||
@@ -0,0 +1,5 @@
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="110dp" android:minHeight="250dp"
|
||||
android:minResizeWidth="110dp" android:minResizeHeight="250dp"
|
||||
android:initialLayout="@layout/duty_widget_tall"
|
||||
android:resizeMode="horizontal|vertical" android:widgetCategory="home_screen" android:updatePeriodMillis="1800000" />
|
||||
@@ -0,0 +1,5 @@
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="110dp" android:minHeight="110dp"
|
||||
android:minResizeWidth="110dp" android:minResizeHeight="110dp"
|
||||
android:initialLayout="@layout/duty_widget_today"
|
||||
android:resizeMode="horizontal|vertical" android:widgetCategory="home_screen" android:updatePeriodMillis="1800000" />
|
||||
@@ -0,0 +1,5 @@
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="250dp" android:minHeight="110dp"
|
||||
android:minResizeWidth="250dp" android:minResizeHeight="110dp"
|
||||
android:initialLayout="@layout/duty_widget_wide"
|
||||
android:resizeMode="horizontal|vertical" android:widgetCategory="home_screen" android:updatePeriodMillis="1800000" />
|
||||
@@ -43,6 +43,31 @@ class ScheduleTest {
|
||||
assertTrue(days.contains(LocalDate.of(2026, 8, 31)))
|
||||
}
|
||||
@Test(expected = IllegalArgumentException::class) fun emptyCycleRejected() { Schedule(anchor, emptyList()) }
|
||||
@Test fun mondayGridHandlesSundayMonthStartAndYearBoundary() {
|
||||
assertEquals(LocalDate.of(2026,10,26),calendarDays(YearMonth.of(2026,11),1).first())
|
||||
assertEquals(LocalDate.of(2026,11,1),calendarDays(YearMonth.of(2026,11),0).first())
|
||||
assertEquals(LocalDate.of(2026,12,28),calendarDays(YearMonth.of(2027,1),1).first())
|
||||
assertEquals(LocalDate.of(2028,2,29),calendarDays(YearMonth.of(2028,2),1).single{it==LocalDate.of(2028,2,29)})
|
||||
assertEquals(LocalDate.of(2026,11,16),startOfWeek(LocalDate.of(2026,11,22),1))
|
||||
assertEquals(listOf(1,2,3,4,5,6,0),calendarWeekdays(1))
|
||||
}
|
||||
@Test fun changingWeekStartOnlyChangesLayout() {
|
||||
val sunday=Schedule(anchor,Schedule.preset(3),5,true,true,true)
|
||||
val monday=sunday.copy(weekStart=1)
|
||||
for(offset in -400L..400L) {
|
||||
val date=anchor.plusDays(offset)
|
||||
assertEquals(sunday.shiftOn(date),monday.shiftOn(date))
|
||||
assertEquals(sunday.dateColor(date,true),monday.dateColor(date,true))
|
||||
}
|
||||
for(year in 2024..2028)for(month in 1..12)for(start in 0..1) {
|
||||
val ym=YearMonth.of(year,month);val dates=calendarDays(ym,start)
|
||||
assertEquals(42,dates.size)
|
||||
assertEquals(ym.lengthOfMonth(),dates.count{YearMonth.from(it)==ym})
|
||||
assertEquals(if(start==1)java.time.DayOfWeek.MONDAY else java.time.DayOfWeek.SUNDAY,dates.first().dayOfWeek)
|
||||
assertEquals(41L,java.time.temporal.ChronoUnit.DAYS.between(dates.first(),dates.last()))
|
||||
}
|
||||
}
|
||||
@Test(expected = IllegalArgumentException::class) fun invalidWeekStartRejected() { Schedule(anchor,Schedule.preset(2),weekStart=2) }
|
||||
@Test fun longestCycleWorks() {
|
||||
val schedule = Schedule(anchor, Schedule.preset(366))
|
||||
assertEquals(Shift.REGULAR, schedule.shiftOn(anchor.plusDays(365)))
|
||||
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
# 소스 구조와 자료 흐름
|
||||
|
||||
제작자 블리어 (이창현) · 0.10.0
|
||||
제작자 블리어 (이창현) · 0.12.0
|
||||
|
||||
## 폴더별 역할
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
## 위젯 표시 흐름
|
||||
|
||||
`DutyWidget`이 위젯 번호별 월과 `WidgetStyle`을 읽어 42칸 RemoteViews를 만듭니다. 가로·세로 크기 변경은 `onAppWidgetOptionsChanged`로 받아 다시 표시합니다. 자동 배치는 현재 방향의 높이를 보고 간단한 배치와 상세 배치를 고릅니다. 글자 배율은 RemoteViews의 실제 글자 크기에 적용합니다.
|
||||
`WidgetKind`가 월간과 두 주 및 목록과 오늘의 네 공급자를 구분합니다. `DutyWidget`은 월간의 42칸을 표시하고 작은 세 종류는 `CompactWidgetViews`로 보냅니다. 모든 갱신과 꾸미기 목록은 네 공급자의 위젯 번호를 함께 조회합니다. 월과 기간 및 모양은 위젯 번호별로 따로 읽습니다. 가로·세로 크기 변경은 `onAppWidgetOptionsChanged`로 받아 다시 표시합니다. Android 12 이상은 전달받은 크기 목록별 RemoteViews를 구성합니다. 자동 배치는 현재 방향의 높이를 보고 간단한 배치와 상세 배치를 고릅니다. 글자 배율은 RemoteViews의 실제 글자 크기에 적용합니다.
|
||||
|
||||
투명도는 배경의 알파값만 바꿉니다. 글자까지 흐려지지 않게 색상을 따로 유지합니다. 위젯마다 다른 설정 키를 사용하며 전체 적용을 선택하면 개별 키를 비우고 기본값을 저장합니다. 삭제된 위젯의 모양 키도 함께 정리합니다. 손상된 값은 기본 모양으로 복구해 달력이 사라지지 않게 합니다.
|
||||
|
||||
@@ -57,3 +57,9 @@
|
||||
- 소속 공유 자료에 개인 일정과 기념일이 섞이지 않는지 검사합니다.
|
||||
- 공휴일 수신 실패와 잘못된 JSON 및 빈 응답에서 마지막 정상 자료가 남는지 검사합니다.
|
||||
- 화면만 바꾼 작업에 DB 변경을 끼워 넣지 않습니다. 자료 이전은 백업과 복구 절차를 따로 준비합니다.
|
||||
|
||||
## 주 시작 저장과 호환
|
||||
|
||||
개인 표시 설정의 `weekStart`는 일요일 0과 월요일 1만 허용합니다. 앱과 웹의 요일 머리글과 첫 날짜는 같은 설정으로 계산합니다. 토요일과 일요일 색상은 열 번호가 아니라 실제 요일을 기준으로 합니다.
|
||||
|
||||
구버전이 해당 필드를 보내지 않으면 서버는 이미 저장한 값을 유지합니다. 명시한 0은 일요일로 바꾸는 요청입니다. 반복 근무와 개인 설정은 기존 버전 비교와 같은 트랜잭션에서 맞춥니다. 새 DB 테이블이나 자료 일괄 이전은 없습니다.
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
# 새 버전 배포와 복구
|
||||
|
||||
제작자 블리어 (이창현) · 0.10.0
|
||||
제작자 블리어 (이창현) · 0.12.0
|
||||
|
||||
## 배포 위치
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
| `server/web/index.html` | 소개의 버전과 최신 포럼 링크 |
|
||||
| `server/app.py` | 상태 응답의 버전 |
|
||||
|
||||
빌드한 APK의 파일 이름과 바이트 수 및 SHA-256을 `release.json`의 apkFile과 apkBytes 및 apkSha256에 넣습니다. 예를 들어 0.10.0은 versionCode 14이며 웹 빌드는 2026-11-20.10입니다. 값만 미리 올리고 실제 파일을 늦게 배치하면 업데이트 검증이 실패합니다.
|
||||
빌드한 APK의 파일 이름과 바이트 수 및 SHA-256을 `release.json`의 apkFile과 apkBytes 및 apkSha256에 넣습니다. 예를 들어 0.12.0은 versionCode 16이며 웹 빌드는 2026-11-21.2입니다. 값만 미리 올리고 실제 파일을 늦게 배치하면 업데이트 검증이 실패합니다.
|
||||
|
||||
```powershell
|
||||
Get-FileHash app/build/outputs/apk/debug/app-debug.apk -Algorithm SHA256
|
||||
|
||||
+22
-3
@@ -1,6 +1,6 @@
|
||||
# 당직근무 설치와 사용법
|
||||
|
||||
제작자 블리어 (이창현) · 0.10.0
|
||||
제작자 블리어 (이창현) · 0.12.0
|
||||
|
||||
## 설치와 처음 설정
|
||||
|
||||
@@ -18,6 +18,25 @@
|
||||
|
||||
주 5일제를 고르면 토요일의 일반근무는 휴무로 계산합니다. 주 6일제의 토요일은 기존 근무 규칙을 따릅니다. 당직 날짜는 유지합니다. 옵션의 **당직일 평일색**은 주말과 공휴일에 걸린 당직 날짜 숫자를 평일색으로 보여 줍니다. **비번 빨간색**은 비번 날짜를 빨간색으로 표시합니다. 두 옵션은 달력 색상에 대한 설정이며 실제 반복 순서를 바꾸지 않습니다.
|
||||
|
||||
## 주 시작 요일
|
||||
|
||||
**옵션 → 주 시작 요일**에서 월요일 시작과 일요일 시작을 고릅니다. 앱과 웹 달력 및 4×4 월간 위젯과 4×2 두 주 위젯에 함께 적용합니다. 2×4 근무 목록과 2×2 오늘 근무는 오늘부터 보는 형태를 유지합니다.
|
||||
|
||||
로그인하지 않은 앱은 현재 기기에 저장합니다. 회원 연결 중이면 개인 설정을 서버에 보관해 같은 계정으로 연결한 기기에 반영합니다. 주 시작을 바꿔도 근무 기준일과 반복 배열 및 토요일·일요일 색상은 유지됩니다. 기존 자료에 선택이 없으면 일요일 시작입니다.
|
||||
|
||||
## 위젯 크기 고르기
|
||||
|
||||
**홈 화면에 달력 추가**를 누르면 크기 목록이 나타납니다. 홈 화면의 위젯 목록에서도 네 종류를 따로 고를 수 있습니다.
|
||||
|
||||
| 크기 · 가로×세로 | 표시 내용 |
|
||||
| --- | --- |
|
||||
| 4×4 월간 달력 | 한 달 전체와 월 이동 |
|
||||
| 4×2 두 주 달력 | 이번 주와 다음 주의 14일 근무 |
|
||||
| 2×4 근무 목록 | 오늘부터 7일간 날짜와 근무를 세로로 표시 |
|
||||
| 2×2 오늘 근무 | 오늘 근무와 내일 근무를 크게 표시 |
|
||||
|
||||
4×2는 가로형이며 2×4는 세로형입니다. 기존 월간 달력을 억지로 줄이는 방식이 아니라 각 크기에 맞는 별도 위젯입니다. 두 주 달력의 이전·다음은 14일씩 이동하고 근무 목록은 7일씩 이동합니다. 오늘 버튼은 현재 기간으로 돌아갑니다. 날짜나 내일 근무를 누르면 앱에서 해당 날짜를 엽니다.
|
||||
|
||||
## 위젯 모양 바꾸기
|
||||
|
||||
위젯 위의 **꾸미기**를 누르면 해당 위젯만 바꿉니다. 앱의 **위젯 꾸미기 · 투명도와 크기** 또는 **옵션 → 위젯 꾸미기**에서는 위젯 하나를 고르거나 모든 위젯에 함께 적용할 수 있습니다.
|
||||
@@ -32,9 +51,9 @@
|
||||
| 일정 표시 | 일정과 기념일이 있는 날의 + 표시 켜기·끄기 |
|
||||
| 오늘 표시 | 오늘 날짜 배경 강조 켜기·끄기 |
|
||||
|
||||
위젯 전체 크기는 홈 화면에서 길게 누른 뒤 테두리를 끌어 조절합니다. 최소 크기와 가능한 칸 수는 홈 화면 앱에 따라 달라집니다. 자동 배치는 높이가 작은 위젯에서 추가 글줄을 숨깁니다. 작은 크기에서는 글자 100%나 80%가 적당합니다. 큰 글자를 쓰려면 위젯도 넓히세요.
|
||||
위젯 전체 크기는 홈 화면에서 길게 누른 뒤 테두리를 끌어 조절합니다. 최소 크기와 가능한 칸 수는 홈 화면 앱에 따라 달라집니다. 월간 달력의 자동 배치는 높이가 작은 위젯에서 추가 글줄을 숨깁니다. 두 주 달력은 날짜와 근무를 우선 표시합니다. 세로 근무 목록의 상세 내용은 충분히 높일 때 표시합니다. 오늘 근무의 상세 내용은 한 줄에 들어가는 범위만 표시합니다. 작은 크기에서는 글자 100%나 80%가 적당합니다. 큰 글자를 쓰려면 위젯도 넓히세요.
|
||||
|
||||
음력은 앱의 음력 옵션도 켜져 있어야 보입니다. 함께 근무하는 사람은 회원 연결 중에만 표시합니다. 투명 배경에서는 휴대폰 배경과 대비되는 글자색을 고르세요. **기본값**은 설정 화면을 초기 값으로 돌립니다. 실제 적용은 **저장**을 눌러야 합니다. 여러 위젯의 월 이동과 모양은 각각 유지됩니다. 모든 위젯에 적용하면 기존 개별 모양도 함께 바뀝니다.
|
||||
음력은 앱의 음력 옵션도 켜져 있어야 보입니다. 함께 근무하는 사람은 회원 연결 중에만 표시합니다. 투명 배경에서는 휴대폰 배경과 대비되는 글자색을 고르세요. **기본값**은 설정 화면을 초기 값으로 돌립니다. 실제 적용은 **저장**을 눌러야 합니다. 여러 위젯의 월이나 기간 이동과 모양은 각각 유지됩니다. 모든 위젯에 적용하면 기존 개별 모양도 함께 바뀝니다.
|
||||
|
||||
## 일정과 알바 시간표
|
||||
|
||||
|
||||
+24
-4
@@ -1,6 +1,6 @@
|
||||
# Android Studio로 당직근무 만들기
|
||||
|
||||
제작자 블리어 (이창현) · 0.10.0
|
||||
제작자 블리어 (이창현) · 0.12.0
|
||||
|
||||
## 준비할 환경
|
||||
|
||||
@@ -46,7 +46,8 @@ APK: `app/build/outputs/apk/debug/app-debug.apk`
|
||||
|
||||
Device Manager에서 API 36 가상 기기를 만들고 앱을 실행합니다. 근무 기준일과 배열을 저장한 뒤 홈 화면에 위젯을 추가합니다. 아래 항목은 실제 화면에서 확인합니다.
|
||||
|
||||
- 월 이동과 오늘 복귀 및 날짜를 눌렀을 때 앱의 선택 날짜
|
||||
- 위젯 목록의 4×4·4×2·2×4·2×2 네 항목과 실제 기본 칸 수
|
||||
- 월 이동과 14일·7일 이동 및 오늘 복귀와 날짜를 눌렀을 때 앱의 선택 날짜
|
||||
- 투명도 0%와 100% 및 어두운 글자·밝은 글자
|
||||
- 80%와 120% 글자 크기 및 작은 위젯의 간단한 배치
|
||||
- 여러 위젯에서 월과 모양이 서로 영향을 주지 않는지
|
||||
@@ -61,7 +62,7 @@ adb install -r app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
|
||||
adb shell am instrument -w -e widgetCheck true kr.co.itosm.dutycalendar.test/kr.co.itosm.dutycalendar.StorageSyncCheck
|
||||
```
|
||||
|
||||
검사 코드는 위젯 모양을 바꾸어 검사한 뒤 원래 값을 복원합니다. 다른 저장 검사에는 미연결 기기나 별도 검증 서버가 필요한 항목이 있습니다. 운영 계정을 검사 계정으로 사용하지 마세요.
|
||||
검사 코드는 네 공급자 등록과 기본 칸 수 및 작은 위젯의 최소 크기에서 글자 80%·100%·120%의 실제 RemoteViews 높이를 확인합니다. 홈에 놓인 가로형과 세로형 위젯이 있으면 기간 이동도 검사합니다. 검사 중 바꾼 위젯 모양과 기간은 원래 값으로 복원합니다. 다른 저장 검사에는 미연결 기기나 별도 검증 서버가 필요한 항목이 있습니다. 운영 계정을 검사 계정으로 사용하지 마세요.
|
||||
|
||||
## 주요 수정 위치
|
||||
|
||||
@@ -71,7 +72,9 @@ adb shell am instrument -w -e widgetCheck true kr.co.itosm.dutycalendar.test/kr.
|
||||
| 버전 이름과 번호 | `app/build.gradle.kts` |
|
||||
| 앱 화면과 옵션 진입 | `MainActivity.kt` |
|
||||
| 근무 계산과 색상 | `Schedule.kt` |
|
||||
| 홈 위젯 달력 | `DutyWidget.kt`와 `res/layout/duty_widget.xml` |
|
||||
| 월간 위젯과 갱신 | `DutyWidget.kt`와 `res/layout/duty_widget.xml` |
|
||||
| 위젯 네 종류 등록 | `WidgetKind.kt`와 `AndroidManifest.xml` 및 `res/xml`과 `res/xml-v31` |
|
||||
| 작은 위젯 표시 | `CompactWidgetViews.kt`와 `duty_widget_wide.xml` 및 `duty_widget_tall.xml`과 `duty_widget_today.xml` |
|
||||
| 위젯 모양 저장과 편집 | `WidgetStyle.kt` |
|
||||
| 서버 기본 주소 | `SyncClient.kt`의 `WEB_URL` |
|
||||
| 개인 일정과 반복 | `PlannerStore.kt`와 `PlannerDialogs.kt` |
|
||||
@@ -84,3 +87,20 @@ Kotlin 파일은 `app/src/main/java/kr/co/itosm/dutycalendar`에 있습니다.
|
||||
공식 APK와 직접 빌드한 APK는 같은 소스여도 서명이 다를 수 있습니다. Android는 업데이트 때 앱 식별자와 서명을 확인합니다. 앱을 배포하기로 했다면 본인의 서명 키를 별도로 만들고 안전하게 보관하세요. 키와 비밀번호는 Git이나 공개 ZIP에 넣지 않습니다. 자세한 절차는 [앱 서명 공식 문서](https://developer.android.com/studio/publish/app-signing)에 있습니다.
|
||||
|
||||
공식 미리보기 앱의 자료를 보존하려면 공식 업데이트를 기존 앱 위에 설치합니다. 서명 충돌을 피하려고 앱을 삭제하면 기기 자료가 사라질 수 있습니다. 본인 실험용 앱은 별도 applicationId와 가상 기기를 사용하는 편이 좋습니다.
|
||||
|
||||
## 위젯 크기 구현
|
||||
|
||||
| 크기 · 가로×세로 | 표시 내용 |
|
||||
| --- | --- |
|
||||
| 4×4 월간 달력 | 한 달 전체와 월 이동 |
|
||||
| 4×2 두 주 달력 | 이번 주와 다음 주의 14일 근무 |
|
||||
| 2×4 근무 목록 | 오늘부터 7일간 날짜와 근무를 세로로 표시 |
|
||||
| 2×2 오늘 근무 | 오늘 근무와 내일 근무를 크게 표시 |
|
||||
|
||||
각 종류는 별도 AppWidgetProvider로 등록합니다. 기존 `DutyWidget` 이름은 유지해 이미 배치한 월간 위젯이 사라지지 않게 했습니다. Android 12 이상에서는 `targetCellWidth`와 `targetCellHeight`로 기본 칸 수를 지정합니다. 이전 버전은 최소 dp 크기를 사용합니다. 홈 화면의 칸 간격에 따라 실제 외곽 크기는 달라집니다.
|
||||
|
||||
홈 화면이 전달하는 크기 목록마다 RemoteViews를 준비합니다. 작은 위젯의 글자는 크기에 맞춰 상한을 두므로 120%를 골라도 최소 높이에서 두 줄이 잘리지 않습니다. 다른 홈 화면 앱과 큰 시스템 글자 설정은 별도로 확인해야 합니다. [Android 위젯 크기 공식 문서](https://developer.android.com/develop/ui/views/appwidgets/layouts)를 참고하세요.
|
||||
|
||||
## 주 시작 검사
|
||||
|
||||
`Schedule.kt`의 `startOfWeek`와 `calendarDays` 및 `calendarWeekdays`를 사용합니다. 월간 달력과 두 주 위젯 모두 같은 계산으로 시작합니다. 월초가 일요일인 2026년 11월은 월요일 시작에서 10월 26일이 첫 칸입니다. 2027년 1월과 윤년 2월도 단위 검사에 포함했습니다. 실제 RemoteViews 검사에서는 요일 머리글과 첫 날짜 및 일요일 색상을 확인합니다. 웹의 대응 계산은 `week-start.js`이며 서버의 정적 파일 허용 목록에도 등록해야 합니다.
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# 당직근무 웹 서버 설치와 회원 관리
|
||||
|
||||
제작자 블리어 (이창현) · 0.10.0
|
||||
제작자 블리어 (이창현) · 0.12.0
|
||||
|
||||
## 구성과 설치 전 확인
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# 당직근무 웹 서버
|
||||
|
||||
제작자 블리어 (이창현) · 0.10.0
|
||||
제작자 블리어 (이창현) · 0.12.0
|
||||
|
||||
설치와 초기 관리자 등록 및 검사와 백업은 [웹 서버 제작 매뉴얼](../docs/제작매뉴얼-웹서버.md)에 정리했습니다. 서버를 실행하기 전에 데이터 경로와 HTTPS 주소를 맞추세요. 운영 DB와 보호 키 및 인증 정보는 이 저장소와 소스 ZIP에 포함하지 않습니다.
|
||||
|
||||
|
||||
+7
-3
@@ -6,7 +6,7 @@
|
||||
"""
|
||||
import asyncio
|
||||
import company
|
||||
from personal import validate_personal, mirror_display, validate_event_options
|
||||
from personal import validate_personal, mirror_display, validate_event_options, validate_week_start, preserve_week_start
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
@@ -479,6 +479,8 @@ def validate(op):
|
||||
op["data"]["showLunar"] = data["showLunar"]
|
||||
if "offAsHoliday" in data:
|
||||
op["data"]["offAsHoliday"] = data["offAsHoliday"]
|
||||
if kind == "rotation":
|
||||
op["data"].update(validate_week_start(data))
|
||||
return
|
||||
if not isinstance(data.get("title"), str) or not 1 <= len(data["title"].strip()) <= 120:
|
||||
raise ValueError("제목은 1자부터 120자까지 입력해 주세요.")
|
||||
@@ -568,6 +570,8 @@ async def mutations(request: Request):
|
||||
previous_display = json.loads(current["data"]).get("dutyAsWeekday")
|
||||
if type(previous_display) is bool:
|
||||
op["data"]["dutyAsWeekday"] = previous_display
|
||||
if not op["deleted"]:
|
||||
preserve_week_start(conn, client["calendar"], op["kind"], op["data"], current)
|
||||
conn.execute("INSERT INTO items VALUES(?,?,?,?,?,?) ON CONFLICT(calendar,id) DO UPDATE SET version=excluded.version,deleted=excluded.deleted,data=excluded.data", (client["calendar"], op["id"], op["kind"], version + 1, int(op["deleted"]), json.dumps(op["data"], ensure_ascii=False)))
|
||||
conn.execute("UPDATE calendars SET revision=revision+1 WHERE id=?", (client["calendar"],))
|
||||
if not op["deleted"]:
|
||||
@@ -604,7 +608,7 @@ company.setup(app, identity, payload, db, throttle, changed, snapshot)
|
||||
|
||||
@app.get(PREFIX + "/health")
|
||||
async def health():
|
||||
return {"status": "ok", "version": "0.10.0"}
|
||||
return {"status": "ok", "version": "0.12.0"}
|
||||
|
||||
|
||||
@app.get(PREFIX + "/download")
|
||||
@@ -650,7 +654,7 @@ async def index():
|
||||
|
||||
@app.get(PREFIX + "/assets/{name}")
|
||||
async def asset(name: str):
|
||||
if name not in ("app.js", "anniversary-dates.js", "anniversaries.js", "company.js", "updates.js", "style.css", "holidays.json", "holidays-LICENSE.txt", "work-patterns.json", "lunar-months.json", "lunar-LICENSE.txt"):
|
||||
if name not in ("app.js", "week-start.js", "anniversary-dates.js", "anniversaries.js", "company.js", "updates.js", "style.css", "holidays.json", "holidays-LICENSE.txt", "work-patterns.json", "lunar-months.json", "lunar-LICENSE.txt"):
|
||||
raise HTTPException(404)
|
||||
if name == "holidays.json":
|
||||
return holiday_response()
|
||||
|
||||
+28
-1
@@ -5,6 +5,32 @@ import json
|
||||
DISPLAY_FIELDS = ('dutyAsWeekday', 'showLunar', 'offAsHoliday')
|
||||
REMINDER_MINUTES = (-1, 0, 10, 30, 60, 1440)
|
||||
|
||||
|
||||
def validate_week_start(data):
|
||||
"""값 생략은 구버전 요청으로 구분한다. 값이 있으면 일요일 0과 월요일 1만 허용한다."""
|
||||
if 'weekStart' not in data:
|
||||
return {}
|
||||
if type(data['weekStart']) is not int or data['weekStart'] not in (0, 1):
|
||||
raise ValueError('주 시작은 일요일 또는 월요일을 선택해 주세요.')
|
||||
return {'weekStart': data['weekStart']}
|
||||
|
||||
|
||||
def preserve_week_start(conn, calendar, kind, data, current):
|
||||
"""구버전이 주 시작 값을 생략하면 이미 저장한 개인 선택을 보존한다.
|
||||
|
||||
반복 근무와 개인 설정 어느 쪽을 저장해도 같은 선택을 유지한다.
|
||||
새 회원의 자료에는 임의 기본값을 쓰지 않으며 명시적인 0은 일요일 변경으로 처리한다.
|
||||
"""
|
||||
if kind not in ('rotation', 'preferences') or 'weekStart' in data:
|
||||
return
|
||||
saved = json.loads(current['data']) if current else {}
|
||||
target = 'rotation' if kind == 'preferences' else 'preferences'
|
||||
if 'weekStart' not in saved:
|
||||
other = conn.execute('SELECT data FROM items WHERE calendar=? AND id=? AND deleted=0', (calendar, target)).fetchone()
|
||||
saved = json.loads(other['data']) if other else {}
|
||||
if type(saved.get('weekStart')) is int and saved['weekStart'] in (0, 1):
|
||||
data['weekStart'] = saved['weekStart']
|
||||
|
||||
def validate_reminder(data):
|
||||
value=data.get('reminderMinutes',-1)
|
||||
if type(value) is not int or value not in REMINDER_MINUTES:
|
||||
@@ -25,7 +51,7 @@ def validate_personal(kind, data):
|
||||
if kind == 'preferences':
|
||||
if any(type(data.get(key)) is not bool for key in DISPLAY_FIELDS):
|
||||
raise ValueError('개인 표시 설정을 확인해 주세요.')
|
||||
return {key: data[key] for key in DISPLAY_FIELDS}
|
||||
return {**{key: data[key] for key in DISPLAY_FIELDS}, **validate_week_start(data)}
|
||||
if not isinstance(data.get('title'), str) or not 1 <= len(data['title'].strip()) <= 60:
|
||||
raise ValueError('기념일 이름은 1~60자로 입력해 주세요.')
|
||||
if data.get('category') not in ('BIRTHDAY', 'ANNIVERSARY') or data.get('calendar') not in ('SOLAR', 'LUNAR'):
|
||||
@@ -57,6 +83,7 @@ def mirror_display(conn, calendar, kind, data):
|
||||
return
|
||||
saved = json.loads(current['data'])
|
||||
values = {key: data[key] for key in DISPLAY_FIELDS if type(data.get(key)) is bool}
|
||||
values.update(validate_week_start(data))
|
||||
if not values or all(saved.get(key) == value for key,value in values.items()):
|
||||
return
|
||||
saved.update(values)
|
||||
|
||||
+10
-10
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"appVersion": "0.10.0",
|
||||
"appVersionCode": 14,
|
||||
"webVersion": "2026-11-20.10",
|
||||
"apkFile": "duty-calendar-0.10.0.apk",
|
||||
"appVersion": "0.12.0",
|
||||
"appVersionCode": 16,
|
||||
"webVersion": "2026-11-21.2",
|
||||
"apkFile": "duty-calendar-0.12.0.apk",
|
||||
"notes": [
|
||||
"위젯 배경 투명도와 밝은·어두운 색상 및 글자 크기를 조절할 수 있습니다.",
|
||||
"위젯마다 모양을 따로 저장하거나 모든 위젯에 함께 적용합니다.",
|
||||
"작은 위젯의 간단한 배치와 음력·공휴일·함께 근무·기념일 표시를 선택합니다.",
|
||||
"공식 앱과 소스 및 제작 매뉴얼은 포럼의 웹·앱 자료실 → 당직근무에서 제공합니다."
|
||||
"옵션에서 주 시작 요일을 월요일 또는 일요일로 고를 수 있습니다.",
|
||||
"앱과 웹 달력 및 월간·두 주 위젯에 같은 주 시작을 적용합니다.",
|
||||
"회원의 선택은 서버에 보관해 같은 계정으로 연결한 기기에 반영합니다.",
|
||||
"주 시작을 바꿔도 당직 기준일과 근무 순서 및 주말과 공휴일 색상은 유지됩니다."
|
||||
],
|
||||
"apkBytes": 1040735,
|
||||
"apkSha256": "a1e5f0da7b2d82d4a7be2a533bb79480947407b70339bf0d7242b424cbe2b977"
|
||||
"apkBytes": 1060715,
|
||||
"apkSha256": "e97e3bdd4d08197092eb5ac6d76aa33e22685f2f0988e9ef3f5b6b95f83e41d6"
|
||||
}
|
||||
@@ -16,6 +16,45 @@ import app as service
|
||||
|
||||
|
||||
class CalendarTests(unittest.TestCase):
|
||||
def test_public_page_script_assets_are_served(self):
|
||||
import re
|
||||
page=self.client.get('/calendar/').text
|
||||
scripts=re.findall(r'<script src="(assets/[^"?]+)"',page)
|
||||
self.assertIn('assets/week-start.js',scripts)
|
||||
for script in scripts:
|
||||
self.assertEqual(self.client.get('/calendar/'+script).status_code,200,script)
|
||||
|
||||
def test_week_start_restores_and_old_clients_preserve_choice(self):
|
||||
self.write_rotation()
|
||||
self.assertEqual(self.write([self.personal_op('preferences',weekStart=1)]).status_code,200)
|
||||
rows={i['id']:i for i in self.state()['items']}
|
||||
self.assertEqual(rows['rotation']['data']['weekStart'],1)
|
||||
self.assertEqual(self.write_rotation(version=rows['rotation']['version']).status_code,200)
|
||||
rows={i['id']:i for i in self.state()['items']}
|
||||
self.assertEqual(rows['rotation']['data']['weekStart'],1)
|
||||
self.assertEqual(self.write([self.personal_op('preferences',version=rows['preferences']['version'],showLunar=False)]).status_code,200)
|
||||
rows={i['id']:i for i in self.state()['items']}
|
||||
self.assertEqual(rows['preferences']['data']['weekStart'],1)
|
||||
self.assertEqual(rows['rotation']['data']['weekStart'],1)
|
||||
before=self.state()['items']
|
||||
login=self.client.post('/calendar/api/login',json={'kind':'android','username':self.username,'password':self.password},headers=self.headers)
|
||||
self.assertEqual(self.state(login.json()['token'])['items'],before)
|
||||
self.assertEqual(self.state(self.other_member())['items'],[])
|
||||
self.assertEqual(self.write([self.personal_op('preferences',version=rows['preferences']['version'],weekStart=0)]).status_code,200)
|
||||
rows={i['id']:i for i in self.state()['items']}
|
||||
self.assertEqual(rows['rotation']['data']['weekStart'],0)
|
||||
self.assertEqual(rows['preferences']['data']['weekStart'],0)
|
||||
|
||||
def test_week_start_rejects_invalid_values_and_stale_choice(self):
|
||||
for value in (-1,2,True,False,'1',None,1.0):
|
||||
self.assertEqual(self.write([self.personal_op('preferences',weekStart=value)]).status_code,400)
|
||||
op={'id':'rotation','kind':'rotation','changeId':str(uuid.uuid4()),'baseVersion':0,'deleted':False,'data':{'anchor':'2026-11-20','pattern':['DUTY','OFF'],'weekStart':value}}
|
||||
self.assertEqual(self.write([op]).status_code,400)
|
||||
self.write([self.personal_op('preferences',weekStart=1)])
|
||||
stale=self.write([self.personal_op('preferences',weekStart=0)]).json()
|
||||
self.assertEqual(len(stale['conflicts']),1)
|
||||
self.assertEqual(self.state()['items'][0]['data']['weekStart'],1)
|
||||
|
||||
def personal_op(self, kind='anniversary', version=0, key=None, **values):
|
||||
data={'title':'개인 생일','category':'BIRTHDAY','calendar':'LUNAR','month':1,'day':1,'leapMonth':False,'notes':'개인 메모'} if kind=='anniversary' else {'dutyAsWeekday':True,'showLunar':True,'offAsHoliday':True}
|
||||
data.update(values)
|
||||
|
||||
@@ -3,18 +3,18 @@ const fs=require('node:fs'),vm=require('node:vm'),assert=require('node:assert/st
|
||||
const source=fs.readFileSync(__dirname+'/web/updates.js','utf8');
|
||||
async function setup(seen=''){
|
||||
const storage=new Map([['duty-web-update-seen',seen]]),nodes=new Map();
|
||||
let release={webVersion:'2026-11-20.10',appVersion:'0.10.0',notes:['검증']},reloaded=0,editing=false;
|
||||
let release={webVersion:'2026-11-21.2',appVersion:'0.12.0',notes:['검증']},reloaded=0,editing=false;
|
||||
const node=id=>{if(!nodes.has(id))nodes.set(id,{textContent:'',open:false,showModal(){this.open=true;},close(){this.open=false;},addEventListener(){}});return nodes.get(id);};
|
||||
const context={console,$:node,localStorage:{getItem:k=>storage.get(k)||null,setItem:(k,v)=>storage.set(k,v),removeItem:k=>storage.delete(k)},document:{visibilityState:'visible',querySelector:()=>editing||node('update-dialog').open,addEventListener(){}},pending:[],saving:false,connected:false,notify(){},setInterval(){},location:{reload(){reloaded++;}},fetch:async()=>({ok:true,json:async()=>release})};
|
||||
vm.createContext(context);vm.runInContext(source,context);await new Promise(setImmediate);
|
||||
return {context,node,storage,setRelease:v=>release=v,setEditing:v=>editing=v,reloaded:()=>reloaded,check:async()=>{await vm.runInContext('checkWebVersion()',context);}};
|
||||
}
|
||||
(async()=>{
|
||||
const first=await setup();assert.equal(first.node('update-dialog').open,true);assert.equal(first.node('update-apply').textContent,'확인');first.node('update-apply').onclick();assert.equal(first.reloaded(),0);assert.equal(first.storage.get('duty-web-update-seen'),'2026-11-20.10');
|
||||
const first=await setup();assert.equal(first.node('update-dialog').open,true);assert.equal(first.node('update-apply').textContent,'확인');first.node('update-apply').onclick();assert.equal(first.reloaded(),0);assert.equal(first.storage.get('duty-web-update-seen'),'2026-11-21.2');
|
||||
const returning=await setup('2026-11-20.4');assert.equal(returning.node('update-dialog').open,true);
|
||||
const latest=await setup('2026-11-20.10');assert.equal(latest.node('update-dialog').open,false);
|
||||
latest.setEditing(true);latest.setRelease({webVersion:'2026-11-20.11',appVersion:'0.10.0',notes:['검증']});await latest.check();assert.equal(latest.node('update-dialog').open,false);
|
||||
const latest=await setup('2026-11-21.2');assert.equal(latest.node('update-dialog').open,false);
|
||||
latest.setEditing(true);latest.setRelease({webVersion:'2026-11-21.3',appVersion:'0.12.0',notes:['검증']});await latest.check();assert.equal(latest.node('update-dialog').open,false);
|
||||
latest.setEditing(false);await latest.check();assert.equal(latest.node('update-dialog').open,true);assert.equal(latest.node('update-apply').textContent,'업데이트 적용');latest.node('update-later').onclick();await latest.check();assert.equal(latest.node('update-dialog').open,false);
|
||||
latest.storage.delete('duty-web-update-later');await latest.check();latest.node('update-apply').onclick();assert.equal(latest.reloaded(),1);assert.equal(latest.storage.get('duty-web-update-seen'),'2026-11-20.11');
|
||||
latest.storage.delete('duty-web-update-later');await latest.check();latest.node('update-apply').onclick();assert.equal(latest.reloaded(),1);assert.equal(latest.storage.get('duty-web-update-seen'),'2026-11-21.3');
|
||||
console.log('웹 업데이트: 첫 안내, 재접속, 현재 버전, 편집 보호, 나중에, 동의 후 적용 통과');
|
||||
})().catch(error=>{console.error(error);process.exitCode=1;});
|
||||
@@ -0,0 +1,13 @@
|
||||
// 일요일인 월초와 연말 및 윤년에서도 앱과 같은 날짜 범위를 표시해야 한다.
|
||||
const assert=require('node:assert/strict');
|
||||
const {calendarWeekdays,calendarFirstDate}=require('./web/week-start.js');
|
||||
assert.deepEqual(calendarWeekdays(1),[1,2,3,4,5,6,0]);
|
||||
assert.deepEqual(calendarWeekdays(),[0,1,2,3,4,5,6]);
|
||||
for(const [month,start,wanted] of [['2026-11',1,'2026-10-26'],['2026-11',0,'2026-11-01'],['2027-01',1,'2026-12-28'],['2028-02',1,'2028-01-31']])assert.equal(calendarFirstDate(month,start).toISOString().slice(0,10),wanted);
|
||||
for(let year=2024;year<=2028;year++)for(let month=1;month<=12;month++)for(const start of [0,1]){
|
||||
const key=year+'-'+String(month).padStart(2,'0'),first=calendarFirstDate(key,start);
|
||||
assert.equal(first.getUTCDay(),start);
|
||||
const dates=Array.from({length:42},(_,i)=>new Date(first.getTime()+i*86400000).toISOString().slice(0,10));
|
||||
assert.equal(dates.filter(date=>date.startsWith(key)).length,new Date(Date.UTC(year,month,0)).getUTCDate());
|
||||
}
|
||||
console.log('월·일 시작과 월초·연말·윤년의 42칸 범위 검사 통과');
|
||||
+5
-3
@@ -77,7 +77,8 @@ function render(){
|
||||
$('rotation-label').textContent=r?'주'+(r.workWeek||6)+'일제 · '+r.pattern.length+'일 반복 근무':'반복 근무를 등록할 수 있습니다.';
|
||||
const days=Array.from({length:new Date(Number(month.slice(0,4)),Number(month.slice(5)),0).getDate()},(_,i)=>month+'-'+String(i+1).padStart(2,'0'));$('month-count').textContent=effective().filter(item=>item.kind==='event'&&days.some(key=>eventOccurrence(item.data,key)!==null)).length+personalAnniversaries().filter(item=>days.some(key=>annualMatches(item.data,key,lunarData))).length;
|
||||
$('month').textContent=Number(month.slice(0,4))+'년 '+Number(month.slice(5))+'월';
|
||||
const companions=people();document.body.classList.toggle('with-people',companions.length>0);$('grid').replaceChildren();const first=dayDate(month+'-01');first.setUTCDate(1-first.getUTCDay());
|
||||
const companions=people();document.body.classList.toggle('with-people',companions.length>0);$('grid').replaceChildren();const first=calendarFirstDate(month,display.weekStart);
|
||||
$('calendar-weekdays').replaceChildren();for(const day of calendarWeekdays(display.weekStart))$('calendar-weekdays').append(text('span',['일','월','화','수','목','금','토'][day],day===0?'sun':day===6?'sat':''));
|
||||
for(let i=0;i<42;i++){const date=new Date(first);date.setUTCDate(first.getUTCDate()+i);const key=dateKey(date),shift=shiftOn(key),name=holiday(key),events=eventsOn(key);const button=document.createElement('button');button.type='button';button.className='day'+(key.slice(0,7)!==month?' outside':'')+(key===selected?' selected':'')+(key===today?' current':'')+(date.getUTCDay()===0?' sun':date.getUTCDay()===6?' sat':'')+(name?' holiday':'')+(display.dutyAsWeekday===true&&shift==='DUTY'?' duty-weekday':'')+(display.offAsHoliday===true&&shift==='OFF'?' off-red':'');button.setAttribute('aria-label',`${key} ${shift?labels[shift]:''} ${name} 일정 ${events.length}개`);button.append(text('span',String(date.getUTCDate()),'day-number'));const lunar=display.showLunar?lunarLabel(key):null;if(lunar){button.classList.add('with-lunar');button.append(text('span',lunar,'lunar-date'));button.setAttribute('aria-label',button.getAttribute('aria-label')+' '+lunar);}if(shift)button.append(text('span',shift==='REGULAR'?'일반':labels[shift],'shift '+classes[shift]));if(name)button.append(text('span',name.includes('대체공휴일')?'대체휴일':name.replace('기독탄신일','성탄절').replace('1월 1일','신정'),'holiday-name'));if(events.length)button.append(text('span','일정 '+events.length+'개','event-count'));const annual=events.find(item=>item.kind==='anniversary');if(annual)button.append(text('span',annual.data.title,'anniversary-badge'));const duties=companions.filter(item=>!['OFF','REST'].includes(personShift(item,key)));for(const item of duties.slice(0,2))button.append(text('span',item.data.name,'person-badge person-'+item.data.color.toLowerCase()));if(duties.length>2)button.append(text('span','외 '+(duties.length-2)+'명','event-count'));button.setAttribute('aria-label',button.getAttribute('aria-label')+' 함께 근무 '+duties.map(item=>item.data.name).join(' '));button.onclick=()=>{selected=key;render();};$('grid').append(button);}
|
||||
const selectedDay=dayDate(selected);$('selected-date').textContent=new Intl.DateTimeFormat('ko-KR',{month:'long',day:'numeric',weekday:'short',timeZone:'UTC'}).format(selectedDay);$('day-detail').textContent=[labels[shiftOn(selected)],holiday(selected)].filter(Boolean).join(' · ')||'등록한 일정을 확인하고 새로 추가하세요.';
|
||||
$('agenda').replaceChildren();const events=eventsOn(selected);if(!events.length)$('agenda').append(text('div','등록된 일정이 없습니다.\n가벼운 메모부터 시작해 보세요.','empty'));for(const item of events){const node=document.createElement('button');node.className='event-item '+(item.data.category==='PARTTIME'?'parttime':item.data.category==='WORK'?'work':item.data.category==='LEAVE'?'leave':'');node.append(text('strong',item.data.title),text('span',eventTimeSummary(item.data)),text('span',categories[item.data.category]));node.onclick=()=>openEvent(item);$('agenda').append(node);}
|
||||
@@ -105,10 +106,11 @@ $('display-options').onclick=()=>{
|
||||
$('rotation-duty-weekday').checked=r.dutyAsWeekday===true;
|
||||
$('rotation-show-lunar').checked=r.showLunar===true;
|
||||
$('rotation-off-red').checked=r.offAsHoliday===true;
|
||||
$('rotation-week-start').value=String(r.weekStart===1?1:0);
|
||||
$('options-dialog').showModal();
|
||||
};
|
||||
$('options-form').onsubmit=event=>{
|
||||
event.preventDefault();queue('preferences','preferences',{dutyAsWeekday:$('rotation-duty-weekday').checked,showLunar:$('rotation-show-lunar').checked,offAsHoliday:$('rotation-off-red').checked});
|
||||
event.preventDefault();queue('preferences','preferences',{dutyAsWeekday:$('rotation-duty-weekday').checked,showLunar:$('rotation-show-lunar').checked,offAsHoliday:$('rotation-off-red').checked,weekStart:Number($('rotation-week-start').value)});
|
||||
$('options-dialog').close();notify('개인 설정을 저장했습니다.');
|
||||
};
|
||||
let authMode='login', memberPage=1, editingMember=null, personId=null;
|
||||
@@ -138,7 +140,7 @@ $('member-form').onsubmit=async event=>{event.preventDefault();const button=even
|
||||
$('member-reset').onclick=async()=>{if(!await confirmAction('이 회원의 일회용 비밀번호 복구 코드를 발급할까요? 기존 복구 코드는 만료됩니다.','복구 코드 발급'))return;try{const result=await api('admin/members/'+editingMember.id,{action:'reset'});$('member-reset-code').value=result.resetCode;$('member-reset-result').hidden=false;}catch(error){$('member-edit-error').textContent=error.message;}};
|
||||
$('member-delete').onclick=async()=>{if(!await confirmAction(editingMember.username+' 회원과 해당 회원의 일정 및 함께 보는 근무표를 모두 삭제합니다. 되돌릴 수 없습니다. 계속할까요?','회원과 일정 삭제'))return;try{await api('admin/members/'+editingMember.id,{action:'delete'});$('member-dialog').close();await loadMembers();}catch(error){$('member-edit-error').textContent=error.message;}};
|
||||
|
||||
function describe(item){if(!item||item.deleted)return '삭제된 일정';const d=item.data;if(item.kind==='anniversary')return d.title+'\n'+annualDescription(d)+'\n'+d.notes;if(item.kind==='preferences')return '당직일 평일색: '+(d.dutyAsWeekday?'켜짐':'꺼짐')+'\n비번 빨간색: '+(d.offAsHoliday?'켜짐':'꺼짐')+'\n음력 표시: '+(d.showLunar?'켜짐':'꺼짐');if(item.kind==='person')return `${d.name} · ${personColors[d.color]}\n첫째 날: ${d.anchor}\n${d.pattern.map(key=>labels[key]).join(' → ')}`;if(item.kind==='rotation')return `첫째 날: ${d.anchor}\n${d.pattern.map(key=>labels[key]).join(' → ')}`;return `${d.title}\n${d.date} ~ ${d.endDate}\n${d.allDay?'하루 종일':d.startTime+' ~ '+d.endTime}\n${categories[d.category]}\n${d.notes}`;}
|
||||
function describe(item){if(!item||item.deleted)return '삭제된 일정';const d=item.data;if(item.kind==='anniversary')return d.title+'\n'+annualDescription(d)+'\n'+d.notes;if(item.kind==='preferences')return '당직일 평일색: '+(d.dutyAsWeekday?'켜짐':'꺼짐')+'\n비번 빨간색: '+(d.offAsHoliday?'켜짐':'꺼짐')+'\n음력 표시: '+(d.showLunar?'켜짐':'꺼짐')+'\n주 시작: '+(d.weekStart===1?'월요일':'일요일');if(item.kind==='person')return `${d.name} · ${personColors[d.color]}\n첫째 날: ${d.anchor}\n${d.pattern.map(key=>labels[key]).join(' → ')}`;if(item.kind==='rotation')return `첫째 날: ${d.anchor}\n${d.pattern.map(key=>labels[key]).join(' → ')}`;return `${d.title}\n${d.date} ~ ${d.endDate}\n${d.allDay?'하루 종일':d.startTime+' ~ '+d.endTime}\n${categories[d.category]}\n${d.notes}`;}
|
||||
function showConflict(){const op=pending.find(item=>conflicts.includes(item.changeId));if(!op){$('conflict-dialog').close();return;}$('conflict-local').textContent=describe(op);$('conflict-remote').textContent=describe(model.items.find(item=>item.id===op.id));if(!$('conflict-dialog').open)$('conflict-dialog').showModal();}
|
||||
$('resolve').onclick=showConflict;
|
||||
function resolveConflict(useLocal){const op=pending.find(item=>conflicts.includes(item.changeId));if(!op)return;pending=pending.filter(item=>item.changeId!==op.changeId);conflicts=conflicts.filter(id=>id!==op.changeId);if(useLocal)pending.push({...op,baseVersion:model.items.find(item=>item.id===op.id)?.version??0,changeId:crypto.randomUUID()});persist();render();showConflict();sync();}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="ko">
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="theme-color" content="#26364d"><title>당직근무 · 블리어</title><link rel="stylesheet" href="assets/style.css"><script src="assets/anniversary-dates.js" defer></script><script src="assets/app.js" defer></script><script src="assets/anniversaries.js" defer></script><script src="assets/company.js" defer></script><script src="assets/updates.js" defer></script></head>
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="theme-color" content="#26364d"><title>당직근무 · 블리어</title><link rel="stylesheet" href="assets/style.css"><script src="assets/anniversary-dates.js" defer></script><script src="assets/week-start.js" defer></script><script src="assets/app.js" defer></script><script src="assets/anniversaries.js" defer></script><script src="assets/company.js" defer></script><script src="assets/updates.js" defer></script></head>
|
||||
<body>
|
||||
<header class="topbar"><a class="brand" href="./"><svg class="brand-mark" viewBox="0 0 40 44" aria-hidden="true"><path d="M5 6H35V40H5Z" fill="#fffdf8" stroke="currentColor" stroke-width="2"/><path d="M5 6H35V15H5Z" fill="currentColor"/><path d="M12 2V9M28 2V9" stroke="currentColor" stroke-width="3"/><path d="M12 22H17V27H12ZM23 22H28V27H23ZM12 31H17V36H12Z" fill="#b65b3c"/><path d="M23 31H28V36H23Z" fill="currentColor"/></svg><span>당직근무<small>나의 근무 기록</small></span></a><div class="top-actions"><span id="status" role="status">연결 확인 중</span><a class="download-small" href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47">앱 다운로드</a><nav id="public-auth" aria-label="회원 이용"><button id="join" class="secondary">로그인</button><button id="create" class="text-button">회원가입</button></nav><button id="admin-open" class="secondary" hidden>회원 관리</button><button id="refresh-data" class="secondary" hidden>새로 불러오기</button><button id="company-open" class="secondary" hidden>소속 회사</button><button id="connect" class="secondary" hidden>내 정보</button></div></header>
|
||||
<main>
|
||||
<section id="welcome" class="welcome">
|
||||
<div class="welcome-hero">
|
||||
<div class="welcome-copy"><p class="eyebrow">당직 · 교대근무 · 개인 일정</p><h1>다음 당직,<br>달력에서 바로.</h1><p class="intro">내 근무 순서대로 채워지는 달력.<br>휴대폰을 켜면 홈 화면에서 바로 확인하세요.</p><div class="welcome-actions"><a class="download-button" href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v12m-5-5 5 5 5-5M5 16v5h14v-5"/></svg>안드로이드 앱 받기</a><a class="install-link" href="#install-guide">설치 안내</a></div><p class="download-meta"><a href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47">공식 배포 · 소스 · 제작 매뉴얼</a><br>Android 8.0 이상 · 미리보기 0.10.0</p><div class="welcome-caption"><strong>내 달력은 로그인 없이.</strong><p>함께 보는 근무표와 소속 공유는<br>회원 로그인 후 이용할 수 있습니다.</p></div></div>
|
||||
<div class="welcome-copy"><p class="eyebrow">당직 · 교대근무 · 개인 일정</p><h1>다음 당직,<br>달력에서 바로.</h1><p class="intro">내 근무 순서대로 채워지는 달력.<br>휴대폰을 켜면 홈 화면에서 바로 확인하세요.</p><div class="welcome-actions"><a class="download-button" href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v12m-5-5 5 5 5-5M5 16v5h14v-5"/></svg>안드로이드 앱 받기</a><a class="install-link" href="#install-guide">설치 안내</a></div><p class="download-meta"><a href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47">공식 배포 · 소스 · 제작 매뉴얼</a><br>Android 8.0 이상 · 미리보기 0.12.0</p><div class="welcome-caption"><strong>내 달력은 로그인 없이.</strong><p>함께 보는 근무표와 소속 공유는<br>회원 로그인 후 이용할 수 있습니다.</p></div></div>
|
||||
<figure class="calendar-preview" aria-label="3당직근무 화면 예시">
|
||||
<figcaption><span>홈 화면에 두는 나의 근무표</span><span>화면 예시</span></figcaption>
|
||||
<div class="calendar-paper"><div class="paper-heading"><div><span class="paper-year">2026</span><strong>11<span>월</span></strong></div><div class="paper-note"><b>당직근무</b><span>당직 · 비번 · 일반근무</span></div></div><div class="sample-week"><span>일</span><span>월</span><span>화</span><span>수</span><span>목</span><span>금</span><span>토</span></div><div class="sample-grid"><div class="sample-day sun"><span>1</span><em class="off">비번</em></div><div class="sample-day"><span>2</span><em class="regular">일반</em></div><div class="sample-day"><span>3</span><em class="duty">당직</em></div><div class="sample-day"><span>4</span><em class="off">비번</em></div><div class="sample-day"><span>5</span><em class="regular">일반</em></div><div class="sample-day"><span>6</span><em class="duty">당직</em></div><div class="sample-day sat"><span>7</span><em class="off">비번</em></div><div class="sample-day sun"><span>8</span><em class="regular">일반</em></div><div class="sample-day"><span>9</span><em class="duty">당직</em></div><div class="sample-day"><span>10</span><em class="off">비번</em></div><div class="sample-day"><span>11</span><em class="regular">일반</em></div><div class="sample-day"><span>12</span><em class="duty">당직</em></div><div class="sample-day"><span>13</span><em class="off">비번</em></div><div class="sample-day sat"><span>14</span><em class="regular">일반</em></div><div class="sample-day sun"><span>15</span><em class="duty">당직</em></div><div class="sample-day"><span>16</span><em class="off">비번</em></div><div class="sample-day"><span>17</span><em class="regular">일반</em></div><div class="sample-day"><span>18</span><em class="duty">당직</em></div><div class="sample-day"><span>19</span><em class="off">비번</em></div><div class="sample-day"><span>20</span><em class="regular">일반</em></div><div class="sample-day sat picked"><span>21</span><em class="duty">당직</em></div><div class="sample-day sun"><span>22</span><em class="off">비번</em></div><div class="sample-day"><span>23</span><em class="regular">일반</em></div><div class="sample-day"><span>24</span><em class="duty">당직</em></div><div class="sample-day"><span>25</span><em class="off">비번</em></div><div class="sample-day"><span>26</span><em class="regular">일반</em></div><div class="sample-day"><span>27</span><em class="duty">당직</em></div><div class="sample-day sat"><span>28</span><em class="off">비번</em></div><div class="sample-day sun"><span>29</span><em class="regular">일반</em></div><div class="sample-day"><span>30</span><em class="duty">당직</em></div><div class="sample-day empty-day" aria-hidden="true"></div><div class="sample-day empty-day" aria-hidden="true"></div><div class="sample-day empty-day" aria-hidden="true"></div><div class="sample-day empty-day" aria-hidden="true"></div><div class="sample-day empty-day" aria-hidden="true"></div></div><div class="paper-footer"><span><i></i>선택한 날 · 11월 21일 당직</span><span>3일 반복</span></div></div>
|
||||
@@ -20,14 +20,14 @@
|
||||
<div class="page-heading"><div><div class="eyebrow">근무와 일정</div><h1>나의 달력</h1></div><button id="add">일정 추가</button></div>
|
||||
<div class="summary-row"><article class="today-card"><div id="today-date" class="small"></div><h2 id="today-duty"></h2><p id="today-caption"></p></article><article class="month-summary"><span class="small">이번 달의 일정</span><strong id="month-count">0</strong><span id="rotation-label"></span><div class="settings-actions"><button id="rotation" class="text-button">당직 기초 설정</button><button id="display-options" class="secondary">옵션</button></div></article></div>
|
||||
<section id="company-start" class="company-start" hidden><div><h2>함께 일하는 사람들</h2><p>소속을 만들거나 초대코드로 가입하세요. 본인의 근무표만 공유합니다.</p></div><button id="company-start-open">소속 만들기·가입</button></section>
|
||||
<div class="calendar-layout"><section class="calendar-card"><div class="month-heading"><h2 id="month"></h2><div class="month-controls"><button id="prev" class="icon-button" aria-label="이전 달"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 5-7 7 7 7"/></svg></button><button id="today" class="secondary">오늘</button><button id="next" class="icon-button" aria-label="다음 달"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 5 7 7-7 7"/></svg></button></div></div><div class="week"><span>일</span><span>월</span><span>화</span><span>수</span><span>목</span><span>금</span><span>토</span></div><div id="grid" class="grid"></div><div class="legend"><span class="duty">당직</span><span class="off">비번</span><span class="regular">일반근무</span><span class="shift daytime">주간</span><span class="shift evening">오후</span><span class="shift night">야간</span><span class="shift rest">휴무</span><span>공휴일에도 근무 순서는 유지됩니다.</span></div></section><aside class="agenda-card"><div class="agenda-heading"><div><span class="small">선택한 날짜</span><h2 id="selected-date"></h2></div><button id="day-add" class="text-button">추가</button></div><p id="day-detail"></p><button id="parttime-add" class="secondary parttime-add">알바·시간근무 추가</button><div id="agenda"></div><section class="anniversary-panel"><div class="agenda-heading"><h3>내 생일·기념일</h3><button id="anniversary-open" class="text-button">관리</button></div><p class="small">양력·음력 매년 반복 · 내 계정에 보관</p><p class="small">서버 저장 완료 후 같은 계정으로 로그인하면 재설치해도 복원됩니다.</p></section><section class="people-panel"><div class="agenda-heading"><h3>함께 보는 근무표</h3><button id="person-add" class="text-button">사람 추가</button></div><p class="small">선택한 날짜의 근무 · 이름을 눌러 수정</p><div id="people-list"></div></section><div id="conflict-notice" hidden><strong>동시에 수정된 일정이 있습니다.</strong><p>작성한 내용은 보관 중입니다. 저장할 내용을 선택해 주세요.</p><button id="resolve">내용 비교</button></div></aside></div>
|
||||
<div class="calendar-layout"><section class="calendar-card"><div class="month-heading"><h2 id="month"></h2><div class="month-controls"><button id="prev" class="icon-button" aria-label="이전 달"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 5-7 7 7 7"/></svg></button><button id="today" class="secondary">오늘</button><button id="next" class="icon-button" aria-label="다음 달"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 5 7 7-7 7"/></svg></button></div></div><div class="week" id="calendar-weekdays"><span>일</span><span>월</span><span>화</span><span>수</span><span>목</span><span>금</span><span>토</span></div><div id="grid" class="grid"></div><div class="legend"><span class="duty">당직</span><span class="off">비번</span><span class="regular">일반근무</span><span class="shift daytime">주간</span><span class="shift evening">오후</span><span class="shift night">야간</span><span class="shift rest">휴무</span><span>공휴일에도 근무 순서는 유지됩니다.</span></div></section><aside class="agenda-card"><div class="agenda-heading"><div><span class="small">선택한 날짜</span><h2 id="selected-date"></h2></div><button id="day-add" class="text-button">추가</button></div><p id="day-detail"></p><button id="parttime-add" class="secondary parttime-add">알바·시간근무 추가</button><div id="agenda"></div><section class="anniversary-panel"><div class="agenda-heading"><h3>내 생일·기념일</h3><button id="anniversary-open" class="text-button">관리</button></div><p class="small">양력·음력 매년 반복 · 내 계정에 보관</p><p class="small">서버 저장 완료 후 같은 계정으로 로그인하면 재설치해도 복원됩니다.</p></section><section class="people-panel"><div class="agenda-heading"><h3>함께 보는 근무표</h3><button id="person-add" class="text-button">사람 추가</button></div><p class="small">선택한 날짜의 근무 · 이름을 눌러 수정</p><div id="people-list"></div></section><div id="conflict-notice" hidden><strong>동시에 수정된 일정이 있습니다.</strong><p>작성한 내용은 보관 중입니다. 저장할 내용을 선택해 주세요.</p><button id="resolve">내용 비교</button></div></aside></div>
|
||||
<p class="source-note">공휴일 자료: holidays-kr · <a href="assets/holidays-LICENSE.txt">이용 조건</a> · <a href="assets/lunar-LICENSE.txt">한국 음력 자료 이용 조건</a><span id="holiday-note"></span></p>
|
||||
</section>
|
||||
</main><footer><span>당직근무</span><span>제작자 블리어 (이창현)</span><button id="web-update-check">업데이트 확인</button><button id="logout" class="text-button" hidden>로그아웃</button></footer>
|
||||
<dialog id="anniversary-list-dialog"><div class="dialog-heading"><h2>내 생일·기념일</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div><p class="small">내 계정에만 보관합니다. 같은 소속의 다른 회원에게 공유하지 않습니다.</p><div id="anniversary-list"></div><div class="dialog-actions"><button type="button" class="secondary close">닫기</button><button id="anniversary-add">추가</button></div></dialog>
|
||||
<dialog id="anniversary-dialog"><form id="anniversary-form"><div class="dialog-heading"><h2 id="anniversary-heading">생일·기념일 추가</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div><label>기념일 이름<input id="anniversary-title" maxlength="60" required placeholder="내 생일 · 결혼기념일"></label><div class="field-row"><label>종류<select id="anniversary-category"><option value="BIRTHDAY">생일</option><option value="ANNIVERSARY">기념일</option></select></label><label>날짜 기준<select id="anniversary-calendar"><option value="SOLAR">양력</option><option value="LUNAR">음력</option></select></label></div><div class="field-row"><label>월<input id="anniversary-month" type="number" min="1" max="12" required></label><label>일<input id="anniversary-day" type="number" min="1" max="31" required></label></div><label id="anniversary-leap-label" class="check-label" hidden><input id="anniversary-leap" type="checkbox">음력 윤달</label><p class="small">매년 반복됩니다. 양력 2월 29일과 음력 30일이 없는 해에는 그달 말일에 표시합니다. 윤달이 없는 해에는 같은 일반 월에 표시합니다. 음력은 1900~2050년 자료를 사용합니다.</p><label>휴대폰 알림<select id="anniversary-reminder"><option value="-1">알림 없음</option><option value="0">시작 시간</option><option value="10">10분 전</option><option value="30">30분 전</option><option value="60">1시간 전</option><option value="1440">하루 전</option></select></label><p class="small">기념일 오전 9시를 기준으로 알립니다. 안드로이드 앱의 알림 허용이 필요합니다.</p><label>메모<textarea id="anniversary-notes" maxlength="1000" rows="2"></textarea></label><p class="small">인터넷이 끊기면 기기에 보관한 뒤 연결될 때 서버에 전송합니다. 재설치 전 서버 저장 완료를 확인해 주세요.</p><p id="anniversary-error" class="form-error" role="alert"></p><div class="dialog-actions"><button id="anniversary-delete" type="button" class="danger" hidden>삭제</button><button type="button" class="secondary close">취소</button><button type="submit">저장</button></div></form></dialog>
|
||||
<dialog id="event-dialog"><form id="event-form"><div class="dialog-heading"><h2 id="event-heading">일정 추가</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div><p class="small">알바는 근무지와 시간대별로 각각 추가하세요. 밤을 넘기면 종료 날짜를 다음 날로 정합니다.</p><label>제목·근무지<input id="event-title" maxlength="120" required placeholder="어떤 일정인가요?"></label><label>일정 종류<select id="event-category"><option value="GENERAL">개인 일정</option><option value="WORK">업무</option><option value="PARTTIME">알바·시간근무</option><option value="LEAVE">휴가·휴무</option></select></label><div class="field-row"><label>시작 날짜<input id="event-date" type="date" min="2000-01-01" max="2099-12-31" required></label><label>종료 날짜<input id="event-end" type="date" min="2000-01-01" max="2099-12-31" required></label></div><label class="check-label"><input id="event-all-day" type="checkbox" checked>하루 종일</label><div id="time-fields" class="field-row" hidden><label>시작 시간<input id="event-start-time" type="time" value="09:00"></label><label>종료 시간<input id="event-end-time" type="time" value="10:00"></label></div><label>반복<select id="event-repeat"><option value="NONE">반복 없음</option><option value="DAILY">매일</option><option value="WEEKLY">매주</option><option value="MONTHLY">매월</option><option value="YEARLY">매년</option></select></label><label id="event-repeat-until-label">반복 종료일 (선택)<input id="event-repeat-until" type="date" min="2000-01-01" max="2099-12-31"></label><p class="small">반복 수정과 삭제는 전체 반복에 적용합니다. 해당 날짜가 없는 달에는 그달 말일에 표시합니다.</p><label>휴대폰 알림<select id="event-reminder"><option value="-1">알림 없음</option><option value="0">시작 시간</option><option value="10">10분 전</option><option value="30">30분 전</option><option value="60">1시간 전</option><option value="1440">하루 전</option></select></label><p class="small">하루 종일 일정은 오전 9시 기준입니다. 안드로이드 앱에서 알림을 허용해야 하며 절전 중에는 늦게 울릴 수 있습니다. 웹에서는 알림 선택만 저장합니다.</p><label>메모<textarea id="event-notes" maxlength="2000" rows="3" placeholder="장소나 기억할 내용을 적어 주세요."></textarea></label><p id="event-error" class="form-error" role="alert"></p><div class="dialog-actions"><button id="event-delete" type="button" class="danger" hidden>삭제</button><button type="button" class="secondary close">취소</button><button type="submit">저장</button></div></form></dialog>
|
||||
<dialog id="options-dialog"><form id="options-form"><div class="dialog-heading"><h2>옵션</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div><h3>달력 표시</h3><p class="small">내 계정의 개인 설정으로 서버에 보관합니다. 같은 계정으로 로그인한 앱과 홈 위젯에도 적용합니다. 근무 순서와 기준일은 바뀌지 않습니다.</p><label class="check-label"><input id="rotation-duty-weekday" type="checkbox">당직일은 평일색으로 표시</label><p class="small">주말·공휴일이어도 당직 날짜는 평일색으로 표시합니다. 공휴일 이름과 근무 순서는 유지됩니다.</p><label class="check-label"><input id="rotation-off-red" type="checkbox">비번을 빨간색으로 표시</label><p class="small">비번 날짜와 비번 글씨를 빨간색으로 표시합니다.</p><label class="check-label"><input id="rotation-show-lunar" type="checkbox">음력 날짜 함께 보기</label><p class="small">양력 아래에 작은 글씨로 표시합니다. 윤달은 윤으로 구분합니다.</p><div class="dialog-actions"><button type="button" class="secondary close">취소</button><button type="submit">저장</button></div></form></dialog>
|
||||
<dialog id="options-dialog"><form id="options-form"><div class="dialog-heading"><h2>옵션</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div><h3>달력 표시</h3><p class="small">내 계정의 개인 설정으로 서버에 보관합니다. 같은 계정으로 로그인한 앱과 홈 위젯에도 적용합니다. 근무 순서와 기준일은 바뀌지 않습니다.</p><label>주 시작 요일<select id="rotation-week-start"><option value="1">월요일 시작</option><option value="0">일요일 시작</option></select></label><label class="check-label"><input id="rotation-duty-weekday" type="checkbox">당직일은 평일색으로 표시</label><p class="small">주말·공휴일이어도 당직 날짜는 평일색으로 표시합니다. 공휴일 이름과 근무 순서는 유지됩니다.</p><label class="check-label"><input id="rotation-off-red" type="checkbox">비번을 빨간색으로 표시</label><p class="small">비번 날짜와 비번 글씨를 빨간색으로 표시합니다.</p><label class="check-label"><input id="rotation-show-lunar" type="checkbox">음력 날짜 함께 보기</label><p class="small">양력 아래에 작은 글씨로 표시합니다. 윤달은 윤으로 구분합니다.</p><div class="dialog-actions"><button type="button" class="secondary close">취소</button><button type="submit">저장</button></div></form></dialog>
|
||||
<dialog id="rotation-dialog"><form id="rotation-form"><div class="dialog-heading"><h2>당직 기초 설정</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div><p class="small">기준 날짜를 첫째 날로 삼아 같은 순서로 반복합니다. 날짜 색상과 음력은 옵션에서 바꿀 수 있습니다.</p><label>토요일 근무제<select id="rotation-work-week"><option value="6">주6일제 · 토요일 기존 근무</option><option value="5">주5일제 · 토요일 당직만 근무</option></select></label><p class="small">주5일제는 토요일을 빨간색으로 표시하며 당직이 아니면 휴무입니다. 주6일제는 파란색으로 표시하고 원래 근무를 따릅니다.</p><label>근무 유형<select id="rotation-mode"><option value="custom">직접 설정</option><option value="duty">일당직 · 숫자로 입력</option></select></label><label id="rotation-remainder-label" hidden>당직·비번 다음 남은 날<select id="rotation-remainder"><option value="REGULAR">일반근무</option><option value="OFF">비번</option><option value="REST">휴무</option></select></label><p class="small">일당직은 숫자만 입력하면 당직·비번 다음의 근무를 채웁니다. 교대 유형은 예시이며 아래 순서를 직접 고칠 수 있습니다.</p><label>반복 일수<input id="rotation-count" type="number" min="1" max="366" required></label><div id="rotation-days" class="rotation-days"></div><label>첫째 날의 날짜<input id="rotation-anchor" type="date" min="2000-01-01" max="2099-12-31" required></label><p id="rotation-error" class="form-error" role="alert"></p><div class="dialog-actions"><button type="button" class="secondary close">취소</button><button type="submit">저장</button></div></form></dialog>
|
||||
<dialog id="auth-dialog"><form id="auth-form"><div class="dialog-heading"><h2 id="auth-heading">회원 로그인</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div><p id="auth-help" class="small"></p><label>아이디<input id="auth-username" autocomplete="username" minlength="3" maxlength="32" pattern="[a-zA-Z0-9_]{3,32}" required></label><label id="auth-name-label" hidden>이름<input id="auth-name" maxlength="40" autocomplete="name"></label><label id="auth-code-label" hidden>복구 코드<input id="auth-code" maxlength="32" autocomplete="off"></label><label>비밀번호<input id="auth-password" type="password" maxlength="128" autocomplete="current-password" required></label><label id="auth-repeat-label" hidden>비밀번호 확인<input id="auth-repeat" type="password" maxlength="128" autocomplete="new-password"></label><p id="auth-error" class="form-error" role="alert"></p><div class="dialog-actions"><button id="auth-recovery" type="button" class="text-button">비밀번호 복구</button><button id="auth-submit" type="submit">로그인</button></div></form></dialog>
|
||||
<dialog id="account-dialog"><div class="dialog-heading"><h2>내 정보</h2><button class="icon-button close" aria-label="닫기">×</button></div><p id="account-description"></p><p class="small">앱의 웹 연동을 켠 뒤 같은 아이디로 로그인하면 일정과 함께 보는 근무표가 동기화됩니다.</p><div class="dialog-actions"><button id="password-open">비밀번호 변경</button></div></dialog>
|
||||
|
||||
@@ -7,7 +7,7 @@ main{max-width:1320px;margin:auto;padding:40px}.welcome{padding:12px 0 0}.welcom
|
||||
.calendar-preview{margin:0;min-width:0;position:relative;padding:0 12px 0 0}.calendar-preview figcaption{display:flex;justify-content:space-between;margin:0 0 13px;font-size:11px;letter-spacing:.02em;color:var(--muted)}.calendar-preview figcaption span:last-child{color:#7c8188}.calendar-paper{position:relative;padding:24px 25px 16px;background:var(--paper);border:1px solid #dbd8ce;border-top:5px solid var(--ink);border-radius:3px;box-shadow:8px 8px 0 #e8e4da,0 15px 30px #29334509}.paper-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:19px}.paper-heading>div:first-child{display:flex;align-items:baseline;gap:15px}.paper-year{font-size:12px;font-weight:550;color:#5c6471;writing-mode:vertical-rl;transform:rotate(180deg)}.paper-heading strong{font-size:54px;line-height:1;letter-spacing:-2px;font-weight:600;font-variant-numeric:tabular-nums}.paper-heading strong span{font-size:15px;margin-left:5px;letter-spacing:0}.paper-note{text-align:right;display:flex;flex-direction:column;gap:7px;font-size:12px}.paper-note span{font-size:10px;color:var(--muted)}.sample-week,.sample-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}.sample-week{text-align:center;border-top:1px solid var(--ink);border-bottom:1px solid var(--line);padding:10px 0;font-size:10px}.sample-week span:first-child{color:var(--red)}.sample-week span:last-child{color:var(--blue)}.sample-day{min-height:57px;padding:8px 2px 5px;border-bottom:1px solid #e8e7e1;display:flex;flex-direction:column;align-items:center;gap:5px}.sample-day>span{font-size:14px;font-variant-numeric:tabular-nums}.sample-day.sun>span{color:var(--red)}.sample-day.sat>span{color:var(--blue)}.sample-day em{font-size:9px;font-style:normal;padding:2px 5px;border-radius:2px}.sample-day.picked{background:#f9eee6;box-shadow:inset 0 0 0 1px #c27859}.paper-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding-top:13px;font-size:10px;color:#686d75}.paper-footer i{display:inline-block;width:5px;height:5px;background:var(--accent);margin:0 6px 2px 0}.preview-detail{position:relative;display:flex;align-items:center;gap:16px;margin:18px 0 0 35px;padding:13px 18px;border-left:3px solid var(--accent);background:#e9e3d7}.detail-index{font-size:30px;font-weight:500;line-height:1}.preview-detail strong{font-size:12px}.preview-detail p{font-size:11px;color:var(--muted);margin-top:4px}.detail-tag{margin-left:auto;font-size:10px;color:#655e57}
|
||||
.feature-ledger{display:grid;grid-template-columns:1fr 2fr;gap:55px;border-top:1px solid var(--ink);padding:31px 0 50px}.ledger-heading>span{font-size:18px;font-weight:700;letter-spacing:-.5px}.ledger-heading p{margin-top:11px;font-size:12px;line-height:1.8;color:var(--muted)}.feature-rows article{display:flex;align-items:flex-start;gap:23px;padding:23px 0;border-bottom:1px solid #d7d9d7}.feature-rows article:first-child{padding-top:0}.feature-number{font-size:12px;color:var(--accent);font-variant-numeric:tabular-nums;line-height:24px}.feature-rows h2{font-size:16px;margin-bottom:8px}.feature-rows p{font-size:13px;line-height:1.8;color:var(--muted)}.feature-label{margin-left:auto;flex-shrink:0;font-size:10px;padding-top:5px;color:var(--muted)}.install-guide{display:grid;grid-template-columns:1fr 2fr;gap:55px;border-top:1px solid var(--ink);padding:34px 0 12px;scroll-margin-top:25px}.install-guide h2{font-size:29px;line-height:1.4;letter-spacing:-1px;margin:15px 0}.install-guide>div>p:not(.eyebrow):not(.install-notice){font-size:13px;line-height:1.8;color:var(--muted)}.install-guide .install-link{margin-top:12px}.install-guide ol{list-style:none;margin:0;padding:0;counter-reset:steps}.install-guide li{position:relative;counter-increment:steps;padding:0 0 24px 38px}.install-guide li:before{content:counter(steps);position:absolute;left:0;top:1px;font-size:12px;border-bottom:1px solid var(--accent);padding:0 4px 4px;color:var(--accent)}.install-guide strong{display:block;font-size:14px;margin-bottom:8px}.install-guide li span{display:block;font-size:13px;line-height:1.8;color:var(--muted)}.install-notice{font-size:11px;line-height:1.9;color:var(--muted);padding:15px 0 0;border-top:1px solid var(--line)}
|
||||
/* 회원 화면은 달력을 주 작업 영역으로 두고 당일 정보와 소속 안내를 얇은 띠로 배치한다. */
|
||||
.page-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:25px}.summary-row{display:grid;grid-template-columns:1.3fr 1fr;border-top:2px solid var(--ink);border-bottom:1px solid #cbd0d2;margin-bottom:22px;background:var(--paper)}.today-card{padding:21px 25px;border-left:4px solid var(--accent)}.today-card h2{font-size:25px;margin:5px 0 7px}.today-card p{color:var(--muted);font-size:12px}.month-summary{padding:21px 25px;border-left:1px solid var(--line);display:grid;grid-template-columns:1fr auto;align-items:center;gap:3px}.month-summary strong{font-size:31px;font-weight:550;grid-row:span 2;font-variant-numeric:tabular-nums}.month-summary span:nth-child(3){font-size:12px;color:var(--muted)}.month-summary button{justify-self:start;padding:3px 0;min-height:32px}.company-start{display:flex;justify-content:space-between;align-items:center;gap:22px;padding:3px 0 21px;border-bottom:1px solid #d6dadb;margin-bottom:25px}.company-start h2{font-size:14px;margin-bottom:6px}.company-start p{font-size:12px;line-height:1.7;color:var(--muted)}.company-start button{font-size:12px;flex-shrink:0;background:transparent;color:var(--ink);border-color:#bfc6cd}.calendar-layout{display:grid;grid-template-columns:minmax(0,1fr) 270px;gap:30px;align-items:start}.calendar-card{background:var(--paper);border:1px solid #d6d7d4;border-top:4px solid var(--ink);border-radius:3px;padding:23px}.agenda-card{padding:5px 0;background:transparent}.month-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:19px}.month-heading h2{font-size:26px;letter-spacing:-1px}.month-controls{display:flex;gap:3px;align-items:center}.week,.grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}.week{font-size:11px;color:var(--muted);text-align:center;border-top:1px solid #818b95;padding:12px 0}.week span:first-child{color:var(--red)}.week span:last-child{color:var(--blue)}.day{background:transparent;border:0;border-top:1px solid #e5e5df;border-radius:0;min-height:98px;padding:9px 2px 6px;color:var(--ink);display:flex;align-items:center;flex-direction:column;gap:5px;overflow:hidden;min-width:0;font-weight:450}.day:hover{background:#efeee7}.day.selected{background:#f4efe5;box-shadow:inset 0 0 0 1px #c1a484}.day.outside{opacity:.35}.day-number{font-size:15px;min-width:25px;line-height:25px;border-radius:3px;text-align:center;font-variant-numeric:tabular-nums}.day.current .day-number{background:var(--ink);color:white!important}.day.sun .day-number,.day.holiday .day-number{color:var(--red)}.day.sat:not(.holiday) .day-number{color:var(--blue)}.five-day .week span:last-child,.five-day .day.sat:not(.holiday) .day-number{color:var(--red)}.shift{border-radius:2px;padding:2px 5px;font-size:10px;line-height:16px}.duty{color:#aa4c2e;background:#faeadd}.off{color:#666f7c;background:#edf0f2}.regular{color:#365fad;background:#eaf0fc}.shift.daytime{color:#9b561d;background:#fff1df}.shift.evening{color:#ad3d6e;background:#fbeaf0}.shift.night{color:#79459d;background:#f1eaf8}.shift.rest{color:#64748b;background:#f0f3f5}.holiday-name{font-size:9px;color:var(--red);white-space:nowrap;max-width:100%;overflow:hidden;text-overflow:ellipsis}.event-count{font-size:10px;font-weight:650;color:#885c2e;white-space:nowrap}.legend{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:17px;font-size:10px;color:var(--muted)}.legend span{padding:3px 5px;border-radius:2px}.legend span:last-child{padding:3px 0;width:100%}.agenda-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}.agenda-heading h2{margin-top:7px;font-size:22px}.agenda-card>p{font-size:12px;line-height:1.8;color:var(--muted);margin:13px 0 20px}.event-item{width:100%;text-align:left;background:#fffefa;color:var(--ink);border:1px solid #d5d7d6;border-left:3px solid #7c899a;margin:0 0 10px;padding:13px;border-radius:2px;font-weight:500;overflow-wrap:anywhere}.event-item:hover{background:#eaeef2}.event-item.work{border-left-color:#365fad}.event-item.leave{border-left-color:var(--accent)}.event-item strong{display:block;font-size:14px;line-height:1.5}.event-item span{display:block;font-size:11px;color:var(--muted);margin-top:6px}.empty{padding:23px 0;color:var(--muted);font-size:12px;line-height:1.9;border-top:1px solid var(--line)}.source-note{font-size:10px;color:var(--muted);margin-top:18px;line-height:1.8}.source-note span{display:block}.people-panel{border-top:1px solid #bfc5ca;margin-top:22px;padding-top:20px}.people-panel h3{font-size:15px}.people-panel>p{margin:8px 0 15px}.person-row{display:block;text-align:left;width:100%;background:var(--paper);margin:8px 0;border:1px solid var(--line);border-left:3px solid currentColor;border-radius:2px;overflow-wrap:anywhere}.person-row:hover{background:#eaeef2}.person-row small{display:block;color:var(--muted);font-weight:400;font-size:11px;margin-top:5px}.person-badge{font-size:10px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:650}.person-blLine truncated
|
||||
.page-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:25px}.summary-row{display:grid;grid-template-columns:1.3fr 1fr;border-top:2px solid var(--ink);border-bottom:1px solid #cbd0d2;margin-bottom:22px;background:var(--paper)}.today-card{padding:21px 25px;border-left:4px solid var(--accent)}.today-card h2{font-size:25px;margin:5px 0 7px}.today-card p{color:var(--muted);font-size:12px}.month-summary{padding:21px 25px;border-left:1px solid var(--line);display:grid;grid-template-columns:1fr auto;align-items:center;gap:3px}.month-summary strong{font-size:31px;font-weight:550;grid-row:span 2;font-variant-numeric:tabular-nums}.month-summary span:nth-child(3){font-size:12px;color:var(--muted)}.month-summary button{justify-self:start;padding:3px 0;min-height:32px}.company-start{display:flex;justify-content:space-between;align-items:center;gap:22px;padding:3px 0 21px;border-bottom:1px solid #d6dadb;margin-bottom:25px}.company-start h2{font-size:14px;margin-bottom:6px}.company-start p{font-size:12px;line-height:1.7;color:var(--muted)}.company-start button{font-size:12px;flex-shrink:0;background:transparent;color:var(--ink);border-color:#bfc6cd}.calendar-layout{display:grid;grid-template-columns:minmax(0,1fr) 270px;gap:30px;align-items:start}.calendar-card{background:var(--paper);border:1px solid #d6d7d4;border-top:4px solid var(--ink);border-radius:3px;padding:23px}.agenda-card{padding:5px 0;background:transparent}.month-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:19px}.month-heading h2{font-size:26px;letter-spacing:-1px}.month-controls{display:flex;gap:3px;align-items:center}.week,.grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}.week{font-size:11px;color:var(--muted);text-align:center;border-top:1px solid #818b95;padding:12px 0}.week span.sun{color:var(--red)}.week span.sat{color:var(--blue)}.day{background:transparent;border:0;border-top:1px solid #e5e5df;border-radius:0;min-height:98px;padding:9px 2px 6px;color:var(--ink);display:flex;align-items:center;flex-direction:column;gap:5px;overflow:hidden;min-width:0;font-weight:450}.day:hover{background:#efeee7}.day.selected{background:#f4efe5;box-shadow:inset 0 0 0 1px #c1a484}.day.outside{opacity:.35}.day-number{font-size:15px;min-width:25px;line-height:25px;border-radius:3px;text-align:center;font-variant-numeric:tabular-nums}.day.current .day-number{background:var(--ink);color:white!important}.day.sun .day-number,.day.holiday .day-number{color:var(--red)}.day.sat:not(.holiday) .day-number{color:var(--blue)}.five-day .week span.sat,.five-day .day.sat:not(.holiday) .day-number{color:var(--red)}.shift{border-radius:2px;padding:2px 5px;font-size:10px;line-height:16px}.duty{color:#aa4c2e;background:#faeadd}.off{color:#666f7c;background:#edf0f2}.regular{color:#365fad;background:#eaf0fc}.shift.daytime{color:#9b561d;background:#fff1df}.shift.evening{color:#ad3d6e;background:#fbeaf0}.shift.night{color:#79459d;background:#f1eaf8}.shift.rest{color:#64748b;background:#f0f3f5}.holiday-name{font-size:9px;color:var(--red);white-space:nowrap;max-width:100%;overflow:hidden;text-overflow:ellipsis}.event-count{font-size:10px;font-weight:650;color:#885c2e;white-space:nowrap}.legend{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-top:17px;font-size:10px;color:var(--muted)}.legend span{padding:3px 5px;border-radius:2px}.legend span:last-child{padding:3px 0;width:100%}.agenda-heading{display:flex;align-items:center;justify-content:space-between;gap:8px}.agenda-heading h2{margin-top:7px;font-size:22px}.agenda-card>p{font-size:12px;line-height:1.8;color:var(--muted);margin:13px 0 20px}.event-item{width:100%;text-align:left;background:#fffefa;color:var(--ink);border:1px solid #d5d7d6;border-left:3px solid #7c899a;margin:0 0 10px;padding:13px;border-radius:2px;font-weight:500;overflow-wrap:anywhere}.event-item:hover{background:#eaeef2}.event-item.work{border-left-color:#365fad}.event-item.leave{border-left-color:var(--accent)}.event-item strong{display:block;font-size:14px;line-height:1.5}.event-item span{display:block;font-size:11px;color:var(--muted);margin-top:6px}.empty{padding:23px 0;color:var(--muted);font-size:12px;line-height:1.9;border-top:1px solid var(--line)}.source-note{font-size:10px;color:var(--muted);margin-top:18px;line-height:1.8}.source-note span{display:block}.people-panel{border-top:1px solid #bfc5ca;margin-top:22px;padding-top:20px}.people-panel h3{font-size:15px}.people-panel>p{margin:8px 0 15px}.person-row{display:block;text-align:left;width:100%;background:var(--paper);margin:8px 0;border:1px solid var(--line);border-left:3px solid currentColor;border-radius:2px;overflow-wrap:anywhere}.person-row:hover{background:#eaeef2}.person-row small{display:block;color:var(--muted);font-weight:400;font-size:11px;margin-top:5px}.person-badge{font-size:10px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:650}.person-blue{color:#365fad}.persLine truncated
|
||||
footer{max-width:1240px;margin:15px auto 0;padding:24px 0 34px;border-top:1px solid #bec4c7;display:flex;align-items:center;gap:20px;color:var(--muted);font-size:11px}footer span:first-child{font-weight:700;margin-right:auto;color:var(--ink)}
|
||||
/* 입력 창은 제목과 입력칸의 경계를 분명히 둔다. 키보드와 화면 읽기 기능의 기본 동작을 유지한다. */
|
||||
dialog{border:1px solid #c2c8cd;border-top:4px solid var(--ink);border-radius:5px;padding:27px;width:min(540px,calc(100% - 28px));max-height:90dvh;color:var(--ink);background:var(--paper);box-shadow:0 18px 60px #16203024}dialog::backdrop{background:#18243780}.dialog-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}.dialog-heading .close{font-size:26px}.dialog-actions{display:flex;gap:9px;justify-content:flex-end;margin-top:23px}.dialog-actions .danger{margin-right:auto}.danger{background:#f8e9e6;color:#9e3934;border-color:#e4c3be}.danger:hover{background:#eed2cd}label{display:flex;flex-direction:column;gap:8px;font-size:13px;font-weight:650;margin-top:18px}input,select,textarea{width:100%;min-width:0;border:1px solid #b8c0c9;border-radius:4px;background:#fff;padding:11px 12px;color:var(--ink);font-size:15px;line-height:1.5}textarea{resize:vertical}.field-row{display:flex;gap:12px}.field-row>label{flex:1;min-width:0}.check-label{flex-direction:row;align-items:center}.check-label input{width:19px;height:19px;accent-color:var(--ink)}.form-error{color:#9e3934;font-size:13px;line-height:1.7;margin-top:12px}.rotation-days{display:grid;grid-template-columns:1fr 1fr;gap:0 14px}.rotation-days label{margin-top:12px}.pair-code{font-size:28px;letter-spacing:4px}.pair-code+p,dialog p{line-height:1.8}.toast{position:fixed;bottom:25px;left:50%;transform:translateX(-50%);z-index:10;max-width:calc(100% - 30px);padding:13px 22px;background:var(--ink);color:white;border-radius:4px;font-size:13px;box-shadow:0 5px 15px #0002}pre{white-space:pre-wrap;overflow-wrap:anywhere;font-family:inherit;font-size:13px;line-height:1.8;padding:15px;background:#f0efe9;border:1px solid var(--line)}#conflict-notice{padding:18px 0;margin-top:20px;border-top:2px solid var(--accent)}#conflict-notice p{margin:10px 0;font-size:12px}#conflict-dialog h3{margin-top:18px}.wide-dialog{width:min(850px,calc(100% - 28px))}.member-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 0;border-bottom:1px solid var(--line)}.member-row strong{overflow-wrap:anywhere}.member-row>div{min-width:0}.member-row button{flex-shrink:0}#member-total{margin:16px 0 4px}#member-delete{margin-top:20px;width:100%}#confirm-message{margin-top:15px}#account-description{margin-bottom:14px}#member-reset-code,#company-invite-code{font-family:monospace}#account-notice:empty{display:none}.company-member{display:flex;justify-content:space-between;gap:14px;padding:15px 0;border-bottom:1px solid var(--line)}.company-member>div{min-width:0}.company-member p{overflow-wrap:anywhere}.company-actions{display:flex;gap:8px;align-items:flex-start;flex-wrap:wrap}.company-actions button{font-size:12px;padding:9px}#company-dialog h3{margin-top:24px}#company-dialog form>button,#company-invite,#company-delete,#company-leave{margin-top:14px}#company-dialog hr{margin:24px 0;border:0;border-top:1px solid var(--line)}#company-code-box{padding:10px 16px;background:#e9edf3;border-radius:4px;margin-top:16px}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
const WEB_BUILD = '2026-11-20.10';
|
||||
const WEB_BUILD = '2026-11-21.2';
|
||||
let offeredRelease=null, versionChecking=false;
|
||||
const versionDeferKey='duty-web-update-later';
|
||||
const versionSeenKey='duty-web-update-seen';
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
// 화면 열의 위치와 실제 요일을 분리한다. 없는 설정은 기존 일요일 시작으로 읽는다.
|
||||
function calendarWeekdays(weekStart=0){
|
||||
const start=weekStart===1?1:0;
|
||||
return Array.from({length:7},(_,index)=>(index+start)%7);
|
||||
}
|
||||
function calendarFirstDate(month,weekStart=0){
|
||||
const date=new Date(month+'-01T00:00:00Z');
|
||||
date.setUTCDate(1-(date.getUTCDay()-(weekStart===1?1:0)+7)%7);
|
||||
return date;
|
||||
}
|
||||
if(typeof module!=='undefined')module.exports={calendarWeekdays,calendarFirstDate};
|
||||
Reference in new issue
Block a user