forked from upstream-mirrors/quik
Allow external app to launch blocking screen
This commit is contained in:
@@ -21,6 +21,7 @@ package com.moez.QKSMS.feature.main
|
||||
import android.Manifest
|
||||
import android.animation.ObjectAnimator
|
||||
import android.app.AlertDialog
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
@@ -78,6 +79,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
@Inject lateinit var itemTouchCallback: ConversationItemTouchCallback
|
||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
|
||||
override val onNewIntentIntent: Subject<Intent> = PublishSubject.create()
|
||||
override val activityResumedIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val queryChangedIntent by lazy { toolbarSearch.textChanges() }
|
||||
override val composeIntent by lazy { compose.clicks() }
|
||||
@@ -125,6 +127,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.main_activity)
|
||||
viewModel.bindView(this)
|
||||
onNewIntentIntent.onNext(intent)
|
||||
|
||||
(snackbar as? ViewStub)?.setOnInflateListener { _, _ ->
|
||||
snackbarButton.clicks().autoDisposable(scope()).subscribe(snackbarButtonIntent)
|
||||
@@ -180,6 +183,11 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
conversationsAdapter.autoScrollToStart(recyclerView)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
intent?.run(onNewIntentIntent::onNext)
|
||||
}
|
||||
|
||||
override fun render(state: MainState) {
|
||||
if (state.hasError) {
|
||||
finish()
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
*/
|
||||
package com.moez.QKSMS.feature.main
|
||||
|
||||
import android.content.Intent
|
||||
import com.moez.QKSMS.common.base.QkView
|
||||
import com.moez.QKSMS.manager.ChangelogManager
|
||||
import io.reactivex.Observable
|
||||
|
||||
interface MainView : QkView<MainState> {
|
||||
|
||||
val onNewIntentIntent: Observable<Intent>
|
||||
val activityResumedIntent: Observable<*>
|
||||
val queryChangedIntent: Observable<CharSequence>
|
||||
val composeIntent: Observable<Unit>
|
||||
|
||||
@@ -145,6 +145,15 @@ class MainViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { syncMessages.execute(Unit) }
|
||||
|
||||
// Launch screen from intent
|
||||
view.onNewIntentIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { intent ->
|
||||
when (intent.getStringExtra("screen")) {
|
||||
"blocking" -> navigator.showBlockedConversations()
|
||||
}
|
||||
}
|
||||
|
||||
// Show changelog
|
||||
if (changelogManager.didUpdate()) {
|
||||
if (Locale.getDefault().language.startsWith("en")) {
|
||||
|
||||
Reference in New Issue
Block a user