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 #565: Domain on-boarding flag #574

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
android:name=".mydownloads.MyDownloadsActivity"
android:screenOrientation="portrait"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".onBoarding.OnBoardingingActivity"
android:screenOrientation="portrait"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".player.exploration.ExplorationActivity"
android:screenOrientation="portrait"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.oppia.app.help.HelpActivity
import org.oppia.app.home.HomeActivity
import org.oppia.app.home.continueplaying.ContinuePlayingActivity
import org.oppia.app.mydownloads.MyDownloadsActivity
import org.oppia.app.onBoarding.OnBoardingingActivity
import org.oppia.app.player.exploration.ExplorationActivity
import org.oppia.app.profile.AddProfileActivity
import org.oppia.app.profile.AdminAuthActivity
Expand All @@ -18,6 +19,7 @@ import org.oppia.app.settings.profile.ProfileEditActivity
import org.oppia.app.settings.profile.ProfileListActivity
import org.oppia.app.settings.profile.ProfileRenameActivity
import org.oppia.app.settings.profile.ProfileResetPinActivity
import org.oppia.app.splash.SplashActivity
import org.oppia.app.story.StoryActivity
import org.oppia.app.story.testing.StoryFragmentTestActivity
import org.oppia.app.testing.AudioFragmentTestActivity
Expand Down Expand Up @@ -66,13 +68,15 @@ interface ActivityComponent {
fun inject(htmlParserTestActivity: HtmlParserTestActivity)
fun inject(myDownloadsActivity: MyDownloadsActivity)
fun inject(navigationDrawerTestActivity: NavigationDrawerTestActivity)
fun inject(onBoardingActivity: OnBoardingingActivity)
fun inject(pinPasswordActivity: PinPasswordActivity)
fun inject(profileActivity: ProfileActivity)
fun inject(questionPlayerActivity: QuestionPlayerActivity)
fun inject(profileEditActivity: ProfileEditActivity)
fun inject(profileListActivity: ProfileListActivity)
fun inject(profileRenameActivity: ProfileRenameActivity)
fun inject(profileResetPinActivity: ProfileResetPinActivity)
fun inject(splashActivity: SplashActivity)
fun inject(storyActivity: StoryActivity)
fun inject(topicActivity: TopicActivity)
fun inject(topicTestActivity: TopicTestActivity)
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/org/oppia/app/onBoarding/OnBoardingActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.oppia.app.onBoarding

import android.os.Bundle
import org.oppia.app.activity.InjectableAppCompatActivity
import org.oppia.app.profile.ProfileActivity
import javax.inject.Inject

/** An activity that shows a temporary OnBoardinging page until the app is onborarded then navigates to [ProfileActivity]. */
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
class OnBoardingingActivity : InjectableAppCompatActivity() {

@Inject lateinit var onBoardingActivityPresenter: OnBoardingingActivityPresenter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityComponent.inject(this)
onBoardingActivityPresenter.handleOnCreate()
}
}

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.oppia.app.onBoarding

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.on_boarding_activity.*
import org.oppia.app.R
import org.oppia.app.activity.ActivityScope
import org.oppia.app.profile.ProfileActivity
import org.oppia.domain.OnBoardingingFlowController
import javax.inject.Inject

/** The presenter for [OnBoardingingActivity]. */
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
@ActivityScope
class OnBoardingingActivityPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val onBoardingFlowController: OnBoardingingFlowController
) {

fun handleOnCreate() {
activity.setContentView(R.layout.on_boarding_activity)
activity.onBoard.setOnClickListener({ subscribeOnBoarding() })
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
}

private fun subscribeOnBoarding() {
onBoardingFlowController.markOnBoardingingFlowCompleted()
val intent = Intent(activity, ProfileActivity::class.java)
activity.startActivity(intent)
activity.finish()
}
}
19 changes: 8 additions & 11 deletions app/src/main/java/org/oppia/app/splash/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package org.oppia.app.splash

import android.content.Intent
import android.os.Bundle
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import org.oppia.app.R
import org.oppia.app.activity.InjectableAppCompatActivity
import org.oppia.app.help.SplashActivityPresenter
import org.oppia.app.profile.ProfileActivity
import javax.inject.Inject

/** An activity that shows a temporary loading page until the app is fully loaded then navigates to [ProfileActivity]. */
class SplashActivity : AppCompatActivity() {
class SplashActivity : InjectableAppCompatActivity() {

@Inject lateinit var splashActivityPresenter: SplashActivityPresenter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.splash_activity)

window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
val intent = Intent(this@SplashActivity, ProfileActivity::class.java)
startActivity(intent)
finish()
activityComponent.inject(this)
splashActivityPresenter.handleOnCreate()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.oppia.app.help
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved

import android.content.Intent
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.Transformations
import org.oppia.app.R
import org.oppia.app.activity.ActivityScope
import org.oppia.app.model.OnBoardingingFlow
import org.oppia.app.onBoarding.OnBoardingingActivity
import org.oppia.app.profile.ProfileActivity
import org.oppia.domain.OnBoardingingFlowController
import org.oppia.util.data.AsyncResult
import javax.inject.Inject

/** The presenter for [SplashActivity]. */
@ActivityScope
class SplashActivityPresenter @Inject constructor(
private val activity: AppCompatActivity,
onBoardingFlowController: OnBoardingingFlowController
) {

val onBoardingFlow = onBoardingFlowController.getOnBoardingingFlow()

fun handleOnCreate() {
activity.setContentView(R.layout.splash_activity)
activity.window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
subscribeToOnBoardingingFlow()
}

private fun showOnBoardingingActivity() {
val intent = Intent(activity, OnBoardingingActivity::class.java)
activity.startActivity(intent)
activity.finish()
}

private fun subscribeToOnBoardingingFlow() {
getOnBoardingingFlow().observe(activity, Observer<OnBoardingingFlow> { result ->
if (result.alreadyOnBoardedApp) {
val intent = Intent(activity, ProfileActivity::class.java)
activity.startActivity(intent)
activity.finish()
} else {
showOnBoardingingActivity()
}
})
}

private fun getOnBoardingingFlow(): LiveData<OnBoardingingFlow> {
// If there's an error loading the data, assume the default.
return Transformations.map(onBoardingFlow, ::processOnBoardingingFlowResult)
}

private fun processOnBoardingingFlowResult(onboardingResult: AsyncResult<OnBoardingingFlow>): OnBoardingingFlow {
if (onboardingResult.isFailure()) {
}
return onboardingResult.getOrDefault(OnBoardingingFlow.getDefaultInstance())
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/layout/on_boarding_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">

<Button
android:id="@+id/onBoard"
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="on-board" />
</LinearLayout>
Loading