Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/develop_PR_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:

- name: Add Local Properties
env:
KAKAO_API_KEY: ${{ secrets.KAKAO_API_KEY }}
HMH_DEV_BASE_URL: ${{ secrets.HMH_DEV_BASE_URL }}
HMH_PROD_BASE_URL: ${{ secrets.HMH_PROD_BASE_URL }}
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:

- name: Add Local Properties
env:
KAKAO_API_KEY: ${{ secrets.KAKAO_API_KEY }}
HMH_DEV_BASE_URL: ${{ secrets.HMH_DEV_BASE_URL }}
HMH_PROD_BASE_URL: ${{ secrets.HMH_PROD_BASE_URL }}
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
Expand Down
6 changes: 0 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,16 @@ dependencies {
// Domain
implementation(projects.domain.usagestats)
implementation(projects.domain.userinfo)
implementation(projects.domain.login)
implementation(projects.domain.challenge)
implementation(projects.domain.onboarding)
implementation(projects.domain.point)
implementation(projects.domain.lock)

// Data
implementation(projects.data.usagestats)
implementation(projects.data.userinfo)
implementation(projects.data.login)
implementation(projects.data.challenge)
implementation(projects.data.device)
implementation(projects.data.onboarding)
implementation(projects.data.point)
implementation(projects.data.lock)
implementation(projects.data.main)

Expand All @@ -107,8 +103,6 @@ dependencies {
implementation(libs.splash.screen)
implementation(libs.lottie)

// kakao
implementation(libs.kakao.login)

// Hilt Worker
implementation(libs.androidx.hilt.common)
Expand Down
5 changes: 0 additions & 5 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

##---------------Begin: Kakao SDK ----------
-keep class com.kakao.sdk.**.model.* { <fields>; }
-keep class * extends com.google.gson.TypeAdapter
##---------------END: Kakao SDK ----------

##---------------Begin: Okio ----------
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@
</intent-filter>
</activity>

<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="oauth"
android:scheme="kakao${kakaoApiKey}" />
</intent-filter>
</activity>

<activity
android:name=".common.permission.PermissionActivity"
android:exported="false" />
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/hmh/hamyeonham/HMHApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.amplitude.api.Amplitude
import com.hmh.hamyeonham.core.notification.AppNotificationManager
import com.hmh.hamyeonham.firebase.setFirebaseCrashlyticsEnabled
import com.hmh.hamyeonham.hus.usagestats.HMHUsageStatsManager
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.EntryPoint
import dagger.hilt.EntryPoints
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -35,7 +34,6 @@ class HMHApplication : Application(), Configuration.Provider {
super.onCreate()
setFirebaseCrashlyticsEnabled(!BuildConfig.DEBUG)
setAmplitude()
KakaoSdk.init(this, BuildConfig.KAKAO_API_KEY)
HMHUsageStatsManager.init(this)
notificationManager.setupNotificationChannel()
}
Expand Down
23 changes: 6 additions & 17 deletions app/src/main/java/com/hmh/hamyeonham/StartActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.hmh.hamyeonham.common.dialog.OneButtonCommonDialog
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.databinding.ActivitySampleBinding
import com.hmh.hamyeonham.feature.login.LoginActivity
import com.hmh.hamyeonham.feature.main.MainActivity
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers

@AndroidEntryPoint
class StartActivity : AppCompatActivity() {
private val binding by viewBinding(ActivitySampleBinding::inflate)
private val coroutineScope = CoroutineScope(Dispatchers.Main)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -27,22 +23,15 @@ class StartActivity : AppCompatActivity() {

private fun initLottieSplash() {
binding.splashLottieAppLogo.playAnimation()
OneButtonCommonDialog
.newInstance(
title = "서비스를 개선하고 있어요",
description = "서비스를 개선하고 있어요 더 나은 모습으로 만나요",
iconRes = null,
confirmButtonText = "확인",
)
.setConfirmButtonClickListener {
finish()
binding.splashLottieAppLogo.addAnimatorUpdateListener {
if (it.animatedFraction == 1.0f) {
navigateToLogin()
}
.showAllowingStateLoss(supportFragmentManager)

}
Comment on lines +26 to +30
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve animation completion detection and cleanup.

The current implementation has a few potential issues:

  1. Floating point precision: Using exact equality (== 1.0f) for floating point comparison can be unreliable. Animation fraction might not reach exactly 1.0f due to precision issues.

  2. Missing cleanup: The animator listener is not removed, which could potentially cause memory leaks.

Apply this diff to improve the implementation:

 private fun initLottieSplash() {
     binding.splashLottieAppLogo.playAnimation()
-    binding.splashLottieAppLogo.addAnimatorUpdateListener {
-        if (it.animatedFraction == 1.0f) {
+    binding.splashLottieAppLogo.addAnimatorUpdateListener { animator ->
+        if (animator.animatedFraction >= 0.99f) {
+            binding.splashLottieAppLogo.removeAllUpdateListeners()
             navigateToLogin()
         }
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
binding.splashLottieAppLogo.addAnimatorUpdateListener {
if (it.animatedFraction == 1.0f) {
navigateToLogin()
}
.showAllowingStateLoss(supportFragmentManager)
}
private fun initLottieSplash() {
binding.splashLottieAppLogo.playAnimation()
binding.splashLottieAppLogo.addAnimatorUpdateListener { animator ->
if (animator.animatedFraction >= 0.99f) {
binding.splashLottieAppLogo.removeAllUpdateListeners()
navigateToLogin()
}
}
}
🤖 Prompt for AI Agents
In app/src/main/java/com/hmh/hamyeonham/StartActivity.kt around lines 29 to 33,
replace the exact floating point equality check on animatedFraction with a
threshold comparison (e.g., check if animatedFraction is greater than or equal
to 0.99f) to handle precision issues. Additionally, after navigating to login,
remove the animator update listener to prevent potential memory leaks by
unregistering the listener from the animation.

}

private fun navigateToLogin() {
startActivity(Intent(this, LoginActivity::class.java))
startActivity(Intent(this, MainActivity::class.java))
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package com.hmh.hamyeonham.navigation

import android.content.Context
import android.content.Intent
import com.hmh.hamyeonham.challenge.point.PointActivity
import com.hmh.hamyeonham.common.navigation.NavigationProvider
import com.hmh.hamyeonham.common.permission.PermissionActivity
import com.hmh.hamyeonham.feature.lock.LockActivity
import com.hmh.hamyeonham.feature.login.LoginActivity
import com.hmh.hamyeonham.feature.main.MainActivity
import com.hmh.hamyeonham.feature.onboarding.OnBoardingActivity
import com.hmh.hamyeonham.feature.onboarding.OnBoardingStoryActivity
Expand All @@ -25,10 +23,6 @@ class DefaultNavigationProvider @Inject constructor(
return Intent(context, OnBoardingStoryActivity::class.java)
}

override fun toLogin(): Intent {
return Intent(context, LoginActivity::class.java)
}

override fun toMain(): Intent {
return Intent(context, MainActivity::class.java)
}
Expand All @@ -41,10 +35,6 @@ class DefaultNavigationProvider @Inject constructor(
return Intent(context, StoreActivity::class.java)
}

override fun toPoint(): Intent {
return Intent(context, PointActivity::class.java)
}

override fun toPermission(): Intent {
return Intent(context, PermissionActivity::class.java)
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
app:lottie_autoPlay="true"
app:lottie_loop="false"
app:lottie_rawRes="@raw/splash_logo_white"
app:lottie_speed="1" />
app:lottie_speed="1.5" />

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ internal fun Project.configureAndroidCommonPlugin() {

extensions.getByType<BaseExtension>().apply {
defaultConfig {
val kakaoApiKey = properties["kakaoApiKey"] as? String ?: ""
manifestPlaceholders["kakaoApiKey"] = properties["kakaoApiKey"] as String
buildConfigField("String", "KAKAO_API_KEY", "\"${kakaoApiKey}\"")

val amplitudeApiKey = properties["amplitudeApiKey"] as? String ?: ""
buildConfigField("String", "AMPLITUDE_API_KEY", "\"${amplitudeApiKey}\"")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ interface NavigationProvider {

fun toOnBoarding(): Intent
fun toOnBoardingStory(): Intent
fun toLogin(): Intent
fun toMain(): Intent
fun toLock(packageName: String): Intent
fun toStore(): Intent
fun toPoint(): Intent
fun toPermission(): Intent
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.hmh.hamyeonham.common.permission

import android.app.usage.UsageStatsManager
import android.app.AppOpsManager
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import com.hmh.hamyeonham.common.context.hasNotificationPermission
import com.hmh.hamyeonham.common.context.toast
import com.hmh.hamyeonham.common.databinding.ActivityPermissionBinding
Expand Down Expand Up @@ -115,27 +117,11 @@ class PermissionActivity : AppCompatActivity() {

private fun requestUsageAccessPermission() {
try {
val packageUri = Uri.parse("package:$packageName")
val packageUri = "package:$packageName".toUri()
val intent = Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS, packageUri)
usageStatsPermissionLauncher.launch(intent)
} catch (e: Exception) {
usageStatsPermissionLauncher.launch(Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS))
}
}

private fun hasUsageStatsPermission(): Boolean {
val usageStatsManager = getSystemService(Context.USAGE_STATS_SERVICE) as? UsageStatsManager
val time = System.currentTimeMillis()
val stats = usageStatsManager?.queryUsageStats(
UsageStatsManager.INTERVAL_DAILY,
time - 1000 * 60,
time,
)
return !stats.isNullOrEmpty()

}

private fun hasOverlayPermission(): Boolean {
return Settings.canDrawOverlays(this)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hmh.hamyeonham.common.permission

import android.Manifest
import android.app.AppOpsManager
import android.app.usage.UsageStatsManager
import android.content.Context
import android.content.Intent
Expand Down Expand Up @@ -38,14 +39,29 @@ fun AppCompatActivity.requestUsageAccessPermission() {
}

fun AppCompatActivity.hasUsageStatsPermission(): Boolean {
val usageStatsManager = getSystemService(Context.USAGE_STATS_SERVICE) as UsageStatsManager
val time = System.currentTimeMillis()
val stats = usageStatsManager.queryUsageStats(
UsageStatsManager.INTERVAL_DAILY,
time - 1000 * 60,
time,
)
return stats != null && stats.isNotEmpty()
val ops = getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
val mode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ops.unsafeCheckOpNoThrow(
AppOpsManager.OPSTR_GET_USAGE_STATS,
android.os.Process.myUid(),
packageName
)
} else {
ops.checkOpNoThrow(
AppOpsManager.OPSTR_GET_USAGE_STATS,
android.os.Process.myUid(),
packageName
)
}

return when (mode) {
AppOpsManager.MODE_ALLOWED -> true
AppOpsManager.MODE_DEFAULT,
AppOpsManager.MODE_IGNORED,
AppOpsManager.MODE_ERRORED -> false

else -> false
}
}

fun AppCompatActivity.hasOverlayPermission(): Boolean {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.hmh.hamyeonham.core.database

import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.hmh.hamyeonham.core.database.dao.ChallengeDao
import com.hmh.hamyeonham.core.database.dao.DeletedGoalsDao
import com.hmh.hamyeonham.core.database.dao.LockDao
Expand All @@ -26,9 +28,9 @@ import kotlinx.coroutines.launch
DailyChallengeEntity::class,
DeletedGoalWithUsageEntity::class,
DeletedUsageEntity::class,
LockWithDateEntity::class
LockWithDateEntity::class,
],
version = 1,
version = 2,
exportSchema = false
)
abstract class HMHRoomDatabase : RoomDatabase() {
Expand All @@ -47,6 +49,42 @@ abstract class HMHRoomDatabase : RoomDatabase() {
deletedGoalsDao().deleteAll()
lockDao().deleteAll()
}
}

companion object {
// 버전 1에서 버전 2로 마이그레이션
val MIGRATION_1_2 = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
// UserAuth 테이블 생성
database.execSQL(
"""
CREATE TABLE IF NOT EXISTS `user_auth` (
`id` INTEGER NOT NULL,
`userId` INTEGER NOT NULL,
`providerType` TEXT NOT NULL,
`isLoggedIn` INTEGER NOT NULL,
`lastLoginTimestamp` INTEGER NOT NULL,
PRIMARY KEY(`id`)
)
"""
)

// UserProfile 테이블 생성
database.execSQL(
"""
CREATE TABLE IF NOT EXISTS `user_profile` (
`userId` INTEGER NOT NULL,
`nickname` TEXT,
`profileImageUrl` TEXT,
`email` TEXT,
`ageRange` TEXT,
`gender` TEXT,
`updatedAt` INTEGER NOT NULL,
PRIMARY KEY(`userId`)
)
"""
)
}
}
}
}
Loading