From 2893862448d7cd45ef3320c49e4edd508075c190 Mon Sep 17 00:00:00 2001 From: marysoloman Date: Tue, 24 Dec 2019 15:24:03 +0530 Subject: [PATCH 01/19] isAppAlreadyOnboarded introduced --- app/src/main/AndroidManifest.xml | 4 +++ .../oppia/app/home/UserAppHistoryViewModel.kt | 3 ++ .../oppia/app/splash/OnboardingActivity.kt | 29 +++++++++++++++++++ .../org/oppia/app/splash/SplashActivity.kt | 19 +++++++++--- app/src/main/res/layout/dummy_onboard.xml | 16 ++++++++++ .../oppia/domain/UserAppHistoryController.kt | 12 ++++++++ model/src/main/proto/example.proto | 1 + 7 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/org/oppia/app/splash/OnboardingActivity.kt create mode 100644 app/src/main/res/layout/dummy_onboard.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cabc2b96a91..e0f41aeeee0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -60,6 +60,10 @@ + (false) fun setAlreadyAppOpened(alreadyOpenedApp: Boolean) = isAppAlreadyOpened.set(alreadyOpenedApp) + var isAppAlreadyOnboarded = ObservableField(false) + + fun setAlreadyAppOnboarded(isalreadyOnboardedApp: Boolean) = isAppAlreadyOnboarded.set(isalreadyOnboardedApp) } diff --git a/app/src/main/java/org/oppia/app/splash/OnboardingActivity.kt b/app/src/main/java/org/oppia/app/splash/OnboardingActivity.kt new file mode 100644 index 00000000000..7fbbbcd6531 --- /dev/null +++ b/app/src/main/java/org/oppia/app/splash/OnboardingActivity.kt @@ -0,0 +1,29 @@ +package org.oppia.app.splash + +import android.content.Intent +import android.os.Bundle +import android.view.View +import androidx.appcompat.app.AppCompatActivity +import org.oppia.app.R +import org.oppia.app.profile.ProfileActivity +import org.oppia.domain.UserAppHistoryController +import javax.inject.Inject + +/** An activity that shows a temporary Onboarding page until the app is onborarded then navigates to [ProfileActivity]. */ +class OnboardingActivity : AppCompatActivity() { + @Inject lateinit var userAppHistoryController: UserAppHistoryController + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.dummy_onboard) + + } + + private fun subscribeToUserAppHistory(view: View) { + userAppHistoryController.markUserOnboardedApp() + val intent = Intent(this, ProfileActivity::class.java) + startActivity(intent) + finish() + } + +} diff --git a/app/src/main/java/org/oppia/app/splash/SplashActivity.kt b/app/src/main/java/org/oppia/app/splash/SplashActivity.kt index e2e45056e3c..24800879e12 100644 --- a/app/src/main/java/org/oppia/app/splash/SplashActivity.kt +++ b/app/src/main/java/org/oppia/app/splash/SplashActivity.kt @@ -5,18 +5,29 @@ import android.os.Bundle import android.view.WindowManager import androidx.appcompat.app.AppCompatActivity import org.oppia.app.R +import org.oppia.app.model.UserAppHistory 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() { + @Inject lateinit var userAppHistory: UserAppHistory + 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() + if (userAppHistory.alreadyOnBoardedApp) { + val intent = Intent(this@SplashActivity, ProfileActivity::class.java) + startActivity(intent) + finish() + } else { + // TODO (#454) : Replace ProfileActivity in this with OnboaridngActivity + val intent = Intent(this@SplashActivity, OnboardingActivity::class.java) + startActivity(intent) + finish() + } } + } diff --git a/app/src/main/res/layout/dummy_onboard.xml b/app/src/main/res/layout/dummy_onboard.xml new file mode 100644 index 00000000000..52610900c50 --- /dev/null +++ b/app/src/main/res/layout/dummy_onboard.xml @@ -0,0 +1,16 @@ + + + +