forked from upstream-mirrors/quik
Merge pull request #249 from gavine99/scheduled-messages-click-doesnt-schedule-18
Scheduled messages click doesnt schedule 18
This commit is contained in:
@@ -95,9 +95,10 @@ class Navigator @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showCompose(body: String? = null, attachments: List<Uri>? = null) {
|
fun showCompose(body: String? = null, attachments: List<Uri>? = null, mode: String? = null) {
|
||||||
val intent = Intent(context, ComposeActivity::class.java)
|
val intent = Intent(context, ComposeActivity::class.java)
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, body)
|
intent.putExtra(Intent.EXTRA_TEXT, body)
|
||||||
|
intent.putExtra("mode", mode)
|
||||||
|
|
||||||
attachments?.takeIf { it.isNotEmpty() }?.let {
|
attachments?.takeIf { it.isNotEmpty() }?.let {
|
||||||
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, ArrayList(attachments))
|
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, ArrayList(attachments))
|
||||||
|
|||||||
@@ -71,10 +71,12 @@ import dev.octoshrimpy.quik.feature.contacts.ContactsActivity
|
|||||||
import dev.octoshrimpy.quik.model.Attachment
|
import dev.octoshrimpy.quik.model.Attachment
|
||||||
import dev.octoshrimpy.quik.model.Recipient
|
import dev.octoshrimpy.quik.model.Recipient
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
|
import io.reactivex.Single
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
import kotlinx.android.synthetic.main.compose_activity.*
|
import kotlinx.android.synthetic.main.compose_activity.*
|
||||||
import kotlinx.android.synthetic.main.main_activity.toolbar
|
import kotlinx.android.synthetic.main.main_activity.toolbar
|
||||||
|
import kotlinx.coroutines.reactive.publish
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -94,6 +96,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
override val chipDeletedIntent: Subject<Recipient> by lazy { chipsAdapter.chipDeleted }
|
override val chipDeletedIntent: Subject<Recipient> by lazy { chipsAdapter.chipDeleted }
|
||||||
override val menuReadyIntent: Observable<Unit> = menu.map { Unit }
|
override val menuReadyIntent: Observable<Unit> = menu.map { Unit }
|
||||||
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
||||||
|
override val scheduleAction: Subject<Boolean> = PublishSubject.create()
|
||||||
override val sendAsGroupIntent by lazy { sendAsGroupBackground.clicks() }
|
override val sendAsGroupIntent by lazy { sendAsGroupBackground.clicks() }
|
||||||
override val messageClickIntent: Subject<Long> by lazy { messageAdapter.clicks }
|
override val messageClickIntent: Subject<Long> by lazy { messageAdapter.clicks }
|
||||||
override val messagePartClickIntent: Subject<Long> by lazy { messageAdapter.partClicks }
|
override val messagePartClickIntent: Subject<Long> by lazy { messageAdapter.partClicks }
|
||||||
@@ -323,6 +326,10 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
)
|
)
|
||||||
constraintSet.applyTo(constraintLayout)
|
constraintSet.applyTo(constraintLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if scheduling mode is set, show schedule dialog
|
||||||
|
if (state.scheduling)
|
||||||
|
scheduleAction.onNext(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSelection() = messageAdapter.clearSelection()
|
override fun clearSelection() = messageAdapter.clearSelection()
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ class ComposeActivityModule {
|
|||||||
return Attachments(uris.mapNotNull { Attachment(it) })
|
return Attachments(uris.mapNotNull { Attachment(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("mode")
|
||||||
|
fun provideSharedAction(activity: ComposeActivity): String {
|
||||||
|
return activity.intent.getStringExtra("mode") ?: "";
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@IntoMap
|
@IntoMap
|
||||||
@ViewModelKey(ComposeViewModel::class)
|
@ViewModelKey(ComposeViewModel::class)
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ data class ComposeState(
|
|||||||
val scheduled: Long = 0,
|
val scheduled: Long = 0,
|
||||||
val attachments: List<Attachment> = ArrayList(),
|
val attachments: List<Attachment> = ArrayList(),
|
||||||
val attaching: Boolean = false,
|
val attaching: Boolean = false,
|
||||||
|
val scheduling: Boolean = false,
|
||||||
val remaining: String = "",
|
val remaining: String = "",
|
||||||
val subscription: SubscriptionInfoCompat? = null,
|
val subscription: SubscriptionInfoCompat? = null,
|
||||||
val canSend: Boolean = false,
|
val canSend: Boolean = false,
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ interface ComposeView : QkView<ComposeState> {
|
|||||||
val attachAnyFileIntent: Observable<*>
|
val attachAnyFileIntent: Observable<*>
|
||||||
val attachImageFileIntent: Observable<*>
|
val attachImageFileIntent: Observable<*>
|
||||||
val scheduleIntent: Observable<*>
|
val scheduleIntent: Observable<*>
|
||||||
|
val scheduleAction: Observable<*>
|
||||||
val attachContactIntent: Observable<*>
|
val attachContactIntent: Observable<*>
|
||||||
val attachAnyFileSelectedIntent: Observable<Uri>
|
val attachAnyFileSelectedIntent: Observable<Uri>
|
||||||
val contactSelectedIntent: Observable<Uri>
|
val contactSelectedIntent: Observable<Uri>
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class ComposeViewModel @Inject constructor(
|
|||||||
@Named("addresses") private val addresses: List<String>,
|
@Named("addresses") private val addresses: List<String>,
|
||||||
@Named("text") private val sharedText: String,
|
@Named("text") private val sharedText: String,
|
||||||
@Named("attachments") private val sharedAttachments: Attachments,
|
@Named("attachments") private val sharedAttachments: Attachments,
|
||||||
|
@Named("mode") private val mode: String,
|
||||||
private val contactRepo: ContactRepository,
|
private val contactRepo: ContactRepository,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val activeConversationManager: ActiveConversationManager,
|
private val activeConversationManager: ActiveConversationManager,
|
||||||
@@ -243,6 +244,10 @@ class ComposeViewModel @Inject constructor(
|
|||||||
val sub = if (subs.size > 1) subs.firstOrNull { it.subscriptionId == subId } ?: subs[0] else null
|
val sub = if (subs.size > 1) subs.firstOrNull { it.subscriptionId == subId } ?: subs[0] else null
|
||||||
newState { copy(subscription = sub) }
|
newState { copy(subscription = sub) }
|
||||||
}.subscribe()
|
}.subscribe()
|
||||||
|
|
||||||
|
// actions
|
||||||
|
if (mode == "scheduling")
|
||||||
|
newState { copy(scheduling = true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bindView(view: ComposeView) {
|
override fun bindView(view: ComposeView) {
|
||||||
@@ -575,6 +580,12 @@ class ComposeViewModel @Inject constructor(
|
|||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { view.requestDatePicker() }
|
.subscribe { view.requestDatePicker() }
|
||||||
|
|
||||||
|
view.scheduleAction
|
||||||
|
.take(1)
|
||||||
|
.doOnNext{ newState { copy(scheduling = false) } }
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe { view.requestDatePicker() }
|
||||||
|
|
||||||
// a file, photo or otherwise, was picked by the user
|
// a file, photo or otherwise, was picked by the user
|
||||||
Observable.merge(
|
Observable.merge(
|
||||||
view.attachAnyFileSelectedIntent.map { uri -> Attachment(uri) },
|
view.attachAnyFileSelectedIntent.map { uri -> Attachment(uri) },
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class ScheduledViewModel @Inject constructor(
|
|||||||
|
|
||||||
view.composeIntent
|
view.composeIntent
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { navigator.showCompose() }
|
.subscribe { navigator.showCompose(mode = "scheduling") }
|
||||||
|
|
||||||
view.upgradeIntent
|
view.upgradeIntent
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
|
|||||||
Reference in New Issue
Block a user