mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 11:56:51 -06:00
Handle URLs from FCM push notification (#1070)
This commit is contained in:
parent
d332369872
commit
a99e742472
@ -9,6 +9,17 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="http" />
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="https" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:name=".WulkanowyApp"
|
||||
android:allowBackup="false"
|
||||
@ -112,8 +123,7 @@
|
||||
|
||||
<meta-data
|
||||
android:name="install_channel"
|
||||
android:value="${install_channel}">
|
||||
</meta-data>
|
||||
android:value="${install_channel}" />
|
||||
|
||||
<!-- workaround for https://github.com/firebase/firebase-android-sdk/issues/473 enabled:false -->
|
||||
<!-- https://firebase.googleblog.com/2017/03/take-control-of-your-firebase-init-on.html -->
|
||||
|
@ -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<SplashPresenter, ViewBinding>(), 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<SplashPresenter, ViewBinding>(), 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()
|
||||
}
|
||||
|
@ -14,8 +14,13 @@ class SplashPresenter @Inject constructor(
|
||||
studentRepository: StudentRepository
|
||||
) : BasePresenter<SplashView>(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")
|
||||
|
@ -7,4 +7,6 @@ interface SplashView : BaseView {
|
||||
fun openLoginView()
|
||||
|
||||
fun openMainView()
|
||||
|
||||
fun openExternalUrlAndFinish(url: String)
|
||||
}
|
||||
|
@ -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() }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user