Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Part of #4938: Introduce Create profile screen #5380

Merged
merged 134 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
5d86f13
Add drawable resources
adhiamboperes Mar 27, 2024
a17713d
Make SurveyOnboardingBackgroundView generic for reuse.
adhiamboperes Mar 27, 2024
7c11bcd
Create app language selection UI
adhiamboperes Mar 27, 2024
722c759
Add tests for the new app language screen
adhiamboperes Mar 27, 2024
0a24f11
Fix UI
adhiamboperes Mar 27, 2024
1462eb7
Fix buildifier issue
adhiamboperes Mar 27, 2024
a337b9b
Merge remote-tracking branch 'upstream/new-onboarding-screen' into on…
adhiamboperes Apr 2, 2024
785716e
Add OnboardingProfileTypeActivity
adhiamboperes Apr 3, 2024
3067ff2
Add drawable resources
adhiamboperes Apr 3, 2024
5a41256
Add profile type selection UI with navigation.
adhiamboperes Apr 3, 2024
40d188f
Add tests
adhiamboperes Apr 3, 2024
434d9dc
Add test file exemptions
adhiamboperes Apr 3, 2024
5bd5239
Fix ktlint issue
adhiamboperes Apr 3, 2024
5fb890e
Addressed general feedback
adhiamboperes Apr 3, 2024
adbdbed
Fix curve background for landscape orientation
adhiamboperes Apr 3, 2024
4f0c57b
Flatten Bg drawable
adhiamboperes Apr 3, 2024
187726c
Merge branch 'develop' of github.com:oppia/oppia-android into new-onb…
adhiamboperes Apr 3, 2024
3d2313c
Merge remote-tracking branch 'upstream/new-onboarding-screen' into on…
adhiamboperes Apr 3, 2024
352bf33
Merge branch 'onboarding-profile-type-screen' into create-profile-screen
adhiamboperes Apr 9, 2024
75c39bc
Create CreateProfileActivity
adhiamboperes Apr 9, 2024
125a408
Create CreateProfileFragment
adhiamboperes Apr 9, 2024
cf1f68f
Navigate to CreateProfileActivity
adhiamboperes Apr 9, 2024
eebf64d
Fix ktlint failures
adhiamboperes Apr 9, 2024
027d912
Add tests
adhiamboperes Apr 9, 2024
0d7980f
Add tests for profile picture upload
adhiamboperes Apr 9, 2024
312fc38
Add layout for tablets
adhiamboperes Apr 9, 2024
6ccba79
Fix self review comments
adhiamboperes Apr 9, 2024
0bc5547
Merge branch 'develop' into new-onboarding-screen
adhiamboperes Apr 9, 2024
f31e23d
Create tablet layouts and darkmode bg
adhiamboperes Apr 9, 2024
3e6c7b3
Merge branch 'new-onboarding-screen' of github.com:oppia/oppia-androi…
adhiamboperes Apr 9, 2024
f1d9092
Fix formatting
adhiamboperes Apr 9, 2024
3e2166e
Fix failing test
adhiamboperes Apr 9, 2024
fc452fc
Merge remote-tracking branch 'upstream/onboarding-profile-type-screen…
adhiamboperes Apr 9, 2024
98fcfe6
Fix failing test
adhiamboperes Apr 9, 2024
ccca3a4
Fix missing bazel declaration for CreateProfileViewModel
adhiamboperes Apr 9, 2024
5d052e4
Fix missing bazel declaration for CreateProfileViewModel
adhiamboperes Apr 9, 2024
3b4e235
Fix paint style for OppiaCurveBackgroundView.kt
adhiamboperes Apr 17, 2024
b7935e1
Merge branch 'develop' of github.com:oppia/oppia-android into new-onb…
adhiamboperes Apr 17, 2024
b722e49
Merge branch 'new-onboarding-screen' of github.com:oppia/oppia-androi…
adhiamboperes Apr 17, 2024
8f7e355
Adjust height of the otter drawable
adhiamboperes Apr 17, 2024
b411179
Improve styling for phone layouts
adhiamboperes May 22, 2024
bad32c5
Improve styling for tablet layouts
adhiamboperes May 22, 2024
7345107
Clean up padding and text size dimensions
adhiamboperes May 22, 2024
30b26e0
Clean up padding and text size dimensions
adhiamboperes May 22, 2024
2c10cd2
Remove space
adhiamboperes May 22, 2024
3d7cf86
Fix failing test
adhiamboperes May 22, 2024
e67a2f0
Merge branch 'new-onboarding-screen' into onboarding-profile-type-screen
adhiamboperes May 23, 2024
4f53fb5
Update styling
adhiamboperes May 23, 2024
70fac4a
Remove unnecessary tests
adhiamboperes May 23, 2024
8d5c408
Fix indentation
adhiamboperes May 23, 2024
73874b8
Fix general review comments
adhiamboperes May 23, 2024
9547f8d
Create style for back navigation button
adhiamboperes May 23, 2024
cd54544
Fix mobile landscape layout
adhiamboperes May 23, 2024
16c9a97
Fix tests and add tests for mobile landscape layout
adhiamboperes May 23, 2024
0ea7456
Fix ktlint
adhiamboperes May 23, 2024
076c7f0
Fix ktlint
adhiamboperes May 23, 2024
ca2fbfe
Merge branch 'onboarding-profile-type-screen' into create-profile-screen
adhiamboperes May 23, 2024
ab2ee84
Improve phone layout styling
adhiamboperes May 23, 2024
b2bc62d
Improve tablet layout styling
adhiamboperes May 23, 2024
8e5ac97
Fix tests
adhiamboperes May 23, 2024
827afae
Flatten the activity layout
adhiamboperes May 23, 2024
114ae78
Revert formatting changes in the styles file
adhiamboperes May 23, 2024
fde105c
Merge branch 'develop' of github.com:oppia/oppia-android into new-onb…
adhiamboperes May 23, 2024
01c45af
Merge branch 'new-onboarding-screen' into onboarding-profile-type-screen
adhiamboperes May 23, 2024
0bdd447
Fix margin and update with develop
adhiamboperes May 24, 2024
1a4ae23
Merge remote-tracking branch 'upstream/onboarding-profile-type-screen…
adhiamboperes May 24, 2024
497d35b
Fix missing kdoc
adhiamboperes May 24, 2024
9dcf007
Fix kdoc
adhiamboperes May 24, 2024
bbe7221
Refactor existing OnboardingFragmentPresenter to OnboardingFragmentPr…
adhiamboperes May 28, 2024
05f598d
Refactor the dropdown
adhiamboperes May 31, 2024
6565d73
Refactor the dropdown in alternate layouts
adhiamboperes May 31, 2024
d67f5ed
Refactor custom background to a binding adapter
adhiamboperes Jun 2, 2024
7c69c15
Fix failing tests and set up bazel test
adhiamboperes Jun 2, 2024
0a7c600
Merge remote-tracking branch 'upstream/develop' into new-onboarding-s…
adhiamboperes Jun 2, 2024
1c0494f
Fix ktlint
adhiamboperes Jun 2, 2024
a8c207a
Replace otter png with SVG
adhiamboperes Jun 3, 2024
1172ff6
Fix failing tests and general cleanup
adhiamboperes Jun 3, 2024
4612e6b
Fix test file exemption
adhiamboperes Jun 3, 2024
d3451ab
Fix accessibility label exemption
adhiamboperes Jun 3, 2024
6095c54
Fix drawable vector hex exemption
adhiamboperes Jun 3, 2024
2540989
Fix unused exemption
adhiamboperes Jun 3, 2024
65d9f11
Fix failing test
adhiamboperes Jun 3, 2024
3bf91c3
Move files to onboarding package
adhiamboperes Jun 3, 2024
18ba375
Merge remote-tracking branch 'upstream/new-onboarding-screen' into on…
adhiamboperes Jun 3, 2024
05d05f1
Resolve merge conflicts
adhiamboperes Jun 3, 2024
1067e57
Added oxford comma
adhiamboperes Jun 3, 2024
e79b69b
Removed leftover exemption
adhiamboperes Jun 3, 2024
c694f51
Fix tests
adhiamboperes Jun 3, 2024
12fbcad
Fix static check errors
adhiamboperes Jun 4, 2024
56f2998
Move everything to onboarding package
adhiamboperes Jun 4, 2024
3fe2539
Merge remote-tracking branch 'upstream/onboarding-profile-type-screen…
adhiamboperes Jun 4, 2024
d955011
Address initial review comments + pull in changes from upstream
adhiamboperes Jun 4, 2024
7286c86
Address styling suggestions
adhiamboperes Jun 4, 2024
787c3f1
Add textwatcher to name edittext
adhiamboperes Jun 4, 2024
2d895c0
Switch to glide util
adhiamboperes Jun 4, 2024
26b7f1e
Add test for image loading
adhiamboperes Jun 4, 2024
e39cd19
Add test for image loading
adhiamboperes Jun 4, 2024
c9f4d82
Fix script check failures
adhiamboperes Jun 4, 2024
c23baab
Fix missing build input
adhiamboperes Jun 4, 2024
90d56c1
Fix script check failures
adhiamboperes Jun 4, 2024
f14bbb1
Merge remote-tracking branch 'upstream/develop' into new-onboarding-s…
adhiamboperes Jun 11, 2024
ea056af
Merge branch 'new-onboarding-screen' into onboarding-profile-type-screen
adhiamboperes Jun 11, 2024
5237f63
Merge remote-tracking branch 'upstream/onboarding-profile-type-screen…
adhiamboperes Jun 11, 2024
3fdf74f
Fix merge conflict
adhiamboperes Jun 11, 2024
c2c244b
Merge branch 'new-onboarding-screen' into onboarding-profile-type-screen
adhiamboperes Jun 11, 2024
b802921
Merge branch 'onboarding-profile-type-screen' into create-profile-screen
adhiamboperes Jun 11, 2024
a435c11
Create new style for error messages
adhiamboperes Jun 11, 2024
3f3b810
Add textwatcher test
adhiamboperes Jun 11, 2024
5b3ecba
Fix small issues
adhiamboperes Jun 11, 2024
5b43705
Fix small issues
adhiamboperes Jun 11, 2024
72624f5
Merge branch 'develop' into new-onboarding-screen
adhiamboperes Jun 17, 2024
13d9ac5
Merge branch 'new-onboarding-screen' into onboarding-profile-type-screen
adhiamboperes Jun 17, 2024
f0d0c57
Merge branch 'onboarding-profile-type-screen' into create-profile-screen
adhiamboperes Jun 17, 2024
485dc54
Replace Lifecycle.State check with activity.isFinishing
adhiamboperes Jun 18, 2024
33624d7
Flatten layout
adhiamboperes Jun 19, 2024
2b10f80
Resolve merge conflicts
adhiamboperes Jun 19, 2024
1ade253
Merge branch 'onboarding-profile-type-screen' into create-profile-screen
adhiamboperes Jun 19, 2024
49586cc
Adjust profile picture prompt
adhiamboperes Jun 19, 2024
2d5d438
Add assertions for image loaded
adhiamboperes Jun 19, 2024
41dea0b
Replace Lifecycle.State check with activity.isFinishing
adhiamboperes Jun 19, 2024
1bb7508
Merge branch 'develop' into onboarding-profile-type-screen
adhiamboperes Jun 24, 2024
6e0401f
Update test_file_exemptions to the new format
adhiamboperes Jun 24, 2024
2f84098
Fix indent
adhiamboperes Jun 24, 2024
d979d1b
Merge branch 'onboarding-profile-type-screen' into create-profile-screen
adhiamboperes Jun 24, 2024
2d83378
Update test_file_exemptions
adhiamboperes Jun 24, 2024
04acfa9
Merge branch 'develop' into onboarding-profile-type-screen
adhiamboperes Jun 30, 2024
223150b
Replace png images with svgs
adhiamboperes Jun 30, 2024
90428af
Add exemptions for new svgs
adhiamboperes Jun 30, 2024
e248fb1
Pull upstream and fix conflicts
adhiamboperes Jun 30, 2024
9fd9fbc
Change default avatar bg in v2
adhiamboperes Jun 30, 2024
2ec249d
Fix profile prompt background
adhiamboperes Jun 30, 2024
988ab47
Merge branch 'develop' into create-profile-screen
adhiamboperes Jun 30, 2024
af6ed95
Fix deprecated api
adhiamboperes Jun 30, 2024
05d02c3
Fix kdoc
adhiamboperes Jun 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ VIEW_MODELS_WITH_RESOURCE_IMPORTS = [
"src/main/java/org/oppia/android/app/home/recentlyplayed/PromotedStoryViewModel.kt",
"src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedViewModel.kt",
"src/main/java/org/oppia/android/app/home/topiclist/TopicSummaryViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/CreateProfileViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/OnboadingSlideViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/OnboardingViewModel.kt",
"src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicItemViewModel.kt",
Expand Down Expand Up @@ -408,9 +409,9 @@ VIEWS_WITH_RESOURCE_IMPORTS = [
"src/main/java/org/oppia/android/app/customview/ChapterNotStartedContainerConstraintLayout.kt",
"src/main/java/org/oppia/android/app/customview/ContinueButtonView.kt",
"src/main/java/org/oppia/android/app/customview/LessonThumbnailImageView.kt",
"src/main/java/org/oppia/android/app/customview/OppiaCurveBackgroundView.kt",
"src/main/java/org/oppia/android/app/customview/PromotedStoryCardView.kt",
"src/main/java/org/oppia/android/app/customview/SegmentedCircularProgressView.kt",
"src/main/java/org/oppia/android/app/customview/SurveyOnboardingBackgroundView.kt",
"src/main/java/org/oppia/android/app/customview/VerticalDashedLineView.kt",
"src/main/java/org/oppia/android/app/survey/SurveyMultipleChoiceOptionView.kt",
"src/main/java/org/oppia/android/app/survey/SurveyNpsItemOptionView.kt",
Expand Down Expand Up @@ -485,6 +486,7 @@ BINDING_ADAPTERS_WITH_RESOURCE_IMPORTS = [
BINDING_ADAPTERS = [
"src/main/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdapters.java",
"src/main/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdapters.java",
"src/main/java/org/oppia/android/app/databinding/ColorBindingAdapters.java",
"src/main/java/org/oppia/android/app/databinding/ConstraintLayoutAdapters.java",
"src/main/java/org/oppia/android/app/databinding/EditTextBindingAdapters.java",
"src/main/java/org/oppia/android/app/databinding/GuidelineBindingAdapters.java",
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,18 @@
android:label="@string/survey_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar"
android:windowSoftInputMode="adjustNothing" />
<activity
android:name=".app.testing.ColorBindingAdaptersTestActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />

<activity
android:name=".app.onboarding.OnboardingProfileTypeActivity"
android:label="@string/onboarding_profile_type_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.onboarding.CreateProfileActivity"
android:label="@string/create_profile_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import org.oppia.android.app.help.thirdparty.ThirdPartyDependencyListActivity
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.CreateProfileActivity
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 @@ -59,6 +61,7 @@ import org.oppia.android.app.testing.AdministratorControlsFragmentTestActivity
import org.oppia.android.app.testing.AppCompatCheckBoxBindingAdaptersTestActivity
import org.oppia.android.app.testing.AudioFragmentTestActivity
import org.oppia.android.app.testing.CircularProgressIndicatorAdaptersTestActivity
import org.oppia.android.app.testing.ColorBindingAdaptersTestActivity
import org.oppia.android.app.testing.ConceptCardFragmentTestActivity
import org.oppia.android.app.testing.DragDropTestActivity
import org.oppia.android.app.testing.DrawableBindingAdaptersTestActivity
Expand Down Expand Up @@ -216,4 +219,7 @@ interface ActivityComponentImpl :
fun inject(viewEventLogsTestActivity: ViewEventLogsTestActivity)
fun inject(walkthroughActivity: WalkthroughActivity)
fun inject(surveyActivity: SurveyActivity)
fun inject(colorBindingAdaptersTestActivity: ColorBindingAdaptersTestActivity)
fun inject(onboardingProfileTypeActivity: OnboardingProfileTypeActivity)
fun inject(createProfileActivity: CreateProfileActivity)
}
Original file line number Diff line number Diff line change
@@ -1,50 +1,54 @@
package org.oppia.android.app.customview

import android.content.Context
import android.content.res.Configuration
import android.content.res.Resources
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Path
import android.util.AttributeSet
import android.view.View
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import org.oppia.android.R
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.view.ViewComponentFactory
import org.oppia.android.app.view.ViewComponentImpl
import javax.inject.Inject

/**
* CustomView to add a background to [SurveyWelcomeDialogFragment] and [SurveyOutroDialogFragment].
* Without chaptersFinished and totalChapters values this custom-view cannot be created.
* CustomView to add a background to views that require a bezier curve background.
*
* Reference: // https://proandroiddev.com/how-i-drew-custom-shapes-in-bottom-bar-c4539d86afd7 and
* // https://ciechanow.ski/drawing-bezier-curves/
*/
class SurveyOnboardingBackgroundView : View {
@Inject
lateinit var resourceHandler: AppLanguageResourceHandler
class OppiaCurveBackgroundView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
/**
* Used to retrieve the layout direction that should be used to mirror the direction of the
* curve based on locale.
*/
@Inject lateinit var resourceHandler: AppLanguageResourceHandler

private val isRtl by lazy {
resourceHandler.getLayoutDirection() == ViewCompat.LAYOUT_DIRECTION_RTL
}

private val orientation = Resources.getSystem().configuration.orientation

private var customBackgroundColor = Color.WHITE // Default color.

private lateinit var paint: Paint
private lateinit var path: Path
private var strokeWidth = 2f

constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)

init {
/** Sets the desired background color to the view and initializes the view. */
fun setCustomBackgroundColor(colorRes: Int) {
this.customBackgroundColor = colorRes
setupCurvePaint()
}

Expand All @@ -61,17 +65,37 @@ class SurveyOnboardingBackgroundView : View {
val width = this.width.toFloat()
val height = this.height.toFloat()

val controlPoint1X = width * 0.5f
val controlPoint1Y = 0f

val controlPoint2X = width * 0.5f
val controlPoint2Y = height * 0.2f

val controlPoint3X = width * 1f
val controlPoint3Y = height * 0.1f
val controlPoint1X: Float
val controlPoint1Y: Float

val controlPoint2X: Float
val controlPoint2Y: Float

val controlPoint3X: Float
val controlPoint3Y: Float

if (orientation == Configuration.ORIENTATION_PORTRAIT) {
controlPoint1X = width * 0.55f
controlPoint1Y = 0f
controlPoint2X = width * 0.52f
controlPoint2Y = height * 0.2f
controlPoint3X = width * 1f
controlPoint3Y = height * 0.1f
} else {
controlPoint1X = width * 0.40f
controlPoint1Y = 0f
controlPoint2X = width * 0.60f
controlPoint2Y = height * 0.40f
controlPoint3X = width * 1f
controlPoint3Y = height * 0.2f
}

path.reset()
path.moveTo(0f, height * 0.1f)
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
path.moveTo(0f, height * 0.10f)
} else {
path.moveTo(0f, height * 0.30f)
}
path.cubicTo(
controlPoint1X,
controlPoint1Y,
Expand All @@ -90,12 +114,9 @@ class SurveyOnboardingBackgroundView : View {
path = Path()
paint = Paint(Paint.ANTI_ALIAS_FLAG)
paint.apply {
style = Paint.Style.FILL_AND_STROKE
strokeWidth = this@SurveyOnboardingBackgroundView.strokeWidth
color = ContextCompat.getColor(
context,
R.color.component_color_survey_popup_background_color
)
style = Paint.Style.FILL
strokeWidth = this@OppiaCurveBackgroundView.strokeWidth
color = customBackgroundColor
}
setBackgroundColor(Color.TRANSPARENT)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.oppia.android.app.databinding;

import android.view.View;
import androidx.databinding.BindingAdapter;

/** Holds all custom binding adapters that set color values. */
public final class ColorBindingAdapters {

/** Binding adapter for setting the `customBackgroundColor` for a [View]. */
@BindingAdapter("app:customBackgroundColor")
public static void setCustomBackgroundColor(View view, int color) {
view.setBackgroundColor(color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import org.oppia.android.app.notice.ForcedAppDeprecationNoticeDialogFragment
import org.oppia.android.app.notice.GeneralAvailabilityUpgradeNoticeDialogFragment
import org.oppia.android.app.notice.OptionalAppDeprecationNoticeDialogFragment
import org.oppia.android.app.notice.OsDeprecationNoticeDialogFragment
import org.oppia.android.app.onboarding.CreateProfileFragment
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 @@ -194,4 +196,6 @@ interface FragmentComponentImpl : FragmentComponent, ViewComponentBuilderInjecto
fun inject(exitSurveyConfirmationDialogFragment: ExitSurveyConfirmationDialogFragment)
fun inject(surveyWelcomeDialogFragment: SurveyWelcomeDialogFragment)
fun inject(surveyOutroDialogFragment: SurveyOutroDialogFragment)
fun inject(onboardingProfileTypeFragment: OnboardingProfileTypeFragment)
fun inject(createProfileFragment: CreateProfileFragment)
}
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.CREATE_PROFILE_ACTIVITY
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import javax.inject.Inject

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

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

learnerProfileActivityPresenter.handleOnCreate()
}

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

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 [CreateProfileActivity]. */
class CreateProfileActivityPresenter @Inject constructor(
private val activity: AppCompatActivity
) {
private lateinit var binding: CreateProfileActivityBinding

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

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

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

import android.content.Context
import android.content.Intent
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 CreateProfileFragment : InjectableFragment() {
@Inject
lateinit var createProfileFragmentPresenter: CreateProfileFragmentPresenter

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

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return createProfileFragmentPresenter.handleCreateView(inflater, container)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
createProfileFragmentPresenter.handleOnActivityResult(requestCode, resultCode, data)
}
}
Loading
Loading