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 4 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 @@ -62,6 +62,10 @@
<activity
android:name=".settings.profile.ProfileResetPinActivity"
android:screenOrientation="portrait" />
<activity
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
android:name=".splash.OnboardingActivity"
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
android:screenOrientation="portrait"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".splash.SplashActivity"
android:screenOrientation="portrait"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ 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.OnboardingActivity
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: OnboardingActivity)
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ class UserAppHistoryViewModel : HomeItemViewModel() {
var isAppAlreadyOpened = ObservableField<Boolean>(false)

fun setAlreadyAppOpened(alreadyOpenedApp: Boolean) = isAppAlreadyOpened.set(alreadyOpenedApp)
var isAppAlreadyOnboarded = ObservableField<Boolean>(false)

fun setAlreadyAppOnboarded(isalreadyOnboardedApp: Boolean) = isAppAlreadyOnboarded.set(isalreadyOnboardedApp)
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
}
21 changes: 21 additions & 0 deletions app/src/main/java/org/oppia/app/splash/OnboardingActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.oppia.app.splash

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

/** An activity that shows a temporary Onboarding page until the app is onborarded then navigates to [ProfileActivity]. */
class OnboardingActivity : InjectableAppCompatActivity() {

@Inject
lateinit var onboardingActivityPresenter: OnboardingActivityPresenter

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.oppia.app.help

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

/** The presenter for [OnboardingActivity]. */
@ActivityScope
class OnboardingActivityPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val onboardingFlowController: OnboardingFlowController
) {

fun handleOnCreate() {
activity.setContentView(R.layout.dummy_onboard)
activity.onboard.setOnClickListener({ subscribeToUserAppHistory() })
}

private fun subscribeToUserAppHistory() {
onboardingFlowController.markOnboardingFlowCompleted()
val intent = Intent(activity, ProfileActivity::class.java)
activity.startActivity(intent)
activity.finish()
}
}
21 changes: 10 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,21 @@
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
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved

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.OnboardingFlow
import org.oppia.app.profile.ProfileActivity
import org.oppia.app.splash.OnboardingActivity
import org.oppia.domain.OnboardingFlowController
import org.oppia.util.data.AsyncResult
import javax.inject.Inject

/** The presenter for [OnboardingActivity]. */
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
@ActivityScope
class SplashActivityPresenter @Inject constructor(
private val activity: AppCompatActivity,
onboardingFlowController: OnboardingFlowController
) {

val sample = onboardingFlowController.getOnboardingFlow()
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved

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

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

private fun subscribeToOnboardingFlow() {
getOnboardingFlow().observe(activity, Observer<OnboardingFlow> { result ->
if (result.alreadyOnBoardedApp) {
val intent = Intent(activity, ProfileActivity::class.java)
activity.startActivity(intent)
activity.finish()
} else {
showOnboardingActivity()
}
})
}

private fun getOnboardingFlow(): LiveData<OnboardingFlow> {
// If there's an error loading the data, assume the default.
return Transformations.map(sample, ::processOnboardingFlowResult)
}

private fun processOnboardingFlowResult(appHistoryResult: AsyncResult<OnboardingFlow>): OnboardingFlow {
if (appHistoryResult.isFailure()) {
}
return appHistoryResult.getOrDefault(OnboardingFlow.getDefaultInstance())
}
}
14 changes: 14 additions & 0 deletions app/src/main/res/layout/dummy_onboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
<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"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="onboard" />
</LinearLayout>

nikitamarysolomanpvt marked this conversation as resolved.
Show resolved Hide resolved
Loading