diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt index 1d813fe2..656ce0d4 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt @@ -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 = PublishSubject.create() override val backPressedIntent: Subject = 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) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt index 3f4c6d6b..572fbae4 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeView.kt @@ -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 { val scheduleCancelIntent: Observable<*> val changeSimIntent: Observable<*> val sendIntent: Observable + val viewQksmsPlusIntent: Subject + val backPressedIntent: Observable fun clearSelection() fun showDetails(details: String) @@ -62,6 +65,6 @@ interface ComposeView : QkView { fun requestDatePicker() fun setDraft(draft: String) fun scrollToMessage(id: Long) - val backPressedIntent: Observable + fun showQksmsPlusSnackbar(@StringRes message: Int) } \ No newline at end of file diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt index 4eb70813..9adbf4ea 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt @@ -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, 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 } diff --git a/presentation/src/main/res/layout/compose_activity.xml b/presentation/src/main/res/layout/compose_activity.xml index d48de855..7ce3b3e6 100644 --- a/presentation/src/main/res/layout/compose_activity.xml +++ b/presentation/src/main/res/layout/compose_activity.xml @@ -17,7 +17,8 @@ ~ You should have received a copy of the GNU General Public License ~ along with QKSMS. If not, see . --> - + + - - Contact card Scheduled for Selected time must be in the future! + You must unlock QKSMS+ to use scheduled messaging Added to scheduled messages Write a message… Copy text @@ -220,7 +221,7 @@ Auto-respond Automatically respond to incoming messages with a preset response More - QKSMS is under active development, and your subscription will include all future QKSMS+ features! + QKSMS is under active development, and your purchase will include all future QKSMS+ features! Loading… View more conversations