Skip to content

Commit

Permalink
Merge pull request #72 from Team-HMH/feat/onboarding_permission
Browse files Browse the repository at this point in the history
[feat/onboarding permission] 온보딩 권한 허용 기능 구현
  • Loading branch information
kez-lab authored Jan 12, 2024
2 parents ad76268 + 88c8ce3 commit f2760b8
Show file tree
Hide file tree
Showing 43 changed files with 599 additions and 111 deletions.
7 changes: 3 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ plugins {
alias(libs.plugins.crashlytics)
}

val properties =
Properties().apply {
load(rootProject.file("local.properties").inputStream())
}
val properties = Properties().apply {
load(rootProject.file("local.properties").inputStream())
}

android {
namespace = "com.hmh.hamyeonham"
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/java/com/hmh/hamyeonham/SampleActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import android.view.animation.AnimationUtils
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.hmh.hamyeonham.challenge.appselection.AppselectionActivity
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

@AndroidEntryPoint
Expand All @@ -23,8 +21,7 @@ class SampleActivity : AppCompatActivity() {
val splashScreen = installSplashScreen()
initSplashAnimation(splashScreen)
setContentView(binding.root)
// startActivity(Intent(this, LoginActivity::class.java))
startActivity(Intent(this, MainActivity::class.java))
startActivity(Intent(this, LoginActivity::class.java))
finish()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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.main.MainActivity
import com.hmh.hamyeonham.feature.onboarding.OnBoardingActivity
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
Expand All @@ -18,4 +19,8 @@ class DefaultNavigationProvider @Inject constructor(
override fun toLogin(): Intent {
return Intent(context, LoginActivity::class.java)
}

override fun toMain(): Intent {
return Intent(context, MainActivity::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import android.content.Intent
interface NavigationProvider {
fun toOnBoarding(): Intent
fun toLogin(): Intent
fun toMain(): Intent
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ inline fun SpannableStringBuilder.textAppearance(
@StyleRes style: Int,
builderAction: SpannableStringBuilder.() -> Unit
) = inSpans(TextAppearanceSpan(context, style), builderAction = builderAction)

fun String.extractDigits(): Int {
return try {
this.filter { it.isDigit() }.toIntOrNull() ?: 0
} catch (e: NumberFormatException) {
0
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ fun convertTimeToString(time: Long): String {
if (minutes > 0 || hours == 0L) append(" $minutes")
}.trim()
}

// 분을 ms로 바꾸는 함수
fun Int.timeToMs(): Long {
return this * 60 * 1000L
}
Empty file added core/network/consumer-rules.pro
Empty file.
Empty file added core/network/proguard-rules.pro
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions data/userinfo/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Empty file.
21 changes: 21 additions & 0 deletions domain/userinfo/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.hmh.hamyeonham.common.context.toast
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.hmh.hamyeonham.common.navigation.NavigationProvider
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.feature.login.databinding.ActivityLoginBinding
Expand Down
Empty file.
21 changes: 21 additions & 0 deletions feature/mypage/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
1 change: 1 addition & 0 deletions feature/onboarding/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ android {
dependencies {
implementation(projects.core.common)
implementation(projects.core.designsystem)
implementation(project(":feature:main"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.hmh.hamyeonham.feature.onboarding
import android.accessibilityservice.AccessibilityService
import android.util.Log
import android.view.accessibility.AccessibilityEvent
import com.hmh.hamyeonham.common.context.toast

class OnBoardingAccessibilityService : AccessibilityService() {
override fun onAccessibilityEvent(event: AccessibilityEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.feature.onboarding.databinding.ActivityOnBoardingBinding
import com.hmh.hamyeonham.feature.onboarding.viewModel.OnBoardingViewModel
import com.hmh.hamyeonham.feature.onboarding.viewmodel.OnBoardingEffect
import com.hmh.hamyeonham.feature.onboarding.viewmodel.OnBoardingViewModel
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand All @@ -25,29 +26,35 @@ class OnBoardingActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
initViewPager()
initViews()
checkNextButtonEnable()
setBackPressedCallback()
}

private fun initViews() {
initBackButton()
initViewPager()
}

private fun initBackButton() {
binding.ivOnboardingBack.setOnClickListener {
navigateToPreviousOnboardingStep()
}
}

private fun initViewPager() {
val pagerAdapter = setOnboardingPageAdapter()
binding.btnOnboardingNext.setOnClickListener {
viewModel.initializeButtonStates()
navigateToNextOnboardingStep(pagerAdapter)
}
binding.ivOnboardingBack.setOnClickListener {
viewModel.initializeButtonStates()
navigateToPreviousOnboardingStep()
}
}

private fun navigateToPreviousOnboardingStep() {
binding.vpOnboardingContainer.let { viewPager ->
val currentItem = viewPager.currentItem
binding.vpOnboardingContainer.run {
val currentItem = this.currentItem
if (currentItem > 0) {
viewPager.currentItem = currentItem - 1
updateProgressBar(currentItem - 1, viewPager.adapter?.itemCount ?: 1)
this.currentItem = currentItem - 1
updateProgressBar(currentItem - 1, adapter?.itemCount ?: 1)
} else {
onBackPressedCallback.isEnabled = false
onBackPressedDispatcher.onBackPressed()
Expand All @@ -70,11 +77,14 @@ class OnBoardingActivity : AppCompatActivity() {
}

private fun checkNextButtonEnable() {
viewModel.clickNextButtonEnable.flowWithLifecycle(lifecycle)
.onEach { clickNextButtonEnable ->
binding.btnOnboardingNext.isEnabled = clickNextButtonEnable
binding.btnOnboardingNext.isSelected = clickNextButtonEnable
}.launchIn(lifecycleScope)
viewModel.onboardEffect.flowWithLifecycle(lifecycle).onEach {
when (it) {
is OnBoardingEffect.ActiveNextButton -> {
binding.btnOnboardingNext.isEnabled = it.isActive
binding.btnOnboardingNext.isSelected = it.isActive
}
}
}.launchIn(lifecycleScope)
}

private fun setBackPressedCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@ package com.hmh.hamyeonham.feature.onboarding

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.hmh.hamyeonham.common.navigation.NavigationProvider
import com.hmh.hamyeonham.common.view.viewBinding
import com.hmh.hamyeonham.feature.onboarding.databinding.ActivityOnBoardingDoneSingUpBinding
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class OnBoardingDoneSingUpActivity : AppCompatActivity() {
private val binding by viewBinding(ActivityOnBoardingDoneSingUpBinding::inflate)

@Inject
lateinit var navigationProvider: NavigationProvider

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)

binding.btnOnboardingDoneNext.setOnClickListener {
moveToMainActivity()
}
}

private fun moveToMainActivity() {
startActivity(navigationProvider.toMain())
finish()
}
}
Loading

0 comments on commit f2760b8

Please sign in to comment.