당직근무 0.10.0 소스와 위젯 꾸미기 및 제작 매뉴얼 공개

위젯별 투명도와 밝은·어두운 색상 및 글자 크기와 표시 항목을 추가했다.
모든 위젯에 함께 적용하는 기본값과 개별 설정을 구분하고 크기에 따라 배치를 바꾼다.
포럼에 APK와 전체 소스 및 사용법과 제작 매뉴얼을 함께 배포한다.

앱 단위 검사 34개와 서버 검사 63개 및 웹 날짜·업데이트 검사 통과.
공개 소스에서 APK 빌드와 정적 검사 오류 0개 확인. 경고는 69개다.
Android 16 가상 기기에서 기존 앱 위에 설치하고 투명 위젯과 큰 글자 및 RemoteViews 검사를 확인했다.
실제 휴대폰과 다른 홈 화면 앱의 절전·크기 동작은 별도 확인이 필요하다.
회원 DB와 인증 정보 및 배포 서명 키와 내부 운영 기록은 공개 자료에 포함하지 않았다.
This commit is contained in:
블리어 committed 2026-11-20 10:00:42 +00:00
commit 8112721fa8
96 files changed
+7495

No files matched your search

@@ -0,0 +1,121 @@
package kr.co.itosm.dutycalendar
import android.app.*
import android.content.*
import android.os.Bundle
import android.provider.CalendarContract
import org.json.JSONObject
import java.io.File
import java.time.*
import java.util.UUID
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
/** 검증용 가상 기기에서만 실행한다. 빈 저장소 복원과 계정 분리 및 실제 알림을 검사하고 원래 설정을 돌려놓는다.
* 서버 계정은 qa09_ 접두사가 있는 일회성 계정만 허용한다. 인증값은 결과에 남기지 않는다.
*/
object PersonalFeatureCheck {
private fun done(action:((Boolean)->Unit)->Unit) {
val latch=CountDownLatch(1);var success=false
action{success=it;latch.countDown()};check(latch.await(45,TimeUnit.SECONDS)&&success)
}
fun run(test:Instrumentation,outage:Boolean=false) {
val app=test.targetContext
if(SyncClient.enabled(app)||PlannerStore.calendarId(app).isNotBlank()) {
test.finish(Activity.RESULT_CANCELED,Bundle().apply{putString("stream","미연결 검증 기기에서만 실행합니다.")});return
}
val names=listOf("schedule","planner","web_sync","reminders")
val saved=names.associateWith{app.getSharedPreferences(it,0).all.toMap()}
val credentials=File(app.filesDir,"verification-personal.json")
val noticeId=UUID.randomUUID().toString()
fun empty() {
SyncClient.disable(app);done{SyncClient.sync(app,complete=it)}
names.forEach{app.getSharedPreferences(it,0).edit().clear().commit()}
}
var ok=false;var stage="초기 검사"
try {
empty()
val today=LocalDate.now()
val event=JSONObject().put("title","검증 일정").put("notes","").put("category","GENERAL")
.put("date",today.toString()).put("endDate",today.toString()).put("allDay",true)
.put("startTime","09:00").put("endTime","10:00").put("repeat","MONTHLY").put("repeatUntil","").put("reminderMinutes",0)
PlannerStore.put(app,noticeId,"event",event)
val next=today.plusMonths(1)
check(PlannerStore.eventsOn(app,next).size==1)
stage="달력 전달"
val intent=DeviceCalendar.insertIntent(event,next)
check(intent.action==Intent.ACTION_INSERT&&intent.data==CalendarContract.Events.CONTENT_URI)
check(intent.getLongExtra(CalendarContract.EXTRA_EVENT_END_TIME,0)-intent.getLongExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,0)==86400000L)
check(intent.getBooleanExtra(CalendarContract.EXTRA_EVENT_ALL_DAY,false))
stage="예약과 알림"
val future=Reminders.plans(app,System.currentTimeMillis()).first()
check(future.at>System.currentTimeMillis())
val time=ZonedDateTime.now().minusMinutes(1).withSecond(0).withNano(0)
event.put("date",time.toLocalDate().toString()).put("endDate",time.toLocalDate().toString()).put("allDay",false)
.put("startTime",time.toLocalTime().toString()).put("endTime",time.plusMinutes(1).toLocalTime().toString()).put("repeat","NONE")
if(time.toLocalDate()==time.plusMinutes(1).toLocalDate()) {
PlannerStore.put(app,noticeId,"event",event)
val at=time.toInstant().toEpochMilli()
synchronized(Reminders) {
app.getSharedPreferences("reminders",0).edit().putLong("at",at).commit()
Reminders.receive(app,Intent("kr.co.itosm.dutycalendar.REMIND").putExtra("at",at))
}
check(app.getSystemService(NotificationManager::class.java).activeNotifications.any{it.tag==noticeId})
}
if(credentials.isFile) {
val accounts=JSONObject(credentials.readText())
fun connect(key:String){val account=accounts.getJSONObject(key);check(account.getString("username").startsWith("qa09_"));done{cb->SyncClient.connect(app,account.getString("username"),account.getString("password")){cb(it==null)}}}
empty();stage="첫 회원 복원";connect("a")
check(ScheduleStore.load(app).showLunar&&ScheduleStore.load(app).offAsHoliday)
check(Anniversaries.on(app,LocalDate.of(2026,2,17)).size==1)
if(outage) {
stage="인터넷 중단 대기"
File(app.filesDir,"qa09-network-ready").writeText("ready")
val deadline=System.currentTimeMillis()+90000
while(!File(app.filesDir,"qa09-network-offline").exists()&&System.currentTimeMillis()<deadline)Thread.sleep(200)
check(File(app.filesDir,"qa09-network-offline").exists())
}
val annual=JSONObject().put("title","복원 검사 기념일").put("category","ANNIVERSARY").put("calendar","SOLAR").put("month",2).put("day",29).put("leapMonth",false).put("notes","").put("reminderMinutes",-1)
val id=UUID.randomUUID().toString();PlannerStore.put(app,id,"anniversary",annual)
if(outage) {
stage="인터넷 없는 일정 저장"
val first=JSONObject(event.toString()).put("title","카페 오전").put("category","PARTTIME").put("date","2026-11-20").put("endDate","2026-11-20").put("startTime","08:00").put("endTime","12:00").put("allDay",false).put("repeat","WEEKLY").put("reminderMinutes",30)
val second=JSONObject(first.toString()).put("title","편의점 야간").put("endDate","2026-11-21").put("startTime","22:00").put("endTime","06:00")
PlannerStore.put(app,UUID.randomUUID().toString(),"event",first)
PlannerStore.put(app,UUID.randomUUID().toString(),"event",second)
check(PlannerStore.eventsOn(app,LocalDate.of(2026,11,27)).size==2)
check(PlannerStore.eventsOn(app,LocalDate.of(2026,11,28)).size==1)
check(PlannerStore.timeSummary(second)=="22:00 – 다음 날 06:00 · 알바")
check(Reminders.plans(app,System.currentTimeMillis()).isNotEmpty())
check(Anniversaries.on(app,LocalDate.of(2027,2,28)).any{it.getString("id")==id})
check(Holidays.name(app,LocalDate.of(2026,12,25))!=null)
DutyWidget.updateAll(app)
done{cb->SyncClient.sync(app,force=true){cb(!it)}}
check(SyncClient.connected(app)&&PlannerStore.pendingCount(app)>=3)
File(app.filesDir,"qa09-offline-saved").writeText("saved")
stage="인터넷 복구 대기"
val deadline=System.currentTimeMillis()+90000
while(!File(app.filesDir,"qa09-network-restored").exists()&&System.currentTimeMillis()<deadline)Thread.sleep(200)
check(File(app.filesDir,"qa09-network-restored").exists())
}
stage="복구 후 서버 저장"
done{SyncClient.sync(app,force=true,complete=it)};check(PlannerStore.pendingCount(app)==0)
empty();stage="빈 저장소 재로그인 복원";connect("a")
check(Anniversaries.on(app,LocalDate.of(2027,2,28)).any{it.getString("id")==id})
empty();stage="다른 회원 분리";connect("b")
check(!ScheduleStore.load(app).showLunar&&!ScheduleStore.load(app).offAsHoliday)
check(Anniversaries.all(app).isEmpty())
}
ok=true
} catch(error:Throwable) {
stage+=" 실패: "+error.javaClass.simpleName+" / "+error.stackTrace.firstOrNull{it.className.contains("PersonalFeatureCheck")}?.lineNumber
} finally {
empty()
saved.forEach{(name,values)->val edit=app.getSharedPreferences(name,0).edit().clear();values.forEach{(key,value)->when(value){is String->edit.putString(key,value);is Boolean->edit.putBoolean(key,value);is Int->edit.putInt(key,value);is Long->edit.putLong(key,value);is Float->edit.putFloat(key,value)}};edit.commit()}
app.getSystemService(NotificationManager::class.java).cancel(noticeId,0)
Reminders.reschedule(app);DutyWidget.updateAll(app);credentials.delete()
listOf("qa09-network-ready","qa09-network-offline","qa09-offline-saved","qa09-network-restored").forEach{File(app.filesDir,it).delete()}
}
test.finish(if(ok)Activity.RESULT_OK else Activity.RESULT_CANCELED,Bundle().apply{putString("stream",if(ok)"반복 일정과 달력 전달 값 및 실제 알림 확인. 회원 기념일과 표시 설정의 빈 저장소 복원 및 계정 분리 확인."+(if(outage)" 실제 인터넷 차단 중 기념일·알바 2개 저장과 위젯·알림 유지 및 연결 복구 후 서버 반영 확인." else "") else stage)})
}
}
@@ -0,0 +1,134 @@
package kr.co.itosm.dutycalendar
import android.app.Activity
import android.app.Instrumentation
import android.app.job.JobScheduler
import android.content.Context
import android.os.Bundle
import org.json.JSONObject
import java.io.File
import java.time.LocalDate
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
/**
* 가상 기기의 실제 저장소와 예약 작업을 검사한다. 연결하지 않은 기기에서만 시작하며
* 원래 근무표는 마지막에 복원한다. 선택적인 서버 검증 계정은 앱 내부 임시 파일로만 받는다.
* 계정 정보와 인증값은 결과에 출력하지 않는다. 배포 APK에는 이 검사 코드가 들어가지 않는다.
*/
class StorageSyncCheck : Instrumentation() {
private var updateCheck = false
private var personalCheck = false
private var outageCheck = false
private var widgetCheck = false
override fun onCreate(arguments: Bundle?) { super.onCreate(arguments); widgetCheck = arguments?.getString("widgetCheck") == "true"; outageCheck = arguments?.getString("outageCheck") == "true"; personalCheck = arguments?.getString("personalCheck") == "true"; updateCheck = arguments?.getString("updateCheck") == "true"; start() }
private fun done(action: ((Boolean) -> Unit) -> Unit) {
val latch = CountDownLatch(1)
var success = false
action { success = it; latch.countDown() }
check(latch.await(45, TimeUnit.SECONDS) && success) { "자료 처리 검증 실패" }
}
override fun onStart() {
if (widgetCheck) { WidgetAppearanceCheck.run(this); return }
if (personalCheck) { PersonalFeatureCheck.run(this, outageCheck); return }
if (updateCheck) { checkUpdateFiles(); return }
val app = targetContext
val credentials = File(app.filesDir, "verification-account.json")
val original = ScheduleStore.load(app)
val preferences = app.getSharedPreferences("planner", Context.MODE_PRIVATE)
val priorDocument = preferences.getString("document", null)
val priorMigrated = preferences.getBoolean("migrated", false)
if (SyncClient.enabled(app) || PlannerStore.calendarId(app).isNotBlank() || !ScheduleStore.isConfigured(app)) {
finish(Activity.RESULT_CANCELED, Bundle().apply { putString("stream", "근무표가 있는 미연결 검증 기기에서 실행해 주세요.") })
return
}
var result = ""
var ok = false
try {
val trial = Schedule(LocalDate.of(2026, 11, 20), listOf(Shift.DUTY, Shift.REGULAR, Shift.NIGHT), 5, true, true, true)
ScheduleStore.save(app, trial)
check(ScheduleStore.load(app) == trial && !SyncClient.connected(app))
check(LunarDates.label(app, LocalDate.of(2026, 2, 17)) == "음1.1")
check(LunarDates.label(app, LocalDate.of(2026, 9, 25)) == "음8.15")
check(LunarDates.label(app, LocalDate.of(2025, 7, 25)) == "윤6.1")
check(LunarDates.label(app, LocalDate.of(2051, 1, 1)) == null)
check(ScheduleStore.load(app).shiftOn(LocalDate.of(2026, 11, 21)) == Shift.REST)
// 이전 버전에서 로그인 없이 등록한 사람을 흉내 낸다. 기록은 보관하되 회원 연결 전에는 표시하지 않는다.
PlannerStore.put(app, java.util.UUID.randomUUID().toString(), "person", JSONObject()
.put("name", "보관 검증").put("color", "TEAL").put("anchor", "2026-11-20")
.put("pattern", org.json.JSONArray(listOf("DUTY", "REGULAR"))).put("workWeek", 5))
check(People.all(app).isEmpty())
check(Holidays.name(app, LocalDate.of(2026, 12, 25)) != null)
done { Holidays.refresh(app, force = true, complete = it) }
check(Holidays.revision(app).isNotBlank())
DutyWidget.updateAll(app)
done { SyncClient.sync(app, complete = it) }
check(PlannerStore.refreshedAt(app) == 0L && PlannerStore.pendingCount(app) > 0)
result = "로그인 없는 본인 근무 저장과 토요일 휴무 및 공휴일과 위젯 갱신 확인. 회원용 근무표 숨김과 원본 보관 확인"
if (credentials.isFile) {
val account = JSONObject(credentials.readText())
check(account.getString("username").startsWith("qa06_"))
done { callback -> SyncClient.connect(app, account.getString("username"), account.getString("password")) { callback(it == null) } }
// 같은 검증 계정을 재사용한 경우 첫 근무표가 이미 서버에 있으므로 현재 시험값으로 정리한다.
if (PlannerStore.conflictCount(app) > 0) {
PlannerStore.resolve(app, useLocal = true)
done { SyncClient.sync(app, complete = it) }
}
check(PlannerStore.pendingCount(app) == 0 && PlannerStore.conflictCount(app) == 0)
val colleagues = People.all(app).filter { it.shared }
check(colleagues.size == 1 && colleagues[0].name == "공유검증 동료")
check(colleagues[0].schedule.workWeek == 5)
check(People.all(app).any { !it.shared && it.name == "보관 검증" })
check(PlannerStore.items(app).none { it.getString("kind") == "event" })
val before = PlannerStore.refreshedAt(app)
done { SyncClient.sync(app, complete = it) }
check(PlannerStore.refreshedAt(app) == before) { "캐시가 불필요하게 갱신됐습니다." }
done { SyncClient.sync(app, force = true, complete = it) }
check(PlannerStore.refreshedAt(app) > before)
SyncClient.schedule(app); Holidays.schedule(app)
val jobs = app.getSystemService(JobScheduler::class.java)
check(jobs.getPendingJob(2102)?.intervalMillis == RefreshPolicy.MONTH_MS)
check(jobs.getPendingJob(2101)?.intervalMillis == RefreshPolicy.MONTH_MS)
check(jobs.getPendingJob(2102)?.flexMillis == RefreshPolicy.FLEX_MS)
result += "; 실제 서버의 소속 공유와 개인 일정 차단 및 캐시 유지와 수동 갱신 및 30일 예약 확인"
}
ok = true
} catch (error: Throwable) {
result = "검증 실패: " + error.javaClass.simpleName + " / " + error.stackTrace.firstOrNull { it.className == javaClass.name }?.lineNumber
} finally {
if (SyncClient.enabled(app)) SyncClient.disable(app)
check(People.all(app).isEmpty())
done { SyncClient.sync(app, complete = it) }
preferences.edit().clear().apply {
if (priorDocument != null) putString("document", priorDocument)
putBoolean("migrated", priorMigrated)
}.commit()
ScheduleStore.save(app, original, fromSync = true)
// 검사가 끝나면 프로세스가 종료될 수 있어 비동기 설정 저장이 끝날 때까지 기다린다.
app.getSharedPreferences("schedule", Context.MODE_PRIVATE).edit()
.putString("anchor", original.anchor.toString())
.putString("pattern", original.pattern.joinToString(",") { it.name }).commit()
app.getSharedPreferences("schedule", Context.MODE_PRIVATE).edit().putInt("workWeek", original.workWeek).putBoolean("dutyAsWeekday", original.dutyAsWeekday).putBoolean("showLunar", original.showLunar).putBoolean("offAsHoliday", original.offAsHoliday).commit()
credentials.delete()
}
finish(if (ok) Activity.RESULT_OK else Activity.RESULT_CANCELED, Bundle().apply { putString("stream", result) })
}
private fun checkUpdateFiles() {
val app = targetContext
try {
val target = File(app.filesDir, "verification-update.apk")
val wanted = AppUpdate.parse(JSONObject(File(app.filesDir, "verification-update.json").readText()))
AppUpdate.validate(app, target, wanted)
for (bad in listOf(wanted.copy(sha256 = "0".repeat(64)), wanted.copy(bytes = wanted.bytes + 1), wanted.copy(code = wanted.code + 1))) {
check(runCatching { AppUpdate.validate(app, target, bad) }.isFailure)
}
val wrong = File(app.filesDir, "verification-wrong.apk")
val checksum = java.security.MessageDigest.getInstance("SHA-256").digest(wrong.readBytes()).joinToString("") { "%02x".format(it) }
check(runCatching { AppUpdate.validate(app, wrong, wanted.copy(bytes = wrong.length(), sha256 = checksum)) }.isFailure)
check(runCatching { AppUpdate.parse(wanted.json().put("apkBytes", 67108865)) }.isFailure)
finish(Activity.RESULT_OK, Bundle().apply { putString("stream", "정상 업데이트 파일 승인. 크기와 해시 및 버전 불일치와 다른 앱 차단 확인.") })
} catch (error: Throwable) {
finish(Activity.RESULT_CANCELED, Bundle().apply { putString("stream", "업데이트 파일 검사 실패: " + error.javaClass.simpleName + ": " + error.message) })
}
}
}
@@ -0,0 +1,63 @@
package kr.co.itosm.dutycalendar
import android.app.Activity
import android.app.Instrumentation
import android.appwidget.AppWidgetManager
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
/** 홈 화면이 사용하는 RemoteViews를 실제 기기에서 펼쳐 확인한다.
* 개별 설정과 전체 적용을 바꾼 뒤에는 기존 값을 복원해 검증이 사용자의 위젯에 남지 않게 한다.
*/
object WidgetAppearanceCheck {
fun run(checker:Instrumentation) {
val app=checker.targetContext
val prefs=app.getSharedPreferences("widget_style",0)
val original=prefs.all.toMap()
var success=false
var message=""
try {
val dark=WidgetStyle(transparency=100,dark=true,scale=120,detail="COMPACT",today=false)
WidgetStyle.save(app,99001,dark)
WidgetStyle.save(app,99002,WidgetStyle(transparency=40,detail="FULL"))
check(WidgetStyle.load(app,99001)==dark)
check(WidgetStyle.load(app,99002).transparency==40)
var failure:Throwable?=null
checker.runOnMainSync {
try {
fun render(id:Int,height:Int):View {
val options=Bundle().apply { putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,height);putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,height) }
return DutyWidget.buildViews(app,id,options).apply(app,FrameLayout(app))
}
val small=render(99001,250)
check(Color.alpha((small.background as ColorDrawable).color)==0)
check(small.findViewById<TextView>(R.id.day_0).maxLines==2)
check(small.findViewById<TextView>(R.id.widget_title).currentTextColor==dark.ink)
check(small.findViewById<TextView>(R.id.day_0).text.toString().lines().size==2)
check(Color.alpha((small.findViewById<View>(R.id.day_20).background as ColorDrawable).color)==0)
val full=render(99002,500)
check(Color.alpha((full.background as ColorDrawable).color)==153)
check(full.findViewById<TextView>(R.id.day_0).maxLines==7)
WidgetStyle.save(app,null,WidgetStyle())
check(!prefs.contains("style_99001")&&!prefs.contains("style_99002"))
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)
} catch(error:Throwable){failure=error}
}
failure?.let{throw it}
success=true
message="위젯별 설정 분리와 전체 적용 및 투명도 100%·40% 확인. 실제 RemoteViews의 색상과 간단·자세한 배치 및 크기 자동 전환 확인."
} catch(error:Throwable) {message=error.stackTraceToString()}
finally {
val editor=prefs.edit().clear()
original.forEach{(key,value)->editor.putString(key,value as String)}
check(editor.commit());DutyWidget.updateAll(app)
}
checker.finish(if(success)Activity.RESULT_OK else Activity.RESULT_CANCELED,Bundle().apply{putString("stream",message)})
}
}