mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Require QKSMS+ to schedule messages
This commit is contained in:
@@ -39,6 +39,7 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.jakewharton.rxbinding2.widget.textChanges
|
||||
import com.moez.QKSMS.R
|
||||
@@ -105,6 +106,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
override val changeSimIntent by lazy { sim.clicks() }
|
||||
override val scheduleCancelIntent by lazy { scheduledCancel.clicks() }
|
||||
override val sendIntent by lazy { send.clicks() }
|
||||
override val viewQksmsPlusIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
|
||||
|
||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ComposeViewModel::class.java] }
|
||||
@@ -299,6 +301,13 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
?.let(messageList::scrollToPosition)
|
||||
}
|
||||
|
||||
override fun showQksmsPlusSnackbar(message: Int) {
|
||||
Snackbar.make(contentView, message, Snackbar.LENGTH_LONG).run {
|
||||
setAction(R.string.button_more) { viewQksmsPlusIntent.onNext(Unit) }
|
||||
show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menuInflater.inflate(R.menu.compose, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.moez.QKSMS.feature.compose
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.view.inputmethod.InputContentInfoCompat
|
||||
import com.moez.QKSMS.common.base.QkView
|
||||
import com.moez.QKSMS.model.Attachment
|
||||
@@ -53,6 +54,8 @@ interface ComposeView : QkView<ComposeState> {
|
||||
val scheduleCancelIntent: Observable<*>
|
||||
val changeSimIntent: Observable<*>
|
||||
val sendIntent: Observable<Unit>
|
||||
val viewQksmsPlusIntent: Subject<Unit>
|
||||
val backPressedIntent: Observable<Unit>
|
||||
|
||||
fun clearSelection()
|
||||
fun showDetails(details: String)
|
||||
@@ -62,6 +65,6 @@ interface ComposeView : QkView<ComposeState> {
|
||||
fun requestDatePicker()
|
||||
fun setDraft(draft: String)
|
||||
fun scrollToMessage(id: Long)
|
||||
val backPressedIntent: Observable<Unit>
|
||||
fun showQksmsPlusSnackbar(@StringRes message: Int)
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.Navigator
|
||||
import com.moez.QKSMS.common.androidxcompat.scope
|
||||
import com.moez.QKSMS.common.base.QkViewModel
|
||||
import com.moez.QKSMS.common.util.BillingManager
|
||||
import com.moez.QKSMS.common.util.ClipboardUtils
|
||||
import com.moez.QKSMS.common.util.MessageDetailsFormatter
|
||||
import com.moez.QKSMS.common.util.extensions.makeToast
|
||||
@@ -79,6 +80,7 @@ class ComposeViewModel @Inject constructor(
|
||||
@Named("text") private val sharedText: String,
|
||||
@Named("attachments") private val sharedAttachments: List<Attachment>,
|
||||
private val context: Context,
|
||||
private val billingManager: BillingManager,
|
||||
private val cancelMessage: CancelDelayedMessage,
|
||||
private val contactFilter: ContactFilter,
|
||||
private val contactsRepo: ContactRepository,
|
||||
@@ -464,6 +466,10 @@ class ComposeViewModel @Inject constructor(
|
||||
// Choose a time to schedule the message
|
||||
view.scheduleIntent
|
||||
.doOnNext { newState { copy(attaching = false) } }
|
||||
.withLatestFrom(billingManager.upgradeStatus) { _, upgraded -> upgraded }
|
||||
.filter { upgraded ->
|
||||
upgraded.also { if (!upgraded) view.showQksmsPlusSnackbar(R.string.compose_scheduled_plus) }
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.requestDatePicker() }
|
||||
|
||||
@@ -607,6 +613,11 @@ class ComposeViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
// View QKSMS+
|
||||
view.viewQksmsPlusIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { navigator.showQksmsPlusActivity() }
|
||||
|
||||
// Navigate back
|
||||
view.optionsItemIntent
|
||||
.filter { it == android.R.id.home }
|
||||
|
||||
Reference in New Issue
Block a user