mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +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 }
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/contentView"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -194,6 +194,13 @@
|
||||
app:summary="@string/qksms_plus_night_summary"
|
||||
app:title="@string/qksms_plus_night_title" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_event_black_24dp"
|
||||
app:summary="@string/qksms_plus_scheduled_summary"
|
||||
app:title="@string/qksms_plus_scheduled_title" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -236,14 +243,6 @@
|
||||
app:summary="@string/qksms_plus_backup_summary"
|
||||
app:title="@string/qksms_plus_backup_title" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.25"
|
||||
app:icon="@drawable/ic_event_black_24dp"
|
||||
app:summary="@string/qksms_plus_scheduled_summary"
|
||||
app:title="@string/qksms_plus_scheduled_title" />
|
||||
|
||||
<com.moez.QKSMS.common.widget.PreferenceView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
<string name="compose_vcard_label">Contact card</string>
|
||||
<string name="compose_scheduled_for">Scheduled for</string>
|
||||
<string name="compose_scheduled_future">Selected time must be in the future!</string>
|
||||
<string name="compose_scheduled_plus">You must unlock QKSMS+ to use scheduled messaging</string>
|
||||
<string name="compose_scheduled_toast">Added to scheduled messages</string>
|
||||
<string name="compose_hint">Write a message…</string>
|
||||
<string name="compose_menu_copy">Copy text</string>
|
||||
@@ -220,7 +221,7 @@
|
||||
<string name="qksms_plus_respond_title">Auto-respond</string>
|
||||
<string name="qksms_plus_respond_summary">Automatically respond to incoming messages with a preset response</string>
|
||||
<string name="qksms_plus_more_title">More</string>
|
||||
<string name="qksms_plus_more_summary">QKSMS is under active development, and your subscription will include all future QKSMS+ features!</string>
|
||||
<string name="qksms_plus_more_summary">QKSMS is under active development, and your purchase will include all future QKSMS+ features!</string>
|
||||
|
||||
<string name="widget_loading">Loading…</string>
|
||||
<string name="widget_more">View more conversations</string>
|
||||
|
||||
Reference in New Issue
Block a user