Skip to content

Commit

Permalink
Fix Part of #4938: Introduce Onboarding profile type screen (#5378)
Browse files Browse the repository at this point in the history
<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
Fixes Part of #4938: Introduce Onboarding profile type screen

Adds the profile type selection screen.

The new "I am a student" flow is not implemented, and tests have been
set up to fail when the flow has been implemented.

The "I am a parent/teacher" flow has been set up to route to the
existing profile screen.

## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

All tests pass on Espresso
![Screenshot 2024-05-23 at 18 06
46](https://github.com/oppia/oppia-android/assets/59600948/6d2414c9-6ddf-4340-a408-52a7a5c8acdc)

## For UI-specific PRs only
||||
| --- | --- | --- |
|| Portrait | Landscape |
| Mobile Light Mode
|![Screenshot_1719762068](https://github.com/oppia/oppia-android/assets/59600948/6adbff2d-6cc7-4884-bd31-8ddbc4f0d359)|![Screenshot_1719762228](https://github.com/oppia/oppia-android/assets/59600948/e9dcb7bc-9d1b-44e7-86ea-2f4d669fe5c6)|
| Mobile Dark Mode
|![Screenshot_1719761957](https://github.com/oppia/oppia-android/assets/59600948/c1248dda-d377-4586-9613-803517fd7d24)|![Screenshot_1719762205](https://github.com/oppia/oppia-android/assets/59600948/9cf78a42-8d7d-442b-9b4e-8db02d3c5bdf)|
| Tablet Light Mode
|![Screenshot_1719762364](https://github.com/oppia/oppia-android/assets/59600948/ee8d2de4-90e6-478c-b9e2-cfbba5b7b012)|![Screenshot_1719762334](https://github.com/oppia/oppia-android/assets/59600948/6e5d6f81-b7e1-4ac4-ab99-05832bb7a7a8)|
| Tablet Dark Mode
|![Screenshot_1719762388](https://github.com/oppia/oppia-android/assets/59600948/1e74ded0-4110-4995-a8f8-68feba04e769)|![Screenshot_1719762309](https://github.com/oppia/oppia-android/assets/59600948/8edef377-64aa-4828-aba4-42804a7fb029)|
  • Loading branch information
adhiamboperes authored Jun 30, 2024
1 parent 103f5a8 commit b278b5e
Show file tree
Hide file tree
Showing 29 changed files with 2,363 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@
android:name=".app.classroom.ClassroomListActivity"
android:label="@string/classroom_list_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.onboarding.OnboardingProfileTypeActivity"
android:label="@string/onboarding_profile_type_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.oppia.android.app.home.HomeActivity
import org.oppia.android.app.home.recentlyplayed.RecentlyPlayedActivity
import org.oppia.android.app.mydownloads.MyDownloadsActivity
import org.oppia.android.app.onboarding.OnboardingActivity
import org.oppia.android.app.onboarding.OnboardingProfileTypeActivity
import org.oppia.android.app.ongoingtopiclist.OngoingTopicListActivity
import org.oppia.android.app.options.AppLanguageActivity
import org.oppia.android.app.options.AudioLanguageActivity
Expand Down Expand Up @@ -220,4 +221,5 @@ interface ActivityComponentImpl :
fun inject(surveyActivity: SurveyActivity)
fun inject(colorBindingAdaptersTestActivity: ColorBindingAdaptersTestActivity)
fun inject(classroomListActivity: ClassroomListActivity)
fun inject(onboardingProfileTypeActivity: OnboardingProfileTypeActivity)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.oppia.android.app.notice.GeneralAvailabilityUpgradeNoticeDialogFragme
import org.oppia.android.app.notice.OptionalAppDeprecationNoticeDialogFragment
import org.oppia.android.app.notice.OsDeprecationNoticeDialogFragment
import org.oppia.android.app.onboarding.OnboardingFragment
import org.oppia.android.app.onboarding.OnboardingProfileTypeFragment
import org.oppia.android.app.ongoingtopiclist.OngoingTopicListFragment
import org.oppia.android.app.options.AppLanguageFragment
import org.oppia.android.app.options.AudioLanguageFragment
Expand Down Expand Up @@ -196,4 +197,5 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(surveyWelcomeDialogFragment: SurveyWelcomeDialogFragment)
fun inject(surveyOutroDialogFragment: SurveyOutroDialogFragment)
fun inject(classroomListFragment: ClassroomListFragment)
fun inject(onboardingProfileTypeFragment: OnboardingProfileTypeFragment)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.oppia.android.app.onboarding
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import org.oppia.android.R
import org.oppia.android.app.fragment.FragmentScope
Expand All @@ -13,6 +14,7 @@ import javax.inject.Inject
/** The presenter for [OnboardingFragment]. */
@FragmentScope
class OnboardingFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val appLanguageResourceHandler: AppLanguageResourceHandler
) {
Expand All @@ -33,6 +35,12 @@ class OnboardingFragmentPresenter @Inject constructor(
R.string.onboarding_language_activity_title,
appLanguageResourceHandler.getStringInLocale(R.string.app_name)
)

onboardingLanguageLetsGoButton.setOnClickListener {
val intent =
OnboardingProfileTypeActivity.createOnboardingProfileTypeActivityIntent(activity)
fragment.startActivity(intent)
}
}

return binding.root
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.oppia.android.app.onboarding

import android.content.Context
import android.content.Intent
import android.os.Bundle
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.model.ScreenName.ONBOARDING_PROFILE_TYPE_ACTIVITY
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import javax.inject.Inject

/** The activity for showing the profile type selection screen. */
class OnboardingProfileTypeActivity : InjectableAutoLocalizedAppCompatActivity() {
@Inject
lateinit var onboardingProfileTypeActivityPresenter: OnboardingProfileTypeActivityPresenter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)

onboardingProfileTypeActivityPresenter.handleOnCreate()
}

companion object {
/** Returns a new [Intent] open a [OnboardingProfileTypeActivity] with the specified params. */
fun createOnboardingProfileTypeActivityIntent(context: Context): Intent {
return Intent(context, OnboardingProfileTypeActivity::class.java).apply {
decorateWithScreenName(ONBOARDING_PROFILE_TYPE_ACTIVITY)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.oppia.android.app.onboarding

import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityScope
import org.oppia.android.databinding.OnboardingProfileTypeActivityBinding
import javax.inject.Inject

private const val TAG_PROFILE_TYPE_FRAGMENT = "TAG_PROFILE_TYPE_FRAGMENT"

/** The Presenter for [OnboardingProfileTypeActivity]. */
@ActivityScope
class OnboardingProfileTypeActivityPresenter @Inject constructor(
private val activity: AppCompatActivity
) {
private lateinit var binding: OnboardingProfileTypeActivityBinding

/** Handle creation and binding of the OnboardingProfileTypeActivity layout. */
fun handleOnCreate() {
binding = DataBindingUtil.setContentView(activity, R.layout.onboarding_profile_type_activity)
binding.apply {
lifecycleOwner = activity
}

if (getOnboardingProfileTypeFragment() == null) {
val onboardingProfileTypeFragment = OnboardingProfileTypeFragment()
activity.supportFragmentManager.beginTransaction().add(
R.id.profile_type_fragment_placeholder,
onboardingProfileTypeFragment,
TAG_PROFILE_TYPE_FRAGMENT
).commitNow()
}
}

private fun getOnboardingProfileTypeFragment(): OnboardingProfileTypeFragment? {
return activity.supportFragmentManager.findFragmentByTag(
TAG_PROFILE_TYPE_FRAGMENT
) as? OnboardingProfileTypeFragment
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.oppia.android.app.onboarding

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.oppia.android.app.fragment.FragmentComponentImpl
import org.oppia.android.app.fragment.InjectableFragment
import javax.inject.Inject

/** Fragment that contains the profile type selection flow of the app. */
class OnboardingProfileTypeFragment : InjectableFragment() {
@Inject
lateinit var onboardingProfileTypeFragmentPresenter: OnboardingProfileTypeFragmentPresenter

override fun onAttach(context: Context) {
super.onAttach(context)
(fragmentComponent as FragmentComponentImpl).inject(this)
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return onboardingProfileTypeFragmentPresenter.handleCreateView(inflater, container)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.oppia.android.app.onboarding

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import org.oppia.android.app.profile.ProfileChooserActivity
import org.oppia.android.databinding.OnboardingProfileTypeFragmentBinding
import javax.inject.Inject

/** The presenter for [OnboardingProfileTypeFragment]. */
class OnboardingProfileTypeFragmentPresenter @Inject constructor(
private val fragment: Fragment,
private val activity: AppCompatActivity
) {
private lateinit var binding: OnboardingProfileTypeFragmentBinding

/** Handle creation and binding of the OnboardingProfileTypeFragment layout. */
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View {
binding = OnboardingProfileTypeFragmentBinding.inflate(
inflater,
container,
/* attachToRoot= */ false
)

binding.apply {
lifecycleOwner = fragment

profileTypeSupervisorNavigationCard.setOnClickListener {
val intent = ProfileChooserActivity.createProfileChooserActivity(activity)
fragment.startActivity(intent)
}

onboardingNavigationBack.setOnClickListener {
activity.finish()
}
}
return binding.root
}
}
Loading

0 comments on commit b278b5e

Please sign in to comment.