forked from upstream-mirrors/quik
#874 - Multi selection for conversations
This commit is contained in:
@@ -48,6 +48,7 @@ import model.Message
|
|||||||
import model.MmsPart
|
import model.MmsPart
|
||||||
import util.MessageUtils
|
import util.MessageUtils
|
||||||
import util.Preferences
|
import util.Preferences
|
||||||
|
import util.extensions.anyOf
|
||||||
import util.extensions.asMaybe
|
import util.extensions.asMaybe
|
||||||
import util.extensions.insertOrUpdate
|
import util.extensions.insertOrUpdate
|
||||||
import util.extensions.map
|
import util.extensions.map
|
||||||
@@ -236,71 +237,82 @@ class MessageRepositoryImpl @Inject constructor(
|
|||||||
.findAll()
|
.findAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateConversation(threadId: Long) {
|
override fun updateConversations(vararg threadIds: Long) {
|
||||||
Realm.getDefaultInstance().use { realm ->
|
Realm.getDefaultInstance().use { realm ->
|
||||||
realm.refresh()
|
realm.refresh()
|
||||||
|
|
||||||
val conversation = realm
|
threadIds.forEach { threadId ->
|
||||||
.where(Conversation::class.java)
|
val conversation = realm
|
||||||
.equalTo("id", threadId)
|
.where(Conversation::class.java)
|
||||||
.findFirst() ?: return
|
.equalTo("id", threadId)
|
||||||
|
.findFirst() ?: return
|
||||||
|
|
||||||
val messages = realm
|
val messages = realm
|
||||||
.where(Message::class.java)
|
.where(Message::class.java)
|
||||||
.equalTo("threadId", threadId)
|
.equalTo("threadId", threadId)
|
||||||
.sort("date", Sort.DESCENDING)
|
.sort("date", Sort.DESCENDING)
|
||||||
.findAll()
|
.findAll()
|
||||||
|
|
||||||
val message = messages.firstOrNull()
|
val message = messages.firstOrNull()
|
||||||
|
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
conversation.count = messages.size
|
conversation.count = messages.size
|
||||||
conversation.date = message?.date ?: 0
|
conversation.date = message?.date ?: 0
|
||||||
conversation.snippet = message?.getSummary() ?: ""
|
conversation.snippet = message?.getSummary() ?: ""
|
||||||
conversation.read = message?.read ?: true
|
conversation.read = message?.read ?: true
|
||||||
conversation.me = message?.isMe() ?: false
|
conversation.me = message?.isMe() ?: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun markArchived(threadId: Long) {
|
override fun markArchived(vararg threadIds: Long) {
|
||||||
val realm = Realm.getDefaultInstance()
|
Realm.getDefaultInstance().use { realm ->
|
||||||
val conversation = realm.where(Conversation::class.java)
|
val conversations = realm.where(Conversation::class.java)
|
||||||
.equalTo("id", threadId)
|
.anyOf("id", threadIds)
|
||||||
.findFirst()
|
.findAll()
|
||||||
|
|
||||||
realm.executeTransaction { conversation?.archived = true }
|
realm.executeTransaction {
|
||||||
realm.close()
|
conversations.forEach { it.archived = true }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun markUnarchived(threadId: Long) {
|
override fun markUnarchived(vararg threadIds: Long) {
|
||||||
val realm = Realm.getDefaultInstance()
|
Realm.getDefaultInstance().use { realm ->
|
||||||
val conversation = realm.where(Conversation::class.java)
|
val conversations = realm.where(Conversation::class.java)
|
||||||
.equalTo("id", threadId)
|
.anyOf("id", threadIds)
|
||||||
.findFirst()
|
.findAll()
|
||||||
|
|
||||||
realm.executeTransaction { conversation?.archived = false }
|
realm.executeTransaction {
|
||||||
realm.close()
|
conversations.forEach { it.archived = false }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun markBlocked(threadId: Long) {
|
override fun markBlocked(vararg threadIds: Long) {
|
||||||
val realm = Realm.getDefaultInstance()
|
Realm.getDefaultInstance().use { realm ->
|
||||||
val conversation = realm.where(Conversation::class.java)
|
val conversations = realm.where(Conversation::class.java)
|
||||||
.equalTo("id", threadId)
|
.anyOf("id", threadIds)
|
||||||
.findFirst()
|
.findAll()
|
||||||
|
|
||||||
realm.executeTransaction { conversation?.blocked = true }
|
realm.executeTransaction {
|
||||||
realm.close()
|
conversations.forEach { it.blocked = true }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun markUnblocked(threadId: Long) {
|
override fun markUnblocked(vararg threadIds: Long) {
|
||||||
val realm = Realm.getDefaultInstance()
|
Realm.getDefaultInstance().use { realm ->
|
||||||
val conversation = realm.where(Conversation::class.java)
|
val conversations = realm.where(Conversation::class.java)
|
||||||
.equalTo("id", threadId)
|
.anyOf("id", threadIds)
|
||||||
.findFirst()
|
.equalTo("archived", false)
|
||||||
|
.findAll()
|
||||||
|
|
||||||
realm.executeTransaction { conversation?.blocked = false }
|
realm.executeTransaction {
|
||||||
realm.close()
|
conversations.forEach { it.blocked = false }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun markAllSeen() {
|
override fun markAllSeen() {
|
||||||
@@ -611,10 +623,10 @@ class MessageRepositoryImpl @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteConversation(threadId: Long) {
|
override fun deleteConversations(vararg threadIds: Long) {
|
||||||
Realm.getDefaultInstance().use { realm ->
|
Realm.getDefaultInstance().use { realm ->
|
||||||
val conversation = realm.where(Conversation::class.java).equalTo("id", threadId).findAll()
|
val conversation = realm.where(Conversation::class.java).anyOf("id", threadIds).findAll()
|
||||||
val messages = realm.where(Message::class.java).equalTo("threadId", threadId).findAll()
|
val messages = realm.where(Message::class.java).anyOf("threadId", threadIds).findAll()
|
||||||
|
|
||||||
realm.executeTransaction {
|
realm.executeTransaction {
|
||||||
conversation.deleteAllFromRealm()
|
conversation.deleteAllFromRealm()
|
||||||
@@ -622,8 +634,10 @@ class MessageRepositoryImpl @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val uri = ContentUris.withAppendedId(Telephony.Threads.CONTENT_URI, threadId)
|
threadIds.forEach { threadId ->
|
||||||
context.contentResolver.delete(uri, null, null)
|
val uri = ContentUris.withAppendedId(Telephony.Threads.CONTENT_URI, threadId)
|
||||||
|
context.contentResolver.delete(uri, null, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getConversationFromCp(threadId: Long): Conversation? {
|
private fun getConversationFromCp(threadId: Long): Conversation? {
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ import io.reactivex.Observable
|
|||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmModel
|
import io.realm.RealmModel
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
|
import io.realm.RealmQuery
|
||||||
import io.realm.RealmResults
|
import io.realm.RealmResults
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
fun RealmModel.insertOrUpdate() {
|
fun RealmModel.insertOrUpdate() {
|
||||||
val realm = Realm.getDefaultInstance()
|
val realm = Realm.getDefaultInstance()
|
||||||
@@ -43,3 +45,12 @@ fun <T : RealmObject> RealmObject.asObservable(): Observable<T> {
|
|||||||
fun <T : RealmObject> RealmResults<T>.asObservable(): Observable<RealmResults<T>> {
|
fun <T : RealmObject> RealmResults<T>.asObservable(): Observable<RealmResults<T>> {
|
||||||
return asFlowable().toObservable()
|
return asFlowable().toObservable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T : RealmObject> RealmQuery<T>.anyOf(fieldName: String, values: LongArray): RealmQuery<T> {
|
||||||
|
values.forEach { Timber.v("vararg: $it") }
|
||||||
|
|
||||||
|
return when (values.isEmpty()) {
|
||||||
|
true -> equalTo(fieldName, -1L)
|
||||||
|
false -> `in`(fieldName, values.toTypedArray())
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-5
@@ -22,14 +22,14 @@ import io.reactivex.Flowable
|
|||||||
import repository.MessageRepository
|
import repository.MessageRepository
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class DeleteConversation @Inject constructor(
|
class DeleteConversations @Inject constructor(
|
||||||
private val messageRepo: MessageRepository,
|
private val messageRepo: MessageRepository,
|
||||||
private val updateBadge: UpdateBadge
|
private val updateBadge: UpdateBadge
|
||||||
): Interactor<Long>() {
|
) : Interactor<List<Long>>() {
|
||||||
|
|
||||||
override fun buildObservable(params: Long): Flowable<*> {
|
override fun buildObservable(params: List<Long>): Flowable<*> {
|
||||||
return Flowable.just(Unit)
|
return Flowable.just(params.toLongArray())
|
||||||
.doOnNext { messageRepo.deleteConversation(params) }
|
.doOnNext { threadIds -> messageRepo.deleteConversations(*threadIds) }
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,9 +32,9 @@ class DeleteMessage @Inject constructor(
|
|||||||
.doOnNext { messageId ->
|
.doOnNext { messageId ->
|
||||||
val threadId = messageRepo.getMessage(messageId)?.threadId
|
val threadId = messageRepo.getMessage(messageId)?.threadId
|
||||||
messageRepo.deleteMessage(messageId)
|
messageRepo.deleteMessage(messageId)
|
||||||
threadId?.let { messageRepo.updateConversation(it) }
|
threadId?.let { messageRepo.updateConversations(it) }
|
||||||
}
|
}
|
||||||
.doOnNext { messageRepo.updateConversation(params) } // Update the conversation
|
.doOnNext { messageRepo.updateConversations(params) } // Update the conversation
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ import io.reactivex.Flowable
|
|||||||
import repository.MessageRepository
|
import repository.MessageRepository
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MarkArchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
class MarkArchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<List<Long>>() {
|
||||||
|
|
||||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
override fun buildObservable(params: List<Long>): Flowable<*> {
|
||||||
return Flowable.just(Unit)
|
return Flowable.just(params.toLongArray())
|
||||||
.doOnNext { messageRepo.markArchived(params) }
|
.doOnNext { threadIds -> messageRepo.markArchived(*threadIds) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,11 +22,11 @@ import io.reactivex.Flowable
|
|||||||
import repository.MessageRepository
|
import repository.MessageRepository
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MarkBlocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
class MarkBlocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<List<Long>>() {
|
||||||
|
|
||||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
override fun buildObservable(params: List<Long>): Flowable<*> {
|
||||||
return Flowable.just(Unit)
|
return Flowable.just(params.toLongArray())
|
||||||
.doOnNext { messageRepo.markBlocked(params) }
|
.doOnNext { threadIds -> messageRepo.markBlocked(*threadIds) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ class MarkRead @Inject constructor(
|
|||||||
override fun buildObservable(params: Long): Flowable<*> {
|
override fun buildObservable(params: Long): Flowable<*> {
|
||||||
return Flowable.just(Unit)
|
return Flowable.just(Unit)
|
||||||
.doOnNext { messageRepo.markRead(params) }
|
.doOnNext { messageRepo.markRead(params) }
|
||||||
.doOnNext { messageRepo.updateConversation(params) } // Update the conversation
|
.doOnNext { messageRepo.updateConversations(params) } // Update the conversation
|
||||||
.doOnNext { notificationManager.update(params) }
|
.doOnNext { notificationManager.update(params) }
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ import io.reactivex.Flowable
|
|||||||
import repository.MessageRepository
|
import repository.MessageRepository
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MarkUnarchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
class MarkUnarchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<List<Long>>() {
|
||||||
|
|
||||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
override fun buildObservable(params: List<Long>): Flowable<*> {
|
||||||
return Flowable.just(Unit)
|
return Flowable.just(params.toLongArray())
|
||||||
.doOnNext { messageRepo.markUnarchived(params) }
|
.doOnNext { threadIds -> messageRepo.markUnarchived(*threadIds) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,11 +22,11 @@ import io.reactivex.Flowable
|
|||||||
import repository.MessageRepository
|
import repository.MessageRepository
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MarkUnblocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
class MarkUnblocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<List<Long>>() {
|
||||||
|
|
||||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
override fun buildObservable(params: List<Long>): Flowable<*> {
|
||||||
return Flowable.just(Unit)
|
return Flowable.just(params.toLongArray())
|
||||||
.doOnNext { messageRepo.markUnblocked(params) }
|
.doOnNext { threadIds -> messageRepo.markUnblocked(*threadIds) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ class ReceiveMms @Inject constructor(
|
|||||||
if (blocked) messageRepo.deleteMessage(message.id)
|
if (blocked) messageRepo.deleteMessage(message.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.doOnNext { message -> messageRepo.updateConversation(message.threadId) } // Update the conversation
|
.doOnNext { message -> messageRepo.updateConversations(message.threadId) } // Update the conversation
|
||||||
.mapNotNull { message -> messageRepo.getOrCreateConversation(message.threadId) } // Map message to conversation
|
.mapNotNull { message -> messageRepo.getOrCreateConversation(message.threadId) } // Map message to conversation
|
||||||
.filter { conversation -> !conversation.blocked } // Don't notify for blocked conversations
|
.filter { conversation -> !conversation.blocked } // Don't notify for blocked conversations
|
||||||
.doOnNext { conversation -> if (conversation.archived) messageRepo.markUnarchived(conversation.id) } // Unarchive conversation if necessary
|
.doOnNext { conversation -> if (conversation.archived) messageRepo.markUnarchived(conversation.id) } // Unarchive conversation if necessary
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class ReceiveSms @Inject constructor(
|
|||||||
|
|
||||||
messageRepo.insertReceivedSms(address, body, time) // Add the message to the db
|
messageRepo.insertReceivedSms(address, body, time) // Add the message to the db
|
||||||
}
|
}
|
||||||
.doOnNext { message -> messageRepo.updateConversation(message.threadId) } // Update the conversation
|
.doOnNext { message -> messageRepo.updateConversations(message.threadId) } // Update the conversation
|
||||||
.mapNotNull { message -> messageRepo.getOrCreateConversation(message.threadId) } // Map message to conversation
|
.mapNotNull { message -> messageRepo.getOrCreateConversation(message.threadId) } // Map message to conversation
|
||||||
.filter { conversation -> !conversation.blocked } // Don't notify for blocked conversations
|
.filter { conversation -> !conversation.blocked } // Don't notify for blocked conversations
|
||||||
.doOnNext { conversation -> if (conversation.archived) messageRepo.markUnarchived(conversation.id) } // Unarchive conversation if necessary
|
.doOnNext { conversation -> if (conversation.archived) messageRepo.markUnarchived(conversation.id) } // Unarchive conversation if necessary
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class SyncMessage @Inject constructor(
|
|||||||
override fun buildObservable(params: Uri): Flowable<Message> {
|
override fun buildObservable(params: Uri): Flowable<Message> {
|
||||||
return Flowable.just(params)
|
return Flowable.just(params)
|
||||||
.mapNotNull { uri -> syncManager.syncMessage(uri) }
|
.mapNotNull { uri -> syncManager.syncMessage(uri) }
|
||||||
.doOnNext { message -> messageRepo.updateConversation(message.threadId) }
|
.doOnNext { message -> messageRepo.updateConversations(message.threadId) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -72,15 +72,15 @@ interface MessageRepository {
|
|||||||
/**
|
/**
|
||||||
* Updates message-related fields in the conversation, like the date and snippet
|
* Updates message-related fields in the conversation, like the date and snippet
|
||||||
*/
|
*/
|
||||||
fun updateConversation(threadId: Long)
|
fun updateConversations(vararg threadIds: Long)
|
||||||
|
|
||||||
fun markArchived(threadId: Long)
|
fun markArchived(vararg threadIds: Long)
|
||||||
|
|
||||||
fun markUnarchived(threadId: Long)
|
fun markUnarchived(vararg threadIds: Long)
|
||||||
|
|
||||||
fun markBlocked(threadId: Long)
|
fun markBlocked(vararg threadIds: Long)
|
||||||
|
|
||||||
fun markUnblocked(threadId: Long)
|
fun markUnblocked(vararg threadIds: Long)
|
||||||
|
|
||||||
fun markAllSeen()
|
fun markAllSeen()
|
||||||
|
|
||||||
@@ -122,6 +122,6 @@ interface MessageRepository {
|
|||||||
|
|
||||||
fun deleteMessage(messageId: Long)
|
fun deleteMessage(messageId: Long)
|
||||||
|
|
||||||
fun deleteConversation(threadId: Long)
|
fun deleteConversations(vararg threadIds: Long)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -61,6 +61,10 @@ abstract class QkActivity<VM : QkViewModel<*, *>> : AppCompatActivity() {
|
|||||||
title = title // The title may have been set before layout inflation
|
title = title // The title may have been set before layout inflation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setTitle(titleId: Int) {
|
||||||
|
title = getString(titleId)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setTitle(title: CharSequence?) {
|
override fun setTitle(title: CharSequence?) {
|
||||||
super.setTitle(title)
|
super.setTitle(title)
|
||||||
toolbarTitle?.text = title
|
toolbarTitle?.text = title
|
||||||
@@ -74,7 +78,7 @@ abstract class QkActivity<VM : QkViewModel<*, *>> : AppCompatActivity() {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun showBackButton(show: Boolean) {
|
protected open fun showBackButton(show: Boolean) {
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(show)
|
supportActionBar?.setDisplayHomeAsUpEnabled(show)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ package common.base
|
|||||||
|
|
||||||
import android.support.v7.util.DiffUtil
|
import android.support.v7.util.DiffUtil
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
|
import io.reactivex.subjects.Subject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base RecyclerView.Adapter that provides some convenience when creating a new Adapter, such as
|
* Base RecyclerView.Adapter that provides some convenience when creating a new Adapter, such as
|
||||||
@@ -37,6 +39,38 @@ abstract class QkAdapter<T> : RecyclerView.Adapter<QkViewHolder>() {
|
|||||||
onDatasetChanged()
|
onDatasetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val selectionChanges: Subject<List<Long>> = BehaviorSubject.create()
|
||||||
|
|
||||||
|
private val selection = mutableListOf<Long>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the selected state for a particular view
|
||||||
|
*
|
||||||
|
* If we are currently in selection mode (we have an active selection), then the state will
|
||||||
|
* toggle. If we are not in selection mode, then we will only toggle if [force]
|
||||||
|
*/
|
||||||
|
protected fun toggleSelection(id: Long, force: Boolean = true): Boolean {
|
||||||
|
if (!force && selection.isEmpty()) return false
|
||||||
|
|
||||||
|
when (selection.contains(id)) {
|
||||||
|
true -> selection.remove(id)
|
||||||
|
false -> selection.add(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
selectionChanges.onNext(selection)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun isSelected(id: Long): Boolean {
|
||||||
|
return selection.contains(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearSelection() {
|
||||||
|
selection.clear()
|
||||||
|
selectionChanges.onNext(selection)
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
|
||||||
fun getItem(position: Int): T {
|
fun getItem(position: Int): T {
|
||||||
return data[position]
|
return data[position]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,6 +159,15 @@ class Colors @Inject constructor(private val context: Context, private val prefs
|
|||||||
.map { res -> getColor(res) }
|
.map { res -> getColor(res) }
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
|
|
||||||
|
val ripple: Observable<Int> = prefs.night.asObservable()
|
||||||
|
.map { night ->
|
||||||
|
when (night) {
|
||||||
|
true -> R.drawable.ripple_dark
|
||||||
|
false -> R.drawable.ripple
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.distinctUntilChanged()
|
||||||
|
|
||||||
val field: Observable<Int> = prefs.night.asObservable()
|
val field: Observable<Int> = prefs.night.asObservable()
|
||||||
.map { night -> if (night) R.color.fieldDark else R.color.fieldLight }
|
.map { night -> if (night) R.color.fieldDark else R.color.fieldLight }
|
||||||
.map { res -> getColor(res) }
|
.map { res -> getColor(res) }
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class BlockedViewModel : QkViewModel<BlockedView, BlockedState>(BlockedState())
|
|||||||
view.confirmUnblockIntent
|
view.confirmUnblockIntent
|
||||||
.withLatestFrom(view.unblockIntent, { _, threadId -> threadId })
|
.withLatestFrom(view.unblockIntent, { _, threadId -> threadId })
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { threadId -> markUnblocked.execute(threadId) }
|
.subscribe { threadId -> markUnblocked.execute(listOf(threadId)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ import com.uber.autodispose.kotlin.autoDisposable
|
|||||||
import common.Navigator
|
import common.Navigator
|
||||||
import common.base.QkViewModel
|
import common.base.QkViewModel
|
||||||
import injection.appComponent
|
import injection.appComponent
|
||||||
import interactor.DeleteConversation
|
import interactor.DeleteConversations
|
||||||
import interactor.MarkArchived
|
import interactor.MarkArchived
|
||||||
import interactor.MarkBlocked
|
import interactor.MarkBlocked
|
||||||
import interactor.MarkUnarchived
|
import interactor.MarkUnarchived
|
||||||
@@ -48,7 +48,7 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
|||||||
@Inject lateinit var markBlocked: MarkBlocked
|
@Inject lateinit var markBlocked: MarkBlocked
|
||||||
@Inject lateinit var markUnblocked: MarkUnblocked
|
@Inject lateinit var markUnblocked: MarkUnblocked
|
||||||
@Inject lateinit var navigator: Navigator
|
@Inject lateinit var navigator: Navigator
|
||||||
@Inject lateinit var deleteConversation: DeleteConversation
|
@Inject lateinit var deleteConversations: DeleteConversations
|
||||||
|
|
||||||
private val conversation: Observable<Conversation>
|
private val conversation: Observable<Conversation>
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
|||||||
disposables += markUnarchived
|
disposables += markUnarchived
|
||||||
disposables += markBlocked
|
disposables += markBlocked
|
||||||
disposables += markUnblocked
|
disposables += markUnblocked
|
||||||
disposables += deleteConversation
|
disposables += deleteConversations
|
||||||
|
|
||||||
// Update the recipients whenever they change
|
// Update the recipients whenever they change
|
||||||
disposables += conversation
|
disposables += conversation
|
||||||
@@ -118,8 +118,8 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
|||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { conversation ->
|
.subscribe { conversation ->
|
||||||
when (conversation.archived) {
|
when (conversation.archived) {
|
||||||
true -> markUnarchived.execute(conversation.id)
|
true -> markUnarchived.execute(listOf(conversation.id))
|
||||||
false -> markArchived.execute(conversation.id)
|
false -> markArchived.execute(listOf(conversation.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +129,8 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
|||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { conversation ->
|
.subscribe { conversation ->
|
||||||
when (conversation.blocked) {
|
when (conversation.blocked) {
|
||||||
true -> markUnblocked.execute(conversation.id)
|
true -> markUnblocked.execute(listOf(conversation.id))
|
||||||
false -> markBlocked.execute(conversation.id)
|
false -> markBlocked.execute(listOf(conversation.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
|||||||
view.confirmDeleteIntent
|
view.confirmDeleteIntent
|
||||||
.withLatestFrom(conversation, { _, conversation -> conversation })
|
.withLatestFrom(conversation, { _, conversation -> conversation })
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { conversation -> deleteConversation.execute(conversation.id) }
|
.subscribe { conversation -> deleteConversations.execute(listOf(conversation.id)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,29 +20,31 @@ package feature.conversations
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
import com.jakewharton.rxbinding2.view.longClicks
|
import com.jakewharton.rxbinding2.view.longClicks
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
|
import common.Navigator
|
||||||
import common.base.FlowableAdapter
|
import common.base.FlowableAdapter
|
||||||
import common.base.QkViewHolder
|
import common.base.QkViewHolder
|
||||||
import common.util.Colors
|
import common.util.Colors
|
||||||
import common.util.DateFormatter
|
import common.util.DateFormatter
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.rxkotlin.plusAssign
|
||||||
import kotlinx.android.synthetic.main.conversation_list_item.view.*
|
import kotlinx.android.synthetic.main.conversation_list_item.view.*
|
||||||
import model.Conversation
|
import model.Conversation
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ConversationsAdapter @Inject constructor(
|
class ConversationsAdapter @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
|
private val colors: Colors,
|
||||||
private val dateFormatter: DateFormatter,
|
private val dateFormatter: DateFormatter,
|
||||||
private val colors: Colors
|
private val navigator: Navigator
|
||||||
) : FlowableAdapter<Conversation>() {
|
) : FlowableAdapter<Conversation>() {
|
||||||
|
|
||||||
val clicks: Subject<Long> = PublishSubject.create()
|
private val disposables = CompositeDisposable()
|
||||||
val longClicks: Subject<Long> = PublishSubject.create()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setHasStableIds(true)
|
setHasStableIds(true)
|
||||||
@@ -52,6 +54,9 @@ class ConversationsAdapter @Inject constructor(
|
|||||||
val layoutInflater = LayoutInflater.from(context)
|
val layoutInflater = LayoutInflater.from(context)
|
||||||
val view = layoutInflater.inflate(R.layout.conversation_list_item, parent, false)
|
val view = layoutInflater.inflate(R.layout.conversation_list_item, parent, false)
|
||||||
|
|
||||||
|
disposables += colors.ripple
|
||||||
|
.subscribe { res -> view.setBackgroundResource(res) }
|
||||||
|
|
||||||
if (viewType == 1) {
|
if (viewType == 1) {
|
||||||
view.title.setTypeface(view.title.typeface, Typeface.BOLD)
|
view.title.setTypeface(view.title.typeface, Typeface.BOLD)
|
||||||
|
|
||||||
@@ -70,18 +75,33 @@ class ConversationsAdapter @Inject constructor(
|
|||||||
val conversation = getItem(position)
|
val conversation = getItem(position)
|
||||||
val view = viewHolder.itemView
|
val view = viewHolder.itemView
|
||||||
|
|
||||||
view.clicks().subscribe { clicks.onNext(conversation.id) }
|
view.clicks().subscribe {
|
||||||
view.longClicks().subscribe { longClicks.onNext(conversation.id) }
|
when (toggleSelection(conversation.id, false)) {
|
||||||
|
true -> view.isSelected = isSelected(conversation.id)
|
||||||
|
false -> navigator.showConversation(conversation.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
view.longClicks().subscribe {
|
||||||
|
toggleSelection(conversation.id)
|
||||||
|
view.isSelected = isSelected(conversation.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
view.isSelected = isSelected(conversation.id)
|
||||||
|
|
||||||
view.avatars.contacts = conversation.recipients
|
view.avatars.contacts = conversation.recipients
|
||||||
view.title.text = conversation.getTitle()
|
view.title.text = conversation.getTitle()
|
||||||
view.date.text = dateFormatter.getConversationTimestamp(conversation.date)
|
view.date.text = dateFormatter.getConversationTimestamp(conversation.date)
|
||||||
view.snippet.text = when(conversation.me) {
|
view.snippet.text = when (conversation.me) {
|
||||||
true -> context.getString(R.string.main_sender_you, conversation.snippet)
|
true -> context.getString(R.string.main_sender_you, conversation.snippet)
|
||||||
false -> conversation.snippet
|
false -> conversation.snippet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||||
|
super.onDetachedFromRecyclerView(recyclerView)
|
||||||
|
disposables.clear()
|
||||||
|
}
|
||||||
|
|
||||||
override fun getItemId(index: Int): Long {
|
override fun getItemId(index: Int): Long {
|
||||||
return getItem(index).id
|
return getItem(index).id
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.support.v7.widget.helper.ItemTouchHelper
|
|||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import com.jakewharton.rxbinding2.support.v4.widget.drawerOpen
|
import com.jakewharton.rxbinding2.support.v4.widget.drawerOpen
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
import com.jakewharton.rxbinding2.widget.textChanges
|
import com.jakewharton.rxbinding2.widget.textChanges
|
||||||
@@ -37,14 +38,12 @@ import com.moez.QKSMS.R
|
|||||||
import com.uber.autodispose.android.lifecycle.scope
|
import com.uber.autodispose.android.lifecycle.scope
|
||||||
import com.uber.autodispose.kotlin.autoDisposable
|
import com.uber.autodispose.kotlin.autoDisposable
|
||||||
import common.Navigator
|
import common.Navigator
|
||||||
import common.QkDialog
|
|
||||||
import common.base.QkThemedActivity
|
import common.base.QkThemedActivity
|
||||||
import common.util.extensions.autoScrollToStart
|
import common.util.extensions.autoScrollToStart
|
||||||
import common.util.extensions.dismissKeyboard
|
import common.util.extensions.dismissKeyboard
|
||||||
import common.util.extensions.setBackgroundTint
|
import common.util.extensions.setBackgroundTint
|
||||||
import common.util.extensions.setTint
|
import common.util.extensions.setTint
|
||||||
import common.util.extensions.setVisible
|
import common.util.extensions.setVisible
|
||||||
import common.widget.QkEditText
|
|
||||||
import feature.conversations.ConversationItemTouchCallback
|
import feature.conversations.ConversationItemTouchCallback
|
||||||
import feature.conversations.ConversationsAdapter
|
import feature.conversations.ConversationsAdapter
|
||||||
import injection.appComponent
|
import injection.appComponent
|
||||||
@@ -60,18 +59,17 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
|
|
||||||
@Inject lateinit var navigator: Navigator
|
@Inject lateinit var navigator: Navigator
|
||||||
@Inject lateinit var conversationsAdapter: ConversationsAdapter
|
@Inject lateinit var conversationsAdapter: ConversationsAdapter
|
||||||
@Inject lateinit var dialog: QkDialog
|
|
||||||
@Inject lateinit var itemTouchCallback: ConversationItemTouchCallback
|
@Inject lateinit var itemTouchCallback: ConversationItemTouchCallback
|
||||||
|
|
||||||
override val viewModelClass = MainViewModel::class
|
override val viewModelClass = MainViewModel::class
|
||||||
override val queryChangedIntent by lazy { toolbarSearch.textChanges() }
|
override val queryChangedIntent by lazy { toolbarSearch.textChanges() }
|
||||||
override val queryCancelledIntent: PublishSubject<Unit> = PublishSubject.create()
|
|
||||||
override val composeIntent by lazy { compose.clicks() }
|
override val composeIntent by lazy { compose.clicks() }
|
||||||
override val drawerOpenIntent: Observable<Boolean> by lazy {
|
override val drawerOpenIntent: Observable<Boolean> by lazy {
|
||||||
drawerLayout
|
drawerLayout
|
||||||
.drawerOpen(Gravity.START)
|
.drawerOpen(Gravity.START)
|
||||||
.doOnNext { dismissKeyboard() }
|
.doOnNext { dismissKeyboard() }
|
||||||
}
|
}
|
||||||
|
override val homeIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val drawerItemIntent: Observable<DrawerItem> by lazy {
|
override val drawerItemIntent: Observable<DrawerItem> by lazy {
|
||||||
Observable.merge(listOf(
|
Observable.merge(listOf(
|
||||||
inbox.clicks().map { DrawerItem.INBOX },
|
inbox.clicks().map { DrawerItem.INBOX },
|
||||||
@@ -81,15 +79,16 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
plus.clicks().map { DrawerItem.PLUS },
|
plus.clicks().map { DrawerItem.PLUS },
|
||||||
help.clicks().map { DrawerItem.HELP }))
|
help.clicks().map { DrawerItem.HELP }))
|
||||||
}
|
}
|
||||||
|
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
||||||
override val dismissRatingIntent by lazy { rateDismiss.clicks() }
|
override val dismissRatingIntent by lazy { rateDismiss.clicks() }
|
||||||
override val rateIntent by lazy { rateOkay.clicks() }
|
override val rateIntent by lazy { rateOkay.clicks() }
|
||||||
override val conversationClickIntent by lazy { conversationsAdapter.clicks }
|
override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges }
|
||||||
override val conversationLongClickIntent by lazy { conversationsAdapter.longClicks }
|
|
||||||
override val conversationMenuItemIntent by lazy { dialog.adapter.menuItemClicks }
|
|
||||||
override val confirmDeleteIntent: Subject<Unit> = PublishSubject.create()
|
override val confirmDeleteIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val swipeConversationIntent by lazy { itemTouchCallback.swipes }
|
override val swipeConversationIntent by lazy { itemTouchCallback.swipes }
|
||||||
override val undoSwipeConversationIntent: Subject<Unit> = PublishSubject.create()
|
override val undoSwipeConversationIntent: Subject<Unit> = PublishSubject.create()
|
||||||
|
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
|
||||||
|
|
||||||
|
private val toggle by lazy { ActionBarDrawerToggle(this, drawerLayout, toolbar, 0, 0) }
|
||||||
private val itemTouchHelper by lazy { ItemTouchHelper(itemTouchCallback) }
|
private val itemTouchHelper by lazy { ItemTouchHelper(itemTouchCallback) }
|
||||||
private val archiveSnackbar by lazy {
|
private val archiveSnackbar by lazy {
|
||||||
Snackbar.make(drawerLayout, R.string.toast_archived, Snackbar.LENGTH_INDEFINITE).apply {
|
Snackbar.make(drawerLayout, R.string.toast_archived, Snackbar.LENGTH_INDEFINITE).apply {
|
||||||
@@ -105,9 +104,12 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.main_activity)
|
setContentView(R.layout.main_activity)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
toolbarSearch.setHint(R.string.title_conversations)
|
|
||||||
|
|
||||||
val toggle = ActionBarDrawerToggle(this, drawerLayout, toolbar, 0, 0).apply { syncState() }
|
toggle.syncState()
|
||||||
|
toolbar.setNavigationOnClickListener {
|
||||||
|
dismissKeyboard()
|
||||||
|
homeIntent.onNext(Unit)
|
||||||
|
}
|
||||||
|
|
||||||
recyclerView.setHasFixedSize(true)
|
recyclerView.setHasFixedSize(true)
|
||||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
@@ -184,20 +186,35 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: MainState) {
|
override fun render(state: MainState) {
|
||||||
toolbarSearch.isEnabled = state.page is Inbox
|
if (state.hasError) {
|
||||||
toolbarSearch.setTextSize(if (state.page is Inbox) QkEditText.SIZE_PRIMARY else QkEditText.SIZE_TOOLBAR)
|
finish()
|
||||||
|
return
|
||||||
toolbar.menu.findItem(R.id.clear)?.run {
|
|
||||||
isVisible = state.page is Inbox && state.page.showClearButton
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val selectedConversations = when (state.page) {
|
||||||
|
is Inbox -> state.page.selected
|
||||||
|
is Archived -> state.page.selected
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
|
||||||
|
toolbarSearch.setVisible(state.page is Inbox && state.page.selected == 0)
|
||||||
|
toolbarTitle.setVisible(toolbarSearch.visibility != View.VISIBLE)
|
||||||
|
|
||||||
|
toolbar.menu.findItem(R.id.archive)?.isVisible = state.page is Inbox && selectedConversations != 0
|
||||||
|
toolbar.menu.findItem(R.id.unarchive)?.isVisible = state.page is Archived && selectedConversations != 0
|
||||||
|
toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
|
||||||
|
toolbar.menu.findItem(R.id.delete)?.isVisible = selectedConversations != 0
|
||||||
|
|
||||||
syncing.setVisible(state.syncing)
|
syncing.setVisible(state.syncing)
|
||||||
synced.setVisible(!state.syncing)
|
synced.setVisible(!state.syncing)
|
||||||
rateLayout.setVisible(state.showRating)
|
rateLayout.setVisible(state.showRating)
|
||||||
|
|
||||||
|
compose.setVisible(state.page is Inbox || state.page is Archived)
|
||||||
|
|
||||||
when (state.page) {
|
when (state.page) {
|
||||||
is Inbox -> {
|
is Inbox -> {
|
||||||
if (!inbox.isSelected) toolbarSearch.text = null
|
showBackButton(state.page.showClearButton)
|
||||||
|
title = getString(R.string.main_title_selected, state.page.selected)
|
||||||
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||||
conversationsAdapter.flowable = state.page.data
|
conversationsAdapter.flowable = state.page.data
|
||||||
itemTouchHelper.attachToRecyclerView(recyclerView)
|
itemTouchHelper.attachToRecyclerView(recyclerView)
|
||||||
@@ -205,24 +222,25 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
true -> R.string.inbox_search_empty_text
|
true -> R.string.inbox_search_empty_text
|
||||||
false -> R.string.inbox_empty_text
|
false -> R.string.inbox_empty_text
|
||||||
})
|
})
|
||||||
compose.setVisible(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is Archived -> {
|
is Archived -> {
|
||||||
if (!archived.isSelected) toolbarSearch.setText(R.string.title_archived)
|
showBackButton(state.page.showClearButton)
|
||||||
|
title = when (state.page.selected != 0) {
|
||||||
|
true -> getString(R.string.main_title_selected, state.page.selected)
|
||||||
|
false -> getString(R.string.title_archived)
|
||||||
|
}
|
||||||
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||||
conversationsAdapter.flowable = state.page.data
|
conversationsAdapter.flowable = state.page.data
|
||||||
itemTouchHelper.attachToRecyclerView(null)
|
itemTouchHelper.attachToRecyclerView(null)
|
||||||
empty.setText(R.string.archived_empty_text)
|
empty.setText(R.string.archived_empty_text)
|
||||||
compose.setVisible(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is Scheduled -> {
|
is Scheduled -> {
|
||||||
if (!scheduled.isSelected) toolbarSearch.setText(R.string.title_scheduled)
|
setTitle(R.string.title_scheduled)
|
||||||
recyclerView.adapter = null
|
recyclerView.adapter = null
|
||||||
itemTouchHelper.attachToRecyclerView(null)
|
itemTouchHelper.attachToRecyclerView(null)
|
||||||
empty.setText(R.string.scheduled_empty_text)
|
empty.setText(R.string.scheduled_empty_text)
|
||||||
compose.setVisible(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,24 +250,24 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inbox.isSelected = state.page is Inbox
|
inbox.isSelected = state.page is Inbox
|
||||||
inboxIcon.isSelected = state.page is Inbox
|
|
||||||
archived.isSelected = state.page is Archived
|
archived.isSelected = state.page is Archived
|
||||||
archivedIcon.isSelected = state.page is Archived
|
|
||||||
scheduled.isSelected = state.page is Scheduled
|
scheduled.isSelected = state.page is Scheduled
|
||||||
scheduledIcon.isSelected = state.page is Scheduled
|
|
||||||
|
|
||||||
if (drawerLayout.isDrawerOpen(Gravity.START) && !state.drawerOpen) drawerLayout.closeDrawer(Gravity.START)
|
if (drawerLayout.isDrawerOpen(Gravity.START) && !state.drawerOpen) drawerLayout.closeDrawer(Gravity.START)
|
||||||
else if (!drawerLayout.isDrawerVisible(Gravity.START) && state.drawerOpen) drawerLayout.openDrawer(Gravity.START)
|
else if (!drawerLayout.isDrawerVisible(Gravity.START) && state.drawerOpen) drawerLayout.openDrawer(Gravity.START)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun showBackButton(show: Boolean) {
|
||||||
|
toggle.onDrawerSlide(drawer, if (show) 1f else 0f)
|
||||||
|
}
|
||||||
|
|
||||||
override fun clearSearch() {
|
override fun clearSearch() {
|
||||||
dismissKeyboard()
|
dismissKeyboard()
|
||||||
toolbarSearch.text = null
|
toolbarSearch.text = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showDialog(menuItems: List<common.MenuItem>) {
|
override fun clearSelection() {
|
||||||
dialog.adapter.data = menuItems
|
conversationsAdapter.clearSelection()
|
||||||
dialog.show(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showDeleteDialog() {
|
override fun showDeleteDialog() {
|
||||||
@@ -267,12 +285,12 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
optionsItemIntent.onNext(item.itemId)
|
||||||
R.id.clear -> queryCancelledIntent.onNext(Unit)
|
|
||||||
else -> return super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
backPressedIntent.onNext(Unit)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import io.reactivex.Flowable
|
|||||||
import model.Conversation
|
import model.Conversation
|
||||||
|
|
||||||
data class MainState(
|
data class MainState(
|
||||||
|
val hasError: Boolean = false,
|
||||||
val page: MainPage = Inbox(),
|
val page: MainPage = Inbox(),
|
||||||
val drawerOpen: Boolean = false,
|
val drawerOpen: Boolean = false,
|
||||||
val syncing: Boolean = false,
|
val syncing: Boolean = false,
|
||||||
@@ -33,10 +34,13 @@ sealed class MainPage
|
|||||||
data class Inbox(
|
data class Inbox(
|
||||||
val showClearButton: Boolean = false,
|
val showClearButton: Boolean = false,
|
||||||
val data: Flowable<List<Conversation>>? = null,
|
val data: Flowable<List<Conversation>>? = null,
|
||||||
|
val selected: Int = 0,
|
||||||
val showArchivedSnackbar: Boolean = false) : MainPage()
|
val showArchivedSnackbar: Boolean = false) : MainPage()
|
||||||
|
|
||||||
data class Archived(
|
data class Archived(
|
||||||
val data: Flowable<List<Conversation>>? = null) : MainPage()
|
val showClearButton: Boolean = false,
|
||||||
|
val data: Flowable<List<Conversation>>? = null,
|
||||||
|
val selected: Int = 0) : MainPage()
|
||||||
|
|
||||||
data class Scheduled(
|
data class Scheduled(
|
||||||
val data: Any? = null) : MainPage()
|
val data: Any? = null) : MainPage()
|
||||||
@@ -18,28 +18,27 @@
|
|||||||
*/
|
*/
|
||||||
package feature.main
|
package feature.main
|
||||||
|
|
||||||
import common.MenuItem
|
|
||||||
import common.base.QkView
|
import common.base.QkView
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
|
|
||||||
interface MainView : QkView<MainState> {
|
interface MainView : QkView<MainState> {
|
||||||
|
|
||||||
val queryChangedIntent: Observable<CharSequence>
|
val queryChangedIntent: Observable<CharSequence>
|
||||||
val queryCancelledIntent: Observable<*>
|
|
||||||
val composeIntent: Observable<Unit>
|
val composeIntent: Observable<Unit>
|
||||||
val drawerOpenIntent: Observable<Boolean>
|
val drawerOpenIntent: Observable<Boolean>
|
||||||
|
val homeIntent: Observable<*>
|
||||||
val drawerItemIntent: Observable<DrawerItem>
|
val drawerItemIntent: Observable<DrawerItem>
|
||||||
|
val optionsItemIntent: Observable<Int>
|
||||||
val dismissRatingIntent: Observable<*>
|
val dismissRatingIntent: Observable<*>
|
||||||
val rateIntent: Observable<*>
|
val rateIntent: Observable<*>
|
||||||
val conversationClickIntent: Observable<Long>
|
val conversationsSelectedIntent: Observable<List<Long>>
|
||||||
val conversationLongClickIntent: Observable<Long>
|
|
||||||
val conversationMenuItemIntent: Observable<Int>
|
|
||||||
val confirmDeleteIntent: Observable<Unit>
|
val confirmDeleteIntent: Observable<Unit>
|
||||||
val swipeConversationIntent: Observable<Long>
|
val swipeConversationIntent: Observable<Long>
|
||||||
val undoSwipeConversationIntent: Observable<Unit>
|
val undoSwipeConversationIntent: Observable<Unit>
|
||||||
|
val backPressedIntent: Observable<Unit>
|
||||||
|
|
||||||
fun clearSearch()
|
fun clearSearch()
|
||||||
fun showDialog(menuItems: List<MenuItem>)
|
fun clearSelection()
|
||||||
fun showDeleteDialog()
|
fun showDeleteDialog()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,11 @@ import android.support.v4.content.ContextCompat
|
|||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.uber.autodispose.android.lifecycle.scope
|
import com.uber.autodispose.android.lifecycle.scope
|
||||||
import com.uber.autodispose.kotlin.autoDisposable
|
import com.uber.autodispose.kotlin.autoDisposable
|
||||||
import common.MenuItem
|
|
||||||
import common.Navigator
|
import common.Navigator
|
||||||
import common.base.QkViewModel
|
import common.base.QkViewModel
|
||||||
import common.util.filter.ConversationFilter
|
import common.util.filter.ConversationFilter
|
||||||
import injection.appComponent
|
import injection.appComponent
|
||||||
import interactor.DeleteConversation
|
import interactor.DeleteConversations
|
||||||
import interactor.MarkAllSeen
|
import interactor.MarkAllSeen
|
||||||
import interactor.MarkArchived
|
import interactor.MarkArchived
|
||||||
import interactor.MarkBlocked
|
import interactor.MarkBlocked
|
||||||
@@ -56,7 +55,7 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
@Inject lateinit var conversationFilter: ConversationFilter
|
@Inject lateinit var conversationFilter: ConversationFilter
|
||||||
@Inject lateinit var messageRepo: MessageRepository
|
@Inject lateinit var messageRepo: MessageRepository
|
||||||
@Inject lateinit var markAllSeen: MarkAllSeen
|
@Inject lateinit var markAllSeen: MarkAllSeen
|
||||||
@Inject lateinit var deleteConversation: DeleteConversation
|
@Inject lateinit var deleteConversations: DeleteConversations
|
||||||
@Inject lateinit var markArchived: MarkArchived
|
@Inject lateinit var markArchived: MarkArchived
|
||||||
@Inject lateinit var markUnarchived: MarkUnarchived
|
@Inject lateinit var markUnarchived: MarkUnarchived
|
||||||
@Inject lateinit var markBlocked: MarkBlocked
|
@Inject lateinit var markBlocked: MarkBlocked
|
||||||
@@ -66,11 +65,6 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
@Inject lateinit var prefs: Preferences
|
@Inject lateinit var prefs: Preferences
|
||||||
@Inject lateinit var ratingManager: RatingManager
|
@Inject lateinit var ratingManager: RatingManager
|
||||||
|
|
||||||
private val menuArchive by lazy { MenuItem(context.getString(R.string.inbox_menu_archive), 0) }
|
|
||||||
private val menuUnarchive by lazy { MenuItem(context.getString(R.string.inbox_menu_unarchive), 1) }
|
|
||||||
private val menuBlock by lazy { MenuItem(context.getString(R.string.inbox_menu_block), 2) }
|
|
||||||
private val menuDelete by lazy { MenuItem(context.getString(R.string.inbox_menu_delete), 3) }
|
|
||||||
|
|
||||||
private val conversations by lazy { messageRepo.getConversations() }
|
private val conversations by lazy { messageRepo.getConversations() }
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -79,7 +73,7 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
// Now the conversations can be loaded
|
// Now the conversations can be loaded
|
||||||
conversations
|
conversations
|
||||||
|
|
||||||
disposables += deleteConversation
|
disposables += deleteConversations
|
||||||
disposables += markAllSeen
|
disposables += markAllSeen
|
||||||
disposables += markArchived
|
disposables += markArchived
|
||||||
disposables += markUnarchived
|
disposables += markUnarchived
|
||||||
@@ -138,14 +132,24 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
|
||||||
view.queryCancelledIntent
|
|
||||||
.autoDisposable(view.scope())
|
|
||||||
.subscribe { view.clearSearch() }
|
|
||||||
|
|
||||||
view.composeIntent
|
view.composeIntent
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { navigator.showCompose() }
|
.subscribe { navigator.showCompose() }
|
||||||
|
|
||||||
|
view.homeIntent
|
||||||
|
.withLatestFrom(state, { _, state ->
|
||||||
|
when {
|
||||||
|
state.page is Inbox && state.page.selected > 0 -> view.clearSelection()
|
||||||
|
state.page is Inbox && state.page.showClearButton -> view.clearSearch()
|
||||||
|
|
||||||
|
state.page is Archived && state.page.selected > 0 -> view.clearSelection()
|
||||||
|
|
||||||
|
else -> newState { it.copy(drawerOpen = true) }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
view.drawerOpenIntent
|
view.drawerOpenIntent
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { open -> newState { it.copy(drawerOpen = open) } }
|
.subscribe { open -> newState { it.copy(drawerOpen = open) } }
|
||||||
@@ -158,8 +162,8 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.doOnNext {
|
.doOnNext {
|
||||||
when (it) {
|
when (it) {
|
||||||
DrawerItem.INBOX -> newState { it.copy(page = Inbox()) }
|
DrawerItem.INBOX -> newState { it.copy(page = Inbox(data = conversations)) }
|
||||||
DrawerItem.ARCHIVED -> newState { it.copy(page = Archived(messageRepo.getConversations(true))) }
|
DrawerItem.ARCHIVED -> newState { it.copy(page = Archived(data = messageRepo.getConversations(true))) }
|
||||||
DrawerItem.SCHEDULED -> newState { it.copy(page = Scheduled()) }
|
DrawerItem.SCHEDULED -> newState { it.copy(page = Scheduled()) }
|
||||||
else -> {
|
else -> {
|
||||||
} // Do nothing
|
} // Do nothing
|
||||||
@@ -168,6 +172,30 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
|
||||||
|
view.optionsItemIntent
|
||||||
|
.withLatestFrom(view.conversationsSelectedIntent, { itemId, conversations ->
|
||||||
|
when (itemId) {
|
||||||
|
R.id.archive -> {
|
||||||
|
markArchived.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.unarchive -> {
|
||||||
|
markUnarchived.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.block -> {
|
||||||
|
markBlocked.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.delete -> view.showDeleteDialog()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
|
|
||||||
view.rateIntent
|
view.rateIntent
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe {
|
.subscribe {
|
||||||
@@ -179,29 +207,19 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { ratingManager.dismiss() }
|
.subscribe { ratingManager.dismiss() }
|
||||||
|
|
||||||
view.conversationClickIntent
|
view.conversationsSelectedIntent
|
||||||
.doOnNext { view.clearSearch() }
|
.map { selection -> selection.size }
|
||||||
.doOnNext { threadId -> navigator.showConversation(threadId) }
|
.withLatestFrom(state, { selected, state ->
|
||||||
.autoDisposable(view.scope())
|
when (state.page) {
|
||||||
.subscribe()
|
is Inbox -> {
|
||||||
|
val page = state.page.copy(selected = selected, showClearButton = selected > 0)
|
||||||
|
newState { it.copy(page = page) }
|
||||||
|
}
|
||||||
|
|
||||||
view.conversationLongClickIntent
|
is Archived -> {
|
||||||
.withLatestFrom(state, { _, mainState ->
|
val page = state.page.copy(selected = selected, showClearButton = selected > 0)
|
||||||
when (mainState.page) {
|
newState { it.copy(page = page) }
|
||||||
is Inbox -> view.showDialog(listOf(menuArchive, menuBlock, menuDelete))
|
}
|
||||||
is Archived -> view.showDialog(listOf(menuUnarchive, menuBlock, menuDelete))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.autoDisposable(view.scope())
|
|
||||||
.subscribe()
|
|
||||||
|
|
||||||
view.conversationMenuItemIntent
|
|
||||||
.withLatestFrom(view.conversationLongClickIntent, { actionId, threadId ->
|
|
||||||
when (actionId) {
|
|
||||||
menuArchive.actionId -> markArchived.execute(threadId)
|
|
||||||
menuUnarchive.actionId -> markUnarchived.execute(threadId)
|
|
||||||
menuBlock.actionId -> markBlocked.execute(threadId)
|
|
||||||
menuDelete.actionId -> view.showDeleteDialog()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
@@ -209,13 +227,16 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
|
|
||||||
// Delete the conversation
|
// Delete the conversation
|
||||||
view.confirmDeleteIntent
|
view.confirmDeleteIntent
|
||||||
.withLatestFrom(view.conversationLongClickIntent, { _, threadId -> threadId })
|
.withLatestFrom(view.conversationsSelectedIntent, { _, conversations -> conversations })
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { threadId -> deleteConversation.execute(threadId) }
|
.subscribe { conversations ->
|
||||||
|
deleteConversations.execute(conversations)
|
||||||
|
view.clearSelection()
|
||||||
|
}
|
||||||
|
|
||||||
view.swipeConversationIntent
|
view.swipeConversationIntent
|
||||||
.withLatestFrom(state, { threadId, state ->
|
.withLatestFrom(state, { threadId, state ->
|
||||||
markArchived.execute(threadId) {
|
markArchived.execute(listOf(threadId)) {
|
||||||
if (state.page is Inbox) {
|
if (state.page is Inbox) {
|
||||||
val page = state.page.copy(showArchivedSnackbar = true)
|
val page = state.page.copy(showArchivedSnackbar = true)
|
||||||
newState { it.copy(page = page) }
|
newState { it.copy(page = page) }
|
||||||
@@ -224,7 +245,7 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
})
|
})
|
||||||
.switchMap { Observable.timer(2750, TimeUnit.MILLISECONDS) }
|
.switchMap { Observable.timer(2750, TimeUnit.MILLISECONDS) }
|
||||||
.withLatestFrom(state, { threadId, state ->
|
.withLatestFrom(state, { threadId, state ->
|
||||||
markArchived.execute(threadId) {
|
markArchived.execute(listOf(threadId)) {
|
||||||
if (state.page is Inbox) {
|
if (state.page is Inbox) {
|
||||||
val page = state.page.copy(showArchivedSnackbar = false)
|
val page = state.page.copy(showArchivedSnackbar = false)
|
||||||
newState { it.copy(page = page) }
|
newState { it.copy(page = page) }
|
||||||
@@ -237,7 +258,25 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
view.undoSwipeConversationIntent
|
view.undoSwipeConversationIntent
|
||||||
.withLatestFrom(view.swipeConversationIntent, { _, threadId -> threadId })
|
.withLatestFrom(view.swipeConversationIntent, { _, threadId -> threadId })
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { threadId -> markUnarchived.execute(threadId) }
|
.subscribe { threadId -> markUnarchived.execute(listOf(threadId)) }
|
||||||
|
|
||||||
|
view.backPressedIntent
|
||||||
|
.withLatestFrom(state, { _, state ->
|
||||||
|
when {
|
||||||
|
state.drawerOpen -> newState { it.copy(drawerOpen = false) }
|
||||||
|
|
||||||
|
state.page is Inbox && state.page.selected > 0 -> view.clearSelection()
|
||||||
|
state.page is Inbox && state.page.showClearButton -> view.clearSearch()
|
||||||
|
|
||||||
|
state.page is Archived && state.page.selected > 0 -> view.clearSelection()
|
||||||
|
|
||||||
|
state.page !is Inbox -> newState { it.copy(page = Inbox(data = conversations)) }
|
||||||
|
|
||||||
|
else -> newState { it.copy(hasError = true) }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.autoDisposable(view.scope())
|
||||||
|
.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ class SendMessage @Inject constructor(
|
|||||||
sendMms(params.threadId, params.addresses, params.body, params.attachments)
|
sendMms(params.threadId, params.addresses, params.body, params.attachments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.doOnNext { messageRepo.updateConversation(params.threadId) }
|
.doOnNext { messageRepo.updateConversations(params.threadId) }
|
||||||
.doOnNext { messageRepo.markUnarchived(params.threadId) }
|
.doOnNext { messageRepo.markUnarchived(params.threadId) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:color="@color/ripple_material_light">
|
android:color="@color/rippleLight">
|
||||||
|
|
||||||
<item android:id="@android:id/mask">
|
<item android:id="@android:id/mask">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
@@ -30,10 +30,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<selector>
|
<selector>
|
||||||
<item android:state_selected="true">
|
<item android:state_selected="true">
|
||||||
<shape android:shape="rectangle">
|
<color android:color="@color/separatorLight" />
|
||||||
<solid android:color="@color/white" />
|
|
||||||
<corners android:radius="2dp" />
|
|
||||||
</shape>
|
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||||
|
~
|
||||||
|
~ This file is part of QKSMS.
|
||||||
|
~
|
||||||
|
~ QKSMS is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ QKSMS is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="@color/rippleDark">
|
||||||
|
|
||||||
|
<item android:id="@android:id/mask">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/white" />
|
||||||
|
<corners android:radius="2dp" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<selector>
|
||||||
|
<item android:state_selected="true">
|
||||||
|
<color android:color="@color/separatorDark" />
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<color android:color="@android:color/transparent" />
|
||||||
|
</item>
|
||||||
|
</selector>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</ripple>
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
style="@style/Toolbar"
|
style="@style/Toolbar"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@@ -39,11 +40,16 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:background="@color/white">
|
tools:background="@color/white">
|
||||||
|
|
||||||
|
<common.widget.QkTextView
|
||||||
|
android:id="@+id/toolbarTitle"
|
||||||
|
style="@style/ToolbarText" />
|
||||||
|
|
||||||
<common.widget.QkEditText
|
<common.widget.QkEditText
|
||||||
android:id="@+id/toolbarSearch"
|
android:id="@+id/toolbarSearch"
|
||||||
style="@style/ToolbarText"
|
style="@style/ToolbarText"
|
||||||
|
android:hint="@string/title_conversations"
|
||||||
app:textColorHint="tertiary"
|
app:textColorHint="tertiary"
|
||||||
tools:hint="Search something"
|
app:textSize="primary"
|
||||||
tools:textSize="16sp" />
|
tools:textSize="16sp" />
|
||||||
|
|
||||||
</android.support.v7.widget.Toolbar>
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|||||||
@@ -21,10 +21,31 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/clear"
|
android:id="@+id/archive"
|
||||||
android:icon="@drawable/ic_cancel_black_24dp"
|
android:icon="@drawable/ic_archive_black_24dp"
|
||||||
android:title="@string/menu_clear"
|
android:title="@string/main_menu_archive"
|
||||||
android:visible="false"
|
android:visible="false"
|
||||||
app:showAsAction="always" />
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/unarchive"
|
||||||
|
android:icon="@drawable/ic_archive_black_24dp"
|
||||||
|
android:title="@string/main_menu_unarchive"
|
||||||
|
android:visible="false"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/block"
|
||||||
|
android:icon="@drawable/ic_block_black_24dp"
|
||||||
|
android:title="@string/main_menu_block"
|
||||||
|
android:visible="false"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/delete"
|
||||||
|
android:icon="@drawable/ic_delete_black_24dp"
|
||||||
|
android:title="@string/main_menu_delete"
|
||||||
|
android:visible="false"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
<color name="white">#FFFFFF</color>
|
<color name="white">#FFFFFF</color>
|
||||||
<color name="black">#000000</color>
|
<color name="black">#000000</color>
|
||||||
|
|
||||||
|
<color name="rippleLight">#1f000000</color>
|
||||||
|
<color name="rippleDark">#33ffffff</color>
|
||||||
|
|
||||||
<color name="statusBarLight">#F7F7F7</color>
|
<color name="statusBarLight">#F7F7F7</color>
|
||||||
<color name="statusBarDark">#1a1e22</color>
|
<color name="statusBarDark">#1a1e22</color>
|
||||||
|
|
||||||
|
|||||||
@@ -34,13 +34,22 @@
|
|||||||
<string name="setup_skip">Skip</string>
|
<string name="setup_skip">Skip</string>
|
||||||
<string name="setup_next">Continue</string>
|
<string name="setup_next">Continue</string>
|
||||||
|
|
||||||
<string name="menu_clear">Clear</string>
|
|
||||||
<string name="menu_call">Call</string>
|
<string name="menu_call">Call</string>
|
||||||
<string name="menu_info">Details</string>
|
<string name="menu_info">Details</string>
|
||||||
<string name="menu_save">Save image</string>
|
<string name="menu_save">Save image</string>
|
||||||
|
|
||||||
|
<string name="main_title_selected">%d selected</string>
|
||||||
|
<string name="main_menu_clear">Clear</string>
|
||||||
|
<string name="main_menu_archive">Archive</string>
|
||||||
|
<string name="main_menu_unarchive">Unarchive</string>
|
||||||
|
<string name="main_menu_block">Block</string>
|
||||||
|
<string name="main_menu_delete">Delete</string>
|
||||||
<string name="main_syncing">Optimizing database, this might take a minute…</string>
|
<string name="main_syncing">Optimizing database, this might take a minute…</string>
|
||||||
<string name="main_sender_you">You: %s</string>
|
<string name="main_sender_you">You: %s</string>
|
||||||
|
<string name="inbox_empty_text">Your conversations will appear here</string>
|
||||||
|
<string name="inbox_search_empty_text">No results</string>
|
||||||
|
<string name="archived_empty_text">Your archived conversations will appear here</string>
|
||||||
|
<string name="scheduled_empty_text">Your scheduled messages will appear here</string>
|
||||||
|
|
||||||
<string name="drawer_inbox">Inbox</string>
|
<string name="drawer_inbox">Inbox</string>
|
||||||
<string name="drawer_archived">Archived</string>
|
<string name="drawer_archived">Archived</string>
|
||||||
@@ -55,15 +64,6 @@
|
|||||||
<string name="rate_okay">OKAY!</string>
|
<string name="rate_okay">OKAY!</string>
|
||||||
<string name="rate_dismiss">DISMISS</string>
|
<string name="rate_dismiss">DISMISS</string>
|
||||||
|
|
||||||
<string name="inbox_empty_text">Your conversations will appear here</string>
|
|
||||||
<string name="inbox_search_empty_text">No results</string>
|
|
||||||
<string name="inbox_menu_archive">Archive</string>
|
|
||||||
<string name="inbox_menu_unarchive">Unarchive</string>
|
|
||||||
<string name="inbox_menu_block">Block</string>
|
|
||||||
<string name="inbox_menu_delete">Delete</string>
|
|
||||||
<string name="archived_empty_text">Your archived conversations will appear here</string>
|
|
||||||
<string name="scheduled_empty_text">Your scheduled messages will appear here</string>
|
|
||||||
|
|
||||||
<string name="dialog_delete_title">Delete</string>
|
<string name="dialog_delete_title">Delete</string>
|
||||||
<string name="dialog_delete_message">Are you sure you would like to delete this conversation?</string>
|
<string name="dialog_delete_message">Are you sure you would like to delete this conversation?</string>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user