diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cd7c149d..7db67c0e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">
+
{
+ AmplitudeUtils.trackEventWithProperties("click_edit_button")
viewModel.updateModifierState(ModifierState.EDIT)
}
@@ -169,13 +174,14 @@ class ChallengeFragment : Fragment() {
private fun initChallengeCreateButton() {
binding.btnChallengeCreate.setOnClickListener {
+ AmplitudeUtils.trackEventWithProperties("click_newchallenge_button")
if (activityViewModel.isPointLeftToCollect) {
snackBarWithAction(
anchorView = binding.root,
message = getString(com.hmh.hamyeonham.feature.challenge.R.string.challenge_cannot_create),
actionMessage = getString(
- com.hmh.hamyeonham.feature.challenge.R.string.all_move
- )
+ com.hmh.hamyeonham.feature.challenge.R.string.all_move,
+ ),
) {
navigateToPointView()
}
@@ -226,13 +232,12 @@ class ChallengeFragment : Fragment() {
tvChallengeStartDate.text = getString(
com.hmh.hamyeonham.feature.challenge.R.string.challenge_start_date,
startDate.monthNumber,
- startDate.dayOfMonth
+ startDate.dayOfMonth,
+ )
+ tvChallengeDay.text = getString(
+ com.hmh.hamyeonham.feature.challenge.R.string.challenge_day,
+ todayIndexAsDate,
)
- tvChallengeDay.text =
- getString(
- com.hmh.hamyeonham.feature.challenge.R.string.challenge_day,
- todayIndexAsDate
- )
}
}
@@ -262,8 +267,8 @@ class ChallengeFragment : Fragment() {
activityViewModel.generateNewChallenge(
NewChallenge(
period = period ?: 0,
- goalTime = goalTime ?: 0
- )
+ goalTime = goalTime ?: 0,
+ ),
)
}
}
@@ -310,14 +315,18 @@ class ChallengeFragment : Fragment() {
binding.rvAppUsageGoals.run {
adapter = ChallengeUsageGoalsAdapter(
onAppListAddClicked = {
+ AmplitudeUtils.trackEventWithProperties("click_add_button")
val intent = Intent(requireContext(), AppAddActivity::class.java)
appSelectionResultLauncher.launch(intent)
},
onAppItemClicked = { challengeGoal ->
when (viewModel.challengeState.value.modifierState) {
ModifierState.EDIT -> {
- if (challengeGoal.isDeletable) setDeleteAppDialog(challengeGoal.usageStatusAndGoal)
- else toast(getString(com.hmh.hamyeonham.feature.challenge.R.string.challenge_cannot_delete))
+ if (challengeGoal.isDeletable) {
+ setDeleteAppDialog(challengeGoal.usageStatusAndGoal)
+ } else {
+ toast(getString(com.hmh.hamyeonham.feature.challenge.R.string.challenge_cannot_delete))
+ }
}
else -> Unit
diff --git a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/ChallengeViewModel.kt b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/ChallengeViewModel.kt
index 6a1c1654..d96a3e19 100644
--- a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/ChallengeViewModel.kt
+++ b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/ChallengeViewModel.kt
@@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope
import com.hmh.hamyeonham.challenge.model.Apps
import com.hmh.hamyeonham.challenge.usecase.AddUsageGoalsUseCase
import com.hmh.hamyeonham.challenge.usecase.DeleteUsageGoalUseCase
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.core.domain.usagegoal.model.UsageGoal
import com.hmh.hamyeonham.core.viewmodel.CalendarToggleState
import com.hmh.hamyeonham.usagestats.model.UsageStatusAndGoal
@@ -40,7 +41,8 @@ data class ChallengeUsageGoal(
}
enum class ModifierState {
- EDIT, DONE,
+ EDIT,
+ DONE,
}
@HiltViewModel
@@ -48,9 +50,8 @@ class ChallengeViewModel @Inject constructor(
private val addUsageGoalsUseCase: AddUsageGoalsUseCase,
private val deleteUsageGoalUseCase: DeleteUsageGoalUseCase,
private val deletedAppUsageStoreUseCase: DeletedAppUsageStoreUseCase,
- private val checkAndDeleteDeletedAppUsageUseCase: CheckAndDeleteDeletedAppUsageUseCase
+ private val checkAndDeleteDeletedAppUsageUseCase: CheckAndDeleteDeletedAppUsageUseCase,
) : ViewModel() {
-
private val _challengeState = MutableStateFlow(ChallengeState())
val challengeState = _challengeState.asStateFlow()
@@ -70,17 +71,25 @@ class ChallengeViewModel @Inject constructor(
fun addApp(apps: Apps) {
viewModelScope.launch {
- addUsageGoalsUseCase(apps)
+ runCatching {
+ addUsageGoalsUseCase(apps)
+ }.onSuccess {
+ AmplitudeUtils.trackEventWithProperties("complete_add_new")
+ }
checkAndDeleteDeletedAppUsageUseCase(apps.apps.map { it.appCode })
}
}
fun deleteApp(usageStatusAndGoal: UsageStatusAndGoal.App) {
viewModelScope.launch {
- deleteUsageGoalUseCase(usageStatusAndGoal.packageName)
+ runCatching {
+ deleteUsageGoalUseCase(usageStatusAndGoal.packageName)
+ }.onSuccess {
+ AmplitudeUtils.trackEventWithProperties("click_delete_complete")
+ }
deletedAppUsageStoreUseCase(
usageStatusAndGoal.usageTime,
- usageStatusAndGoal.packageName
+ usageStatusAndGoal.packageName,
)
}
}
@@ -96,5 +105,4 @@ class ChallengeViewModel @Inject constructor(
}
}
}
-
}
diff --git a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/appadd/AppAddActivity.kt b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/appadd/AppAddActivity.kt
index 0c6a4e5d..1396d617 100644
--- a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/appadd/AppAddActivity.kt
+++ b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/appadd/AppAddActivity.kt
@@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.feature.challenge.databinding.ActivityAppAddBinding
import dagger.hilt.android.AndroidEntryPoint
@@ -15,7 +16,6 @@ import kotlinx.coroutines.flow.onEach
@AndroidEntryPoint
class AppAddActivity : AppCompatActivity() {
-
companion object {
const val SELECTED_APPS = "selected_apps"
const val GOAL_TIME = "goal_time"
@@ -24,6 +24,11 @@ class AppAddActivity : AppCompatActivity() {
private val binding by viewBinding(ActivityAppAddBinding::inflate)
private val viewModel by viewModels()
+ override fun onResume() {
+ super.onResume()
+ AmplitudeUtils.trackEventWithProperties("view_add_totaltime")
+ }
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
@@ -40,16 +45,14 @@ class AppAddActivity : AppCompatActivity() {
btAppSelection.setOnClickListener { handleNextClicked() }
ivBack.setOnClickListener { finish() }
}
-
}
private fun collectState() {
- viewModel.isNextButtonActive.flowWithLifecycle(lifecycle)
- .onEach { binding.btAppSelection.isEnabled = it }
- .launchIn(lifecycleScope)
+ viewModel.isNextButtonActive.flowWithLifecycle(lifecycle).onEach {
+ binding.btAppSelection.isEnabled = it
+ }.launchIn(lifecycleScope)
}
-
private fun collectEffect() {
viewModel.effect.flowWithLifecycle(lifecycle).onEach {
when (it) {
@@ -67,7 +70,6 @@ class AppAddActivity : AppCompatActivity() {
}.launchIn(lifecycleScope)
}
-
private fun handleNextClicked() {
binding.vpAppAdd.run {
when (currentItem) {
diff --git a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/NewChallengeActivity.kt b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/NewChallengeActivity.kt
index a8cc7995..a865f76a 100644
--- a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/NewChallengeActivity.kt
+++ b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/NewChallengeActivity.kt
@@ -7,14 +7,15 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.hmh.hamyeonham.common.dialog.OneButtonCommonDialog
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.feature.challenge.R
import com.hmh.hamyeonham.feature.challenge.databinding.ActivityNewChallengeBinding
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
+import org.json.JSONObject
class NewChallengeActivity : AppCompatActivity() {
-
private val binding by viewBinding(ActivityNewChallengeBinding::inflate)
private val viewModel by viewModels()
@@ -35,7 +36,16 @@ class NewChallengeActivity : AppCompatActivity() {
vpNewChallenge.adapter = NewChallengeViewPagerAdapter(this@NewChallengeActivity)
vpNewChallenge.isUserInputEnabled = false
- btNewChallenge.setOnClickListener { handleNextClicked() }
+ btNewChallenge.setOnClickListener {
+ handleNextClicked()
+ if (vpNewChallenge.adapter?.itemCount == FRAGMENT.PERIODSELECTION.position) {
+ val properties = JSONObject().put("period", viewModel.state.value.goalDate)
+ AmplitudeUtils.trackEventWithProperties(
+ "click_newchallenge_totaltime",
+ properties
+ )
+ }
+ }
ivBack.setOnClickListener { finish() }
}
}
@@ -50,9 +60,9 @@ class NewChallengeActivity : AppCompatActivity() {
}
private fun collectNewChallengeState() {
- viewModel.state.flowWithLifecycle(lifecycle)
- .onEach { binding.btNewChallenge.isEnabled = it.isNextButtonActive }
- .launchIn(lifecycleScope)
+ viewModel.state.flowWithLifecycle(lifecycle).onEach {
+ binding.btNewChallenge.isEnabled = it.isNextButtonActive
+ }.launchIn(lifecycleScope)
}
private fun showChallengeCreatedDialog() {
@@ -77,4 +87,4 @@ class NewChallengeActivity : AppCompatActivity() {
setResult(RESULT_OK, intent)
finish()
}
-}
\ No newline at end of file
+}
diff --git a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/timeselection/TimeSelectionFragment.kt b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/timeselection/TimeSelectionFragment.kt
index ce17fbda..c6f0d9d8 100644
--- a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/timeselection/TimeSelectionFragment.kt
+++ b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/newchallenge/timeselection/TimeSelectionFragment.kt
@@ -8,6 +8,7 @@ import android.widget.NumberPicker
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import com.hmh.hamyeonham.challenge.newchallenge.NewChallengeViewModel
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.time.hourToMs
import com.hmh.hamyeonham.common.view.setupScreentimeGoalRange
import com.hmh.hamyeonham.common.view.viewBinding
@@ -17,6 +18,11 @@ class TimeSelectionFragment : Fragment() {
private val binding by viewBinding(FragmentTimeSelectionBinding::bind)
private val viewModel by activityViewModels()
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ AmplitudeUtils.trackEventWithProperties("view_newchallenge_totaltime")
+ }
+
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@@ -45,4 +51,4 @@ class TimeSelectionFragment : Fragment() {
val MINTOTAL = 1
val MAXTOTAL = 6
}
-}
\ No newline at end of file
+}
diff --git a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/point/PointActivity.kt b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/point/PointActivity.kt
index f88769d2..ca0e482c 100644
--- a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/point/PointActivity.kt
+++ b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/point/PointActivity.kt
@@ -6,6 +6,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.feature.challenge.databinding.ActivityPointBinding
import dagger.hilt.android.AndroidEntryPoint
@@ -17,6 +18,11 @@ class PointActivity : AppCompatActivity() {
private val binding by viewBinding(ActivityPointBinding::inflate)
private val viewModel by viewModels()
+ override fun onResume() {
+ super.onResume()
+ AmplitudeUtils.trackEventWithProperties("view_point")
+ }
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
@@ -49,17 +55,15 @@ class PointActivity : AppCompatActivity() {
}
private fun collectPointInfo() {
- viewModel.pointInfoList.flowWithLifecycle(lifecycle)
- .onEach { pointInfoList ->
- (binding.rvPoint.adapter as? PointAdapter)?.submitList(pointInfoList)
- }.launchIn(lifecycleScope)
+ viewModel.pointInfoList.flowWithLifecycle(lifecycle).onEach { pointInfoList ->
+ (binding.rvPoint.adapter as? PointAdapter)?.submitList(pointInfoList)
+ }.launchIn(lifecycleScope)
}
private fun collectUserPoint() {
- viewModel.currentPointState.flowWithLifecycle(lifecycle)
- .onEach {
- binding.tvPointTotal.text = it.toString()
- setResult(RESULT_OK, intent.putExtra("point", it))
- }.launchIn(lifecycleScope)
+ viewModel.currentPointState.flowWithLifecycle(lifecycle).onEach {
+ binding.tvPointTotal.text = it.toString()
+ setResult(RESULT_OK, intent.putExtra("point", it))
+ }.launchIn(lifecycleScope)
}
}
diff --git a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/point/PointViewModel.kt b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/point/PointViewModel.kt
index ed3f4bc0..3b65a52c 100644
--- a/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/point/PointViewModel.kt
+++ b/feature/challenge/src/main/java/com/hmh/hamyeonham/challenge/point/PointViewModel.kt
@@ -2,19 +2,20 @@ package com.hmh.hamyeonham.challenge.point
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.domain.point.model.PointInfo
import com.hmh.hamyeonham.domain.point.repository.PointRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
+import org.json.JSONObject
import javax.inject.Inject
-
@HiltViewModel
-class PointViewModel @Inject constructor(private val pointRepository: PointRepository) :
- ViewModel() {
-
+class PointViewModel @Inject constructor(
+ private val pointRepository: PointRepository,
+) : ViewModel() {
private val _currentUserPoint = MutableStateFlow(0)
val currentPointState = _currentUserPoint.asStateFlow()
@@ -28,6 +29,8 @@ class PointViewModel @Inject constructor(private val pointRepository: PointRepos
fun earnChallengePoint(challengeDate: String) {
viewModelScope.launch {
pointRepository.earnPoint(challengeDate).onSuccess {
+ val properties = JSONObject().put("get_point_date", challengeDate)
+ AmplitudeUtils.trackEventWithProperties("click_getpoint_button", properties)
getPointInfoList()
}
}
@@ -42,4 +45,3 @@ class PointViewModel @Inject constructor(private val pointRepository: PointRepos
}
}
}
-
diff --git a/feature/lock/src/main/java/com/hmh/hamyeonham/feature/lock/LockScreen.kt b/feature/lock/src/main/java/com/hmh/hamyeonham/feature/lock/LockScreen.kt
index 2c08a924..4e8b2624 100644
--- a/feature/lock/src/main/java/com/hmh/hamyeonham/feature/lock/LockScreen.kt
+++ b/feature/lock/src/main/java/com/hmh/hamyeonham/feature/lock/LockScreen.kt
@@ -21,6 +21,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.context.getAppNameFromPackageName
import com.hmh.hamyeonham.feature.lock.ui.theme.Blackground
import com.hmh.hamyeonham.feature.lock.ui.theme.BluePurpleButton
@@ -37,6 +38,7 @@ fun LockScreen(
onClickClose: () -> Unit = {},
onClickUnLock: () -> Unit = {},
) {
+ AmplitudeUtils.trackEventWithProperties("view_unlock_popup")
Box(
modifier = Modifier
.fillMaxSize()
@@ -55,7 +57,9 @@ fun LockScreen(
AsyncImage(
model = R.drawable.lock_on,
contentDescription = "LockScreen Icon",
- modifier = Modifier.padding(bottom = 48.dp).size(120.dp),
+ modifier = Modifier
+ .padding(bottom = 48.dp)
+ .size(120.dp),
)
Text(
text = stringResource(R.string.target_usage_time_end),
@@ -80,7 +84,9 @@ fun LockScreen(
stringResource(R.string.remind_alarm_permission),
style = TextStyle(textAlign = TextAlign.Center).merge(HmhTypography.bodySmall),
color = Gray3,
- modifier = Modifier.padding(vertical = 21.dp).align(Alignment.CenterHorizontally),
+ modifier = Modifier
+ .padding(vertical = 21.dp)
+ .align(Alignment.CenterHorizontally),
)
Button(
colors = ButtonDefaults.buttonColors(containerColor = BluePurpleButton),
@@ -99,7 +105,11 @@ fun LockScreen(
)
}
Text(
- modifier = Modifier.clickable(onClick = onClickUnLock)
+ modifier = Modifier
+ .clickable(onClick = {
+ onClickUnLock()
+ AmplitudeUtils.trackEventWithProperties("click_unlock_button")
+ })
.padding(top = 22.dp, bottom = 58.dp),
text = stringResource(R.string.do_unlock),
style = HmhTypography.titleSmall,
@@ -107,4 +117,4 @@ fun LockScreen(
)
}
}
-}
\ No newline at end of file
+}
diff --git a/feature/login/src/main/java/com/hmh/hamyeonham/feature/login/LoginViewModel.kt b/feature/login/src/main/java/com/hmh/hamyeonham/feature/login/LoginViewModel.kt
index b06b84bc..16ba0a18 100644
--- a/feature/login/src/main/java/com/hmh/hamyeonham/feature/login/LoginViewModel.kt
+++ b/feature/login/src/main/java/com/hmh/hamyeonham/feature/login/LoginViewModel.kt
@@ -3,6 +3,7 @@ package com.hmh.hamyeonham.feature.login
import android.content.Context
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.core.database.manger.DatabaseManager
import com.hmh.hamyeonham.core.network.auth.datastore.network.HMHNetworkPreference
import com.hmh.hamyeonham.login.repository.AuthRepository
@@ -20,7 +21,9 @@ import javax.inject.Inject
sealed interface LoginEffect {
data object LoginSuccess : LoginEffect
+
data object LoginFail : LoginEffect
+
data class RequireSignUp(val token: String) : LoginEffect
}
@@ -34,7 +37,6 @@ class LoginViewModel @Inject constructor(
private val hmhNetworkPreference: HMHNetworkPreference,
private val databaseManager: DatabaseManager,
) : ViewModel() {
-
private val _kakaoLoginEvent = MutableSharedFlow()
val kakaoLoginEvent = _kakaoLoginEvent.asSharedFlow()
@@ -62,23 +64,26 @@ class LoginViewModel @Inject constructor(
loginWithKakaoAccount(context)
} else if (token != null) {
viewModelScope.launch {
- authRepository.login(token.accessToken).onSuccess {
- hmhNetworkPreference.run {
- accessToken = it.accessToken
- refreshToken = it.refreshToken
- userId = it.userId
- autoLoginConfigured = true
- }
- _kakaoLoginEvent.emit(LoginEffect.LoginSuccess)
- }.onFailure {
- if (it is HttpException && it.code() == 403) {
- hmhNetworkPreference.clear()
- databaseManager.deleteAll()
- _kakaoLoginEvent.emit(LoginEffect.RequireSignUp(token.accessToken))
- } else {
- _kakaoLoginEvent.emit(LoginEffect.LoginFail)
+ authRepository
+ .login(token.accessToken)
+ .onSuccess {
+ hmhNetworkPreference.run {
+ accessToken = it.accessToken
+ refreshToken = it.refreshToken
+ userId = it.userId
+ autoLoginConfigured = true
+ }
+ _kakaoLoginEvent.emit(LoginEffect.LoginSuccess)
+ AmplitudeUtils.trackEventWithProperties("click_onboarding_kakao")
+ }.onFailure {
+ if (it is HttpException && it.code() == 403) {
+ hmhNetworkPreference.clear()
+ databaseManager.deleteAll()
+ _kakaoLoginEvent.emit(LoginEffect.RequireSignUp(token.accessToken))
+ } else {
+ _kakaoLoginEvent.emit(LoginEffect.LoginFail)
+ }
}
- }
}
}
}
@@ -93,23 +98,26 @@ class LoginViewModel @Inject constructor(
// 닉네임 정보 얻기 실패 시
} else if (token != null) {
viewModelScope.launch {
- authRepository.login(token.accessToken).onSuccess {
- hmhNetworkPreference.run {
- accessToken = it.accessToken
- refreshToken = it.refreshToken
- userId = it.userId
- autoLoginConfigured = true
- }
- _kakaoLoginEvent.emit(LoginEffect.LoginSuccess)
- }.onFailure {
- if (it is HttpException && it.code() == 403) {
- hmhNetworkPreference.clear()
- databaseManager.deleteAll()
- _kakaoLoginEvent.emit(LoginEffect.RequireSignUp(token.accessToken))
- } else {
- _kakaoLoginEvent.emit(LoginEffect.LoginFail)
+ authRepository
+ .login(token.accessToken)
+ .onSuccess {
+ hmhNetworkPreference.run {
+ accessToken = it.accessToken
+ refreshToken = it.refreshToken
+ userId = it.userId
+ autoLoginConfigured = true
+ }
+ _kakaoLoginEvent.emit(LoginEffect.LoginSuccess)
+ AmplitudeUtils.trackEventWithProperties("click_onboarding_kakao")
+ }.onFailure {
+ if (it is HttpException && it.code() == 403) {
+ hmhNetworkPreference.clear()
+ databaseManager.deleteAll()
+ _kakaoLoginEvent.emit(LoginEffect.RequireSignUp(token.accessToken))
+ } else {
+ _kakaoLoginEvent.emit(LoginEffect.LoginFail)
+ }
}
- }
}
}
}
diff --git a/feature/main/src/main/java/com/hmh/hamyeonham/feature/main/MainActivity.kt b/feature/main/src/main/java/com/hmh/hamyeonham/feature/main/MainActivity.kt
index a23be0e1..3a484024 100644
--- a/feature/main/src/main/java/com/hmh/hamyeonham/feature/main/MainActivity.kt
+++ b/feature/main/src/main/java/com/hmh/hamyeonham/feature/main/MainActivity.kt
@@ -7,6 +7,7 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.context.getAppNameFromPackageName
import com.hmh.hamyeonham.common.context.hasNotificationPermission
import com.hmh.hamyeonham.common.dialog.OneButtonCommonDialog
@@ -71,9 +72,10 @@ class MainActivity : AppCompatActivity() {
private fun checkUnlockedPackage() {
val packageName = intent.getStringExtra(NavigationProvider.UN_LOCK_PACKAGE_NAME) ?: return
TwoButtonCommonDialog.newInstance(
- title = getString(
+ title =
+ getString(
R.string.dialog_title_unlock_package,
- getAppNameFromPackageName(packageName)
+ getAppNameFromPackageName(packageName),
),
description = getString(R.string.dialog_description_unlock_package),
confirmButtonText = getString(com.hmh.hamyeonham.core.designsystem.R.string.all_okay),
@@ -99,9 +101,10 @@ class MainActivity : AppCompatActivity() {
title = getString(R.string.dialog_title_challenge_failed),
description = getString(R.string.dialog_description_challenge_failed),
iconRes = R.drawable.ic_challenge_failed,
- confirmButtonText = getString(com.hmh.hamyeonham.core.designsystem.R.string.all_okay),
+ confirmButtonText = getString(com.hmh.hamyeonham.core.designsystem.R.string.all_done),
).apply {
setConfirmButtonClickListener {
+ AmplitudeUtils.trackEventWithProperties("click_unlock_complete_button")
dismiss()
}
}.showAllowingStateLoss(supportFragmentManager, OneButtonCommonDialog.TAG)
diff --git a/feature/mypage/src/main/java/com/hmh/hamyeonham/mypage/MyPageFragment.kt b/feature/mypage/src/main/java/com/hmh/hamyeonham/mypage/MyPageFragment.kt
index 149c95cf..e3eca1b7 100644
--- a/feature/mypage/src/main/java/com/hmh/hamyeonham/mypage/MyPageFragment.kt
+++ b/feature/mypage/src/main/java/com/hmh/hamyeonham/mypage/MyPageFragment.kt
@@ -11,6 +11,7 @@ import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.dialog.TwoButtonCommonDialog
import com.hmh.hamyeonham.common.fragment.toast
import com.hmh.hamyeonham.common.fragment.viewLifeCycle
@@ -25,6 +26,7 @@ import com.hmh.hamyeonham.mypage.viewmodel.UserEffect
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
+import org.json.JSONObject
import javax.inject.Inject
@AndroidEntryPoint
@@ -59,6 +61,8 @@ class MyPageFragment : Fragment() {
private fun initStoreButton() {
binding.vStore.setOnClickListener {
+ val property = JSONObject().put("view_type", "mypage")
+ AmplitudeUtils.trackEventWithProperties("view_shop", property)
val intent = navigationProvider.toStore()
startActivity(intent)
}
diff --git a/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingActivity.kt b/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingActivity.kt
index e8828091..8086f585 100644
--- a/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingActivity.kt
+++ b/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingActivity.kt
@@ -10,10 +10,12 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.viewpager2.widget.ViewPager2
import androidx.viewpager2.widget.ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.context.toast
import com.hmh.hamyeonham.common.view.setProgressWithAnimation
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.feature.onboarding.adapter.OnBoardingFragmentStateAdapter
+import com.hmh.hamyeonham.feature.onboarding.adapter.OnBoardingFragmentType
import com.hmh.hamyeonham.feature.onboarding.databinding.ActivityOnBoardingBinding
import com.hmh.hamyeonham.feature.onboarding.viewmodel.OnBoardingViewModel
import com.hmh.hamyeonham.feature.onboarding.viewmodel.OnboardEffect
@@ -21,6 +23,7 @@ import com.hmh.hamyeonham.feature.onboarding.viewmodel.OnboardEvent
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
+import org.json.JSONObject
@AndroidEntryPoint
class OnBoardingActivity : AppCompatActivity() {
@@ -88,6 +91,7 @@ class OnBoardingActivity : AppCompatActivity() {
val pagerAdapter = setOnboardingPageAdapter()
binding.btnOnboardingNext.setOnClickListener {
+ AmplitudeUtils.trackEventWithProperties("click_onboarding_next")
viewModel.sendEvent(OnboardEvent.UpdateNextButtonActive(false))
navigateToNextOnboardingStep(pagerAdapter)
}
@@ -113,6 +117,24 @@ class OnBoardingActivity : AppCompatActivity() {
when {
currentItem < lastItem -> {
+ when (OnBoardingFragmentType.entries[currentItem]) {
+ OnBoardingFragmentType.SELECT_SCREEN_TIME_GOAL -> {
+ AmplitudeUtils.trackEventWithProperties("click_challenge_totaltime")
+ }
+ OnBoardingFragmentType.SELECT_DATA_TIME -> {
+ val property = JSONObject().put("answer_value", viewModel.onBoardingState.value.usuallyUseTimeButtonIndex) // Int
+ AmplitudeUtils.trackEventWithProperties("click_survey1_answer", property)
+ }
+ OnBoardingFragmentType.SELECT_DATA_PROBLEM -> {
+ val property = JSONObject().put("answer_value", viewModel.onBoardingState.value.problemsButtonIndex) // List
+ AmplitudeUtils.trackEventWithProperties("click_survey2_answer", property)
+ }
+ OnBoardingFragmentType.SELECT_DATA_PERIOD -> {
+ val property = JSONObject().put("period", viewModel.onBoardingState.value.period)
+ AmplitudeUtils.trackEventWithProperties("click_challenge_period_answer", property)
+ }
+ else -> Unit
+ }
navigateToNextViewPager(viewPager, currentItem)
}
diff --git a/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/fragment/OnBoardingSelectAppFragment.kt b/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/fragment/OnBoardingSelectAppFragment.kt
index c7bb3aa9..cb88cc9e 100644
--- a/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/fragment/OnBoardingSelectAppFragment.kt
+++ b/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/fragment/OnBoardingSelectAppFragment.kt
@@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.feature.onboarding.R
import com.hmh.hamyeonham.feature.onboarding.databinding.FragmentOnBoardingSelectAppBinding
import com.hmh.hamyeonham.feature.onboarding.viewmodel.OnBoardingViewModel
@@ -22,6 +23,7 @@ class OnBoardingSelectAppFragment : Fragment() {
override fun onResume() {
super.onResume()
+ AmplitudeUtils.trackEventWithProperties("view_challenge_app_time")
activityViewModel.sendEvent(OnboardEvent.ChangeActivityButtonText(getString(R.string.all_select_app)))
activityViewModel.sendEvent(OnboardEvent.UpdateNextButtonActive(true))
activityViewModel.sendEvent(OnboardEvent.VisibleProgressbar(true))
diff --git a/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/fragment/OnBoardingSelectDataFragment.kt b/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/fragment/OnBoardingSelectDataFragment.kt
index c1b7baf9..44c29f62 100644
--- a/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/fragment/OnBoardingSelectDataFragment.kt
+++ b/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/fragment/OnBoardingSelectDataFragment.kt
@@ -33,11 +33,13 @@ class OnBoardingSelectDataFragment : Fragment() {
companion object {
private const val ARG_FRAGMENT_TYPE = "ARG_FRAGMENT_TYPE"
+
fun newInstance(fragmentType: OnBoardingFragmentType): OnBoardingSelectDataFragment {
val onBoardingFragment = OnBoardingSelectDataFragment()
- val args = Bundle().apply {
- putString(ARG_FRAGMENT_TYPE, fragmentType.name)
- }
+ val args =
+ Bundle().apply {
+ putString(ARG_FRAGMENT_TYPE, fragmentType.name)
+ }
onBoardingFragment.arguments = args
return onBoardingFragment
}
@@ -47,9 +49,7 @@ class OnBoardingSelectDataFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
- ): View {
- return FragmentOnBoardingSelectDataBinding.inflate(inflater, container, false).root
- }
+ ): View = FragmentOnBoardingSelectDataBinding.inflate(inflater, container, false).root
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@@ -87,7 +87,8 @@ class OnBoardingSelectDataFragment : Fragment() {
binding.btnOnboardingSelectData4,
)
- onboardingFragmentButtonList.forEachIndexed { _, button ->
+ onboardingFragmentButtonList.forEachIndexed { index, button ->
+ button.tag = index + 1
button.setOnClickListener {
toggleButtonSelection(button)
}
@@ -128,15 +129,25 @@ class OnBoardingSelectDataFragment : Fragment() {
private fun updateUserResponse() {
val selectedQuestion = selectedButtons.map { it.text.toString() }
+ val buttonIndices =
+ selectedButtons.map { button ->
+ button.tag as? Int ?: -1
+ }
+
val firstSelected = selectedQuestion.firstOrNull()
+ val buttonIndex = buttonIndices.firstOrNull() ?: -1
when (fragmentType) {
OnBoardingFragmentType.SELECT_DATA_TIME -> {
- activityViewModel.sendEvent(OnboardEvent.UpdateUsuallyUseTime(firstSelected.orEmpty()))
+ activityViewModel.sendEvent(
+ OnboardEvent.UpdateUsuallyUseTime(firstSelected.orEmpty(), buttonIndex),
+ )
}
OnBoardingFragmentType.SELECT_DATA_PROBLEM -> {
- activityViewModel.sendEvent(OnboardEvent.UpdateProblems(selectedQuestion))
+ activityViewModel.sendEvent(
+ OnboardEvent.UpdateProblems(selectedQuestion, buttonIndices),
+ )
}
OnBoardingFragmentType.SELECT_DATA_PERIOD -> {
@@ -151,11 +162,10 @@ class OnBoardingSelectDataFragment : Fragment() {
}
}
- private fun String.toOnboardingFragmentType(): OnBoardingFragmentType {
- return try {
+ private fun String.toOnboardingFragmentType(): OnBoardingFragmentType =
+ try {
OnBoardingFragmentType.valueOf(this)
} catch (e: Exception) {
OnBoardingFragmentType.SELECT_DATA_TIME
}
- }
}
diff --git a/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/viewmodel/OnBoardingViewModel.kt b/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/viewmodel/OnBoardingViewModel.kt
index 0d7e5720..3e790047 100644
--- a/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/viewmodel/OnBoardingViewModel.kt
+++ b/feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/viewmodel/OnBoardingViewModel.kt
@@ -2,6 +2,7 @@ package com.hmh.hamyeonham.feature.onboarding.viewmodel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.time.timeToMs
import com.hmh.hamyeonham.core.network.auth.datastore.network.HMHNetworkPreference
import com.hmh.hamyeonham.login.model.SignRequestDomain
@@ -18,8 +19,13 @@ import kotlinx.coroutines.launch
import javax.inject.Inject
sealed interface OnboardEvent {
- data class UpdateUsuallyUseTime(val usuallyUseTime: String) : OnboardEvent
- data class UpdateProblems(val problems: List) : OnboardEvent
+ data class UpdateUsuallyUseTime(val usuallyUseTime: String, val buttonIndex: Int) : OnboardEvent
+
+ data class UpdateProblems(
+ val problems: List,
+ val buttonIndices: List
+ ) : OnboardEvent
+
data class UpdatePeriod(val period: Int) : OnboardEvent
data class UpdateScreenGoalTime(val screeGoalTime: Int) : OnboardEvent
data class AddApps(val appCode: String) : OnboardEvent
@@ -35,12 +41,15 @@ sealed interface OnboardEvent {
sealed interface OnboardEffect {
data object OnboardSuccess : OnboardEffect
+
data object OnboardFail : OnboardEffect
}
data class OnBoardingState(
val usuallyUseTime: String = "",
+ val usuallyUseTimeButtonIndex: Int = -1,
val problems: List = emptyList(),
+ val problemsButtonIndex: List = emptyList(),
val period: Int = -1,
val screenGoalTime: Int = DEFAULT_SCREEN_TIME,
val appCodeList: List = emptyList(),
@@ -63,24 +72,29 @@ data class OnBoardingState(
}
@HiltViewModel
-class OnBoardingViewModel @Inject constructor(
+class OnBoardingViewModel
+@Inject
+constructor(
private val authRepository: AuthRepository,
private val hmhNetworkPreference: HMHNetworkPreference,
) : ViewModel() {
-
private val _onBoardingState = MutableStateFlow(OnBoardingState())
val onBoardingState = _onBoardingState.asStateFlow()
private val _onboardEffect = MutableSharedFlow()
val onboardEffect = _onboardEffect.asSharedFlow()
- val isAppAddSelectionScreenButtonEnabled = onBoardingState.map {
- onBoardingState -> onBoardingState.appCodeList.isNotEmpty()
- }.stateIn(viewModelScope, SharingStarted.Lazily, false)
+ val isAppAddSelectionScreenButtonEnabled =
+ onBoardingState
+ .map { onBoardingState ->
+ onBoardingState.appCodeList.isNotEmpty()
+ }.stateIn(viewModelScope, SharingStarted.Lazily, false)
- val isUseTimeScreenButtonEnabled = onBoardingState.map { onBoardingState ->
- onBoardingState.appGoalTimeHour > 0 || onBoardingState.appGoalTimeMinute > 0
- }.stateIn(viewModelScope, SharingStarted.Lazily, false)
+ val isUseTimeScreenButtonEnabled =
+ onBoardingState
+ .map { onBoardingState ->
+ onBoardingState.appGoalTimeHour > 0 || onBoardingState.appGoalTimeMinute > 0
+ }.stateIn(viewModelScope, SharingStarted.Lazily, false)
private fun updateState(transform: OnBoardingState.() -> OnBoardingState) {
val currentState = onBoardingState.value
@@ -92,13 +106,16 @@ class OnBoardingViewModel @Inject constructor(
when (event) {
is OnboardEvent.UpdateUsuallyUseTime -> {
updateState {
- copy(usuallyUseTime = event.usuallyUseTime)
+ copy(
+ usuallyUseTime = event.usuallyUseTime,
+ usuallyUseTimeButtonIndex = event.buttonIndex
+ )
}
}
is OnboardEvent.UpdateProblems -> {
updateState {
- copy(problems = event.problems)
+ copy(problems = event.problems, problemsButtonIndex = event.buttonIndices)
}
}
@@ -186,6 +203,7 @@ class OnBoardingViewModel @Inject constructor(
}
viewModelScope.launch {
_onboardEffect.emit(OnboardEffect.OnboardSuccess)
+ AmplitudeUtils.trackEventWithProperties("complete_onboarding_finish")
}
}.onFailure {
viewModelScope.launch {
diff --git a/feature/store/src/main/java/com/hmh/hamyeonham/feature/store/StoreActivity.kt b/feature/store/src/main/java/com/hmh/hamyeonham/feature/store/StoreActivity.kt
index 97e171fb..3a4ca147 100644
--- a/feature/store/src/main/java/com/hmh/hamyeonham/feature/store/StoreActivity.kt
+++ b/feature/store/src/main/java/com/hmh/hamyeonham/feature/store/StoreActivity.kt
@@ -1,14 +1,19 @@
package com.hmh.hamyeonham.feature.store
-import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
+import com.hmh.hamyeonham.common.amplitude.AmplitudeUtils
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.feature.store.databinding.ActivityStoreBinding
class StoreActivity : AppCompatActivity() {
private val binding by viewBinding(ActivityStoreBinding::inflate)
+ override fun onResume() {
+ super.onResume()
+ AmplitudeUtils.trackEventWithProperties("view_shop")
+ }
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 0d9cc9ab..d3dbe9a5 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -10,14 +10,14 @@ kotlin = "1.9.24"
kotlinx-serialization-json = "1.6.3"
kotlinx-serialization-converter = "1.0.0"
kotlinx-coroutines = "1.8.1"
-kotlinx-datetime = "0.5.0"
+kotlinx-datetime = "0.6.1"
ksp = "1.9.24-1.0.20"
# android
corektx = "1.13.1"
appcompat = "1.7.0"
activity = "1.9.0"
-lifecycle = "2.8.1"
+lifecycle = "2.8.4"
navigation = "2.7.7"
startup = "1.1.1"
security = "1.1.0-alpha06"
@@ -83,6 +83,7 @@ javax-inject = "1"
androidx-hilt = "1.2.0"
work-runtime-ktx = "2.9.0"
timber = "5.0.1"
+amplitude = "2.+"
[libraries]
@@ -212,6 +213,9 @@ androidx-hilt-common = { group = "androidx.hilt", name = "hilt-work", version.re
androidx-hilt-compiler = {module ="androidx.hilt:hilt-compiler", version.ref = "androidx-hilt" }
androidx-work-runtime-ktx = { group = "androidx.work", name = "work-runtime-ktx", version.ref = "work-runtime-ktx" }
+#amplitude
+amplitude = { module = "com.amplitude:android-sdk", version.ref = "amplitude" }
+
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index e708b1c0..a4b76b95 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index b9afc987..9355b415 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
-#Wed Dec 27 18:18:55 JST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 4f906e0c..f5feea6d 100755
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
-#!/usr/bin/env sh
+#!/bin/sh
#
-# Copyright 2015 the original author or authors.
+# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,69 +15,104 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -87,9 +122,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,88 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
fi
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
fi
- i=`expr $i + 1`
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 107acd32..9b42019c 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,89 +1,94 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega