Skip to content

Commit

Permalink
Create app language selection UI
Browse files Browse the repository at this point in the history
  • Loading branch information
adhiamboperes committed Mar 27, 2024
1 parent a17713d commit 7c11bcd
Show file tree
Hide file tree
Showing 13 changed files with 833 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>

override fun onAttach(context: Context) {
super.onAttach(context)
(fragmentComponent as FragmentComponentImpl).inject(this)
Expand All @@ -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)
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
23 changes: 23 additions & 0 deletions app/src/main/res/drawable/dropdown_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/component_color_shared_white_background_color" />
<corners
android:bottomLeftRadius="@dimen/onboarding_shared_corner_radius"
android:bottomRightRadius="@dimen/onboarding_shared_corner_radius" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="1dp"
android:right="2dp"
android:top="0dp">
<shape android:shape="rectangle">
<solid android:color="@color/component_color_shared_white_background_color" />
<corners
android:bottomLeftRadius="@dimen/onboarding_shared_corner_radius"
android:bottomRightRadius="@dimen/onboarding_shared_corner_radius" />
</shape>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/component_color_onboarding_shared_green_color">

<TextView
android:id="@+id/onboarding_language_title"
style="@style/OnboardingHeaderStyle"
android:layout_marginTop="@dimen/onboarding_shared_margin_medium_large"
android:text="@string/onboarding_language_activity_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/onboarding_language_subtitle"
style="@style/OnboardingLanguageSubtitleStyle"
android:layout_marginTop="@dimen/onboarding_shared_margin_small"
android:text="@string/onboarding_language_activity_subtitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/onboarding_language_title" />

<TextView
android:id="@+id/onboarding_language_text"
style="@style/OnboardingLanguageMessageStyle"
android:layout_marginTop="@dimen/onboarding_shared_margin_medium_small"
android:text="@string/onboarding_language_activity_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/onboarding_language_subtitle" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/onboarding_language_center_guide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.40" />

<org.oppia.android.app.customview.OppiaCurveBackgroundView
android:id="@+id/onboarding_app_language_background"
android:layout_width="match_parent"
android:layout_height="0dp"
app:customBackgroundColor="@color/component_color_onboarding_shared_white_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="@id/onboarding_language_center_guide" />

<ImageView
android:id="@+id/onboarding_app_language_image"
android:layout_width="132dp"
android:layout_height="140dp"
android:layout_marginEnd="@dimen/onboarding_shared_margin_3xl"
android:contentDescription="@string/onboarding_otter_content_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/onboarding_language_title"
app:srcCompat="@drawable/otter" />

<TextView
android:id="@+id/onboarding_language_label"
style="@style/OnboardingLanguageLabelStyle"
android:layout_marginTop="@dimen/onboarding_shared_margin_medium_large"
android:text="@string/onboarding_language_activity_select_label"
app:layout_constraintBottom_toTopOf="@id/onboarding_language_dropdown_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/onboarding_language_center_guide" />

<RelativeLayout
android:id="@+id/onboarding_language_dropdown_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/onboarding_shared_margin_5xl"
android:layout_marginEnd="@dimen/onboarding_shared_margin_5xl"
android:layout_marginBottom="@dimen/onboarding_shared_margin_small"
android:background="@drawable/dropdown_background"
android:elevation="@dimen/onboarding_shared_elevation"
android:padding="@dimen/onboarding_shared_padding_small"
app:layout_constraintBottom_toTopOf="@id/onboarding_language_explanation">

<ImageView
android:id="@+id/onboarding_language_dropdown_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/onboarding_shared_margin_small"
android:layout_marginTop="@dimen/onboarding_shared_margin_x_small"
android:layout_marginEnd="@dimen/onboarding_shared_margin_small"
android:layout_marginBottom="@dimen/onboarding_shared_margin_x_small"
android:contentDescription="@string/onboarding_language_dropdown_icon_description"
app:srcCompat="@drawable/ic_language_icon_black_24dp" />

<Spinner
android:id="@+id/onboarding_language_dropdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginStart="@dimen/onboarding_shared_margin_2xl"
android:layout_toStartOf="@id/onboarding_language_dropdown_arrow"
android:background="@drawable/transparent_background"
android:textColor="@color/component_color_onboarding_shared_text_color"
tools:listheader="English" />

<ImageView
android:id="@+id/onboarding_language_dropdown_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginStart="@dimen/onboarding_shared_margin_small"
android:layout_marginTop="@dimen/onboarding_shared_margin_x_small"
android:layout_marginEnd="@dimen/onboarding_shared_margin_small"
android:layout_marginBottom="@dimen/onboarding_shared_margin_x_small"
android:contentDescription="@string/onboarding_language_dropdown_arrow_icon_description"
app:srcCompat="@drawable/ic_arrow_drop_down_black_24dp" />
</RelativeLayout>

<TextView
android:id="@+id/onboarding_language_explanation"
style="@style/OnboardingLanguageExplanationStyle"
android:layout_marginBottom="@dimen/onboarding_shared_margin_medium_small"
android:text="@string/onboarding_language_activity_explanation_text"
app:layout_constraintBottom_toTopOf="@id/onboarding_language_lets_go_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/onboarding_language_lets_go_button"
style="@style/OnboardingLanguageLetsGoButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/onboarding_language_activity_button_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Loading

0 comments on commit 7c11bcd

Please sign in to comment.