-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] 온보딩 모듈 추가 #438
Merged
Merged
[Feature] 온보딩 모듈 추가 #438
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0bac2b8
del: 좋아요 기능 삭제
ThirFir bfa6f6e
fix: 키워드 알림 상태 버그
ThirFir 0e5ec8e
del: onResume override
ThirFir 26e7a33
fix: 식단 카드 간격 조정
ThirFir a372212
fix: 식단 카드 Radius
ThirFir 7279ad8
fix: 식단 상세 정보 ui
ThirFir 03c0c19
fix: 식단 공유 버튼 ui
ThirFir 107a6dd
add: onboarding 모듈
ThirFir d1ae376
refactor: OnboardingManager 추가, MainActivity 식단 툴팁 변경
ThirFir 26deffb
add: 화살표 위치 매개변수
ThirFir 49d14dc
refactor: 공지 키워드 툴팁 코드 리팩토링
ThirFir 1647ad9
del: Koin 모듈에서 balloon lib 의존성 제거
ThirFir 39e520c
fix: tooltip initialize 여부 조건 추가
ThirFir c038ed3
del: Unused onboarding codes
ThirFir d0b8ece
refactor: Onboarding Hilt Component: Singleton -> ActivityComponent
ThirFir 535d4c6
refactor: 온보딩 바텀시트 액션 모듈화 이용
ThirFir d9d15a4
refactor: DataStore DI 로직 변경
ThirFir d864ea5
fix: 함수명 포괄적으로 변경
ThirFir 85f533d
add: 툴팁 닫기 API
ThirFir b3511fb
add: 식단 공유 툴팁
ThirFir 64b5bf7
add: 이벤트 로깅
ThirFir dded9d7
add: 알림 액티비티에 공지 키워드 진입점 추가
ThirFir 2792822
refactor: enum 위치 이동
ThirFir 37f9ad5
add: 원본 공지 진입버튼
ThirFir 7304ca3
feat: 식단 공유 툴팁 gif로 변경
ThirFir 9f2792a
fix: 빌드 에러
ThirFir 1fb52b3
fix: as -> as?, Dispatchers
ThirFir 9065122
fix: Dispatchers Switching 제거
ThirFir 8211f45
Merge branch 'feature/onboarding' into feature/dining-abtest
ThirFir f621430
Merge remote-tracking branch 'origin/develop' into feature/onboarding
ThirFir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,19 @@ | ||
plugins { | ||
alias(libs.plugins.koin.library) | ||
alias(libs.plugins.koin.hilt) | ||
} | ||
|
||
android { | ||
namespace = "in.koreatech.koin.core.onboarding" | ||
} | ||
kapt { | ||
correctErrorTypes = true | ||
} | ||
dependencies { | ||
implementation(project(":domain")) | ||
|
||
implementation(libs.core.ktx) | ||
implementation(libs.appcompat) | ||
implementation(libs.timber) | ||
implementation(libs.balloon) | ||
} |
Empty file.
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,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 |
24 changes: 24 additions & 0 deletions
24
...oarding/src/androidTest/java/in/koreatech/koin/core/onboarding/ExampleInstrumentedTest.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,24 @@ | ||
package `in`.koreatech.koin.core.onboarding | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("in.koreatech.koin.core.onboarding.test", appContext.packageName) | ||
} | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
16 changes: 16 additions & 0 deletions
16
core/onboarding/src/main/java/in/koreatech/koin/core/onboarding/ArrowDirection.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,16 @@ | ||
package `in`.koreatech.koin.core.onboarding | ||
|
||
import com.skydoves.balloon.ArrowOrientation | ||
|
||
enum class ArrowDirection { | ||
BOTTOM, TOP, LEFT, RIGHT; | ||
|
||
fun toArrowOrientation(): ArrowOrientation { | ||
return when (this) { | ||
BOTTOM -> ArrowOrientation.BOTTOM | ||
TOP -> ArrowOrientation.TOP | ||
LEFT -> ArrowOrientation.START | ||
RIGHT -> ArrowOrientation.END | ||
} | ||
} | ||
} |
161 changes: 161 additions & 0 deletions
161
core/onboarding/src/main/java/in/koreatech/koin/core/onboarding/OnboardingManager.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,161 @@ | ||
package `in`.koreatech.koin.core.onboarding | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import androidx.annotation.FloatRange | ||
import androidx.appcompat.content.res.AppCompatResources | ||
import androidx.lifecycle.DefaultLifecycleObserver | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.lifecycle.repeatOnLifecycle | ||
import com.skydoves.balloon.ArrowOrientationRules | ||
import com.skydoves.balloon.ArrowPositionRules | ||
import com.skydoves.balloon.Balloon | ||
import com.skydoves.balloon.BalloonAnimation | ||
import com.skydoves.balloon.BalloonSizeSpec | ||
import com.skydoves.balloon.IconForm | ||
import com.skydoves.balloon.IconGravity | ||
import `in`.koreatech.koin.domain.repository.OnboardingRepository | ||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.withContext | ||
import javax.inject.Inject | ||
|
||
class OnboardingManager @Inject internal constructor( | ||
private val onboardingRepository: OnboardingRepository, | ||
private val context: Context, | ||
private val mainDispatcher: CoroutineDispatcher = Dispatchers.Main, | ||
private val ioDispatcher: CoroutineDispatcher = Dispatchers.IO | ||
) { | ||
|
||
private lateinit var tooltip: Balloon | ||
private val tooltipDismissObserver = object : DefaultLifecycleObserver { | ||
override fun onPause(owner: LifecycleOwner) { | ||
if (::tooltip.isInitialized) | ||
tooltip.dismiss() | ||
super.onPause(owner) | ||
} | ||
} | ||
|
||
/** | ||
* 앱 실행 최초 1회에만 툴팁 표시 | ||
* @param type 툴팁 타입 | ||
* @param view 툴팁을 위치시킬 뷰 | ||
* @param arrowPosition 화살표 위치 (0.0 ~ 1.0) | ||
* @param arrowDirection 툴팁 화살표 방향 (ex. ArrowDirection.LEFT -> 화살표는 왼쪽방향, 툴팁은 오른쪽에 위치) | ||
* ``` | ||
* // In Activity | ||
* @Inject | ||
* lateinit var onboardingManager: OnboardingManager | ||
* ... | ||
* | ||
* with(onboardingManager) { | ||
* showOnboardingTooltipIfNeeded( | ||
* type = OnboardingType.DINING_IMAGE, | ||
* view = binding.textViewDiningTitle, | ||
* arrowDirection = ArrowDirection.LEFT | ||
* ) | ||
* } | ||
* ``` | ||
* | ||
* binding.textViewDiningTitle 오른쪽에 툴팁 표시됨. | ||
* | ||
* Fragment에서 사용할 때는 viewLifecycleOwner를 사용해야 함 ! | ||
*/ | ||
fun LifecycleOwner.showOnboardingTooltipIfNeeded( | ||
type: OnboardingType, | ||
view: View, | ||
@FloatRange(from = 0.0, to = 1.0) arrowPosition: Float = 0.5f, | ||
arrowDirection: ArrowDirection, | ||
) { | ||
lifecycle.addObserver(tooltipDismissObserver) | ||
lifecycleScope.launch(ioDispatcher) { | ||
repeatOnLifecycle(Lifecycle.State.STARTED) { | ||
val shouldShow = onboardingRepository.getShouldOnboarding(type.name) | ||
delay(500) | ||
withContext(mainDispatcher) { | ||
if (shouldShow) { | ||
tooltip = createTooltip(type, arrowDirection, arrowPosition) | ||
tooltip.showAlign(view, arrowDirection) | ||
onboardingRepository.updateShouldOnboarding(type.name, false) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* 앱 최초 실행 시에 실행시키고 싶은 액션이 있는 경우 사용 | ||
* @param action 실행시킬 액션. ex) BottomSheetDialogFragment.show() | ||
*/ | ||
fun LifecycleOwner.showOnboardingIfNeeded( | ||
type: OnboardingType, | ||
action: () -> Unit | ||
) { | ||
lifecycleScope.launch(ioDispatcher) { | ||
repeatOnLifecycle(Lifecycle.State.STARTED) { | ||
val shouldShow = onboardingRepository.getShouldOnboarding(type.name) | ||
withContext(mainDispatcher) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이것도 마찬가지로 위와 같은 질문! |
||
if (shouldShow) { | ||
action() | ||
onboardingRepository.updateShouldOnboarding(type.name, false) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun dismissTooltip() { | ||
if (::tooltip.isInitialized) | ||
tooltip.dismiss() | ||
} | ||
|
||
private fun createTooltip( | ||
type: OnboardingType, | ||
arrowDirection: ArrowDirection, | ||
arrowPosition: Float | ||
): Balloon { | ||
val iconForm = IconForm.Builder(context) | ||
.setDrawable(AppCompatResources.getDrawable(context, R.drawable.round_close_24)) | ||
.setIconSize(32) | ||
.setDrawableGravity(IconGravity.END) | ||
.build() | ||
|
||
return Balloon.Builder(context) | ||
.setHeight(BalloonSizeSpec.WRAP) | ||
.setWidth(BalloonSizeSpec.WRAP) | ||
.setTextColorResource(R.color.white) | ||
.setBackgroundColorResource(R.color.neutral_600) | ||
.setTextSize(12f) | ||
.setArrowOrientationRules(ArrowOrientationRules.ALIGN_FIXED) | ||
.setArrowOrientation(arrowDirection.toArrowOrientation()) | ||
.setArrowPositionRules(ArrowPositionRules.ALIGN_BALLOON) | ||
.setArrowSize(10) | ||
.setArrowPosition(arrowPosition) | ||
.setPaddingVertical(8) | ||
.setPaddingHorizontal(10) | ||
.setIconForm(iconForm) | ||
.setMargin(10) | ||
.setDismissWhenTouchOutside(false) | ||
.setDismissWhenClicked(true) | ||
.setCornerRadius(8f) | ||
.setBalloonAnimation(BalloonAnimation.FADE) | ||
.apply { | ||
if (type.descriptionResId != 0) | ||
setText(context.getString(type.descriptionResId)) | ||
} | ||
.build() | ||
} | ||
|
||
private fun Balloon.showAlign(view: View, arrowDirection: ArrowDirection) { | ||
when (arrowDirection) { | ||
ArrowDirection.BOTTOM -> showAlignTop(view) | ||
ArrowDirection.TOP -> showAlignBottom(view) | ||
ArrowDirection.LEFT -> showAlignRight(view) | ||
ArrowDirection.RIGHT -> showAlignLeft(view) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
core/onboarding/src/main/java/in/koreatech/koin/core/onboarding/OnboardingModule.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,24 @@ | ||
package `in`.koreatech.koin.core.onboarding | ||
|
||
import android.content.Context | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.components.ActivityComponent | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.android.scopes.ActivityScoped | ||
import `in`.koreatech.koin.domain.repository.OnboardingRepository | ||
|
||
@Module | ||
@InstallIn(ActivityComponent::class) | ||
object OnboardingModule { | ||
|
||
@Provides | ||
@ActivityScoped | ||
fun provideOnboardingManager( | ||
onboardingRepository: OnboardingRepository, | ||
@ApplicationContext context: Context | ||
): OnboardingManager { | ||
return OnboardingManager(onboardingRepository, context) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
core/onboarding/src/main/java/in/koreatech/koin/core/onboarding/OnboardingType.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,16 @@ | ||
package `in`.koreatech.koin.core.onboarding | ||
|
||
import androidx.annotation.StringRes | ||
|
||
/** | ||
* OnboardingType | ||
* @property descriptionResId 툴팁 내용 리소스 아이디. 툴팁이 아닐 경우 0 할당 | ||
*/ | ||
enum class OnboardingType( | ||
@StringRes val descriptionResId: Int, | ||
) { | ||
DINING_IMAGE(R.string.dining_image_tooltip), | ||
DINING_NOTIFICATION(0), | ||
DINING_SHARE(0), | ||
ARTICLE_KEYWORD(R.string.article_keyword_tooltip) | ||
} |
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,5 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"> | ||
|
||
<path android:fillColor="@android:color/white" android:pathData="M18.3,5.71c-0.39,-0.39 -1.02,-0.39 -1.41,0L12,10.59 7.11,5.7c-0.39,-0.39 -1.02,-0.39 -1.41,0 -0.39,0.39 -0.39,1.02 0,1.41L10.59,12 5.7,16.89c-0.39,0.39 -0.39,1.02 0,1.41 0.39,0.39 1.02,0.39 1.41,0L12,13.41l4.89,4.89c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L13.41,12l4.89,-4.89c0.38,-0.38 0.38,-1.02 0,-1.4z"/> | ||
|
||
</vector> |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="white">#ffffff</color> | ||
<color name="neutral_600">#4B4B4B</color> | ||
</resources> |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="dining_image_tooltip">식단 사진을 확인해보세요!</string> | ||
<string name="dining_share_tooltip">식단이 마음에 들었다면 공유하기!</string> | ||
<string name="article_keyword_tooltip">키워드를 추가하고 맞춤 알림을 받아보세요!</string> | ||
</resources> |
17 changes: 17 additions & 0 deletions
17
core/onboarding/src/test/java/in/koreatech/koin/core/onboarding/ExampleUnitTest.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 `in`.koreatech.koin.core.onboarding | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이미 lifecycleScope 와 repeatOnLifecycle를 사용하는데, Main 디스패처를 주입해서 사용한 이유가 있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
launch에 IO Dispatcher를 지정하려 했는데 안했네요 ㅎ.. 🤐