위젯 꾸미기 중복 실행 수정과 달력 처리 및 배포 보안 보완
위젯과 알림에서 기존 MainActivity를 재사용하고 전달한 날짜와 꾸미기 요청을 한 번만 처리한다. 꾸미기 창은 중복 생성하지 않으며 화면 종료 때 닫는다. 첫 실행의 화면 중복 그리기도 제거했다. CalendarSnapshot으로 화면별 원본과 전송 대기를 한 번 읽고 반복 규칙을 재사용한다. 개별 위젯 저장과 날짜 변경 수신자의 갱신 범위를 줄였다. 기본 달력 권한 승인 후 설정을 이어서 열고 기존 하루 예약을 유지한다. 다른 기기에서 복원한 달력 번호로 자동 쓰기가 시작되지 않도록 기기 표식을 검사한다. 기기 종속 설정은 백업과 기기 이전에서 제외한다. 개인 근무와 일정은 보존한다. 배포 APK는 기존 인증서를 사용하는 release 빌드로 바꾸고 디버깅을 껐다. 평문 통신 금지를 명시했다. 주요 파일: AppNavigation과 MainActivity 및 WidgetStyle. CalendarSnapshot과 PlannerStore 및 People와 위젯 렌더러. CalendarMirror와 백업 규칙 및 Manifest와 Gradle 설정. 관련 검사와 사용법 및 Android 제작 매뉴얼과 배포 절차. 앱 단위 42개와 서버 74개 및 배포 빌드와 정적 검사 통과. 오류 0개와 경고 86개. 실제 release APK에서 화면 재사용과 편집 창 단일 유지 및 날짜 이동과 잘못된 입력 거부를 확인했다. 네 위젯 크기와 주 시작 및 글자 배율과 기본 달력의 등록·수정·중복 방지·삭제 및 복원 보호 검사를 통과했다. 200개 일정의 42일 조회 결과가 같았으며 같은 가상 기기의 자료 처리 경로는 113ms에서 6ms로 측정됐다. 전체 앱 성능을 뜻하는 수치는 아니다. 공개 소스 ZIP의 release 빌드도 별도 폴더에서 통과했다. 0.13.2 설치 번호 19 운영 반영. DB 구조 변경과 자료 이전 없음. 기존 회원과 일정 및 소속과 월요일 시작 설정 및 다른 서비스와 원격 세션 보존. 변경 전 소스와 DB는 비공개 20261121-widget-fix 백업에 보관했다. APK와 전체 소스 및 변경 안내는 당직근무 포럼에 게시한다. 실물 휴대폰과 제조사별 홈 화면 및 장시간 절전은 미확인이다. 기존 인증서를 유지하며 스토어용 서명 관리 체계는 후속 범위다.
This commit is contained in:
1 parent
1fc9243c63
commit
2b67afd751
27 files changed
+413
-73
No files matched your search
@@ -1,3 +1,10 @@
|
|||||||
|
# 0.13.2 · 2026년 11월 21일
|
||||||
|
|
||||||
|
- 위젯 꾸미기와 날짜를 누를 때 중복 화면이 쌓이는 문제를 수정했습니다.
|
||||||
|
- 달력과 위젯의 자료 읽기를 줄이고 개별 위젯 갱신을 분리했습니다.
|
||||||
|
- 달력 권한 허용 후 설정 이동과 자동 반영 예약 주기를 바로잡았습니다.
|
||||||
|
- 기기 복원 시 달력 번호 재사용을 막고 배포 APK의 디버깅을 껐습니다.
|
||||||
|
|
||||||
# 0.13.1 · 2026년 11월 21일
|
# 0.13.1 · 2026년 11월 21일
|
||||||
|
|
||||||
- 모든 위젯 크기에서 한 달 전체를 축소하는 선택을 추가했습니다.
|
- 모든 위젯 크기에서 한 달 전체를 축소하는 선택을 추가했습니다.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 당직근무
|
# 당직근무
|
||||||
|
|
||||||
제작자 블리어 (이창현) · 미리보기 0.13.1 · Android 8.0 이상
|
제작자 블리어 (이창현) · 미리보기 0.13.2 · Android 8.0 이상
|
||||||
|
|
||||||
당직과 교대근무를 달력으로 확인하고 홈 화면에 계속 놓아두는 앱입니다. 본인의 근무표는 로그인 없이 사용할 수 있습니다. 서버가 잠시 멈춰도 기기에 저장한 근무와 일정 및 기념일은 그대로 사용합니다.
|
당직과 교대근무를 달력으로 확인하고 홈 화면에 계속 놓아두는 앱입니다. 본인의 근무표는 로그인 없이 사용할 수 있습니다. 서버가 잠시 멈춰도 기기에 저장한 근무와 일정 및 기념일은 그대로 사용합니다.
|
||||||
|
|
||||||
@@ -66,3 +66,13 @@ JDK 21과 Android SDK 36을 설치한 뒤 프로젝트를 Android Studio에서
|
|||||||
이전·다음은 한 달씩 이동합니다. 오늘은 현재 달로 돌아옵니다. 월요일·일요일 주 시작과 날짜 색상 및 배경 투명도는 기존 선택을 따릅니다. 글자 확대를 선택해도 날짜가 잘리지 않도록 작은 크기에서는 배율의 상한을 적용합니다. 실제 크기는 홈 화면 앱의 격자와 여백에 따라 달라집니다.
|
이전·다음은 한 달씩 이동합니다. 오늘은 현재 달로 돌아옵니다. 월요일·일요일 주 시작과 날짜 색상 및 배경 투명도는 기존 선택을 따릅니다. 글자 확대를 선택해도 날짜가 잘리지 않도록 작은 크기에서는 배율의 상한을 적용합니다. 실제 크기는 홈 화면 앱의 격자와 여백에 따라 달라집니다.
|
||||||
|
|
||||||
**종류 기본 표시**로 바꾸면 기존 월간·두 주·근무 목록·오늘 배치로 돌아갑니다. 업데이트만으로 기존 배치를 바꾸지 않습니다. 위젯 모양은 기기별 설정이며 서버의 개인 근무표와 다른 기기는 변경하지 않습니다.
|
**종류 기본 표시**로 바꾸면 기존 월간·두 주·근무 목록·오늘 배치로 돌아갑니다. 업데이트만으로 기존 배치를 바꾸지 않습니다. 위젯 모양은 기기별 설정이며 서버의 개인 근무표와 다른 기기는 변경하지 않습니다.
|
||||||
|
|
||||||
|
## 0.13.2 위젯 실행과 달력 연동 보완
|
||||||
|
|
||||||
|
위젯의 꾸미기와 날짜를 반복해서 눌러도 기존 앱 화면을 재사용합니다. 꾸미기 편집 창은 하나만 열리며 한 번 닫으면 끝납니다. 앱이 열린 상태에서도 위젯에서 고른 날짜로 이동합니다. 위젯 하나를 꾸미면 해당 위젯만 갱신하고 전체 적용을 선택했을 때만 모든 위젯을 갱신합니다.
|
||||||
|
|
||||||
|
달력과 위젯을 그릴 때 일정과 로그인 상태를 날짜마다 반복해서 읽지 않도록 바꿨습니다. 근무와 일정 및 이름·기념일의 결과는 유지합니다. 회원 연결을 끄면 회원 전용 자료도 다음 표시에서 숨깁니다.
|
||||||
|
|
||||||
|
처음 기본 달력 권한을 허용하면 대상 달력 선택으로 이어집니다. 자동 반영의 하루 예약은 같은 설정을 저장해도 다음 실행 시점이 계속 밀리지 않습니다. 휴대폰을 새로 설정하거나 기기 백업에서 복원한 경우에는 대상 달력을 다시 선택합니다. 이전 휴대폰의 달력 번호와 위젯 번호 및 설치 세션은 옮기지 않습니다. 개인 근무와 일정의 기존 백업은 유지합니다.
|
||||||
|
|
||||||
|
배포 APK는 디버깅을 끈 release 빌드입니다. 이전과 같은 인증서로 서명해 앱을 삭제하지 않고 업데이트할 수 있습니다. 기존 회원과 근무 및 일정 자료는 변경하지 않습니다.
|
||||||
+13
-2
@@ -6,14 +6,25 @@ android {
|
|||||||
namespace = "kr.co.itosm.dutycalendar"
|
namespace = "kr.co.itosm.dutycalendar"
|
||||||
compileSdk = 36
|
compileSdk = 36
|
||||||
buildToolsVersion = "36.0.0"
|
buildToolsVersion = "36.0.0"
|
||||||
|
// 배포본 자체의 동작도 검사할 수 있도록 검사 대상 종류를 명시적으로 고른다.
|
||||||
|
testBuildType = providers.gradleProperty("testBuildType").getOrElse("debug")
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "kr.co.itosm.dutycalendar"
|
applicationId = "kr.co.itosm.dutycalendar"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 18
|
versionCode = 19
|
||||||
versionName = "0.13.1"
|
versionName = "0.13.2"
|
||||||
testInstrumentationRunner = "kr.co.itosm.dutycalendar.StorageSyncCheck"
|
testInstrumentationRunner = "kr.co.itosm.dutycalendar.StorageSyncCheck"
|
||||||
}
|
}
|
||||||
|
buildTypes {
|
||||||
|
getByName("release") {
|
||||||
|
// 기존 설치본 위에 업데이트할 수 있도록 같은 인증서를 사용한다. 빌드 종류와
|
||||||
|
// 서명 인증서는 별개다. 배포본은 디버깅을 끄며 서명 키 파일은 소스에 포함하지 않는다.
|
||||||
|
signingConfig = signingConfigs.getByName("debug")
|
||||||
|
isDebuggable = false
|
||||||
|
isMinifyEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
// 빌드 도구는 JDK 21로 실행하지만 앱의 Java와 Kotlin 바이트코드 대상은 17로 통일한다.
|
// 빌드 도구는 JDK 21로 실행하지만 앱의 Java와 Kotlin 바이트코드 대상은 17로 통일한다.
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
|||||||
@@ -22,6 +22,21 @@ object CalendarBridgeCheck {
|
|||||||
var calendar:Long?=null;var passed=false;var stage="달력 만들기"
|
var calendar:Long?=null;var passed=false;var stage="달력 만들기"
|
||||||
try{
|
try{
|
||||||
check(CalendarMirror.allowed(app))
|
check(CalendarMirror.allowed(app))
|
||||||
|
stage="기기 복원과 표식 검사"
|
||||||
|
val mirror=CalendarMirror.prefs(app)
|
||||||
|
mirror.edit().putBoolean("enabled",true).putString("owner",UUID.randomUUID().toString()).commit()
|
||||||
|
check(!CalendarMirror.enabled(app)){"다른 기기의 자동 반영 선택을 허용했습니다."}
|
||||||
|
val restored=object:android.content.ContextWrapper(app){override fun getNoBackupFilesDir()=java.io.File(app.cacheDir,"restore-check-"+UUID.randomUUID())}
|
||||||
|
check(!CalendarMirror.enabled(restored)){"기기 표식 없이 자동 반영을 허용했습니다."}
|
||||||
|
mirror.edit().putBoolean("enabled",false).commit()
|
||||||
|
check(!android.security.NetworkSecurityPolicy.getInstance().isCleartextTrafficPermitted)
|
||||||
|
val expected=setOf("calendar_mirror.xml","widget.xml","widget_style.xml","web_sync.xml","app_update.xml")
|
||||||
|
for(resource in listOf(R.xml.backup_rules,R.xml.data_extraction_rules)) {
|
||||||
|
val seen=mutableListOf<String>();val parser=app.resources.getXml(resource)
|
||||||
|
parser.use { while(it.eventType!=org.xmlpull.v1.XmlPullParser.END_DOCUMENT){if(it.eventType==org.xmlpull.v1.XmlPullParser.START_TAG&&it.name=="exclude")seen.add(it.getAttributeValue(null,"path"));it.next()} }
|
||||||
|
check(seen.toSet()==expected)
|
||||||
|
if(resource==R.xml.data_extraction_rules)check(seen.size==expected.size*2)
|
||||||
|
}
|
||||||
val account="duty-qa-"+UUID.randomUUID();val uri=CalendarContract.Calendars.CONTENT_URI.buildUpon().appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER,"true").appendQueryParameter("account_name",account).appendQueryParameter("account_type",CalendarContract.ACCOUNT_TYPE_LOCAL).build()
|
val account="duty-qa-"+UUID.randomUUID();val uri=CalendarContract.Calendars.CONTENT_URI.buildUpon().appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER,"true").appendQueryParameter("account_name",account).appendQueryParameter("account_type",CalendarContract.ACCOUNT_TYPE_LOCAL).build()
|
||||||
calendar=ContentUris.parseId(checkNotNull(app.contentResolver.insert(uri,ContentValues().apply{put("account_name",account);put("account_type",CalendarContract.ACCOUNT_TYPE_LOCAL);put("name",account);put("calendar_displayName","달력 연동 검증");put("calendar_color",0xFF365FAD.toInt());put("calendar_access_level",700);put("ownerAccount",account);put("visible",1);put("sync_events",1)})))
|
calendar=ContentUris.parseId(checkNotNull(app.contentResolver.insert(uri,ContentValues().apply{put("account_name",account);put("account_type",CalendarContract.ACCOUNT_TYPE_LOCAL);put("name",account);put("calendar_displayName","달력 연동 검증");put("calendar_color",0xFF365FAD.toInt());put("calendar_access_level",700);put("ownerAccount",account);put("visible",1);put("sync_events",1)})))
|
||||||
val calendarId=calendar
|
val calendarId=calendar
|
||||||
@@ -45,6 +60,6 @@ object CalendarBridgeCheck {
|
|||||||
original.forEach{(name,values)->val editor=app.getSharedPreferences(name,0).edit().clear();values.forEach{(key,value)->when(value){is String->editor.putString(key,value);is Boolean->editor.putBoolean(key,value);is Int->editor.putInt(key,value);is Long->editor.putLong(key,value);is Float->editor.putFloat(key,value)}};editor.commit()}
|
original.forEach{(name,values)->val editor=app.getSharedPreferences(name,0).edit().clear();values.forEach{(key,value)->when(value){is String->editor.putString(key,value);is Boolean->editor.putBoolean(key,value);is Int->editor.putInt(key,value);is Long->editor.putLong(key,value);is Float->editor.putFloat(key,value)}};editor.commit()}
|
||||||
DutyWidget.updateAll(app)
|
DutyWidget.updateAll(app)
|
||||||
}
|
}
|
||||||
test.finish(if(passed)Activity.RESULT_OK else Activity.RESULT_CANCELED,Bundle().apply{putString("stream",if(passed)"기본 달력 등록·변경·중복 방지·삭제 범위 검사 통과. 검증 달력 정리 완료." else "달력 검사 실패: $stage")})
|
test.finish(if(passed)Activity.RESULT_OK else Activity.RESULT_CANCELED,Bundle().apply{putString("stream",if(passed)"기기 표식 불일치·복원 시 자동 쓰기 차단과 백업 제외 및 평문 통신 차단 확인. 기본 달력 등록·변경·중복 방지·삭제 범위 검사 통과. 검증 달력 정리 완료." else "달력 검사 실패: $stage")})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package kr.co.itosm.dutycalendar
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import org.json.JSONArray
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
/** 표시용 자료 묶음의 결과와 회원 자료 숨김을 검사한다. 시간 측정은 같은 기기의 참고값이며 절대 성능 기준으로 쓰지 않는다. */
|
||||||
|
object SnapshotCheck {
|
||||||
|
fun run(context:Context):String {
|
||||||
|
check(!SyncClient.connected(context)&&!CalendarMirror.enabled(context))
|
||||||
|
val prefs=context.getSharedPreferences("planner",0);val original=prefs.getString("document",null)
|
||||||
|
val first=LocalDate.of(2026,11,1)
|
||||||
|
fun item(kind:String,data:JSONObject)=JSONObject().put("id",UUID.randomUUID().toString()).put("kind",kind).put("deleted",false).put("data",data)
|
||||||
|
val events=(0 until 200).map{index->item("event",JSONObject().put("title","검증 $index").put("date",first.plusDays((index%7).toLong()).toString()).put("endDate",first.plusDays((index%7).toLong()).toString()).put("allDay",false).put("startTime","09:00").put("endTime","10:00").put("repeat","WEEKLY").put("repeatUntil","").put("notes","").put("category","WORK"))}
|
||||||
|
val name=item("name_rule",JSONObject().put("name","평일 이름").put("mode","WEEKLY").put("anchor","2026-01-01").put("interval",1).put("weekdays",JSONArray(listOf(1,2,3,4,5))).put("enabled",true).put("personId","").put("color","BLUE"))
|
||||||
|
val annual=item("anniversary",JSONObject().put("title","개인 기념일").put("calendar","SOLAR").put("month",11).put("day",23).put("leapMonth",false))
|
||||||
|
val items=events+name+annual
|
||||||
|
try {
|
||||||
|
val document=JSONObject().put("state",JSONObject().put("items",JSONArray(items))).put("pending",JSONArray()).put("conflicts",JSONArray())
|
||||||
|
check(prefs.edit().putString("document",document.toString()).commit())
|
||||||
|
val started=System.nanoTime()
|
||||||
|
val legacy=(0L..41L).map{date->PlannerStore.eventsOn(context,first.plusDays(date)).map{it.getString("id")}}
|
||||||
|
val legacyMs=(System.nanoTime()-started)/1_000_000
|
||||||
|
val snapshotStart=System.nanoTime();val snapshot=CalendarSnapshot.load(context)
|
||||||
|
val actual=(0L..41L).map{date->snapshot.eventsOn(first.plusDays(date)).map{it.getString("id")}}
|
||||||
|
val snapshotMs=(System.nanoTime()-snapshotStart)/1_000_000
|
||||||
|
check(legacy==actual){"최적화 전후 일정 결과 불일치"}
|
||||||
|
val day=LocalDate.of(2026,11,23);val schedule=Schedule(first,listOf(Shift.REGULAR))
|
||||||
|
check(snapshot.anniversariesOn(day).isEmpty()&&snapshot.workNames(day,schedule).isEmpty())
|
||||||
|
val member=CalendarSnapshot(context,items,null,true)
|
||||||
|
check(member.anniversariesOn(day).single().getString("id")==annual.getString("id"))
|
||||||
|
check(member.workNames(day,schedule).single().name=="평일 이름")
|
||||||
|
return "일정 200개·42일 결과 일치와 회원 전용 자료 숨김 확인. 같은 기기 측정: 반복 읽기 ${legacyMs}ms / 한 번 읽기 ${snapshotMs}ms."
|
||||||
|
} finally {
|
||||||
|
val editor=prefs.edit();if(original==null)editor.remove("document") else editor.putString("document",original);check(editor.commit())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,12 +17,13 @@ import java.util.concurrent.TimeUnit
|
|||||||
* 계정 정보와 인증값은 결과에 출력하지 않는다. 배포 APK에는 이 검사 코드가 들어가지 않는다.
|
* 계정 정보와 인증값은 결과에 출력하지 않는다. 배포 APK에는 이 검사 코드가 들어가지 않는다.
|
||||||
*/
|
*/
|
||||||
class StorageSyncCheck : Instrumentation() {
|
class StorageSyncCheck : Instrumentation() {
|
||||||
|
private var widgetEntryCheck = false
|
||||||
private var calendarBridgeCheck = false
|
private var calendarBridgeCheck = false
|
||||||
private var updateCheck = false
|
private var updateCheck = false
|
||||||
private var personalCheck = false
|
private var personalCheck = false
|
||||||
private var outageCheck = false
|
private var outageCheck = false
|
||||||
private var widgetCheck = false
|
private var widgetCheck = false
|
||||||
override fun onCreate(arguments: Bundle?) { super.onCreate(arguments); calendarBridgeCheck = arguments?.getString("calendarBridgeCheck") == "true"; widgetCheck = arguments?.getString("widgetCheck") == "true"; outageCheck = arguments?.getString("outageCheck") == "true"; personalCheck = arguments?.getString("personalCheck") == "true"; updateCheck = arguments?.getString("updateCheck") == "true"; start() }
|
override fun onCreate(arguments: Bundle?) { super.onCreate(arguments); widgetEntryCheck=arguments?.getString("widgetEntryCheck")=="true"; calendarBridgeCheck = arguments?.getString("calendarBridgeCheck") == "true"; 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) {
|
private fun done(action: ((Boolean) -> Unit) -> Unit) {
|
||||||
val latch = CountDownLatch(1)
|
val latch = CountDownLatch(1)
|
||||||
var success = false
|
var success = false
|
||||||
@@ -30,6 +31,7 @@ class StorageSyncCheck : Instrumentation() {
|
|||||||
check(latch.await(45, TimeUnit.SECONDS) && success) { "자료 처리 검증 실패" }
|
check(latch.await(45, TimeUnit.SECONDS) && success) { "자료 처리 검증 실패" }
|
||||||
}
|
}
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
if(widgetEntryCheck){WidgetEntryCheck.run(this);return}
|
||||||
if (calendarBridgeCheck) { CalendarBridgeCheck.run(this); return }
|
if (calendarBridgeCheck) { CalendarBridgeCheck.run(this); return }
|
||||||
if (widgetCheck) { WidgetAppearanceCheck.run(this); return }
|
if (widgetCheck) { WidgetAppearanceCheck.run(this); return }
|
||||||
if (personalCheck) { PersonalFeatureCheck.run(this, outageCheck); return }
|
if (personalCheck) { PersonalFeatureCheck.run(this, outageCheck); return }
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package kr.co.itosm.dutycalendar
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.app.Application
|
||||||
|
import android.app.Instrumentation
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import java.time.LocalDate
|
||||||
|
|
||||||
|
/** 실제 Activity 수명과 위젯 진입 경로를 함께 검사한다. 화면은 종료하고 기존 위젯 설정은 바꾸지 않는다. */
|
||||||
|
object WidgetEntryCheck {
|
||||||
|
fun run(test:Instrumentation) {
|
||||||
|
val app=test.targetContext.applicationContext as Application
|
||||||
|
val alive=mutableSetOf<Activity>()
|
||||||
|
fun main(action:()->Unit) { var failure:Throwable?=null;test.runOnMainSync{try{action()}catch(error:Throwable){failure=error}};failure?.let{throw it} }
|
||||||
|
fun awaitUi(condition:()->Boolean) { val end=android.os.SystemClock.uptimeMillis()+5000;while(true){var ready=false;main{ready=condition()};if(ready)return;check(android.os.SystemClock.uptimeMillis()<end){"화면 응답 시간 초과"};android.os.SystemClock.sleep(50)} }
|
||||||
|
val callbacks=object:Application.ActivityLifecycleCallbacks {
|
||||||
|
override fun onActivityCreated(a:Activity,s:Bundle?){if(a is MainActivity)alive.add(a)}
|
||||||
|
override fun onActivityDestroyed(a:Activity){alive.remove(a)}
|
||||||
|
override fun onActivityStarted(a:Activity){}
|
||||||
|
override fun onActivityResumed(a:Activity){}
|
||||||
|
override fun onActivityPaused(a:Activity){}
|
||||||
|
override fun onActivityStopped(a:Activity){}
|
||||||
|
override fun onActivitySaveInstanceState(a:Activity,s:Bundle){}
|
||||||
|
}
|
||||||
|
app.registerActivityLifecycleCallbacks(callbacks)
|
||||||
|
var ok=false;var message=""
|
||||||
|
try {
|
||||||
|
val snapshotResult=SnapshotCheck.run(app)
|
||||||
|
val initial=test.startActivitySync(AppNavigation.main(app).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) as MainActivity
|
||||||
|
test.waitForIdleSync()
|
||||||
|
val id=WidgetKind.ids(app).firstOrNull()?:error("홈 화면에 검증용 위젯을 먼저 배치해 주세요.")
|
||||||
|
repeat(3) {
|
||||||
|
main { app.startActivity(AppNavigation.widgetStyle(app,id).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) }
|
||||||
|
test.waitForIdleSync()
|
||||||
|
awaitUi { WidgetStyleDialog.current(initial)!=null }
|
||||||
|
main {
|
||||||
|
check(alive.size==1&&alive.single()===initial){"위젯을 눌렀을 때 화면이 ${alive.size}개 생성됐습니다."}
|
||||||
|
check(!initial.intent.hasExtra("widgetStyleId"))
|
||||||
|
val dialog=checkNotNull(WidgetStyleDialog.current(initial))
|
||||||
|
WidgetStyleDialog.show(initial,id);WidgetStyleDialog.show(initial,id)
|
||||||
|
check(WidgetStyleDialog.current(initial)===dialog){"꾸미기 창 중복 생성"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
main { WidgetStyleDialog.dismiss(initial);check(WidgetStyleDialog.current(initial)==null) }
|
||||||
|
val date=LocalDate.of(2027,12,15)
|
||||||
|
main { app.startActivity(AppNavigation.date(app,date).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) }
|
||||||
|
test.waitForIdleSync()
|
||||||
|
fun labels(view:View):List<String> = (if(view is TextView)listOf(view.text.toString()) else emptyList())+
|
||||||
|
(if(view is ViewGroup)(0 until view.childCount).flatMap{labels(view.getChildAt(it))} else emptyList())
|
||||||
|
awaitUi { labels(initial.window.decorView).contains("2027. 12") }
|
||||||
|
main {
|
||||||
|
check(alive.size==1&&alive.single()===initial)
|
||||||
|
check(labels(initial.window.decorView).contains("2027. 12")){"재사용한 화면에 날짜 이동이 반영되지 않았습니다."}
|
||||||
|
check(!initial.intent.hasExtra("selectedDate"))
|
||||||
|
app.startActivity(AppNavigation.main(app).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtra("selectedDate","+999999999-12-31").putExtra("widgetStyleId",-100))
|
||||||
|
}
|
||||||
|
test.waitForIdleSync()
|
||||||
|
main { check(alive.size==1);check(WidgetStyleDialog.current(initial)==null);check(labels(initial.window.decorView).contains("2027. 12")) }
|
||||||
|
ok=true;message="위젯 연속 진입 3회에도 Activity와 꾸미기 창 각각 1개. 한 번 닫기와 기존 화면 날짜 이동 및 잘못된 입력 무시 확인. $snapshotResult"
|
||||||
|
}catch(error:Throwable){message=error.stackTraceToString()}
|
||||||
|
finally {main { alive.toList().forEach{it.finish()} };app.unregisterActivityLifecycleCallbacks(callbacks)}
|
||||||
|
test.finish(if(ok)Activity.RESULT_OK else Activity.RESULT_CANCELED,Bundle().apply{putString("stream",message)})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,8 +12,8 @@
|
|||||||
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
||||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<application android:label="당직근무" android:icon="@drawable/ic_calendar" android:theme="@style/AppTheme" android:allowBackup="true" android:supportsRtl="true">
|
<application android:label="당직근무" android:icon="@drawable/ic_calendar" android:theme="@style/AppTheme" android:allowBackup="true" android:fullBackupContent="@xml/backup_rules" android:dataExtractionRules="@xml/data_extraction_rules" android:usesCleartextTraffic="false" android:supportsRtl="true">
|
||||||
<activity android:name=".MainActivity" android:exported="true">
|
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package kr.co.itosm.dutycalendar
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import java.time.LocalDate
|
||||||
|
|
||||||
|
/** 위젯에서 반복해서 열어도 기존 달력 화면으로 돌아간다.
|
||||||
|
* URI는 날짜와 위젯별 PendingIntent를 구분하는 용도다. 실제 입력은 MainActivity에서
|
||||||
|
* 다시 검사하며 이미 처리한 값은 Intent에서 지워 화면 복원 때 재실행하지 않는다.
|
||||||
|
*/
|
||||||
|
object AppNavigation {
|
||||||
|
fun main(context:Context)=Intent(context,MainActivity::class.java)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||||
|
fun date(context:Context,date:LocalDate)=main(context)
|
||||||
|
.setData(Uri.parse("dutycalendar://date/$date")).putExtra("selectedDate",date.toString())
|
||||||
|
fun widgetStyle(context:Context,id:Int)=main(context)
|
||||||
|
.setData(Uri.parse("dutycalendar://widget/$id/style")).putExtra("widgetStyleId",id)
|
||||||
|
fun takeDate(intent:Intent):LocalDate? {
|
||||||
|
val date=runCatching{intent.getStringExtra("selectedDate")?.takeIf{it.length==10}?.let(LocalDate::parse)?.takeIf{it.year in 1900..2199}}.getOrNull()
|
||||||
|
intent.removeExtra("selectedDate")
|
||||||
|
return date
|
||||||
|
}
|
||||||
|
fun takeWidget(intent:Intent):Int? {
|
||||||
|
val id=runCatching{if(intent.hasExtra("widgetStyleId"))intent.getIntExtra("widgetStyleId",-1).takeIf{it>0} else null}.getOrNull()
|
||||||
|
intent.removeExtra("widgetStyleId")
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,7 +34,17 @@ object CalendarMirror {
|
|||||||
private var waiting:ScheduledFuture<*>?=null
|
private var waiting:ScheduledFuture<*>?=null
|
||||||
fun prefs(context:Context)=context.getSharedPreferences("calendar_mirror",0)
|
fun prefs(context:Context)=context.getSharedPreferences("calendar_mirror",0)
|
||||||
fun allowed(context:Context)=listOf(Manifest.permission.READ_CALENDAR,Manifest.permission.WRITE_CALENDAR).all{context.checkSelfPermission(it)==PackageManager.PERMISSION_GRANTED}
|
fun allowed(context:Context)=listOf(Manifest.permission.READ_CALENDAR,Manifest.permission.WRITE_CALENDAR).all{context.checkSelfPermission(it)==PackageManager.PERMISSION_GRANTED}
|
||||||
fun enabled(context:Context)=prefs(context).getBoolean("enabled",false)
|
fun enabled(context:Context):Boolean {
|
||||||
|
val settings=prefs(context)
|
||||||
|
if(!settings.getBoolean("enabled",false))return false
|
||||||
|
// 예전 백업에는 다른 휴대폰의 달력 번호가 들어 있을 수 있다. 백업되지 않는
|
||||||
|
// 기기 표식이 없거나 일치하지 않으면 자동 쓰기를 시작하지 않고 다시 선택하게 한다.
|
||||||
|
val identity=File(context.noBackupFilesDir,"calendar-mirror-owner")
|
||||||
|
val value=runCatching{identity.readText().trim().also{UUID.fromString(it)}}.getOrNull()?:return false
|
||||||
|
val bound=settings.getString("owner",null)
|
||||||
|
if(bound==null)return settings.edit().putString("owner",value).commit()
|
||||||
|
return bound==value
|
||||||
|
}
|
||||||
private fun owner(context:Context):String {
|
private fun owner(context:Context):String {
|
||||||
val file=File(context.noBackupFilesDir,"calendar-mirror-owner")
|
val file=File(context.noBackupFilesDir,"calendar-mirror-owner")
|
||||||
if(!file.exists())file.writeText(UUID.randomUUID().toString())
|
if(!file.exists())file.writeText(UUID.randomUUID().toString())
|
||||||
@@ -47,13 +57,17 @@ object CalendarMirror {
|
|||||||
waiting=executor.schedule({refresh(app)},800,TimeUnit.MILLISECONDS)
|
waiting=executor.schedule({refresh(app)},800,TimeUnit.MILLISECONDS)
|
||||||
}
|
}
|
||||||
fun schedule(context:Context) {
|
fun schedule(context:Context) {
|
||||||
if(enabled(context))context.getSystemService(JobScheduler::class.java).schedule(JobInfo.Builder(JOB,ComponentName(context,CalendarMirrorService::class.java)).setPersisted(true).setPeriodic(24*60*60*1000L).build())
|
val scheduler=context.getSystemService(JobScheduler::class.java)
|
||||||
|
if(!enabled(context)){scheduler.cancel(JOB);return}
|
||||||
|
val period=24*60*60*1000L
|
||||||
|
// 저장할 때마다 예약을 교체하면 다음 실행 시점이 계속 밀린다. 같은 주기의 기존 작업은 유지한다.
|
||||||
|
if(scheduler.getPendingJob(JOB)?.intervalMillis!=period)scheduler.schedule(JobInfo.Builder(JOB,ComponentName(context,CalendarMirrorService::class.java)).setPersisted(true).setPeriodic(period).build())
|
||||||
}
|
}
|
||||||
fun run(context:Context,finished:(Boolean)->Unit) { executor.execute{finished(refresh(context.applicationContext))} }
|
fun run(context:Context,finished:(Boolean)->Unit) { executor.execute{finished(refresh(context.applicationContext))} }
|
||||||
@Synchronized fun configure(context:Context,calendar:Long,title:String,rotation:Boolean,events:Boolean,anniversaries:Boolean) {
|
@Synchronized fun configure(context:Context,calendar:Long,title:String,rotation:Boolean,events:Boolean,anniversaries:Boolean) {
|
||||||
require(!enabled(context)||prefs(context).getLong("calendar",-1)==calendar){"대상 달력을 바꾸려면 기존 자동 반영을 먼저 해제해 주세요."}
|
require(!enabled(context)||prefs(context).getLong("calendar",-1)==calendar){"대상 달력을 바꾸려면 기존 자동 반영을 먼저 해제해 주세요."}
|
||||||
require(rotation||events||anniversaries){"반영할 항목을 하나 이상 선택해 주세요."}
|
require(rotation||events||anniversaries){"반영할 항목을 하나 이상 선택해 주세요."}
|
||||||
check(prefs(context).edit().putLong("calendar",calendar).putString("title",title).putBoolean("rotation",rotation).putBoolean("events",events).putBoolean("anniversaries",anniversaries).putBoolean("enabled",true).commit())
|
check(prefs(context).edit().putLong("calendar",calendar).putString("owner",owner(context)).putString("title",title).putBoolean("rotation",rotation).putBoolean("events",events).putBoolean("anniversaries",anniversaries).putBoolean("enabled",true).commit())
|
||||||
request(context)
|
request(context)
|
||||||
}
|
}
|
||||||
fun stop(context:Context,remove:Boolean,done:(Boolean)->Unit) {
|
fun stop(context:Context,remove:Boolean,done:(Boolean)->Unit) {
|
||||||
@@ -108,14 +122,15 @@ object CalendarMirror {
|
|||||||
internal fun projection(context:Context,today:LocalDate,rotation:Boolean,events:Boolean,anniversaries:Boolean):List<MirroredEvent> {
|
internal fun projection(context:Context,today:LocalDate,rotation:Boolean,events:Boolean,anniversaries:Boolean):List<MirroredEvent> {
|
||||||
val first=today.minusDays(30);val last=today.plusDays(366);val schedule=ScheduleStore.load(context)
|
val first=today.minusDays(30);val last=today.plusDays(366);val schedule=ScheduleStore.load(context)
|
||||||
val output=linkedMapOf<String,MirroredEvent>();val items=PlannerStore.items(context).filter{it.getString("kind")=="event"}
|
val output=linkedMapOf<String,MirroredEvent>();val items=PlannerStore.items(context).filter{it.getString("kind")=="event"}
|
||||||
|
val snapshot=CalendarSnapshot.load(context);val configured=ScheduleStore.isConfigured(context)
|
||||||
fun add(event:MirroredEvent){output[event.key]=event;require(output.size<=10000){"일정이 10,000개를 넘습니다. 반영할 항목을 줄여 주세요."}}
|
fun add(event:MirroredEvent){output[event.key]=event;require(output.size<=10000){"일정이 10,000개를 넘습니다. 반영할 항목을 줄여 주세요."}}
|
||||||
for(offset in 0L..ChronoUnit.DAYS.between(first,last)){
|
for(offset in 0L..ChronoUnit.DAYS.between(first,last)){
|
||||||
val day=first.plusDays(offset)
|
val day=first.plusDays(offset)
|
||||||
if(rotation&&ScheduleStore.isConfigured(context)){
|
if(rotation&&configured){
|
||||||
val names=WorkNames.on(context,day,schedule).joinToString(" · "){it.name}
|
val names=snapshot.workNames(day,schedule).joinToString(" · "){it.name}
|
||||||
add(allDay("rotation:$day",schedule.shiftOn(day).title+(if(names.isNotBlank())" · $names" else ""),"당직근무에서 수정하면 자동으로 반영됩니다.",day))
|
add(allDay("rotation:$day",schedule.shiftOn(day).title+(if(names.isNotBlank())" · $names" else ""),"당직근무에서 수정하면 자동으로 반영됩니다.",day))
|
||||||
}
|
}
|
||||||
if(anniversaries)for(item in Anniversaries.on(context,day)){val d=item.getJSONObject("data");add(allDay("anniversary:${item.getString("id")}:$day",d.getString("title"),d.getString("notes"),day))}
|
if(anniversaries)for(item in snapshot.anniversariesOn(day)){val d=item.getJSONObject("data");add(allDay("anniversary:${item.getString("id")}:$day",d.getString("title"),d.getString("notes"),day))}
|
||||||
}
|
}
|
||||||
if(events)for(item in items){
|
if(events)for(item in items){
|
||||||
val d=item.getJSONObject("data");val rule=PlannerStore.eventRule(d)
|
val d=item.getJSONObject("data");val rule=PlannerStore.eventRule(d)
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package kr.co.itosm.dutycalendar
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.time.LocalDate
|
||||||
|
|
||||||
|
/** 날짜마다 전체 JSON과 암호화된 로그인 정보를 다시 읽지 않도록 표시 시작 때 한 번 모은다.
|
||||||
|
* 화면 또는 위젯 한 번을 그리는 동안만 사용한다. 전역 캐시가 아니므로 다음 갱신에서는
|
||||||
|
* 최신 자료와 로그인 상태를 다시 확인하며 회원 전용 자료가 로그아웃 뒤 남지 않는다.
|
||||||
|
*/
|
||||||
|
class CalendarSnapshot internal constructor(context:Context,items:List<JSONObject>,company:JSONObject?,val connected:Boolean) {
|
||||||
|
private val app=context.applicationContext
|
||||||
|
val people=if(connected)People.from(items,company) else emptyList()
|
||||||
|
private val peopleById=people.associateBy{it.id}
|
||||||
|
private val events=items.filter{it.getString("kind")=="event"}.mapNotNull{item->
|
||||||
|
runCatching{item to PlannerStore.eventRule(item.getJSONObject("data"))}.getOrNull()
|
||||||
|
}.sortedWith(compareBy<Pair<JSONObject,EventRepeat>>{!it.first.getJSONObject("data").getBoolean("allDay")}
|
||||||
|
.thenBy{it.first.getJSONObject("data").getString("startTime")}.thenBy{it.first.getJSONObject("data").getString("title")})
|
||||||
|
private val anniversaries=if(connected)items.filter{it.getString("kind")=="anniversary"}.sortedBy{it.getJSONObject("data").getString("title")}
|
||||||
|
.mapNotNull{item->runCatching{item to Anniversaries.rule(item.getJSONObject("data"))}.getOrNull()} else emptyList()
|
||||||
|
private val names=if(connected)items.filter{it.getString("kind")=="name_rule"}.mapNotNull{item->
|
||||||
|
runCatching{val data=item.getJSONObject("data");if(data.optBoolean("enabled"))data to WorkNames.rule(data) else null}.getOrNull()
|
||||||
|
} else emptyList()
|
||||||
|
val hasNames get()=names.isNotEmpty()
|
||||||
|
fun eventsOn(date:LocalDate)=events.filter{it.second.occurrenceOn(date)!=null}.map{it.first}
|
||||||
|
fun anniversariesOn(date:LocalDate):List<JSONObject> {
|
||||||
|
val lunar by lazy{LunarDates.day(app,date)}
|
||||||
|
return anniversaries.filter{it.second.matches(date,if(it.second.calendar=="LUNAR")lunar else null)}.map{it.first}
|
||||||
|
}
|
||||||
|
fun workNames(date:LocalDate,schedule:Schedule):List<WorkName> = names.mapNotNull{(data,rule)->
|
||||||
|
val person=peopleById[data.optString("personId")]
|
||||||
|
if(!rule.matches(date,schedule.shiftOn(date),Holidays.name(app,date)!=null,person?.schedule?.shiftOn(date)))null
|
||||||
|
else WorkName(if(data.getString("mode")=="PERSON")person!!.name else data.getString("name"),People.colors.getValue(data.getString("color")).second)
|
||||||
|
}.distinctBy{it.name}
|
||||||
|
companion object {
|
||||||
|
fun load(context:Context):CalendarSnapshot {
|
||||||
|
val connected=SyncClient.connected(context)
|
||||||
|
val (items,company)=PlannerStore.displayData(context)
|
||||||
|
return CalendarSnapshot(context,items,company,connected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,12 +28,13 @@ object CompactWidgetViews {
|
|||||||
return base.plusDays(context.getSharedPreferences("widget",0).getInt("offset_$id",0).toLong())
|
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,
|
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()),
|
AppNavigation.date(context,date),
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||||
|
|
||||||
fun build(context:Context,id:Int,kind:WidgetKind,width:Int,height:Int):RemoteViews {
|
fun build(context:Context,id:Int,kind:WidgetKind,width:Int,height:Int):RemoteViews {
|
||||||
val style=WidgetStyle.load(context,id)
|
val style=WidgetStyle.load(context,id)
|
||||||
val schedule=ScheduleStore.load(context)
|
val schedule=ScheduleStore.load(context)
|
||||||
|
val snapshot=CalendarSnapshot.load(context)
|
||||||
val today=LocalDate.now()
|
val today=LocalDate.now()
|
||||||
val density=context.resources.displayMetrics.density
|
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 layout=when(kind){WidgetKind.WIDE->R.layout.duty_widget_wide;WidgetKind.TALL->R.layout.duty_widget_tall;else->R.layout.duty_widget_today}
|
||||||
@@ -44,7 +45,7 @@ object CompactWidgetViews {
|
|||||||
views.setTextColor(R.id.compact_title,style.ink)
|
views.setTextColor(R.id.compact_title,style.ink)
|
||||||
views.setTextColor(R.id.compact_customize,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)
|
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)
|
val customize=AppNavigation.widgetStyle(context,id)
|
||||||
views.setOnClickPendingIntent(R.id.compact_customize,PendingIntent.getActivity(context,id,customize,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
views.setOnClickPendingIntent(R.id.compact_customize,PendingIntent.getActivity(context,id,customize,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||||
|
|
||||||
if(kind==WidgetKind.TODAY) {
|
if(kind==WidgetKind.TODAY) {
|
||||||
@@ -59,7 +60,7 @@ object CompactWidgetViews {
|
|||||||
views.setTextColor(R.id.compact_tomorrow,style.ink)
|
views.setTextColor(R.id.compact_tomorrow,style.ink)
|
||||||
views.setTextViewTextSize(R.id.compact_tomorrow,TypedValue.COMPLEX_UNIT_SP,11f*scale)
|
views.setTextViewTextSize(R.id.compact_tomorrow,TypedValue.COMPLEX_UNIT_SP,11f*scale)
|
||||||
views.setOnClickPendingIntent(R.id.compact_tomorrow,dateIntent(context,id,today.plusDays(1)))
|
views.setOnClickPendingIntent(R.id.compact_tomorrow,dateIntent(context,id,today.plusDays(1)))
|
||||||
val details=detail(context,today,schedule,style)
|
val details=detail(context,today,schedule,style,snapshot)
|
||||||
views.setTextViewText(R.id.compact_detail,details.ifBlank{"당직근무"})
|
views.setTextViewText(R.id.compact_detail,details.ifBlank{"당직근무"})
|
||||||
views.setTextColor(R.id.compact_detail,style.muted)
|
views.setTextColor(R.id.compact_detail,style.muted)
|
||||||
views.setContentDescription(R.id.compact_shift,"${today} ${schedule.shiftOn(today).title}. $details")
|
views.setContentDescription(R.id.compact_shift,"${today} ${schedule.shiftOn(today).title}. $details")
|
||||||
@@ -79,12 +80,12 @@ object CompactWidgetViews {
|
|||||||
val date=first.plusDays(index.toLong())
|
val date=first.plusDays(index.toLong())
|
||||||
val shift=schedule.shiftOn(date)
|
val shift=schedule.shiftOn(date)
|
||||||
val holiday=Holidays.name(context,date)
|
val holiday=Holidays.name(context,date)
|
||||||
val events=PlannerStore.eventsOn(context,date)
|
val events=snapshot.eventsOn(date)
|
||||||
val anniversaries=Anniversaries.on(context,date)
|
val anniversaries=snapshot.anniversariesOn(date)
|
||||||
val plus=if(style.eventMark&&(events.isNotEmpty()||anniversaries.isNotEmpty()))"+" else ""
|
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 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 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 extra=if(kind==WidgetKind.TALL&&height>=380&&style.detail!="COMPACT")detail(context,date,schedule,style,snapshot) else ""
|
||||||
val separator=if(kind==WidgetKind.WIDE)"\n" else " "
|
val separator=if(kind==WidgetKind.WIDE)"\n" else " "
|
||||||
val text=dateLabel+separator+shiftLabel+(if(extra.isNotBlank())"\n$extra" else "")
|
val text=dateLabel+separator+shiftLabel+(if(extra.isNotBlank())"\n$extra" else "")
|
||||||
val styled=SpannableString(text)
|
val styled=SpannableString(text)
|
||||||
@@ -103,18 +104,18 @@ object CompactWidgetViews {
|
|||||||
views.setTextViewTextSize(cell,TypedValue.COMPLEX_UNIT_SP,minOf(font*style.scale/100,lineLimit.coerceAtLeast(8f)))
|
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.setInt(cell,"setBackgroundColor",if(date==today&&style.today)(if(style.dark)0x554A6D96 else 0x44A7B5CB) else 0)
|
||||||
views.setOnClickPendingIntent(cell,dateIntent(context,id,date))
|
views.setOnClickPendingIntent(cell,dateIntent(context,id,date))
|
||||||
views.setContentDescription(cell,"${date} ${shift.title}. ${holiday.orEmpty()} 일정 ${events.size}개. 기념일 ${anniversaries.size}개. ${detail(context,date,schedule,style)}")
|
views.setContentDescription(cell,"${date} ${shift.title}. ${holiday.orEmpty()} 일정 ${events.size}개. 기념일 ${anniversaries.size}개. ${detail(context,date,schedule,style,snapshot)}")
|
||||||
}
|
}
|
||||||
return views
|
return views
|
||||||
}
|
}
|
||||||
private fun detail(context:Context,date:LocalDate,schedule:Schedule,style:WidgetStyle):String {
|
private fun detail(context:Context,date:LocalDate,schedule:Schedule,style:WidgetStyle,snapshot:CalendarSnapshot):String {
|
||||||
val values=mutableListOf<String>()
|
val values=mutableListOf<String>()
|
||||||
if(style.people)values.addAll(WorkNames.on(context,date,schedule).map{it.name})
|
if(style.people)values.addAll(snapshot.workNames(date,schedule).map{it.name})
|
||||||
if(style.lunar&&schedule.showLunar)LunarDates.label(context,date)?.let{values.add(it)}
|
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.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.anniversaries)snapshot.anniversariesOn(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.people)People.onDuty(snapshot.people,date).firstOrNull()?.let{values.add(it.name)}
|
||||||
if(style.eventMark)PlannerStore.eventsOn(context,date).size.takeIf{it>0}?.let{values.add("일정 ${it}개")}
|
if(style.eventMark)snapshot.eventsOn(date).size.takeIf{it>0}?.let{values.add("일정 ${it}개")}
|
||||||
return values.joinToString(" · ")
|
return values.joinToString(" · ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ open class DutyWidget : AppWidgetProvider() {
|
|||||||
} else if (action in listOf(Intent.ACTION_DATE_CHANGED, Intent.ACTION_TIME_CHANGED, Intent.ACTION_TIMEZONE_CHANGED, Intent.ACTION_BOOT_COMPLETED)) {
|
} else if (action in listOf(Intent.ACTION_DATE_CHANGED, Intent.ACTION_TIME_CHANGED, Intent.ACTION_TIMEZONE_CHANGED, Intent.ACTION_BOOT_COMPLETED)) {
|
||||||
Holidays.schedule(context)
|
Holidays.schedule(context)
|
||||||
SyncClient.schedule(context)
|
SyncClient.schedule(context)
|
||||||
updateAll(context)
|
manager.getAppWidgetIds(ComponentName(context,javaClass)).forEach{update(context,manager,it)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +85,9 @@ open class DutyWidget : AppWidgetProvider() {
|
|||||||
val manager = AppWidgetManager.getInstance(context)
|
val manager = AppWidgetManager.getInstance(context)
|
||||||
WidgetKind.ids(context).forEach { update(context, manager, it) }
|
WidgetKind.ids(context).forEach { update(context, manager, it) }
|
||||||
}
|
}
|
||||||
|
fun updateOne(context:Context,id:Int) {
|
||||||
|
if(id in WidgetKind.ids(context))update(context,AppWidgetManager.getInstance(context),id)
|
||||||
|
}
|
||||||
private fun update(context: Context, manager: AppWidgetManager, id: Int) {
|
private fun update(context: Context, manager: AppWidgetManager, id: Int) {
|
||||||
val options=manager.getAppWidgetOptions(id)
|
val options=manager.getAppWidgetOptions(id)
|
||||||
val kind=WidgetKind.of(context,id)
|
val kind=WidgetKind.of(context,id)
|
||||||
@@ -114,7 +117,8 @@ open class DutyWidget : AppWidgetProvider() {
|
|||||||
val density=context.resources.displayMetrics.density
|
val density=context.resources.displayMetrics.density
|
||||||
val month = selectedMonth(context, id)
|
val month = selectedMonth(context, id)
|
||||||
val schedule = ScheduleStore.load(context)
|
val schedule = ScheduleStore.load(context)
|
||||||
val people = if(style.people&&!compact)People.all(context) else emptyList()
|
val snapshot=CalendarSnapshot.load(context)
|
||||||
|
val people = if(style.people&&!compact)snapshot.people else emptyList()
|
||||||
val today = LocalDate.now()
|
val today = LocalDate.now()
|
||||||
val configured = ScheduleStore.isConfigured(context)
|
val configured = ScheduleStore.isConfigured(context)
|
||||||
val view = RemoteViews(context.packageName, R.layout.duty_widget)
|
val view = RemoteViews(context.packageName, R.layout.duty_widget)
|
||||||
@@ -130,12 +134,12 @@ open class DutyWidget : AppWidgetProvider() {
|
|||||||
view.setTextColor(headers[index], when(day) { 0 -> style.color(0xFFBD5163.toInt()); 6 -> style.color(schedule.saturdayColor); else -> style.muted })
|
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)
|
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)
|
val customize=AppNavigation.widgetStyle(context,id)
|
||||||
view.setOnClickPendingIntent(R.id.widget_customize,PendingIntent.getActivity(context,id,customize,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
view.setOnClickPendingIntent(R.id.widget_customize,PendingIntent.getActivity(context,id,customize,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||||
view.setTextViewText(R.id.widget_title, "${month.year}년 ${month.monthValue}월")
|
view.setTextViewText(R.id.widget_title, "${month.year}년 ${month.monthValue}월")
|
||||||
view.setTextViewText(R.id.widget_subtitle, if (configured) "오늘 ${schedule.shiftOn(today).title} · ${schedule.pattern.size}일 반복" else "앱에서 근무 시작 날짜를 설정해 주세요")
|
view.setTextViewText(R.id.widget_subtitle, if (configured) "오늘 ${schedule.shiftOn(today).title} · ${schedule.pattern.size}일 반복" else "앱에서 근무 시작 날짜를 설정해 주세요")
|
||||||
view.setTextViewText(R.id.widget_footer, if (month.year in Holidays.years(context)) "제작자 블리어 (이창현)" else "${month.year}년 공휴일 자료 확인 필요")
|
view.setTextViewText(R.id.widget_footer, if (month.year in Holidays.years(context)) "제작자 블리어 (이창현)" else "${month.year}년 공휴일 자료 확인 필요")
|
||||||
val open = PendingIntent.getActivity(context, 0, Intent(context, MainActivity::class.java), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
val open = PendingIntent.getActivity(context, 0, AppNavigation.main(context), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||||
view.setOnClickPendingIntent(R.id.widget_root, open)
|
view.setOnClickPendingIntent(R.id.widget_root, open)
|
||||||
// 같은 동작도 위젯 번호별로 다른 PendingIntent를 사용한다. 다른 위젯의 월을 바꾸지 않기 위해서다.
|
// 같은 동작도 위젯 번호별로 다른 PendingIntent를 사용한다. 다른 위젯의 월을 바꾸지 않기 위해서다.
|
||||||
// 명시적 수신 대상과 변경 불가 플래그를 사용해 홈 화면 앱이 전달 내용을 바꾸지 못하게 한다.
|
// 명시적 수신 대상과 변경 불가 플래그를 사용해 홈 화면 앱이 전달 내용을 바꾸지 못하게 한다.
|
||||||
@@ -146,14 +150,14 @@ open class DutyWidget : AppWidgetProvider() {
|
|||||||
calendarDays(month, schedule.weekStart).forEachIndexed { index, date ->
|
calendarDays(month, schedule.weekStart).forEachIndexed { index, date ->
|
||||||
val shift = schedule.shiftOn(date)
|
val shift = schedule.shiftOn(date)
|
||||||
val holiday = Holidays.name(context, date)
|
val holiday = Holidays.name(context, date)
|
||||||
val events = PlannerStore.eventsOn(context, date)
|
val events = snapshot.eventsOn(date)
|
||||||
val personalDays = Anniversaries.on(context, date)
|
val personalDays = snapshot.anniversariesOn(date)
|
||||||
val number = date.dayOfMonth.toString() + if (style.eventMark && (events.isNotEmpty() || personalDays.isNotEmpty())) "+" else ""
|
val number = date.dayOfMonth.toString() + if (style.eventMark && (events.isNotEmpty() || personalDays.isNotEmpty())) "+" else ""
|
||||||
val holidayShort = holiday?.takeIf { style.holidays&&!compact }?.let { if (it.contains("대체공휴일")) "대체휴일" else it.replace(" 전날", "").replace(" 다음 날", "").replace("기독탄신일", "성탄절").replace("1월 1일", "신정") }
|
val holidayShort = holiday?.takeIf { style.holidays&&!compact }?.let { if (it.contains("대체공휴일")) "대체휴일" else it.replace(" 전날", "").replace(" 다음 날", "").replace("기독탄신일", "성탄절").replace("1월 1일", "신정") }
|
||||||
val lunar = if (schedule.showLunar&&style.lunar&&!compact) LunarDates.label(context, date) else null
|
val lunar = if (schedule.showLunar&&style.lunar&&!compact) LunarDates.label(context, date) else null
|
||||||
val heading = number + (lunar?.let { "\n$it" } ?: "")
|
val heading = number + (lunar?.let { "\n$it" } ?: "")
|
||||||
val shiftStart = heading.length + 1
|
val shiftStart = heading.length + 1
|
||||||
val workNames = if (style.people && !compact) WorkNames.on(context, date, schedule) else emptyList()
|
val workNames = if (style.people && !compact) snapshot.workNames(date, schedule) else emptyList()
|
||||||
val workLabel = workNames.take(2).joinToString("\n") { it.name.take(5) }
|
val workLabel = workNames.take(2).joinToString("\n") { it.name.take(5) }
|
||||||
val baseText = "$heading\n${shift.shortTitle}" + (if (workLabel.isNotBlank()) "\n$workLabel" else "") + (holidayShort?.let { "\n$it" } ?: "")
|
val baseText = "$heading\n${shift.shortTitle}" + (if (workLabel.isNotBlank()) "\n$workLabel" else "") + (holidayShort?.let { "\n$it" } ?: "")
|
||||||
val colleagues = People.onDuty(people, date)
|
val colleagues = People.onDuty(people, date)
|
||||||
@@ -200,7 +204,7 @@ open class DutyWidget : AppWidgetProvider() {
|
|||||||
view.setTextColor(cellId, if (YearMonth.from(date) == month) style.ink else 0xFF9AA4B3.toInt())
|
view.setTextColor(cellId, if (YearMonth.from(date) == month) style.ink else 0xFF9AA4B3.toInt())
|
||||||
view.setInt(cellId, "setBackgroundColor", if (date == today && style.today) (if(style.dark)0x554A6D96 else 0x44A7B5CB) else android.graphics.Color.TRANSPARENT)
|
view.setInt(cellId, "setBackgroundColor", if (date == today && style.today) (if(style.dark)0x554A6D96 else 0x44A7B5CB) else android.graphics.Color.TRANSPARENT)
|
||||||
view.setContentDescription(cellId, "${date.monthValue}월 ${date.dayOfMonth}일 ${shift.title} ${lunar.orEmpty()} ${holiday.orEmpty()} 일정 ${events.size}개. 기념일: ${personalDays.joinToString { it.getJSONObject("data").getString("title") }}. 함께 당직: ${colleagues.joinToString { it.name }}")
|
view.setContentDescription(cellId, "${date.monthValue}월 ${date.dayOfMonth}일 ${shift.title} ${lunar.orEmpty()} ${holiday.orEmpty()} 일정 ${events.size}개. 기념일: ${personalDays.joinToString { it.getJSONObject("data").getString("title") }}. 함께 당직: ${colleagues.joinToString { it.name }}")
|
||||||
val dayIntent = Intent(context, MainActivity::class.java).setData(android.net.Uri.parse("dutycalendar://date/$date")).putExtra("selectedDate", date.toString())
|
val dayIntent = AppNavigation.date(context,date)
|
||||||
view.setOnClickPendingIntent(cellId, PendingIntent.getActivity(context, id * 1000 + index + 1, dayIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
view.setOnClickPendingIntent(cellId, PendingIntent.getActivity(context, id * 1000 + index + 1, dayIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||||
}
|
}
|
||||||
return view
|
return view
|
||||||
|
|||||||
@@ -66,17 +66,27 @@ class MainActivity : Activity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
savedInstanceState?.getString("month")?.let { month = YearMonth.parse(it) }
|
savedInstanceState?.getString("month")?.let { month = YearMonth.parse(it) }
|
||||||
savedInstanceState?.getString("selectedDate")?.let { selectedDate = LocalDate.parse(it) }
|
savedInstanceState?.getString("selectedDate")?.let { selectedDate = LocalDate.parse(it) }
|
||||||
if (savedInstanceState == null) intent.getStringExtra("selectedDate")?.let { value -> runCatching { selectedDate = LocalDate.parse(value); month = YearMonth.from(selectedDate) } }
|
|
||||||
PlannerStore.migrate(this)
|
PlannerStore.migrate(this)
|
||||||
render()
|
if(savedInstanceState==null) receiveNavigation(intent)
|
||||||
if(savedInstanceState==null&&intent.hasExtra("widgetStyleId"))window.decorView.post { WidgetStyleDialog.show(this,intent.getIntExtra("widgetStyleId",-1)) }
|
|
||||||
}
|
}
|
||||||
|
private fun receiveNavigation(incoming:android.content.Intent) {
|
||||||
|
AppNavigation.takeDate(incoming)?.let { selectedDate=it;month=YearMonth.from(it) }
|
||||||
|
AppNavigation.takeWidget(incoming)?.let { id -> window.decorView.post {
|
||||||
|
if(!isFinishing&&!isDestroyed)WidgetStyleDialog.show(this,id)
|
||||||
|
} }
|
||||||
|
}
|
||||||
|
override fun onNewIntent(incoming:android.content.Intent) {
|
||||||
|
super.onNewIntent(incoming)
|
||||||
|
setIntent(incoming);receiveNavigation(incoming)
|
||||||
|
}
|
||||||
|
override fun onDestroy() { WidgetStyleDialog.dismiss(this);super.onDestroy() }
|
||||||
override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState); outState.putString("month", month.toString()); outState.putString("selectedDate", selectedDate.toString()) }
|
override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState); outState.putString("month", month.toString()); outState.putString("selectedDate", selectedDate.toString()) }
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume(); render(); DutyWidget.updateAll(this); Reminders.reschedule(this)
|
super.onResume(); render(); DutyWidget.updateAll(this); Reminders.reschedule(this)
|
||||||
CalendarMirror.request(this)
|
CalendarMirror.request(this)
|
||||||
Holidays.schedule(this)
|
Holidays.schedule(this)
|
||||||
Holidays.refresh(this) { success -> if (success) runOnUiThread { if (!isFinishing && !isDestroyed) render() } }
|
val holidayRevision=Holidays.revision(this)
|
||||||
|
Holidays.refresh(this) { success -> if (success&&Holidays.revision(this)!=holidayRevision) runOnUiThread { if (!isFinishing && !isDestroyed) render() } }
|
||||||
SyncClient.schedule(this)
|
SyncClient.schedule(this)
|
||||||
SyncClient.foreground(this) { runOnUiThread { if (!isFinishing && !isDestroyed) render() } }
|
SyncClient.foreground(this) { runOnUiThread { if (!isFinishing && !isDestroyed) render() } }
|
||||||
UpdateChecker.check(this, fresh = true)
|
UpdateChecker.check(this, fresh = true)
|
||||||
@@ -99,7 +109,8 @@ class MainActivity : Activity() {
|
|||||||
val schedule = ScheduleStore.load(this)
|
val schedule = ScheduleStore.load(this)
|
||||||
val configured = ScheduleStore.isConfigured(this)
|
val configured = ScheduleStore.isConfigured(this)
|
||||||
val today = LocalDate.now()
|
val today = LocalDate.now()
|
||||||
val people = People.all(this)
|
val snapshot = CalendarSnapshot.load(this)
|
||||||
|
val people = snapshot.people
|
||||||
val scroll = ScrollView(this).apply {
|
val scroll = ScrollView(this).apply {
|
||||||
isFillViewport = true; setBackgroundColor(0xFFF4F1EA.toInt())
|
isFillViewport = true; setBackgroundColor(0xFFF4F1EA.toInt())
|
||||||
setOnScrollChangeListener { _, _, y, _, _ -> if (!restoringScroll && generation == renderGeneration) scrollOffset = y }
|
setOnScrollChangeListener { _, _, y, _, _ -> if (!restoringScroll && generation == renderGeneration) scrollOffset = y }
|
||||||
@@ -164,9 +175,9 @@ class MainActivity : Activity() {
|
|||||||
val shift = schedule.shiftOn(date)
|
val shift = schedule.shiftOn(date)
|
||||||
val holiday = Holidays.name(this, date)
|
val holiday = Holidays.name(this, date)
|
||||||
val lunar = if (schedule.showLunar) LunarDates.label(this, date) else null
|
val lunar = if (schedule.showLunar) LunarDates.label(this, date) else null
|
||||||
val events = PlannerStore.eventsOn(this, date)
|
val events = snapshot.eventsOn(date)
|
||||||
val personalDays = Anniversaries.on(this, date)
|
val personalDays = snapshot.anniversariesOn(date)
|
||||||
val workNames = WorkNames.on(this, date, schedule)
|
val workNames = snapshot.workNames(date, schedule)
|
||||||
val colleagues = People.onDuty(people, date)
|
val colleagues = People.onDuty(people, date)
|
||||||
val inside = YearMonth.from(date) == month
|
val inside = YearMonth.from(date) == month
|
||||||
val cell = column().apply {
|
val cell = column().apply {
|
||||||
@@ -207,7 +218,7 @@ class MainActivity : Activity() {
|
|||||||
}.setNegativeButton("닫기", null).show()
|
}.setNegativeButton("닫기", null).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cells.addView(cell, LinearLayout.LayoutParams(0, dp((if (people.isEmpty() && WorkNames.rules(this).isEmpty()) 103 else 174) + if (schedule.showLunar) 14 else 0), 1f))
|
cells.addView(cell, LinearLayout.LayoutParams(0, dp((if (people.isEmpty() && !snapshot.hasNames) 103 else 174) + if (schedule.showLunar) 14 else 0), 1f))
|
||||||
}
|
}
|
||||||
calendar.addView(View(this).apply { setBackgroundColor(0xFFE6E4DC.toInt()) }, LinearLayout.LayoutParams(-1, dp(1)))
|
calendar.addView(View(this).apply { setBackgroundColor(0xFFE6E4DC.toInt()) }, LinearLayout.LayoutParams(-1, dp(1)))
|
||||||
calendar.addView(cells)
|
calendar.addView(cells)
|
||||||
@@ -458,6 +469,10 @@ class MainActivity : Activity() {
|
|||||||
override fun onRequestPermissionsResult(requestCode:Int,permissions:Array<out String>,grantResults:IntArray) {
|
override fun onRequestPermissionsResult(requestCode:Int,permissions:Array<out String>,grantResults:IntArray) {
|
||||||
super.onRequestPermissionsResult(requestCode,permissions,grantResults)
|
super.onRequestPermissionsResult(requestCode,permissions,grantResults)
|
||||||
deviceCalendar.permissionResult(requestCode,grantResults)
|
deviceCalendar.permissionResult(requestCode,grantResults)
|
||||||
|
if(requestCode==CalendarMirrorDialogs.REQUEST) {
|
||||||
|
if(CalendarMirror.allowed(this))CalendarMirrorDialogs(this).open()
|
||||||
|
else Toast.makeText(this,"기본 달력 자동 반영에는 달력 읽기와 쓰기 권한이 필요합니다.",Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
if(requestCode==Reminders.REQUEST_NOTIFY) {
|
if(requestCode==Reminders.REQUEST_NOTIFY) {
|
||||||
Reminders.reschedule(this)
|
Reminders.reschedule(this)
|
||||||
Toast.makeText(this,if(grantResults.firstOrNull()==android.content.pm.PackageManager.PERMISSION_GRANTED)"일정 알림을 켰습니다." else "알림을 허용하면 저장한 일정의 알림을 받을 수 있습니다.",Toast.LENGTH_LONG).show()
|
Toast.makeText(this,if(grantResults.firstOrNull()==android.content.pm.PackageManager.PERMISSION_GRANTED)"일정 알림을 켰습니다." else "알림을 허용하면 저장한 일정의 알림을 받을 수 있습니다.",Toast.LENGTH_LONG).show()
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ object MonthWidgetViews {
|
|||||||
val views=RemoteViews(context.packageName,R.layout.duty_widget_month_fit)
|
val views=RemoteViews(context.packageName,R.layout.duty_widget_month_fit)
|
||||||
views.setInt(R.id.widget_root,"setBackgroundColor",style.background)
|
views.setInt(R.id.widget_root,"setBackgroundColor",style.background)
|
||||||
views.setViewPadding(R.id.widget_root,(padding*density).toInt(),(padding*density).toInt(),(padding*density).toInt(),(padding*density).toInt())
|
views.setViewPadding(R.id.widget_root,(padding*density).toInt(),(padding*density).toInt(),(padding*density).toInt(),(padding*density).toInt())
|
||||||
val open=PendingIntent.getActivity(context,0,Intent(context,MainActivity::class.java),PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
val open=PendingIntent.getActivity(context,0,AppNavigation.main(context),PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||||
views.setOnClickPendingIntent(R.id.widget_root,open)
|
views.setOnClickPendingIntent(R.id.widget_root,open)
|
||||||
views.setTextViewText(R.id.widget_title,if(width<180)"${month.year}.${month.monthValue}" else "${month.year}년 ${month.monthValue}월")
|
views.setTextViewText(R.id.widget_title,if(width<180)"${month.year}.${month.monthValue}" else "${month.year}년 ${month.monthValue}월")
|
||||||
val titleFont=if(width<180||short)11f else 17f
|
val titleFont=if(width<180||short)11f else 17f
|
||||||
@@ -55,7 +55,7 @@ object MonthWidgetViews {
|
|||||||
views.setTextColor(control,style.ink)
|
views.setTextColor(control,style.ink)
|
||||||
views.setTextViewTextSize(control,TypedValue.COMPLEX_UNIT_DIP,if(control==R.id.widget_title)titleFont else 9f)
|
views.setTextViewTextSize(control,TypedValue.COMPLEX_UNIT_DIP,if(control==R.id.widget_title)titleFont else 9f)
|
||||||
}
|
}
|
||||||
val customize=Intent(context,MainActivity::class.java).setData(Uri.parse("dutycalendar://widget/$id/style")).putExtra("widgetStyleId",id)
|
val customize=AppNavigation.widgetStyle(context,id)
|
||||||
views.setOnClickPendingIntent(R.id.widget_customize,PendingIntent.getActivity(context,id,customize,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
views.setOnClickPendingIntent(R.id.widget_customize,PendingIntent.getActivity(context,id,customize,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||||
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)
|
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 ->
|
calendarWeekdays(schedule.weekStart).forEachIndexed { index,day ->
|
||||||
@@ -73,13 +73,14 @@ object MonthWidgetViews {
|
|||||||
val intent=Intent(context,kind.receiver).setAction(action).putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,id)
|
val intent=Intent(context,kind.receiver).setAction(action).putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,id)
|
||||||
views.setOnClickPendingIntent(control,PendingIntent.getBroadcast(context,id,intent,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
views.setOnClickPendingIntent(control,PendingIntent.getBroadcast(context,id,intent,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||||
}
|
}
|
||||||
val people=if(style.people)People.all(context) else emptyList()
|
val snapshot=CalendarSnapshot.load(context)
|
||||||
|
val people=if(style.people)snapshot.people else emptyList()
|
||||||
calendarDays(month,schedule.weekStart).forEachIndexed { index,date ->
|
calendarDays(month,schedule.weekStart).forEachIndexed { index,date ->
|
||||||
val shift=schedule.shiftOn(date)
|
val shift=schedule.shiftOn(date)
|
||||||
val holiday=Holidays.name(context,date)
|
val holiday=Holidays.name(context,date)
|
||||||
val events=PlannerStore.eventsOn(context,date)
|
val events=snapshot.eventsOn(date)
|
||||||
val anniversaries=Anniversaries.on(context,date)
|
val anniversaries=snapshot.anniversariesOn(date)
|
||||||
val names=if(style.people)WorkNames.on(context,date,schedule) else emptyList()
|
val names=if(style.people)snapshot.workNames(date,schedule) else emptyList()
|
||||||
val colleagues=People.onDuty(people,date)
|
val colleagues=People.onDuty(people,date)
|
||||||
val lunar=if(style.lunar&&schedule.showLunar)LunarDates.label(context,date) else null
|
val lunar=if(style.lunar&&schedule.showLunar)LunarDates.label(context,date) else null
|
||||||
val extra=names.firstOrNull()?.name
|
val extra=names.firstOrNull()?.name
|
||||||
@@ -122,7 +123,7 @@ object MonthWidgetViews {
|
|||||||
}
|
}
|
||||||
views.setInt(cell,"setBackgroundColor",background)
|
views.setInt(cell,"setBackgroundColor",background)
|
||||||
views.setContentDescription(cell,"${date.year}년 ${date.monthValue}월 ${date.dayOfMonth}일 ${shift.title}. ${holiday.orEmpty()} ${lunar.orEmpty()}. 이름 ${names.joinToString{it.name}}. 함께 당직 ${colleagues.joinToString{it.name}}. 일정 ${events.size}개. 기념일 ${anniversaries.joinToString{it.getJSONObject("data").getString("title")}}")
|
views.setContentDescription(cell,"${date.year}년 ${date.monthValue}월 ${date.dayOfMonth}일 ${shift.title}. ${holiday.orEmpty()} ${lunar.orEmpty()}. 이름 ${names.joinToString{it.name}}. 함께 당직 ${colleagues.joinToString{it.name}}. 일정 ${events.size}개. 기념일 ${anniversaries.joinToString{it.getJSONObject("data").getString("title")}}")
|
||||||
val intent=Intent(context,MainActivity::class.java).setData(Uri.parse("dutycalendar://date/$date")).putExtra("selectedDate",date.toString())
|
val intent=AppNavigation.date(context,date)
|
||||||
views.setOnClickPendingIntent(cell,PendingIntent.getActivity(context,id*1000+index+1,intent,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
views.setOnClickPendingIntent(cell,PendingIntent.getActivity(context,id*1000+index+1,intent,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE))
|
||||||
}
|
}
|
||||||
return views
|
return views
|
||||||
|
|||||||
@@ -18,16 +18,20 @@ object People {
|
|||||||
fun all(context: Context): List<PersonDuty> {
|
fun all(context: Context): List<PersonDuty> {
|
||||||
// 회원 연결이 꺼지면 보관 자료를 지우지 않고 표시에서 제외한다. 위젯도 이 경로를 사용한다.
|
// 회원 연결이 꺼지면 보관 자료를 지우지 않고 표시에서 제외한다. 위젯도 이 경로를 사용한다.
|
||||||
if (!SyncClient.connected(context)) return emptyList()
|
if (!SyncClient.connected(context)) return emptyList()
|
||||||
return PlannerStore.items(context).filter { it.getString("kind") == "person" }.mapNotNull { item ->
|
val (items,company)=PlannerStore.displayData(context)
|
||||||
|
return from(items,company)
|
||||||
|
}
|
||||||
|
internal fun from(items:List<JSONObject>,company:JSONObject?):List<PersonDuty> {
|
||||||
|
return items.filter { it.getString("kind") == "person" }.mapNotNull { item ->
|
||||||
runCatching {
|
runCatching {
|
||||||
val data = item.getJSONObject("data")
|
val data = item.getJSONObject("data")
|
||||||
PersonDuty(item.getString("id"), data.getString("name"), data.getString("color"),
|
PersonDuty(item.getString("id"), data.getString("name"), data.getString("color"),
|
||||||
Schedule(LocalDate.parse(data.getString("anchor")), PlannerStore.listStrings(data.getJSONArray("pattern")).map(Shift::valueOf), data.optInt("workWeek", 6), data.optBoolean("dutyAsWeekday", false)))
|
Schedule(LocalDate.parse(data.getString("anchor")), PlannerStore.listStrings(data.getJSONArray("pattern")).map(Shift::valueOf), data.optInt("workWeek", 6), data.optBoolean("dutyAsWeekday", false)))
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}.plus(shared(context)).sortedBy { it.name }
|
}.plus(shared(company)).sortedBy { it.name }
|
||||||
}
|
}
|
||||||
private fun shared(context: Context): List<PersonDuty> {
|
private fun shared(company: JSONObject?): List<PersonDuty> {
|
||||||
val members = PlannerStore.company(context)?.optJSONArray("members") ?: return emptyList()
|
val members = company?.optJSONArray("members") ?: return emptyList()
|
||||||
return PlannerStore.list(members).filter { !it.optBoolean("isSelf") }.mapNotNull { person ->
|
return PlannerStore.list(members).filter { !it.optBoolean("isSelf") }.mapNotNull { person ->
|
||||||
runCatching {
|
runCatching {
|
||||||
val rotation = person.getJSONObject("rotation")
|
val rotation = person.getJSONObject("rotation")
|
||||||
|
|||||||
@@ -42,11 +42,18 @@ object PlannerStore {
|
|||||||
return JSONArray(list(document.getJSONArray("pending")).filter { it.getString("changeId") !in conflicts }.take(100))
|
return JSONArray(list(document.getJSONArray("pending")).filter { it.getString("changeId") !in conflicts }.take(100))
|
||||||
}
|
}
|
||||||
@Synchronized fun items(context: Context): List<JSONObject> {
|
@Synchronized fun items(context: Context): List<JSONObject> {
|
||||||
val document = read(context)
|
return visibleItems(read(context))
|
||||||
|
}
|
||||||
|
private fun visibleItems(document:JSONObject):List<JSONObject> {
|
||||||
val combined = list(document.getJSONObject("state").getJSONArray("items")).associateBy { it.getString("id") }.toMutableMap()
|
val combined = list(document.getJSONObject("state").getJSONArray("items")).associateBy { it.getString("id") }.toMutableMap()
|
||||||
list(document.getJSONArray("pending")).forEach { combined[it.getString("id")] = it }
|
list(document.getJSONArray("pending")).forEach { combined[it.getString("id")] = it }
|
||||||
return combined.values.filter { !it.getBoolean("deleted") }
|
return combined.values.filter { !it.getBoolean("deleted") }
|
||||||
}
|
}
|
||||||
|
/** 한 화면을 만드는 동안 같은 원본과 전송 대기 내용을 함께 읽는다. 반환 객체는 화면 전용이며 저장에 재사용하지 않는다. */
|
||||||
|
@Synchronized fun displayData(context:Context):Pair<List<JSONObject>,JSONObject?> {
|
||||||
|
val document=read(context)
|
||||||
|
return visibleItems(document) to document.getJSONObject("state").optJSONObject("company")
|
||||||
|
}
|
||||||
fun eventsOn(context: Context, date: LocalDate) = items(context).filter {
|
fun eventsOn(context: Context, date: LocalDate) = items(context).filter {
|
||||||
it.getString("kind") == "event" && eventRule(it.getJSONObject("data")).occurrenceOn(date) != null
|
it.getString("kind") == "event" && eventRule(it.getJSONObject("data")).occurrenceOn(date) != null
|
||||||
}.sortedWith(compareBy<JSONObject> { !it.getJSONObject("data").getBoolean("allDay") }.thenBy { it.getJSONObject("data").getString("startTime") }.thenBy { it.getJSONObject("data").getString("title") })
|
}.sortedWith(compareBy<JSONObject> { !it.getJSONObject("data").getBoolean("allDay") }.thenBy { it.getJSONObject("data").getString("startTime") }.thenBy { it.getJSONObject("data").getString("title") })
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ object Reminders {
|
|||||||
val manager=context.getSystemService(NotificationManager::class.java)
|
val manager=context.getSystemService(NotificationManager::class.java)
|
||||||
manager.createNotificationChannel(NotificationChannel("schedule","일정과 기념일",NotificationManager.IMPORTANCE_DEFAULT))
|
manager.createNotificationChannel(NotificationChannel("schedule","일정과 기념일",NotificationManager.IMPORTANCE_DEFAULT))
|
||||||
for(plan in plans(context,at-1).filter{it.at<=System.currentTimeMillis()}) {
|
for(plan in plans(context,at-1).filter{it.at<=System.currentTimeMillis()}) {
|
||||||
val open=Intent(context,MainActivity::class.java).setData(Uri.parse("dutycalendar://date/${plan.date}")).putExtra("selectedDate",plan.date.toString())
|
val open=AppNavigation.date(context,plan.date)
|
||||||
val tap=PendingIntent.getActivity(context,0,open,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
val tap=PendingIntent.getActivity(context,0,open,PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||||
val notice=Notification.Builder(context,"schedule").setSmallIcon(R.drawable.ic_calendar).setContentTitle(plan.title)
|
val notice=Notification.Builder(context,"schedule").setSmallIcon(R.drawable.ic_calendar).setContentTitle(plan.title)
|
||||||
.setContentText("${plan.date} · 등록한 일정 알림").setContentIntent(tap).setAutoCancel(true).setVisibility(Notification.VISIBILITY_PRIVATE).build()
|
.setContentText("${plan.date} · 등록한 일정 알림").setContentIntent(tap).setAutoCancel(true).setVisibility(Notification.VISIBILITY_PRIVATE).build()
|
||||||
|
|||||||
@@ -44,19 +44,33 @@ data class WidgetStyle(
|
|||||||
if(id==null){prefs.all.keys.filter{it.startsWith("style_")}.forEach{edit.remove(it)};edit.putString("default",style.json().toString())}
|
if(id==null){prefs.all.keys.filter{it.startsWith("style_")}.forEach{edit.remove(it)};edit.putString("default",style.json().toString())}
|
||||||
else edit.putString("style_$id",style.json().toString())
|
else edit.putString("style_$id",style.json().toString())
|
||||||
check(edit.commit()){ "위젯 설정을 저장하지 못했습니다. 저장 공간을 확인해 주세요." }
|
check(edit.commit()){ "위젯 설정을 저장하지 못했습니다. 저장 공간을 확인해 주세요." }
|
||||||
DutyWidget.updateAll(context)
|
if(id==null)DutyWidget.updateAll(context) else DutyWidget.updateOne(context,id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object WidgetStyleDialog {
|
object WidgetStyleDialog {
|
||||||
|
private var opened=java.lang.ref.WeakReference<AlertDialog>(null)
|
||||||
|
internal fun current(activity:Activity)=opened.get()?.takeIf{it.ownerActivity===activity&&it.isShowing}
|
||||||
|
fun dismiss(activity:Activity) { current(activity)?.dismiss() }
|
||||||
|
private fun display(activity:Activity,dialog:AlertDialog) {
|
||||||
|
opened.get()?.dismiss()
|
||||||
|
dialog.setOwnerActivity(activity)
|
||||||
|
opened=java.lang.ref.WeakReference(dialog)
|
||||||
|
dialog.setOnDismissListener { if(opened.get()===dialog)opened.clear() }
|
||||||
|
dialog.show()
|
||||||
|
}
|
||||||
fun show(activity:Activity,id:Int?=null) {
|
fun show(activity:Activity,id:Int?=null) {
|
||||||
|
// 빠른 연속 터치와 같은 위젯의 재진입이 겹쳐도 편집 창을 한 개만 유지한다.
|
||||||
|
// Activity를 강하게 보관하지 않으며 화면 종료 시 현재 창을 함께 닫는다.
|
||||||
|
if(activity.isFinishing||activity.isDestroyed||current(activity)!=null)return
|
||||||
val ids=WidgetKind.ids(activity)
|
val ids=WidgetKind.ids(activity)
|
||||||
if(id!=null){if(id in ids)edit(activity,id);return}
|
if(id!=null){if(id in ids)edit(activity,id);return}
|
||||||
if(ids.isEmpty()){edit(activity,null);return}
|
if(ids.isEmpty()){edit(activity,null);return}
|
||||||
AlertDialog.Builder(activity).setTitle("꾸밀 위젯 선택")
|
val picker=AlertDialog.Builder(activity).setTitle("꾸밀 위젯 선택")
|
||||||
.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])}
|
.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()
|
.setNegativeButton("닫기",null).create()
|
||||||
|
display(activity,picker)
|
||||||
}
|
}
|
||||||
private fun edit(activity:Activity,id:Int?) {
|
private fun edit(activity:Activity,id:Int?) {
|
||||||
val original=WidgetStyle.load(activity,id)
|
val original=WidgetStyle.load(activity,id)
|
||||||
@@ -96,6 +110,6 @@ object WidgetStyleDialog {
|
|||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener{runCatching{WidgetStyle.save(activity,id,value())}.onSuccess{dialog.dismiss();Toast.makeText(activity,"위젯 모양을 저장했습니다.",Toast.LENGTH_SHORT).show()}.onFailure{Toast.makeText(activity,it.message,Toast.LENGTH_LONG).show()}}
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener{runCatching{WidgetStyle.save(activity,id,value())}.onSuccess{dialog.dismiss();Toast.makeText(activity,"위젯 모양을 저장했습니다.",Toast.LENGTH_SHORT).show()}.onFailure{Toast.makeText(activity,it.message,Toast.LENGTH_LONG).show()}}
|
||||||
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener{opacity.progress=0;theme.setSelection(0);size.setSelection(1);details.setSelection(0);monthFit.setSelection(0);listOf(lunar,holidays,people,anniversaries,marks,today).forEach{it.isChecked=true};updatePreview()}
|
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener{opacity.progress=0;theme.setSelection(0);size.setSelection(1);details.setSelection(0);monthFit.setSelection(0);listOf(lunar,holidays,people,anniversaries,marks,today).forEach{it.isChecked=true};updatePreview()}
|
||||||
}
|
}
|
||||||
dialog.show();updatePreview()
|
display(activity,dialog);updatePreview()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- 휴대폰 달력 번호와 위젯 번호 및 설치 세션은 다른 기기로 옮기지 않는다. 개인 근무와 일정은 기존 백업을 유지한다. -->
|
||||||
|
<full-backup-content>
|
||||||
|
<exclude domain="sharedpref" path="calendar_mirror.xml" />
|
||||||
|
<exclude domain="sharedpref" path="widget.xml" />
|
||||||
|
<exclude domain="sharedpref" path="widget_style.xml" />
|
||||||
|
<exclude domain="sharedpref" path="web_sync.xml" />
|
||||||
|
<exclude domain="sharedpref" path="app_update.xml" />
|
||||||
|
</full-backup-content>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<exclude domain="sharedpref" path="calendar_mirror.xml" />
|
||||||
|
<exclude domain="sharedpref" path="widget.xml" />
|
||||||
|
<exclude domain="sharedpref" path="widget_style.xml" />
|
||||||
|
<exclude domain="sharedpref" path="web_sync.xml" />
|
||||||
|
<exclude domain="sharedpref" path="app_update.xml" />
|
||||||
|
</cloud-backup>
|
||||||
|
<device-transfer>
|
||||||
|
<exclude domain="sharedpref" path="calendar_mirror.xml" />
|
||||||
|
<exclude domain="sharedpref" path="widget.xml" />
|
||||||
|
<exclude domain="sharedpref" path="widget_style.xml" />
|
||||||
|
<exclude domain="sharedpref" path="web_sync.xml" />
|
||||||
|
<exclude domain="sharedpref" path="app_update.xml" />
|
||||||
|
</device-transfer>
|
||||||
|
</data-extraction-rules>
|
||||||
+8
-2
@@ -1,6 +1,6 @@
|
|||||||
# 새 버전 배포와 복구
|
# 새 버전 배포와 복구
|
||||||
|
|
||||||
제작자 블리어 (이창현) · 0.13.0
|
제작자 블리어 (이창현) · 0.13.2
|
||||||
|
|
||||||
## 배포 위치
|
## 배포 위치
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
빌드한 APK의 파일 이름과 바이트 수 및 SHA-256을 `release.json`의 apkFile과 apkBytes 및 apkSha256에 넣습니다. 예를 들어 0.13.0은 versionCode 17이며 웹 빌드는 2026-11-21.3입니다. 값만 미리 올리고 실제 파일을 늦게 배치하면 업데이트 검증이 실패합니다.
|
빌드한 APK의 파일 이름과 바이트 수 및 SHA-256을 `release.json`의 apkFile과 apkBytes 및 apkSha256에 넣습니다. 예를 들어 0.13.0은 versionCode 17이며 웹 빌드는 2026-11-21.3입니다. 값만 미리 올리고 실제 파일을 늦게 배치하면 업데이트 검증이 실패합니다.
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Get-FileHash app/build/outputs/apk/debug/app-debug.apk -Algorithm SHA256
|
Get-FileHash app/build/outputs/apk/release/app-release.apk -Algorithm SHA256
|
||||||
```
|
```
|
||||||
|
|
||||||
서명은 SDK의 `apksigner verify --print-certs`로 확인합니다. 이전 배포와 서명이 같은지 대조하고 실제 설치된 앱 위에 덮어 설치해 자료가 유지되는지 확인합니다.
|
서명은 SDK의 `apksigner verify --print-certs`로 확인합니다. 이전 배포와 서명이 같은지 대조하고 실제 설치된 앱 위에 덮어 설치해 자료가 유지되는지 확인합니다.
|
||||||
@@ -66,3 +66,9 @@ Get-FileHash app/build/outputs/apk/debug/app-debug.apk -Algorithm SHA256
|
|||||||
구독 주소에는 비밀값이 포함된다. `/calendar/feed/` 프록시의 접근 기록에는 실제 주소 대신 고정된 경로와 응답 상태만 남긴다. 해당 위치의 오류 기록에도 원문 주소를 남기지 않도록 설정한다. uvicorn은 접근 로그를 끄거나 소스에 포함된 주소 가림 필터를 사용한다.
|
구독 주소에는 비밀값이 포함된다. `/calendar/feed/` 프록시의 접근 기록에는 실제 주소 대신 고정된 경로와 응답 상태만 남긴다. 해당 위치의 오류 기록에도 원문 주소를 남기지 않도록 설정한다. uvicorn은 접근 로그를 끄거나 소스에 포함된 주소 가림 필터를 사용한다.
|
||||||
|
|
||||||
검사는 이름 규칙의 회원 분리와 충돌 및 입력 거부와 함께 구독 범위와 ETag 및 재발급과 해제 및 정지 회원의 접근 거부를 포함한다. 가상 기기의 Calendar Provider에서 등록과 재실행 중복 방지 및 제목 수정과 원본 삭제와 앱 사본만 지우기를 검사한다. 외부 서비스의 실제 구독 갱신 속도와 제조사 달력 화면은 별도로 확인한다.
|
검사는 이름 규칙의 회원 분리와 충돌 및 입력 거부와 함께 구독 범위와 ETag 및 재발급과 해제 및 정지 회원의 접근 거부를 포함한다. 가상 기기의 Calendar Provider에서 등록과 재실행 중복 방지 및 제목 수정과 원본 삭제와 앱 사본만 지우기를 검사한다. 외부 서비스의 실제 구독 갱신 속도와 제조사 달력 화면은 별도로 확인한다.
|
||||||
|
|
||||||
|
## 디버깅을 끈 배포 APK
|
||||||
|
|
||||||
|
0.13.2부터 `assembleRelease`로 만든 `app-release.apk`를 배포합니다. 디버깅용 `assembleDebug` APK는 기기 검사에만 사용합니다. 기존 설치본과 업데이트 호환을 위해 현재 서명 인증서는 유지하며 서명 키는 비공개로 따로 보관합니다. 소스 ZIP에는 키를 넣지 않습니다. 새 PC에서 만들어진 다른 인증서는 기존 앱 업데이트에 사용할 수 없습니다. 배포 전에 `apksigner` 확인과 설치 후 DEBUGGABLE 플래그가 없는지를 검사합니다.
|
||||||
|
|
||||||
|
배포 APK의 실제 동작 검사는 `-PtestBuildType=release :app:assembleReleaseAndroidTest`로 같은 종류의 검사 APK를 만듭니다. debug용 검사 APK를 release 앱에 혼용하지 않습니다.
|
||||||
+11
-1
@@ -1,6 +1,6 @@
|
|||||||
# 당직근무 설치와 사용법
|
# 당직근무 설치와 사용법
|
||||||
|
|
||||||
제작자 블리어 (이창현) · 0.13.1
|
제작자 블리어 (이창현) · 0.13.2
|
||||||
|
|
||||||
## 설치와 처음 설정
|
## 설치와 처음 설정
|
||||||
|
|
||||||
@@ -140,3 +140,13 @@
|
|||||||
이전·다음은 한 달씩 이동합니다. 오늘은 현재 달로 돌아옵니다. 월요일·일요일 주 시작과 날짜 색상 및 배경 투명도는 기존 선택을 따릅니다. 글자 확대를 선택해도 날짜가 잘리지 않도록 작은 크기에서는 배율의 상한을 적용합니다. 실제 크기는 홈 화면 앱의 격자와 여백에 따라 달라집니다.
|
이전·다음은 한 달씩 이동합니다. 오늘은 현재 달로 돌아옵니다. 월요일·일요일 주 시작과 날짜 색상 및 배경 투명도는 기존 선택을 따릅니다. 글자 확대를 선택해도 날짜가 잘리지 않도록 작은 크기에서는 배율의 상한을 적용합니다. 실제 크기는 홈 화면 앱의 격자와 여백에 따라 달라집니다.
|
||||||
|
|
||||||
**종류 기본 표시**로 바꾸면 기존 월간·두 주·근무 목록·오늘 배치로 돌아갑니다. 업데이트만으로 기존 배치를 바꾸지 않습니다. 위젯 모양은 기기별 설정이며 서버의 개인 근무표와 다른 기기는 변경하지 않습니다.
|
**종류 기본 표시**로 바꾸면 기존 월간·두 주·근무 목록·오늘 배치로 돌아갑니다. 업데이트만으로 기존 배치를 바꾸지 않습니다. 위젯 모양은 기기별 설정이며 서버의 개인 근무표와 다른 기기는 변경하지 않습니다.
|
||||||
|
|
||||||
|
## 0.13.2 위젯 실행과 달력 연동 보완
|
||||||
|
|
||||||
|
위젯의 꾸미기와 날짜를 반복해서 눌러도 기존 앱 화면을 재사용합니다. 꾸미기 편집 창은 하나만 열리며 한 번 닫으면 끝납니다. 앱이 열린 상태에서도 위젯에서 고른 날짜로 이동합니다. 위젯 하나를 꾸미면 해당 위젯만 갱신하고 전체 적용을 선택했을 때만 모든 위젯을 갱신합니다.
|
||||||
|
|
||||||
|
달력과 위젯을 그릴 때 일정과 로그인 상태를 날짜마다 반복해서 읽지 않도록 바꿨습니다. 근무와 일정 및 이름·기념일의 결과는 유지합니다. 회원 연결을 끄면 회원 전용 자료도 다음 표시에서 숨깁니다.
|
||||||
|
|
||||||
|
처음 기본 달력 권한을 허용하면 대상 달력 선택으로 이어집니다. 자동 반영의 하루 예약은 같은 설정을 저장해도 다음 실행 시점이 계속 밀리지 않습니다. 휴대폰을 새로 설정하거나 기기 백업에서 복원한 경우에는 대상 달력을 다시 선택합니다. 이전 휴대폰의 달력 번호와 위젯 번호 및 설치 세션은 옮기지 않습니다. 개인 근무와 일정의 기존 백업은 유지합니다.
|
||||||
|
|
||||||
|
배포 APK는 디버깅을 끈 release 빌드입니다. 이전과 같은 인증서로 서명해 앱을 삭제하지 않고 업데이트할 수 있습니다. 기존 회원과 근무 및 일정 자료는 변경하지 않습니다.
|
||||||
+13
-1
@@ -1,6 +1,6 @@
|
|||||||
# Android Studio로 당직근무 만들기
|
# Android Studio로 당직근무 만들기
|
||||||
|
|
||||||
제작자 블리어 (이창현) · 0.13.1
|
제작자 블리어 (이창현) · 0.13.2
|
||||||
|
|
||||||
## 준비할 환경
|
## 준비할 환경
|
||||||
|
|
||||||
@@ -128,3 +128,15 @@ duty_widget_month_fit.xml은 고정된 7열과 6개의 가중치 행을 갖는
|
|||||||
WidgetAppearanceCheck는 실제 RemoteViews를 펼쳐 네 종류와 주 시작 두 가지 및 세 배율과 최소·확장 크기에서 42칸의 날짜와 글자 높이 및 생략 여부를 검사한다. 31일과 마지막 주 및 연말 월 이동과 기존 설정 복원도 확인한다.
|
WidgetAppearanceCheck는 실제 RemoteViews를 펼쳐 네 종류와 주 시작 두 가지 및 세 배율과 최소·확장 크기에서 42칸의 날짜와 글자 높이 및 생략 여부를 검사한다. 31일과 마지막 주 및 연말 월 이동과 기존 설정 복원도 확인한다.
|
||||||
|
|
||||||
기준 문서: [Android 위젯의 유연한 크기와 배치](https://developer.android.com/develop/ui/views/appwidgets/layouts)
|
기준 문서: [Android 위젯의 유연한 크기와 배치](https://developer.android.com/develop/ui/views/appwidgets/layouts)
|
||||||
|
|
||||||
|
## 0.13.2 중복 화면과 자료 읽기 및 기기 복원
|
||||||
|
|
||||||
|
AppNavigation에서 위젯과 알림의 MainActivity 진입을 통일했다. CLEAR_TOP과 SINGLE_TOP으로 기존 화면을 재사용하며 onNewIntent에서 날짜와 위젯 요청을 받는다. 처리한 extra는 즉시 지우고 날짜 범위와 위젯 번호를 검사한다. 초기 onCreate와 onResume의 중복 그리기도 제거했다.
|
||||||
|
|
||||||
|
WidgetStyleDialog는 열린 창을 약한 참조로 확인한다. 같은 화면의 연속 요청은 새 창을 만들지 않고 기존 편집을 유지한다. 선택 창에서 편집 창으로 바꿀 때는 이전 창을 닫고 새 창만 추적한다. Activity 종료 시 해당 창을 닫는다.
|
||||||
|
|
||||||
|
CalendarSnapshot은 한 번의 표시 작업에 사용할 원본과 전송 대기 자료를 묶는다. 일정 반복과 이름 규칙은 한 번 해석한다. 전역 캐시를 사용하지 않으므로 다음 화면에서는 로그인 상태와 최신 자료를 다시 확인한다. MainActivity와 세 종류 위젯 렌더러 및 기본 달력 출력이 사용한다. 위젯 하나의 모양을 저장하면 그 위젯만 갱신한다. 날짜 변경 수신자도 자신의 위젯만 갱신한다.
|
||||||
|
|
||||||
|
기본 달력 반영 설정에는 백업 제외 영역의 기기 표식을 연결한다. 표식이 없거나 다른 기기의 값이면 자동 쓰기를 시작하지 않는다. 구버전에서 같은 기기의 표식이 남아 있으면 최초 확인 시 연결해 기존 동작을 유지한다. Android 11 이하와 Android 12 이상의 백업·기기 이전 규칙에 기기 종속 설정의 제외 목록을 함께 둔다. 개인 근무와 일정은 기존 백업을 유지한다.
|
||||||
|
|
||||||
|
관련 기준: [Android 화면과 백 스택](https://developer.android.com/guide/components/activities/tasks-and-back-stack) · [Android 자동 백업](https://developer.android.com/identity/data/autobackup) · [배포본 디버깅 설정](https://developer.android.com/privacy-and-security/risks/android-debuggable)
|
||||||
+1
-1
@@ -614,7 +614,7 @@ company.setup(app, identity, payload, db, throttle, changed, snapshot)
|
|||||||
|
|
||||||
@app.get(PREFIX + "/health")
|
@app.get(PREFIX + "/health")
|
||||||
async def health():
|
async def health():
|
||||||
return {"status": "ok", "version": "0.13.1"}
|
return {"status": "ok", "version": "0.13.2"}
|
||||||
|
|
||||||
|
|
||||||
@app.get(PREFIX + "/download")
|
@app.get(PREFIX + "/download")
|
||||||
|
|||||||
+9
-8
@@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"appVersion": "0.13.1",
|
"appVersion": "0.13.2",
|
||||||
"appVersionCode": 18,
|
"appVersionCode": 19,
|
||||||
"webVersion": "2026-11-21.3",
|
"webVersion": "2026-11-21.3",
|
||||||
"apkFile": "duty-calendar-0.13.1.apk",
|
"apkFile": "duty-calendar-0.13.2.apk",
|
||||||
"notes": [
|
"notes": [
|
||||||
"2×2·2×4·4×2·4×4 위젯에서 한 달 전체를 크기에 맞춰 축소하는 표시를 선택할 수 있습니다.",
|
"위젯 꾸미기와 날짜를 여러 번 눌러도 앱 화면과 편집 창이 겹쳐 열리지 않도록 수정했습니다.",
|
||||||
"위젯 꾸미기의 보여 줄 화면에서 한 달 전체를 선택하세요. 작은 크기는 날짜를 우선 표시하고 여유 공간에는 근무와 추가 정보가 나타납니다.",
|
"달력과 위젯의 반복 자료 읽기를 줄이고 선택한 위젯만 갱신하도록 개선했습니다.",
|
||||||
"주 시작과 날짜 색상 및 투명도를 유지하며 위젯별로 이전 달과 다음 달 및 오늘 이동을 지원합니다."
|
"기본 달력 권한 허용 후 설정을 이어서 열고 자동 반영의 예약 주기를 유지합니다.",
|
||||||
|
"기기 복원 후 잘못된 달력에 자동 기록되는 것을 막고 배포 APK의 디버깅을 껐습니다."
|
||||||
],
|
],
|
||||||
"apkBytes": 1331507,
|
"apkBytes": 841150,
|
||||||
"apkSha256": "fe52a6fddee65f0ae33a4b83f0591f990de8b17b51591e50ce69cc6641280be9"
|
"apkSha256": "d1aaca74741e89d90d73c4b0d20c31d8ee0fb8243a54c45aa2c78bf71df40b8d"
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<main>
|
<main>
|
||||||
<section id="welcome" class="welcome">
|
<section id="welcome" class="welcome">
|
||||||
<div class="welcome-hero">
|
<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.13.1</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.13.2</p><div class="welcome-caption"><strong>내 달력은 로그인 없이.</strong><p>함께 보는 근무표와 소속 공유는<br>회원 로그인 후 이용할 수 있습니다.</p></div></div>
|
||||||
<figure class="calendar-preview" aria-label="3당직근무 화면 예시">
|
<figure class="calendar-preview" aria-label="3당직근무 화면 예시">
|
||||||
<figcaption><span>홈 화면에 두는 나의 근무표</span><span>화면 예시</span></figcaption>
|
<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>
|
<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>
|
||||||
|
|||||||
Reference in new issue
Block a user