Skip to content

Commit

Permalink
Add create learner profile screen
Browse files Browse the repository at this point in the history
  • Loading branch information
adhiamboperes committed Feb 5, 2024
1 parent dd197e2 commit 2b6a5e2
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@
android:name=".app.onboarding.onboardingv2.OnboardingLearnerIntroActivity"
android:label="@string/onboarding_learner_intro_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.onboarding.onboardingv2.NewLearnerProfileActivity"
android:label="@string/create_profile_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 @@ -32,6 +32,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.onboardingv2.NewLearnerProfileActivity
import org.oppia.android.app.onboarding.onboardingv2.OnboardingLearnerIntroActivity
import org.oppia.android.app.onboarding.onboardingv2.OnboardingProfileTypeActivity
import org.oppia.android.app.ongoingtopiclist.OngoingTopicListActivity
Expand Down Expand Up @@ -125,6 +126,7 @@ interface ActivityComponentImpl :
appCompatCheckBoxBindingAdaptersTestActivity:
AppCompatCheckBoxBindingAdaptersTestActivity
)

fun inject(appLanguageActivity: AppLanguageActivity)
fun inject(appVersionActivity: AppVersionActivity)
fun inject(audioFragmentTestActivity: AudioFragmentTestActivity)
Expand Down Expand Up @@ -216,4 +218,5 @@ interface ActivityComponentImpl :
fun inject(surveyActivity: SurveyActivity)
fun inject(onboardingProfileTypeActivity: OnboardingProfileTypeActivity)
fun inject(onboardingLearnerIntroActivity: OnboardingLearnerIntroActivity)
fun inject(newLearnerProfileActivity: NewLearnerProfileActivity)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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.onboardingv2.NewLearnerProfileFragment
import org.oppia.android.app.onboarding.onboardingv2.OnboardingLearnerIntroFragment
import org.oppia.android.app.onboarding.onboardingv2.OnboardingProfileTypeFragment
import org.oppia.android.app.ongoingtopiclist.OngoingTopicListFragment
Expand Down Expand Up @@ -198,4 +199,5 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(surveyOutroDialogFragment: SurveyOutroDialogFragment)
fun inject(onboardingProfileTypeFragment: OnboardingProfileTypeFragment)
fun inject(onboardingLearnerIntroFragment: OnboardingLearnerIntroFragment)
fun inject(newLearnerProfileFragment: NewLearnerProfileFragment)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.oppia.android.app.onboarding.onboardingv2

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
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import javax.inject.Inject

/** Activity for displaying a new learner profile creation flow. */
class NewLearnerProfileActivity : InjectableAutoLocalizedAppCompatActivity() {
@Inject
lateinit var learnerProfileActivityPresenter: NewLearnerProfileActivityPresenter

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

learnerProfileActivityPresenter.handleOnCreate()
}

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

import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import org.oppia.android.R
import org.oppia.android.databinding.CreateProfileActivityBinding
import javax.inject.Inject

private const val TAG_CREATE_PROFILE_ACTIVITY_FRAGMENT = "TAG_CREATE_PROFILE_ACTIVITY_FRAGMENT"

/** Presenter for [NewLearnerProfileActivity]. */
class NewLearnerProfileActivityPresenter @Inject constructor(
private val activity: AppCompatActivity
) {
private lateinit var binding: CreateProfileActivityBinding

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

if (getNewLearnerProfileFragment() == null) {
val createLearnerProfileFragment = NewLearnerProfileFragment()
activity.supportFragmentManager.beginTransaction().add(
R.id.profile_fragment_placeholder,
createLearnerProfileFragment,
TAG_CREATE_PROFILE_ACTIVITY_FRAGMENT
)
.commitNow()
}
}

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

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 for displaying a new learner profile creation flow. */
class NewLearnerProfileFragment : InjectableFragment() {
@Inject
lateinit var learnerProfileFragmentPresenter: NewLearnerProfileFragmentPresenter

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

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

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.oppia.android.databinding.CreateProfileFragmentBinding
import javax.inject.Inject

/** Presenter for [NewLearnerProfileFragment]. */
class NewLearnerProfileFragmentPresenter @Inject constructor(
private val fragment: Fragment
) {
private lateinit var binding: CreateProfileFragmentBinding

fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View {
binding = CreateProfileFragmentBinding.inflate(
inflater,
container,
/* attachToRoot= */ false
)
binding.let {
it.lifecycleOwner = fragment
}

return binding.root
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OnboardingLearnerIntroActivityPresenter @Inject constructor(
) {
private lateinit var binding: OnboardingLearnerIntroActivityBinding

/** Handle creation and binding of the OnboardingProfileTypeActivity layout. */
/** Handle creation and binding of the OnboardingLearnerIntroActivity layout. */
fun handleOnCreate() {
binding = DataBindingUtil.setContentView(activity, R.layout.onboarding_learner_intro_activity)
binding.apply {
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/create_profile_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".app.onboarding.onboardingv2.NewLearnerProfileActivity">

<FrameLayout
android:id="@+id/profile_fragment_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
104 changes: 104 additions & 0 deletions app/src/main/res/layout/create_profile_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?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_white_color">

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

<TextView
android:id="@+id/create_profile_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="@string/create_profile_activity_header"
android:textColor="@color/color_palette_onboarding_black_color"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/create_profile_header_guide" />

<TextView
android:id="@+id/create_profile_nickname_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:fontFamily="sans-serif"
android:labelFor="@id/create_profile_nickname_edittext"
android:text="@string/create_profile_activity_nickname_label"
android:textColor="@color/component_color_shared_primary_text_color"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/create_profile_title" />

<EditText
android:id="@+id/create_profile_nickname_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:autofillHints="false"
android:background="@drawable/edit_text_background_border"
android:fontFamily="sans-serif"
android:inputType="text"
android:padding="8dp"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/create_profile_nickname_label"
tools:text="John" />

<TextView
android:id="@+id/create_profile_nickname_error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="12dp"
android:fontFamily="sans-serif"
android:labelFor="@id/create_profile_nickname_edittext"
android:text="@string/create_profile_activity_nickname_error"
android:textColor="@color/component_color_shared_input_error_color"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/create_profile_nickname_edittext" />

<TextView
android:id="@+id/onboarding_steps_count"
style="@style/OnboardingStepCountStyle"
android:layout_margin="@dimen/onboarding_language_text_margin"
android:text="@string/onboarding_step_count_three"
app:layout_constraintBottom_toTopOf="@id/onboarding_navigation_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/onboarding_navigation_back"
style="@style/OnboardingNavigationSecondaryButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/onboarding_navigation_back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/onboarding_navigation_continue"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/onboarding_navigation_continue"
style="@style/OnboardingNavigationPrimaryButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/onboarding_navigation_continue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/onboarding_navigation_back" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,13 @@
<!-- Onboarding Profile Type Activity -->
<string name="onboarding_profile_type_activity_title">Profile Type</string>

<!-- Onboarding Create New Profile Activity -->
<string name="create_profile_activity_title">Create Profile</string>
<string name="create_profile_activity_header">What should we call you?</string>
<string name="create_profile_activity_nickname_label">Nickname</string>
<string name="create_profile_activity_profile_picture_prompt">Tap here to add a picture</string>
<string name="create_profile_activity_nickname_error">Click in the box above to type your nickname.</string>

<!-- Onboarding Learner Intro Activity -->
<string name="onboarding_learner_intro_activity_title">Welcome</string>
<string name="onboarding_learner_intro_activity_text">Welcome, %s!</string>
Expand Down
3 changes: 3 additions & 0 deletions model/src/main/proto/screens.proto
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ enum ScreenName {

// Screen name value for the scenario when the learner welcome activity is visible to the user.
ONBOARDING_LEARNER_INTRO_ACTIVITY = 51;

// Screen name value for the scenario when the create new learner profile activity is visible to the user.
CREATE_NEW_LEARNER_PROFILE_ACTIVITY = 52;
}

// Defines the current visible UI screen of the application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ class EventBundleCreator @Inject constructor(
ScreenName.SURVEY_ACTIVITY -> "survey_activity"
ScreenName.ONBOARDING_PROFILE_TYPE_ACTIVITY -> "onboarding_profile_type_activity"
ScreenName.ONBOARDING_LEARNER_INTRO_ACTIVITY -> "onboarding_learner_intro_activity"
ScreenName.CREATE_NEW_LEARNER_PROFILE_ACTIVITY -> "create_new_learner_profile_activity"
}

private fun AppLanguageSelection.toAnalyticsText(): String {
Expand Down

0 comments on commit 2b6a5e2

Please sign in to comment.