From 7c11bcdba0df1ff532a4d2bb283ee66577c290dc Mon Sep 17 00:00:00 2001 From: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:56:27 +0300 Subject: [PATCH] Create app language selection UI --- .../app/onboarding/OnboardingFragment.kt | 16 +- .../OnboardingFragmentPresenter.kt | 40 ++++ .../main/res/drawable/dropdown_background.xml | 23 +++ ...arding_app_language_selection_fragment.xml | 139 ++++++++++++++ ...arding_app_language_selection_fragment.xml | 171 +++++++++++++++++ ...arding_app_language_selection_fragment.xml | 173 ++++++++++++++++++ ...arding_app_language_selection_fragment.xml | 150 +++++++++++++++ .../main/res/values-night/color_palette.xml | 3 + app/src/main/res/values/color_palette.xml | 3 + app/src/main/res/values/component_colors.xml | 4 + app/src/main/res/values/dimens.xml | 36 ++++ app/src/main/res/values/strings.xml | 12 ++ app/src/main/res/values/styles.xml | 64 +++++++ 13 files changed, 833 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/org/oppia/android/app/onboardingv2/OnboardingFragmentPresenter.kt create mode 100644 app/src/main/res/drawable/dropdown_background.xml create mode 100644 app/src/main/res/layout-land/onboarding_app_language_selection_fragment.xml create mode 100644 app/src/main/res/layout-sw600dp-land/onboarding_app_language_selection_fragment.xml create mode 100644 app/src/main/res/layout-sw600dp-port/onboarding_app_language_selection_fragment.xml create mode 100644 app/src/main/res/layout/onboarding_app_language_selection_fragment.xml diff --git a/app/src/main/java/org/oppia/android/app/onboarding/OnboardingFragment.kt b/app/src/main/java/org/oppia/android/app/onboarding/OnboardingFragment.kt index 081abae41ee..26949323a18 100644 --- a/app/src/main/java/org/oppia/android/app/onboarding/OnboardingFragment.kt +++ b/app/src/main/java/org/oppia/android/app/onboarding/OnboardingFragment.kt @@ -7,13 +7,23 @@ import android.view.View import android.view.ViewGroup import org.oppia.android.app.fragment.FragmentComponentImpl import org.oppia.android.app.fragment.InjectableFragment +import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2 +import org.oppia.android.util.platformparameter.PlatformParameterValue import javax.inject.Inject +import org.oppia.android.app.onboardingv2.OnboardingFragmentPresenter as OnboardingFragmentPresenterV2 /** Fragment that contains an onboarding flow of the app. */ class OnboardingFragment : InjectableFragment() { @Inject lateinit var onboardingFragmentPresenter: OnboardingFragmentPresenter + @Inject + lateinit var onboardingFragmentPresenterV2: OnboardingFragmentPresenterV2 + + @Inject + @field:EnableOnboardingFlowV2 + lateinit var enableOnboardingFlowV2: PlatformParameterValue + override fun onAttach(context: Context) { super.onAttach(context) (fragmentComponent as FragmentComponentImpl).inject(this) @@ -24,6 +34,10 @@ class OnboardingFragment : InjectableFragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View? { - return onboardingFragmentPresenter.handleCreateView(inflater, container) + return if (enableOnboardingFlowV2.value) { + onboardingFragmentPresenterV2.handleCreateView(inflater, container) + } else { + onboardingFragmentPresenter.handleCreateView(inflater, container) + } } } diff --git a/app/src/main/java/org/oppia/android/app/onboardingv2/OnboardingFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/onboardingv2/OnboardingFragmentPresenter.kt new file mode 100644 index 00000000000..caa845c047b --- /dev/null +++ b/app/src/main/java/org/oppia/android/app/onboardingv2/OnboardingFragmentPresenter.kt @@ -0,0 +1,40 @@ +package org.oppia.android.app.onboardingv2 + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import javax.inject.Inject +import org.oppia.android.R +import org.oppia.android.app.fragment.FragmentScope +import org.oppia.android.app.translation.AppLanguageResourceHandler +import org.oppia.android.databinding.OnboardingAppLanguageSelectionFragmentBinding + +/** The presenter for [OnboardingFragment] V2. */ +@FragmentScope +class OnboardingFragmentPresenter @Inject constructor( + private val fragment: Fragment, + private val appLanguageResourceHandler: AppLanguageResourceHandler +) { + private lateinit var binding: OnboardingAppLanguageSelectionFragmentBinding + + /** Handle creation and binding of the [OnboardingFragment] V2 layout. */ + fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View { + binding = OnboardingAppLanguageSelectionFragmentBinding.inflate( + inflater, + container, + /* attachToRoot= */ false + ) + + binding.let { + it.lifecycleOwner = fragment + } + + binding.onboardingLanguageTitle.text = appLanguageResourceHandler.getStringInLocaleWithWrapping( + R.string.onboarding_language_activity_title, + appLanguageResourceHandler.getStringInLocale(R.string.app_name) + ) + + return binding.root + } +} diff --git a/app/src/main/res/drawable/dropdown_background.xml b/app/src/main/res/drawable/dropdown_background.xml new file mode 100644 index 00000000000..3eca06cfe8c --- /dev/null +++ b/app/src/main/res/drawable/dropdown_background.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-land/onboarding_app_language_selection_fragment.xml b/app/src/main/res/layout-land/onboarding_app_language_selection_fragment.xml new file mode 100644 index 00000000000..f33dbad10d1 --- /dev/null +++ b/app/src/main/res/layout-land/onboarding_app_language_selection_fragment.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +