From b42770952552163669e3337436cc43a6c49d3aae Mon Sep 17 00:00:00 2001 From: JoYehyun Date: Wed, 7 Aug 2024 17:44:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?ui:=20type=20land=20=EB=B2=84=EC=A0=84=20xm?= =?UTF-8?q?l=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/layout-land/activity_type.xml | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 android/app/src/main/res/layout-land/activity_type.xml diff --git a/android/app/src/main/res/layout-land/activity_type.xml b/android/app/src/main/res/layout-land/activity_type.xml new file mode 100644 index 00000000..2809ceb1 --- /dev/null +++ b/android/app/src/main/res/layout-land/activity_type.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 94213b157dc8d4e0f2e10a83c17c2c1d5e6d0c1b Mon Sep 17 00:00:00 2001 From: JoYehyun Date: Wed, 7 Aug 2024 17:47:28 +0900 Subject: [PATCH 2/3] =?UTF-8?q?ui:=20=ED=99=94=EB=A9=B4=20=EB=AA=A8?= =?UTF-8?q?=EB=93=9C=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EC=83=81=EC=84=B1=20?= =?UTF-8?q?spanCount=20=EB=8B=A4=EB=A5=B4=EA=B2=8C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TypeSelectionBottomSheetFragment.kt | 24 +++++++++++++++---- .../fragment_type_selection_bottom_sheet.xml | 5 ++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/android/app/src/main/java/poke/rogue/helper/presentation/type/selection/TypeSelectionBottomSheetFragment.kt b/android/app/src/main/java/poke/rogue/helper/presentation/type/selection/TypeSelectionBottomSheetFragment.kt index 7035b233..ad5902a7 100644 --- a/android/app/src/main/java/poke/rogue/helper/presentation/type/selection/TypeSelectionBottomSheetFragment.kt +++ b/android/app/src/main/java/poke/rogue/helper/presentation/type/selection/TypeSelectionBottomSheetFragment.kt @@ -1,10 +1,13 @@ package poke.rogue.helper.presentation.type.selection +import android.content.res.Configuration import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.activityViewModels +import androidx.recyclerview.widget.GridLayoutManager +import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialogFragment import poke.rogue.helper.databinding.FragmentTypeSelectionBottomSheetBinding import poke.rogue.helper.presentation.type.TypeEvent @@ -31,7 +34,7 @@ class TypeSelectionBottomSheetFragment : BottomSheetDialogFragment() { private val sharedViewModel by activityViewModels() - private val adapter by lazy { + private val typeSelectionAdapter by lazy { TypeSelectionAdapter( sharedViewModel.allTypes, selectorType, @@ -40,6 +43,12 @@ class TypeSelectionBottomSheetFragment : BottomSheetDialogFragment() { ) } + override fun onStart() { + super.onStart() + val behavior = BottomSheetBehavior.from(requireView().parent as View) + behavior.state = BottomSheetBehavior.STATE_EXPANDED + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -59,9 +68,16 @@ class TypeSelectionBottomSheetFragment : BottomSheetDialogFragment() { } private fun initAdapter() { - binding.rvTypeSelection.adapter = adapter - val decoration = GridSpacingItemDecoration(spanCount = 4, spacing = 20.dp, includeEdge = false) - binding.rvTypeSelection.addItemDecoration(decoration) + with(binding.rvTypeSelection) { + adapter = typeSelectionAdapter + + val spanCount = if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) 6 else 4 + val gridLayoutManager = GridLayoutManager(requireContext(), spanCount) + layoutManager = gridLayoutManager + + val decoration = GridSpacingItemDecoration(spanCount = spanCount, spacing = 20.dp, includeEdge = false) + addItemDecoration(decoration) + } } private fun initObserver() { diff --git a/android/app/src/main/res/layout/fragment_type_selection_bottom_sheet.xml b/android/app/src/main/res/layout/fragment_type_selection_bottom_sheet.xml index c0c4f673..bf550d1f 100644 --- a/android/app/src/main/res/layout/fragment_type_selection_bottom_sheet.xml +++ b/android/app/src/main/res/layout/fragment_type_selection_bottom_sheet.xml @@ -10,22 +10,21 @@ + android:layout_height="wrap_content" /> From a64850d50136c0e7ae60aa057be2964cf07e3e32 Mon Sep 17 00:00:00 2001 From: JoYehyun Date: Wed, 7 Aug 2024 18:23:41 +0900 Subject: [PATCH 3/3] =?UTF-8?q?test:=20ui=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/type/TypeActivityTest.kt | 43 +++++++++++++++++++ .../main/res/layout-land/activity_type.xml | 1 + .../app/src/main/res/layout/activity_type.xml | 7 +-- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 android/app/src/androidTest/java/poke/rogue/helper/presentation/type/TypeActivityTest.kt diff --git a/android/app/src/androidTest/java/poke/rogue/helper/presentation/type/TypeActivityTest.kt b/android/app/src/androidTest/java/poke/rogue/helper/presentation/type/TypeActivityTest.kt new file mode 100644 index 00000000..10cda58b --- /dev/null +++ b/android/app/src/androidTest/java/poke/rogue/helper/presentation/type/TypeActivityTest.kt @@ -0,0 +1,43 @@ +package poke.rogue.helper.presentation.type + +import android.content.pm.ActivityInfo +import androidx.test.espresso.Espresso.onIdle +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.Rule +import org.junit.Test +import org.junit.jupiter.api.DisplayName +import org.junit.runner.RunWith +import poke.rogue.helper.R + +@RunWith(AndroidJUnit4::class) +class TypeActivityTest { + @get:Rule + val activityRule = ActivityScenarioRule(TypeActivity::class.java) + + @Test + @DisplayName("사용자가 아무것도 선택하지 않은 경우에는 선택 안내 이미지가 보인다") + fun test1() { + // then + onView(ViewMatchers.withId(R.id.iv_no_selection)) + .check(matches(isDisplayed())) + } + + @Test + @DisplayName("화면 회전시에도 사용자가 아무것도 선택하지 않은 경우에는 선택 안내 이미지가 보인다") + fun test2() { + // when + activityRule.scenario.onActivity { activity -> + activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE + } + onIdle() + + // then + onView(ViewMatchers.withId(R.id.iv_no_selection)) + .check(matches(isDisplayed())) + } +} diff --git a/android/app/src/main/res/layout-land/activity_type.xml b/android/app/src/main/res/layout-land/activity_type.xml index 2809ceb1..5b16b870 100644 --- a/android/app/src/main/res/layout-land/activity_type.xml +++ b/android/app/src/main/res/layout-land/activity_type.xml @@ -213,6 +213,7 @@ app:layout_constraintTop_toBottomOf="@id/tv_type_result_title" /> @@ -202,11 +202,11 @@