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 New App Language Selection Screen for onboarding #5373

Merged
merged 43 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
43 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
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
0bc5547
Merge branch 'develop' into new-onboarding-screen
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
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
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
f14bbb1
Merge remote-tracking branch 'upstream/develop' into new-onboarding-s…
adhiamboperes Jun 11, 2024
3fdf74f
Fix merge conflict
adhiamboperes Jun 11, 2024
72624f5
Merge branch 'develop' into new-onboarding-screen
adhiamboperes Jun 17, 2024
9b29b36
Address reviewer comments
adhiamboperes Jun 18, 2024
7d72412
Merge branch 'develop' of github.com:oppia/oppia-android into new-onb…
adhiamboperes Jun 18, 2024
275a287
Fix adapter namespace
adhiamboperes Jun 18, 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
2 changes: 1 addition & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -409,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
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.oppia.android.app.customview

import android.content.Context
import android.content.res.Configuration
import android.content.res.Resources
import android.content.res.TypedArray
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
Expand All @@ -18,33 +20,40 @@ 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.
BenHenning marked this conversation as resolved.
Show resolved Hide resolved

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 {
val typedArray: TypedArray =
context.obtainStyledAttributes(attrs, R.styleable.OppiaCurveBackgroundView)
customBackgroundColor =
typedArray.getColor(R.styleable.OppiaCurveBackgroundView_customBackgroundColor, Color.WHITE)
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
typedArray.recycle()
setupCurvePaint()
}

Expand All @@ -61,17 +70,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 +119,9 @@ class SurveyOnboardingBackgroundView : View {
path = Path()
paint = Paint(Paint.ANTI_ALIAS_FLAG)
paint.apply {
style = Paint.Style.FILL_AND_STROKE
strokeWidth = [email protected]
color = ContextCompat.getColor(
context,
R.color.component_color_survey_popup_background_color
)
style = Paint.Style.FILL
strokeWidth = [email protected]
color = customBackgroundColor
}
setBackgroundColor(Color.TRANSPARENT)
}
Expand Down
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
BenHenning marked this conversation as resolved.
Show resolved Hide resolved

/** 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 org.oppia.android.R
import org.oppia.android.app.fragment.FragmentScope
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.databinding.OnboardingAppLanguageSelectionFragmentBinding
import javax.inject.Inject

/** 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.apply {
lifecycleOwner = fragment

onboardingLanguageTitle.text = appLanguageResourceHandler.getStringInLocaleWithWrapping(
R.string.onboarding_language_activity_title,
appLanguageResourceHandler.getStringInLocale(R.string.app_name)
)
}

return binding.root
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import dagger.Subcomponent
import org.oppia.android.app.customview.ChapterNotStartedContainerConstraintLayout
import org.oppia.android.app.customview.ContinueButtonView
import org.oppia.android.app.customview.LessonThumbnailImageView
import org.oppia.android.app.customview.OppiaCurveBackgroundView
import org.oppia.android.app.customview.PromotedStoryCardView
import org.oppia.android.app.customview.SegmentedCircularProgressView
import org.oppia.android.app.customview.SurveyOnboardingBackgroundView
import org.oppia.android.app.home.promotedlist.ComingSoonTopicsListView
import org.oppia.android.app.home.promotedlist.PromotedStoryListView
import org.oppia.android.app.player.state.DragDropSortInteractionView
Expand Down Expand Up @@ -42,7 +42,7 @@ interface ViewComponentImpl : ViewComponent {
fun inject(promotedStoryCardView: PromotedStoryCardView)
fun inject(promotedStoryListView: PromotedStoryListView)
fun inject(segmentedCircularProgressView: SegmentedCircularProgressView)
fun inject(surveyOnboardingBackgroundView: SurveyOnboardingBackgroundView)
fun inject(oppiaCurveBackgroundView: OppiaCurveBackgroundView)
fun inject(surveyMultipleChoiceOptionView: SurveyMultipleChoiceOptionView)
fun inject(surveyNpsItemOptionView: SurveyNpsItemOptionView)
}
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/dropdown_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
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>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_language_icon_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000000"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#000000"
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56 1.84,0.63 3.37,1.91 4.33,3.56zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82c0.43,-1.43 1.08,-2.76 1.91,-3.96zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2 0,0.68 0.06,1.34 0.14,2L4.26,14zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56 -1.84,-0.63 -3.37,-1.9 -4.33,-3.56zM8.03,8L5.08,8c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8zM12,19.96c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96h3.82c-0.43,1.43 -1.08,2.76 -1.91,3.96zM14.34,14L9.66,14c-0.09,-0.66 -0.16,-1.32 -0.16,-2 0,-0.68 0.07,-1.35 0.16,-2h4.68c0.09,0.65 0.16,1.32 0.16,2 0,0.68 -0.07,1.34 -0.16,2zM14.59,19.56c0.6,-1.11 1.06,-2.31 1.38,-3.56h2.95c-0.96,1.65 -2.49,2.93 -4.33,3.56zM16.36,14c0.08,-0.66 0.14,-1.32 0.14,-2 0,-0.68 -0.06,-1.34 -0.14,-2h3.38c0.16,0.64 0.26,1.31 0.26,2s-0.1,1.36 -0.26,2h-3.38z" />
</vector>
Binary file added app/src/main/res/drawable/otter.png
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading