diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a8d2b49e3..eaef43694 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,17 @@ + + + + + + + + + + + - + android:value="${install_channel}" /> diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt index 7fc20d238..80138175d 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt @@ -8,6 +8,7 @@ import dagger.hilt.android.AndroidEntryPoint import io.github.wulkanowy.ui.base.BaseActivity import io.github.wulkanowy.ui.modules.login.LoginActivity import io.github.wulkanowy.ui.modules.main.MainActivity +import io.github.wulkanowy.utils.openInternetBrowser import javax.inject.Inject @AndroidEntryPoint @@ -18,7 +19,7 @@ class SplashActivity : BaseActivity(), SplashView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - presenter.onAttachView(this) + presenter.onAttachView(this, intent?.getStringExtra("external_url")) } override fun openLoginView() { @@ -31,6 +32,11 @@ class SplashActivity : BaseActivity(), SplashView finish() } + override fun openExternalUrlAndFinish(url: String) { + openInternetBrowser(url, ::showMessage) + finish() + } + override fun showError(text: String, error: Throwable) { Toast.makeText(this, text, LENGTH_LONG).show() } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashPresenter.kt index 87392b7bf..795889171 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashPresenter.kt @@ -14,8 +14,13 @@ class SplashPresenter @Inject constructor( studentRepository: StudentRepository ) : BasePresenter(errorHandler, studentRepository) { - override fun onAttachView(view: SplashView) { + fun onAttachView(view: SplashView, externalUrl: String?) { super.onAttachView(view) + + if (!externalUrl.isNullOrBlank()) { + return view.openExternalUrlAndFinish(externalUrl) + } + flowWithResource { studentRepository.isCurrentStudentSet() }.onEach { when (it.status) { Status.LOADING -> Timber.d("Is current user set check started") diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashView.kt index 9efd8123b..a5aa14091 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashView.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashView.kt @@ -7,4 +7,6 @@ interface SplashView : BaseView { fun openLoginView() fun openMainView() + + fun openExternalUrlAndFinish(url: String) } diff --git a/app/src/test/java/io/github/wulkanowy/ui/modules/splash/SplashPresenterTest.kt b/app/src/test/java/io/github/wulkanowy/ui/modules/splash/SplashPresenterTest.kt index 7cced3c9e..71d17b3b8 100644 --- a/app/src/test/java/io/github/wulkanowy/ui/modules/splash/SplashPresenterTest.kt +++ b/app/src/test/java/io/github/wulkanowy/ui/modules/splash/SplashPresenterTest.kt @@ -36,14 +36,14 @@ class SplashPresenterTest { @Test fun testOpenLoginView() { coEvery { studentRepository.isCurrentStudentSet() } returns false - presenter.onAttachView(splashView) + presenter.onAttachView(splashView, null) verify { splashView.openLoginView() } } @Test fun testMainMainView() { coEvery { studentRepository.isCurrentStudentSet() } returns true - presenter.onAttachView(splashView) + presenter.onAttachView(splashView, null) verify { splashView.openMainView() } } }