-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from Team-HMH/release/0.0.2
[release]: release 0.0.2 ์์ finish
- Loading branch information
Showing
25 changed files
with
262 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/hmh/hamyeonham/di/NavigatorModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.hmh.hamyeonham.di | ||
|
||
import com.hmh.hamyeonham.common.navigation.NavigationProvider | ||
import com.hmh.hamyeonham.navigation.DefaultNavigationProvider | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
interface NavigatorModule { | ||
@Binds | ||
@Singleton | ||
fun bindNavigator(navigator: DefaultNavigationProvider): NavigationProvider | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/main/java/com/hmh/hamyeonham/navigation/DefaultNavigationProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.hmh.hamyeonham.navigation | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import com.hmh.hamyeonham.common.navigation.NavigationProvider | ||
import com.hmh.hamyeonham.feature.login.LoginActivity | ||
import com.hmh.hamyeonham.feature.login.UserInfoActivity | ||
import com.hmh.hamyeonham.feature.onboarding.OnBoardingActivity | ||
import com.hmh.hamyeonham.statistics.StaticsActivity | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
|
||
class DefaultNavigationProvider @Inject constructor( | ||
@ApplicationContext private val context: Context | ||
) : NavigationProvider { | ||
override fun toOnboarding(): Intent { | ||
return Intent(context, OnBoardingActivity::class.java) | ||
} | ||
|
||
override fun toLogin(): Intent { | ||
return Intent(context, LoginActivity::class.java) | ||
} | ||
|
||
override fun toUserInfo(): Intent { | ||
return Intent(context, UserInfoActivity::class.java) | ||
} | ||
|
||
override fun toStatics(): Intent { | ||
return Intent(context, StaticsActivity::class.java) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 7 additions & 15 deletions
22
...usagestats/src/main/java/com/hmh/hamyeonham/usagestats/datasource/UsageGoalsDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
package com.hmh.hamyeonham.usagestats.datasource | ||
|
||
import com.hmh.hamyeonham.usagestats.model.UsageGoalModel | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
import javax.inject.Inject | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
class UsageGoalsDataSource { | ||
@Provides | ||
@Singleton | ||
class UsageGoalsDataSource @Inject constructor() { | ||
fun getUsageGoals(): List<UsageGoalModel> { | ||
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), | ||
UsageGoalModel("total", 9459489), | ||
UsageGoalModel("com.kakao.talk", 10737116), | ||
UsageGoalModel("com.google.android.gms", 10607821), | ||
UsageGoalModel("com.google.android.youtube", 7409658), | ||
UsageGoalModel("com.android.chrome", 9346527), | ||
) | ||
} | ||
} |
9 changes: 5 additions & 4 deletions
9
...ats/src/main/java/com/hmh/hamyeonham/usagestats/repository/DefaultUsageGoalsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
package com.hmh.hamyeonham.usagestats.repository | ||
|
||
import com.hmh.hamyeonham.usagestats.datasource.UsageGoalsDataSource | ||
import com.hmh.hamyeonham.usagestats.model.UsageGoal | ||
import com.hmh.hamyeonham.usagestats.model.UsageGoalModel | ||
import javax.inject.Inject | ||
|
||
class DefaultUsageGoalsRepository @Inject constructor( | ||
private val usageGoalList: List<UsageGoalModel>, | ||
private val usageGoalsDataSource: UsageGoalsDataSource | ||
) : UsageGoalsRepository { | ||
override fun getUsageGoals(): List<UsageGoal> { | ||
return usageGoalList.map { | ||
return usageGoalsDataSource.getUsageGoals().map { | ||
UsageGoal(it.packageName, it.goalTime) | ||
} | ||
} | ||
|
||
override fun getUsageGoalTime(packageName: String): Long { | ||
return usageGoalList.firstOrNull { it.packageName == packageName }?.goalTime ?: 0 | ||
return usageGoalsDataSource.getUsageGoals() | ||
.firstOrNull { it.packageName == packageName }?.goalTime ?: 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 61 additions & 46 deletions
107
...nham/usagestats/usecase/StaticsUseCase.kt โ ...stats/usecase/GetUsageStatsListUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,61 @@ | ||
package com.hmh.hamyeonham.usagestats.usecase | ||
|
||
import com.hmh.hamyeonham.usagestats.model.UsageStatAndGoal | ||
import com.hmh.hamyeonham.usagestats.repository.UsageGoalsRepository | ||
import com.hmh.hamyeonham.usagestats.repository.UsageStatsRepository | ||
import javax.inject.Inject | ||
|
||
class StaticsUseCase @Inject constructor( | ||
private val usageStatsRepository: UsageStatsRepository, | ||
private val usageGoalsRepository: UsageGoalsRepository, | ||
) { | ||
fun getUsageStatsAndGoals( | ||
startTime: Long, | ||
endTime: Long, | ||
): List<UsageStatAndGoal> { | ||
val totalUsage = getTotalUsage(startTime, endTime) | ||
val usageForSelectedApps = getUsageStatsAndGoalsForSelectedApps(startTime, endTime) | ||
val totalUsageStatAndGoal = | ||
UsageStatAndGoal("total", totalUsage, usageGoalsRepository.getUsageGoalTime("total")) | ||
return listOf(totalUsageStatAndGoal) + usageForSelectedApps | ||
} | ||
|
||
private fun getUsageStatsAndGoalsForSelectedApps( | ||
startTime: Long, | ||
endTime: Long, | ||
): List<UsageStatAndGoal> { | ||
val appList = getSelectedAppList() | ||
return usageStatsRepository.getUsageTimeForPackages(startTime, endTime, appList).map { | ||
UsageStatAndGoal( | ||
it.packageName, | ||
it.totalTimeInForeground, | ||
usageGoalsRepository.getUsageGoalTime(it.packageName), | ||
) | ||
} | ||
} | ||
|
||
private fun getTotalUsage( | ||
startTime: Long, | ||
endTime: Long, | ||
): Long = usageStatsRepository.getUsageStats(startTime, endTime).sumOf { | ||
it.totalTimeInForeground | ||
} | ||
|
||
private fun getSelectedAppList(): List<String> = | ||
usageGoalsRepository.getUsageGoals().map { it.packageName } | ||
} | ||
package com.hmh.hamyeonham.usagestats.usecase | ||
|
||
import com.hmh.hamyeonham.usagestats.model.UsageStatAndGoal | ||
import com.hmh.hamyeonham.usagestats.repository.UsageGoalsRepository | ||
import com.hmh.hamyeonham.usagestats.repository.UsageStatsRepository | ||
import javax.inject.Inject | ||
|
||
class GetUsageStatsListUseCase @Inject constructor( | ||
private val usageStatsRepository: UsageStatsRepository, | ||
private val usageGoalsRepository: UsageGoalsRepository, | ||
) { | ||
|
||
companion object { | ||
private const val TOTAL = "total" | ||
} | ||
|
||
fun getUsageStatsAndGoals( | ||
startTime: Long, | ||
endTime: Long, | ||
): List<UsageStatAndGoal> { | ||
val totalUsage = getTotalUsage(startTime, endTime) | ||
val usageForSelectedApps = getUsageStatsAndGoalsForSelectedApps(startTime, endTime) | ||
val totalUsageStatAndGoal = | ||
UsageStatAndGoal(TOTAL, totalUsage, usageGoalsRepository.getUsageGoalTime(TOTAL)) | ||
return listOf(totalUsageStatAndGoal) + usageForSelectedApps | ||
} | ||
|
||
private fun getUsageStatsAndGoalsForSelectedApps( | ||
startTime: Long, | ||
endTime: Long, | ||
): List<UsageStatAndGoal> { | ||
val appList = getSelectedPackageList() | ||
return usageStatsRepository.getUsageTimeForPackages(startTime, endTime, appList) | ||
.map { | ||
createUsageStatAndGoal( | ||
it.packageName, | ||
it.totalTimeInForeground, | ||
it.packageName | ||
) | ||
} | ||
} | ||
|
||
private fun getTotalUsage( | ||
startTime: Long, | ||
endTime: Long, | ||
): Long = usageStatsRepository.getUsageStats(startTime, endTime).sumOf { | ||
it.totalTimeInForeground | ||
} | ||
|
||
private fun getSelectedPackageList(): List<String> = | ||
usageGoalsRepository.getUsageGoals().map { it.packageName }.distinct() | ||
|
||
private fun createUsageStatAndGoal( | ||
packageName: String, | ||
totalTimeInForeground: Long, | ||
goalKey: String | ||
): UsageStatAndGoal { | ||
val goalTime = usageGoalsRepository.getUsageGoalTime(goalKey) | ||
return UsageStatAndGoal(packageName, totalTimeInForeground, goalTime) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,4 @@ android { | |
|
||
dependencies { | ||
implementation(projects.core.common) | ||
implementation(projects.feature.login) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/LockActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.hmh.hamyeonham.feature.onboarding | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.hmh.hamyeonham.common.context.toast | ||
import com.hmh.hamyeonham.common.view.viewBinding | ||
import com.hmh.hamyeonham.feature.onboarding.databinding.ActivityLockBinding | ||
|
||
class LockActivity : AppCompatActivity() { | ||
private val binding by viewBinding(ActivityLockBinding::inflate) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(binding.root) | ||
|
||
binding.btnLock.setOnClickListener { | ||
toast("์ ํ๋ธ ์ ๊ธ ์ค์ ์๋ฃ") | ||
} | ||
} | ||
} |
Oops, something went wrong.