Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat/usagestatusmanager] : 이용시간 통계 뷰 구현 #33

Merged
merged 30 commits into from
Jan 4, 2024

Conversation

jihyun0v0
Copy link
Collaborator

@jihyun0v0 jihyun0v0 commented Jan 3, 2024

개요

작업 사항

  • 이용시간 통계 query 구현
  • 이용시간 통계 프로그래스바로 나타내기
  • 이용시간 통계 뷰 ui 구현

변경 사항(optional)

  • 기존에 의진이가 구현했던 DefaultUsageStatsRepository의 getUsageTimeForPackages() 메소드 UsageGoal과의 호환성 때문에 로직 변경 (기능은 같음)

스크린샷(optional)

Screenshot_20240103-162038

기타

  • 텍스트 디자인 등 세부 디자인은 뷰 확정시 수정필요
  • 서버 api배포되면 목표 이용시간(UsageGoal)서버통신 이용해 수정 필요
  • 현재 시간 안나오는 건 공기계 이용시간 너무 적어서(1분 미만) 발생하는 오류. 수정 필요

@jihyun0v0 jihyun0v0 added 💻feat 새로운 기능 추가 🐥지현 지현이 작업 labels Jan 3, 2024
@jihyun0v0 jihyun0v0 self-assigned this Jan 3, 2024
@jihyun0v0 jihyun0v0 requested a review from a team as a code owner January 3, 2024 07:43
Copy link
Member

@kangyuri1114 kangyuri1114 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클릭 아키텍처 열심히 공부한 게 느껴지네요,, 저도 빨리 리팩토링 하겠습니다. 수고하셨어요!

Comment on lines 63 to 66
Log.d("time", time.toString())
Log.d("converted", convertMillisecondsToMinute(time).toString())
Log.d("hour", hour.toString())
Log.d("min", min.toString())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로그가 확인용이라면 확인 후에 push할 때에는 지워줘도 될 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵! 아직 수정할 부분이 남아있을 것 같아 남겨두었습니다! 나중에 로직 완성하면 지우겠습니다~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 이제 지우기 ㄱㄱ?!

Comment on lines 19 to 24
return listOf(
UsageGoalModel("total", 201519990),
UsageGoalModel("com.kakao.talk", 15686 * 2),
UsageGoalModel("com.google.android.gms", 7134),
UsageGoalModel("com.google.android.youtube", 71349),
UsageGoalModel("com.android.chrome", 39445),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저 그냥 궁금해서 그런데 이거는 아직 특정 앱 선택 기능이 없어서 임시적으로 더미데이터로 앱 패키지 값을 넣어주신 것 맞을까요??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 listOf를 변수로 만들고 변수를 return 하는 것으로 수정하면 가독성이 더 좋아질 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞습니다! 서버에서 받아와야 하는 정보인데 일단 급하게 만든 거여서 가독성도 아주,,, bad
수정하겠습니다.

Comment on lines 22 to 26
// for (i in usageStatList.value) {
// Log.d("app name", i.packageName)
// Log.d("total time", i.totalTimeInForeground.toString())
// Log.d("goal time", i.goalTime.toString())
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분도 지워주세요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉스 넴,,,

Comment on lines 18 to 33
binding.tvItemusagestatAppname.text =
context.getAppNameFromPackageName(usageStatAndGoal.packageName)
binding.tvItemusagestatLeftHour.text =
getLeftTimeInString(usageStatAndGoal.totalTimeInForeground, usageStatAndGoal.goalTime)
binding.ivItemusagestatAppicon.setImageDrawable(
context.getAppIconFromPackageName(
usageStatAndGoal.packageName,
),
)
binding.pbItemUsagestat.setProgress(
getUsedPercentage(
usageStatAndGoal.totalTimeInForeground,
usageStatAndGoal.goalTime,
),
)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binidng.~~
을 여러번 쓰는 부분에서는 스코프 함수로
binding.run { ... } 으로 묶어줄 수 있어요!! 가독성을 위해 수정 부탁드립니답

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 감사합니다!

Copy link

@jumining jumining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

짱빠르다 안드..놀랍다..

@kez-lab
Copy link
Member

kez-lab commented Jan 4, 2024

짱빠르다 안드..놀랍다..

ㅋㅋㅋㅋㅋㅋ 대장님 반갑습니당

Copy link
Member

@kez-lab kez-lab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코멘트 확인하고 리마인드 부탁드려요~!!
특히 도메인 코드 너무 좋았습니당

Comment on lines 63 to 66
Log.d("time", time.toString())
Log.d("converted", convertMillisecondsToMinute(time).toString())
Log.d("hour", hour.toString())
Log.d("min", min.toString())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 이제 지우기 ㄱㄱ?!

Comment on lines 72 to 88
fun getUsedPercentage(
usage: Long,
goal: Long,
): Int {
try {
return (usage * 100 / goal).toInt()
} catch (e: ArithmeticException) {
return 0
}
}

fun getLeftTimeInString(
usage: Long,
goal: Long,
): String {
return convertTimeToString(goal - usage)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 함수들이 해당 파일에 있는 것이 맞을까요?? 관심사가 조금 다른 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네! 어제 스크럼 이후에 수정하려 했는데 아직 못했네요. 오늘 스크럼 전까지 해서 올리겠습니다!

Comment on lines 18 to 27
fun provideUsageGoalModels(): List<UsageGoalModel> {
val usageGoalList = listOf(
UsageGoalModel("total", 201519990),
UsageGoalModel("com.kakao.talk", 15686 * 2),
UsageGoalModel("com.google.android.gms", 7134),
UsageGoalModel("com.google.android.youtube", 71349),
UsageGoalModel("com.android.chrome", 39445),
)
return usageGoalList
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음 이렇게 주입해줄거면 차라리 데이터 소스쪽에서 get하는 함수내에서 선언해주는 것이 더 좋을 것 같습니다, 그냥 싱글톤구조에 list넣어둔 것과 다른게 없어보여요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 수정하겠습니다!

Comment on lines 8 to 44
class StaticsUseCase
@Inject
constructor(
private val usageStatsRepository: UsageStatsRepository,
private val usageGoalsRepository: UsageGoalsRepository,
) {
fun getStatics(
startTime: Long,
endTime: Long,
): List<UsageStatAndGoal> {
val totalUsage =
getTotalUsage(startTime, endTime)
val appUsageStat =
getAppUsageStat(startTime, endTime)
val totalUsageStatAndGoal =
UsageStatAndGoal("total", totalUsage, usageGoalsRepository.getUsageGoalTime("total"))
return listOf(totalUsageStatAndGoal) + appUsageStat
}

private fun getAppUsageStat(
startTime: Long,
endTime: Long,
): List<UsageStatAndGoal> {
val appList = getAppList()

val usageStatAndGoal =
usageStatsRepository.getUsageTimeForPackages(startTime, endTime, appList).map {
UsageStatAndGoal(
it.packageName,
it.totalTimeInForeground,
usageGoalsRepository.getUsageGoalTime(it.packageName),
)
}
return usageStatAndGoal
}

private fun getTotalUsage(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

도메인 로직이 좀 장난 아닌데요? 이런 구조를 생각하시고 개발하신 우리 팀원 너무 든든합니다 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의진 스승님 코드 따라해보았읍니다. 더 가르쳐주십시오 꾸벅

Comment on lines 14 to 16
) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(usageStatAndGoal: UsageStatAndGoal) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

줄바꿈 무언가 이상합니다?!?! 혹시 셋팅이...!!??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

허거덩 확인해보겠습니다

@l2hyunwoo
Copy link

짱빠르다 안드..놀랍다..

@jumining 우리 의진이 잘 부탁한다

@kez-lab
Copy link
Member

kez-lab commented Jan 4, 2024

컨플릿 제가 해결할게요

# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/hmh/hamyeonham/SampleActivity.kt
#	settings.gradle.kts
@kez-lab kez-lab force-pushed the feat/usagestatusmanager branch from 451d3b0 to e8a97ea Compare January 4, 2024 13:05
Copy link
Member

@kez-lab kez-lab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨어요~!!

@kez-lab kez-lab merged commit 0c717a6 into develop Jan 4, 2024
1 check passed
@kez-lab kez-lab deleted the feat/usagestatusmanager branch January 4, 2024 14:23
@jihyun0v0 jihyun0v0 changed the title [Feat/usagestatusmanager] : 이용시간 통계 뷰 구현 [feat/usagestatusmanager] : 이용시간 통계 뷰 구현 Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐥지현 지현이 작업 💻feat 새로운 기능 추가
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[feat] : 이용시간 통계 뷰 [feat]: UsageStatsManager data module 추가
5 participants