-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
103f5a8
commit b278b5e
Showing
29 changed files
with
2,363 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/org/oppia/android/app/onboarding/OnboardingProfileTypeActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/org/oppia/android/app/onboarding/OnboardingProfileTypeActivityPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/org/oppia/android/app/onboarding/OnboardingProfileTypeFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/org/oppia/android/app/onboarding/OnboardingProfileTypeFragmentPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.