From 442a2a05422fb63bb694e83920ecb974d9db8666 Mon Sep 17 00:00:00 2001 From: juhwankim-dev Date: Tue, 13 Dec 2022 02:30:57 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EC=98=A8=EB=B3=B4=EB=94=A9=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88,=20=EC=95=A1=ED=8B=B0=EB=B9=84=ED=8B=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 4 ++ presentation/onboarding/.gitignore | 1 + presentation/onboarding/build.gradle | 50 +++++++++++++++++++ presentation/onboarding/consumer-rules.pro | 0 presentation/onboarding/proguard-rules.pro | 21 ++++++++ .../onboarding/ExampleInstrumentedTest.kt | 24 +++++++++ .../onboarding/src/main/AndroidManifest.xml | 2 + .../onboarding/OnboardingActivity.kt | 14 ++++++ .../main/res/layout/activity_onboarding.xml | 16 ++++++ .../src/main/res/values/strings.xml | 1 + .../threedays/onboarding/ExampleUnitTest.kt | 17 +++++++ settings.gradle | 1 + 13 files changed, 152 insertions(+) create mode 100644 presentation/onboarding/.gitignore create mode 100644 presentation/onboarding/build.gradle create mode 100644 presentation/onboarding/consumer-rules.pro create mode 100644 presentation/onboarding/proguard-rules.pro create mode 100644 presentation/onboarding/src/androidTest/java/com/depromeet/threedays/onboarding/ExampleInstrumentedTest.kt create mode 100644 presentation/onboarding/src/main/AndroidManifest.xml create mode 100644 presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt create mode 100644 presentation/onboarding/src/main/res/layout/activity_onboarding.xml create mode 100644 presentation/onboarding/src/main/res/values/strings.xml create mode 100644 presentation/onboarding/src/test/java/com/depromeet/threedays/onboarding/ExampleUnitTest.kt diff --git a/app/build.gradle b/app/build.gradle index 59867542..be26a1f4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,6 +48,7 @@ dependencies { implementation(project(":presentation:history")) implementation(project(":presentation:notification")) implementation(project(":presentation:mate")) + implementation(project(":presentation:onboarding")) implementation(jetpackDeps) implementation(coroutines) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0542ea09..5a024f34 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -46,6 +46,10 @@ + + diff --git a/presentation/onboarding/.gitignore b/presentation/onboarding/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/presentation/onboarding/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/presentation/onboarding/build.gradle b/presentation/onboarding/build.gradle new file mode 100644 index 00000000..5fae7042 --- /dev/null +++ b/presentation/onboarding/build.gradle @@ -0,0 +1,50 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' + id "kotlin-kapt" + id 'dagger.hilt.android.plugin' +} + +android { + namespace 'com.depromeet.threedays.onboarding' + compileSdk 33 + + defaultConfig { + minSdk 26 + targetSdk 33 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } + buildFeatures { + dataBinding true + } +} + +dependencies { + implementation(project(":core")) + implementation(project(":core-design-system")) + implementation(project(":navigator")) + + implementation(jetpackDeps) + + implementation deps.hilt.core + kapt deps.hilt.compiler + + testImplementation(testDeps) + androidTestImplementation(androidTestDeps) +} diff --git a/presentation/onboarding/consumer-rules.pro b/presentation/onboarding/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/presentation/onboarding/proguard-rules.pro b/presentation/onboarding/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/presentation/onboarding/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/presentation/onboarding/src/androidTest/java/com/depromeet/threedays/onboarding/ExampleInstrumentedTest.kt b/presentation/onboarding/src/androidTest/java/com/depromeet/threedays/onboarding/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..2b4681ec --- /dev/null +++ b/presentation/onboarding/src/androidTest/java/com/depromeet/threedays/onboarding/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.depromeet.threedays.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("com.depromeet.threedays.onboarding.test", appContext.packageName) + } +} diff --git a/presentation/onboarding/src/main/AndroidManifest.xml b/presentation/onboarding/src/main/AndroidManifest.xml new file mode 100644 index 00000000..4a3ae8e3 --- /dev/null +++ b/presentation/onboarding/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt b/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt new file mode 100644 index 00000000..7ce924d0 --- /dev/null +++ b/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt @@ -0,0 +1,14 @@ +package com.depromeet.threedays.onboarding + +import android.os.Bundle +import com.depromeet.threedays.core.BaseActivity +import com.depromeet.threedays.onboarding.databinding.ActivityOnboardingBinding +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class OnboardingActivity : BaseActivity(R.layout.activity_onboarding) { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + } +} diff --git a/presentation/onboarding/src/main/res/layout/activity_onboarding.xml b/presentation/onboarding/src/main/res/layout/activity_onboarding.xml new file mode 100644 index 00000000..a53ab57a --- /dev/null +++ b/presentation/onboarding/src/main/res/layout/activity_onboarding.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/presentation/onboarding/src/main/res/values/strings.xml b/presentation/onboarding/src/main/res/values/strings.xml new file mode 100644 index 00000000..7abc06d3 --- /dev/null +++ b/presentation/onboarding/src/main/res/values/strings.xml @@ -0,0 +1 @@ + diff --git a/presentation/onboarding/src/test/java/com/depromeet/threedays/onboarding/ExampleUnitTest.kt b/presentation/onboarding/src/test/java/com/depromeet/threedays/onboarding/ExampleUnitTest.kt new file mode 100644 index 00000000..e395ce46 --- /dev/null +++ b/presentation/onboarding/src/test/java/com/depromeet/threedays/onboarding/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.depromeet.threedays.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) + } +} diff --git a/settings.gradle b/settings.gradle index 3533bcdf..1889bac6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,3 +26,4 @@ include ':presentation:history' include ':presentation:mypage' include ':presentation:mate' include ':presentation:notification' +include ':presentation:onboarding' From 12d0a545f5c06425eb5b7ca76b16c82416f4b716 Mon Sep 17 00:00:00 2001 From: juhwankim-dev Date: Tue, 13 Dec 2022 04:44:12 +0900 Subject: [PATCH 2/4] =?UTF-8?q?ui:=20indicator=EC=97=90=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=A0=20drawable=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/drawable/bg_rect_gray200_r4.xml | 6 ++++++ .../src/main/res/drawable/bg_rect_gray500_r4.xml | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 core-design-system/src/main/res/drawable/bg_rect_gray200_r4.xml create mode 100644 core-design-system/src/main/res/drawable/bg_rect_gray500_r4.xml diff --git a/core-design-system/src/main/res/drawable/bg_rect_gray200_r4.xml b/core-design-system/src/main/res/drawable/bg_rect_gray200_r4.xml new file mode 100644 index 00000000..82bea9ce --- /dev/null +++ b/core-design-system/src/main/res/drawable/bg_rect_gray200_r4.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/core-design-system/src/main/res/drawable/bg_rect_gray500_r4.xml b/core-design-system/src/main/res/drawable/bg_rect_gray500_r4.xml new file mode 100644 index 00000000..880e6e95 --- /dev/null +++ b/core-design-system/src/main/res/drawable/bg_rect_gray500_r4.xml @@ -0,0 +1,6 @@ + + + + + From 4aa7c9db04f6e6db048de56312dc7a0da445dada Mon Sep 17 00:00:00 2001 From: juhwankim-dev Date: Tue, 13 Dec 2022 04:45:19 +0900 Subject: [PATCH 3/4] =?UTF-8?q?ui:=20=EC=98=A8=EB=B3=B4=EB=94=A9=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onboarding/OnboardingActivity.kt | 29 +++++++++ .../onboarding/OnboardingFragment.kt | 61 +++++++++++++++++++ .../main/res/layout/activity_onboarding.xml | 57 +++++++++++++++++ .../main/res/layout/fragment_onboarding.xml | 53 ++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingFragment.kt create mode 100644 presentation/onboarding/src/main/res/layout/fragment_onboarding.xml diff --git a/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt b/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt index 7ce924d0..cd75d1a0 100644 --- a/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt +++ b/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt @@ -1,14 +1,43 @@ package com.depromeet.threedays.onboarding import android.os.Bundle +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity +import androidx.viewpager2.adapter.FragmentStateAdapter +import androidx.viewpager2.widget.ViewPager2 import com.depromeet.threedays.core.BaseActivity import com.depromeet.threedays.onboarding.databinding.ActivityOnboardingBinding import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class OnboardingActivity : BaseActivity(R.layout.activity_onboarding) { + private val NUM_PAGES = 3 // 페이지 수를 정해둠 + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + binding.vpOnBoarding.adapter = ScreenSlidePagerAdapter(this) + binding.vpOnBoarding.orientation = ViewPager2.ORIENTATION_HORIZONTAL + } + + private inner class ScreenSlidePagerAdapter(fa: FragmentActivity) : FragmentStateAdapter(fa) { + override fun getItemCount(): Int = NUM_PAGES // 페이지 수 리턴 + + override fun createFragment(position: Int): Fragment { + return when(position){ // 페이지 포지션에 따라 그에 맞는 프래그먼트를 보여줌 + 0 -> OnboardingFragment.newInstance( + title = getString(R.string.first_on_boarding_page_title), + content = getString(R.string.first_on_boarding_page_content), + ) + 1 -> OnboardingFragment.newInstance( + title = getString(R.string.second_on_boarding_page_title), + content = getString(R.string.second_on_boarding_page_content), + ) + else -> OnboardingFragment.newInstance( + title = getString(R.string.third_on_boarding_page_title), + content = getString(R.string.third_on_boarding_page_content), + ) + } + } } } diff --git a/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingFragment.kt b/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingFragment.kt new file mode 100644 index 00000000..414dc8d1 --- /dev/null +++ b/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingFragment.kt @@ -0,0 +1,61 @@ +package com.depromeet.threedays.onboarding + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.depromeet.threedays.onboarding.databinding.FragmentOnboardingBinding +import dagger.hilt.android.AndroidEntryPoint + +private const val ARG_PARAM1 = "param1" +private const val ARG_PARAM2 = "param2" + +@AndroidEntryPoint +class OnboardingFragment : Fragment() { + private var _binding: FragmentOnboardingBinding? = null + private val binding get() = _binding!! + + private var title: String? = null + private var content: String? = null + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + super.onCreateView(inflater, container, savedInstanceState) + arguments?.let { + title = it.getString(ARG_PARAM1) + content = it.getString(ARG_PARAM2) + } + + _binding = FragmentOnboardingBinding.inflate(inflater, container, false) + binding.lifecycleOwner = viewLifecycleOwner + + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.tvTitle.text = title + binding.tvContent.text = content + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + + companion object { + @JvmStatic + fun newInstance(title: String, content: String) = + OnboardingFragment().apply { + arguments = Bundle().apply { + putString(ARG_PARAM1, title) + putString(ARG_PARAM2, content) + } + } + } +} diff --git a/presentation/onboarding/src/main/res/layout/activity_onboarding.xml b/presentation/onboarding/src/main/res/layout/activity_onboarding.xml index a53ab57a..6f9bb073 100644 --- a/presentation/onboarding/src/main/res/layout/activity_onboarding.xml +++ b/presentation/onboarding/src/main/res/layout/activity_onboarding.xml @@ -12,5 +12,62 @@ android:layout_height="match_parent" tools:context=".OnboardingActivity"> + + + + + + + + + diff --git a/presentation/onboarding/src/main/res/layout/fragment_onboarding.xml b/presentation/onboarding/src/main/res/layout/fragment_onboarding.xml new file mode 100644 index 00000000..cfb0dfa6 --- /dev/null +++ b/presentation/onboarding/src/main/res/layout/fragment_onboarding.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + From 59491ed7f2414990b935d2717b658ee5793cbe6f Mon Sep 17 00:00:00 2001 From: juhwankim-dev Date: Wed, 14 Dec 2022 01:02:46 +0900 Subject: [PATCH 4/4] =?UTF-8?q?ui:=20viewpager=20=EB=8F=99=EC=9E=91=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onboarding/OnboardingActivity.kt | 39 ++++++++++++++++++- .../src/main/res/values/strings.xml | 13 ++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt b/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt index cd75d1a0..74f97284 100644 --- a/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt +++ b/presentation/onboarding/src/main/java/com/depromeet/threedays/onboarding/OnboardingActivity.kt @@ -6,8 +6,10 @@ import androidx.fragment.app.FragmentActivity import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.widget.ViewPager2 import com.depromeet.threedays.core.BaseActivity +import com.depromeet.threedays.core.setOnSingleClickListener import com.depromeet.threedays.onboarding.databinding.ActivityOnboardingBinding import dagger.hilt.android.AndroidEntryPoint +import com.depromeet.threedays.core_design_system.R as core_R @AndroidEntryPoint class OnboardingActivity : BaseActivity(R.layout.activity_onboarding) { @@ -16,23 +18,58 @@ class OnboardingActivity : BaseActivity(R.layout.acti override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + initView() + initEvent() + } + + private fun initView() { binding.vpOnBoarding.adapter = ScreenSlidePagerAdapter(this) binding.vpOnBoarding.orientation = ViewPager2.ORIENTATION_HORIZONTAL } + private fun initEvent() { + binding.vpOnBoarding.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { + override fun onPageSelected(position: Int) { + super.onPageSelected(position) + + binding.viewFirstIndicator.setBackgroundResource(core_R.drawable.bg_rect_gray200_r4) + binding.viewSecondIndicator.setBackgroundResource(core_R.drawable.bg_rect_gray200_r4) + binding.viewThirdIndicator.setBackgroundResource(core_R.drawable.bg_rect_gray200_r4) + + when (position) { + 0 -> binding.viewFirstIndicator.setBackgroundResource(core_R.drawable.bg_rect_gray500_r4) + 1 -> binding.viewSecondIndicator.setBackgroundResource(core_R.drawable.bg_rect_gray500_r4) + else -> binding.viewThirdIndicator.setBackgroundResource(core_R.drawable.bg_rect_gray500_r4) + } + } + }) + + binding.btnNext.setOnSingleClickListener { + binding.vpOnBoarding.run { + if (currentItem == 2) { + // TODO: 시작하기 버튼 클릭됨 + } else { + currentItem += 1 + } + } + } + } + private inner class ScreenSlidePagerAdapter(fa: FragmentActivity) : FragmentStateAdapter(fa) { override fun getItemCount(): Int = NUM_PAGES // 페이지 수 리턴 override fun createFragment(position: Int): Fragment { - return when(position){ // 페이지 포지션에 따라 그에 맞는 프래그먼트를 보여줌 + return when (position) { // 페이지 포지션에 따라 그에 맞는 프래그먼트를 보여줌 0 -> OnboardingFragment.newInstance( title = getString(R.string.first_on_boarding_page_title), content = getString(R.string.first_on_boarding_page_content), ) + 1 -> OnboardingFragment.newInstance( title = getString(R.string.second_on_boarding_page_title), content = getString(R.string.second_on_boarding_page_content), ) + else -> OnboardingFragment.newInstance( title = getString(R.string.third_on_boarding_page_title), content = getString(R.string.third_on_boarding_page_content), diff --git a/presentation/onboarding/src/main/res/values/strings.xml b/presentation/onboarding/src/main/res/values/strings.xml index 7abc06d3..9a24c32e 100644 --- a/presentation/onboarding/src/main/res/values/strings.xml +++ b/presentation/onboarding/src/main/res/values/strings.xml @@ -1 +1,12 @@ - + + 3일부터 차근차근 시작해봐요 + 짝짝짝! 3일 연속 실천했나요? + 짝꿍과 함께 해볼까요? + + 작심삼일을 하며 좌절했던 과거는 안녕,\n작심삼일을 모아모아 작심삼백일까지! + 3일 연속 실천시 박수를 드려요.\n박수를 하나하나 모아볼까요? + 습관에 짝꿍을 연결하고 박수를 모아\n짝꿍을 레벨업 시켜보세요! + + 다음 + 시작하기 +