Today's

길을 나서지 않으면 그 길에서 만날 수 있는 사람을 만날 수 없다

모바일 앱(안드로이드)

습관관리 앱, 개발 작업 일지

Billcorea 2025. 10. 14. 15:44
반응형

 

 

습관관리 앱, 개발 작업 일지

 

1. 하드코딩된 한글 문자열의 strings.xml 이전

  • 앱 내 하드코딩된 한글 텍스트를 strings.xml로 이동하여 다국어 지원 및 유지보수성을 개선함.

개발앱 이미지

 

2. AlertDialog를 MaterialDialog로 변경

  • 기존 AlertDialogcom.afollestad.material-dialogs 라이브러리의 MaterialDialog로 교체.
  • 다이얼로그의 테마와 색상 문제를 해결하기 위해 theme 속성 및 color.xml을 활용하는 방법을 검토함.

3. 다이얼로그 색상 및 테마 적용

  • MaterialDialog에서 배경색 투명 문제 발생 시, theme를 지정하거나 color.xml의 색상 리소스를 활용하여 해결.
  • MaterialDialog의 md_title_color 등 속성은 color.xml에 정의된 색상과 일치시켜 사용하도록 권장.

4. color.xml과 color.kt 색상 동기화

  • color.kt에 정의된 색상과 color.xml의 색상 코드가 일치하도록 정리.
  • 누락된 색상은 color.kt 기준으로 color.xml에 추가함.

5. 홈 화면 뒤로가기 버튼 다이얼로그 추가

  • 홈 화면에서 뒤로가기 버튼 클릭 시 앱 종료 여부를 확인하는 MaterialDialog를 추가.
  • 사용자가 "확인"을 누르면 앱이 종료되고, "취소"를 누르면 다이얼로그가 닫힘.

6. 기타 작업 및 오류 해결

  • MaterialDialog 관련 타입 오류(Argument type mismatch, Cannot infer type) 및 리소스 오류(Cannot resolve symbol 'md_title_color')를 해결.
  • 다이얼로그 중복 호출 방지 로직 추가.

7. 코드 예시

// 뒤로가기 버튼 다이얼로그 예시
BackHandler {
    showExitDialog = true
}
if (showExitDialog) {
    MaterialDialog(context).show {
        title(text = context.getString(R.string.dialog_exit_confirm))
        message(text = context.getString(R.string.exit_app_dialog_message))
        positiveButton(text = context.getString(R.string.dialog_exit_confirm)) {
            (context as? Activity)?.finish()
            showExitDialog = false
        }
        negativeButton(text = context.getString(R.string.dialog_cancel)) {
            showExitDialog = false
        }
    }
    showExitDialog = false
}

8. 결론

  • 오늘 작업을 통해 UI 일관성, 유지보수성, 사용자 경험이 크게 향상됨.
  • MaterialDialog와 리소스 관리 방법을 숙지하여 향후 확장 및 수정이 용이해짐.
반응형