mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Merge branch 'blocking' into qksms3
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
android:theme="@style/AppThemeBlack" />
|
||||
<activity android:name="presentation.feature.conversationinfo.ConversationInfoActivity" />
|
||||
<activity android:name="presentation.feature.notificationprefs.NotificationPrefsActivity" />
|
||||
<activity android:name="presentation.feature.blocked.BlockedActivity" />
|
||||
|
||||
<receiver android:name="presentation.receiver.DefaultSmsChangedReceiver">
|
||||
<intent-filter>
|
||||
|
||||
@@ -22,6 +22,8 @@ import common.QKApplication
|
||||
import common.util.ContactImageLoader
|
||||
import dagger.Component
|
||||
import presentation.common.widget.*
|
||||
import presentation.feature.blocked.BlockedActivity
|
||||
import presentation.feature.blocked.BlockedViewModel
|
||||
import presentation.feature.compose.ComposeActivity
|
||||
import presentation.feature.compose.ComposeViewModel
|
||||
import presentation.feature.compose.DetailedChipView
|
||||
@@ -31,10 +33,10 @@ import presentation.feature.gallery.GalleryActivity
|
||||
import presentation.feature.gallery.GalleryViewModel
|
||||
import presentation.feature.main.MainActivity
|
||||
import presentation.feature.main.MainViewModel
|
||||
import presentation.feature.plus.PlusActivity
|
||||
import presentation.feature.plus.PlusViewModel
|
||||
import presentation.feature.notificationprefs.NotificationPrefsActivity
|
||||
import presentation.feature.notificationprefs.NotificationPrefsViewModel
|
||||
import presentation.feature.plus.PlusActivity
|
||||
import presentation.feature.plus.PlusViewModel
|
||||
import presentation.feature.settings.SettingsActivity
|
||||
import presentation.feature.settings.SettingsViewModel
|
||||
import presentation.feature.setup.SetupActivity
|
||||
@@ -52,6 +54,7 @@ interface AppComponent {
|
||||
|
||||
fun inject(activity: MainActivity)
|
||||
fun inject(activity: SetupActivity)
|
||||
fun inject(activity: BlockedActivity)
|
||||
fun inject(activity: ComposeActivity)
|
||||
fun inject(activity: ConversationInfoActivity)
|
||||
fun inject(activity: GalleryActivity)
|
||||
@@ -84,6 +87,7 @@ interface AppComponent {
|
||||
|
||||
fun inject(viewModel: MainViewModel)
|
||||
fun inject(viewModel: SetupViewModel)
|
||||
fun inject(viewModel: BlockedViewModel)
|
||||
fun inject(viewModel: ComposeViewModel)
|
||||
fun inject(viewModel: ConversationInfoViewModel)
|
||||
fun inject(viewModel: GalleryViewModel)
|
||||
|
||||
@@ -27,6 +27,7 @@ open class Conversation : RealmObject() {
|
||||
@PrimaryKey var id: Long = 0
|
||||
var recipients: RealmList<Recipient> = RealmList()
|
||||
var archived: Boolean = false
|
||||
var blocked: Boolean = false
|
||||
var draft: String = ""
|
||||
|
||||
fun getTitle(): String {
|
||||
|
||||
@@ -64,6 +64,7 @@ class MessageRepository @Inject constructor(
|
||||
|
||||
val conversationFlowable = realm.where(Conversation::class.java)
|
||||
.equalTo("archived", archived)
|
||||
.equalTo("blocked", false)
|
||||
.findAllAsync()
|
||||
.asFlowable()
|
||||
.filter { it.isLoaded }
|
||||
@@ -87,6 +88,16 @@ class MessageRepository @Inject constructor(
|
||||
})
|
||||
}
|
||||
|
||||
fun getBlockedConversations(): Flowable<List<Conversation>> {
|
||||
return Realm.getDefaultInstance()
|
||||
.where(Conversation::class.java)
|
||||
.equalTo("blocked", true)
|
||||
.findAllAsync()
|
||||
.asFlowable()
|
||||
.filter { it.isLoaded }
|
||||
.map { it.toList() }
|
||||
}
|
||||
|
||||
fun getConversationAsync(threadId: Long): Conversation {
|
||||
return Realm.getDefaultInstance()
|
||||
.where(Conversation::class.java)
|
||||
@@ -212,7 +223,6 @@ class MessageRepository @Inject constructor(
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val conversation = realm.where(Conversation::class.java)
|
||||
.equalTo("id", threadId)
|
||||
.equalTo("archived", false)
|
||||
.findFirst()
|
||||
|
||||
realm.executeTransaction { conversation?.archived = true }
|
||||
@@ -223,13 +233,32 @@ class MessageRepository @Inject constructor(
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val conversation = realm.where(Conversation::class.java)
|
||||
.equalTo("id", threadId)
|
||||
.equalTo("archived", true)
|
||||
.findFirst()
|
||||
|
||||
realm.executeTransaction { conversation?.archived = false }
|
||||
realm.close()
|
||||
}
|
||||
|
||||
fun markBlocked(threadId: Long) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val conversation = realm.where(Conversation::class.java)
|
||||
.equalTo("id", threadId)
|
||||
.findFirst()
|
||||
|
||||
realm.executeTransaction { conversation?.blocked = true }
|
||||
realm.close()
|
||||
}
|
||||
|
||||
fun markUnblocked(threadId: Long) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val conversation = realm.where(Conversation::class.java)
|
||||
.equalTo("id", threadId)
|
||||
.findFirst()
|
||||
|
||||
realm.executeTransaction { conversation?.blocked = false }
|
||||
realm.close()
|
||||
}
|
||||
|
||||
fun markAllSeen() {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val messages = realm.where(Message::class.java).equalTo("seen", false).findAll()
|
||||
|
||||
@@ -24,7 +24,7 @@ import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
open class ContactSync @Inject constructor(private val syncManager: SyncManager) : Interactor<Unit, Long>() {
|
||||
open class ContactSync @Inject constructor(private val syncManager: SyncManager) : Interactor<Unit>() {
|
||||
|
||||
override fun buildObservable(params: Unit): Flowable<Long> {
|
||||
return Flowable.just(System.currentTimeMillis())
|
||||
|
||||
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class DeleteConversation @Inject constructor(private val messageRepo: MessageRepository): Interactor<Long, Unit>() {
|
||||
class DeleteConversation @Inject constructor(private val messageRepo: MessageRepository): Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
|
||||
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class DeleteMessage @Inject constructor(private val messageRepository: MessageRepository): Interactor<Long, Long>() {
|
||||
class DeleteMessage @Inject constructor(private val messageRepository: MessageRepository): Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Long> {
|
||||
return Flowable.just(params)
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.inject.Inject
|
||||
class FullSync @Inject constructor(
|
||||
private val syncManager: SyncManager,
|
||||
private val keys: Keys
|
||||
) : Interactor<Unit, Long>() {
|
||||
) : Interactor<Unit>() {
|
||||
|
||||
override fun buildObservable(params: Unit): Flowable<Long> {
|
||||
return Flowable.just(System.currentTimeMillis())
|
||||
|
||||
@@ -22,19 +22,21 @@ import io.reactivex.Flowable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
abstract class Interactor<in Params, Result>: Disposable {
|
||||
abstract class Interactor<in Params>: Disposable {
|
||||
|
||||
private val disposables: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
abstract fun buildObservable(params: Params): Flowable<Result>
|
||||
abstract fun buildObservable(params: Params): Flowable<*>
|
||||
|
||||
fun execute(params: Params, observer: (Result) -> Unit = {}) {
|
||||
disposables.add(buildObservable(params)
|
||||
fun execute(params: Params, onComplete: () -> Unit = {}) {
|
||||
disposables += buildObservable(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(observer))
|
||||
.doOnComplete(onComplete)
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkAllSeen @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Unit, Unit>() {
|
||||
class MarkAllSeen @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Unit>() {
|
||||
|
||||
override fun buildObservable(params: Unit): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
|
||||
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkArchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
|
||||
class MarkArchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
package interactor
|
||||
|
||||
import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkBlocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
.doOnNext { messageRepo.markBlocked(params) }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkDelivered @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
|
||||
class MarkDelivered @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.inject.Inject
|
||||
|
||||
class MarkDeliveryFailed @Inject constructor(
|
||||
private val messageRepo: MessageRepository)
|
||||
: Interactor<MarkDeliveryFailed.Params, Unit>() {
|
||||
: Interactor<MarkDeliveryFailed.Params>() {
|
||||
|
||||
data class Params(val id: Long, val resultCode: Int)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.inject.Inject
|
||||
class MarkFailed @Inject constructor(
|
||||
private val messageRepo: MessageRepository,
|
||||
private val notificationManager: NotificationManager
|
||||
) : Interactor<MarkFailed.Params, Unit>() {
|
||||
) : Interactor<MarkFailed.Params>() {
|
||||
|
||||
data class Params(val id: Long, val resultCode: Int)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.inject.Inject
|
||||
class MarkRead @Inject constructor(
|
||||
private val messageRepo: MessageRepository,
|
||||
private val notificationManager: NotificationManager
|
||||
) : Interactor<Long, Unit>() {
|
||||
) : Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
|
||||
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkSeen @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
|
||||
class MarkSeen @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
|
||||
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkSent @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
|
||||
class MarkSent @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
|
||||
@@ -22,7 +22,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkUnarchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long, Unit>() {
|
||||
class MarkUnarchived @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
package interactor
|
||||
|
||||
import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkUnblocked @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Long>() {
|
||||
|
||||
override fun buildObservable(params: Long): Flowable<Unit> {
|
||||
return Flowable.just(Unit)
|
||||
.doOnNext { messageRepo.markUnblocked(params) }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import javax.inject.Inject
|
||||
open class PartialSync @Inject constructor(
|
||||
private val syncManager: SyncManager,
|
||||
private val permissions: Permissions
|
||||
) : Interactor<Unit, Long>() {
|
||||
) : Interactor<Unit>() {
|
||||
|
||||
override fun buildObservable(params: Unit): Flowable<Long> {
|
||||
return Flowable.just(System.currentTimeMillis())
|
||||
|
||||
@@ -31,12 +31,13 @@ class ReceiveMms @Inject constructor(
|
||||
private val syncManager: SyncManager,
|
||||
private val messageRepo: MessageRepository,
|
||||
private val notificationManager: NotificationManager
|
||||
) : Interactor<Uri, Conversation>() {
|
||||
) : Interactor<Uri>() {
|
||||
|
||||
override fun buildObservable(params: Uri): Flowable<Conversation> {
|
||||
return Flowable.just(params)
|
||||
.flatMap { uri -> syncManager.syncMessage(uri) } // Sync the message
|
||||
.mapNotNull { message -> messageRepo.getOrCreateConversation(message.threadId) } // Map message to conversation
|
||||
.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 -> notificationManager.update(conversation.id) } // Update the notification
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import javax.inject.Inject
|
||||
class ReceiveSms @Inject constructor(
|
||||
private val messageRepo: MessageRepository,
|
||||
private val notificationManager: NotificationManager)
|
||||
: Interactor<Array<SmsMessage>, Conversation>() {
|
||||
: Interactor<Array<SmsMessage>>() {
|
||||
|
||||
override fun buildObservable(params: Array<SmsMessage>): Flowable<Conversation> {
|
||||
return Flowable.just(params)
|
||||
@@ -44,6 +44,7 @@ class ReceiveSms @Inject constructor(
|
||||
messageRepo.insertReceivedSms(address, body, time) // Add the message to the db
|
||||
}
|
||||
.mapNotNull { message -> messageRepo.getOrCreateConversation(message.threadId) } // Map message to conversation
|
||||
.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 -> notificationManager.update(conversation.id) } // Update the notification
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import data.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class RetrySending @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Message, Message>() {
|
||||
class RetrySending @Inject constructor(private val messageRepo: MessageRepository) : Interactor<Message>() {
|
||||
|
||||
override fun buildObservable(params: Message): Flowable<Message> {
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class SendMessage @Inject constructor(
|
||||
private val context: Context,
|
||||
private val prefs: Preferences,
|
||||
private val messageRepo: MessageRepository
|
||||
) : Interactor<SendMessage.Params, Unit>() {
|
||||
) : Interactor<SendMessage.Params>() {
|
||||
|
||||
data class Params(val threadId: Long, val addresses: List<String>, val body: String, val attachments: List<Uri> = listOf())
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.inject.Inject
|
||||
class SyncMessage @Inject constructor(
|
||||
private val syncManager: SyncManager,
|
||||
private val messageRepo: MessageRepository
|
||||
) : Interactor<Uri, Message>() {
|
||||
) : Interactor<Uri>() {
|
||||
|
||||
override fun buildObservable(params: Uri): Flowable<Message> {
|
||||
return Flowable.just(params)
|
||||
|
||||
@@ -31,6 +31,8 @@ import android.provider.Settings
|
||||
import android.provider.Telephony
|
||||
import android.view.View
|
||||
import common.util.NotificationManager
|
||||
import presentation.feature.blocked.BlockedActivity
|
||||
import presentation.feature.blocked.BlockedViewModel
|
||||
import presentation.feature.compose.ComposeActivity
|
||||
import presentation.feature.compose.ComposeViewModel
|
||||
import presentation.feature.conversationinfo.ConversationInfoActivity
|
||||
@@ -126,6 +128,11 @@ class Navigator @Inject constructor(private val context: Context, private val no
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
fun showBlockedConversations() {
|
||||
val intent = Intent(context, BlockedActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
fun showThemePicker() {
|
||||
val intent = Intent(context, ThemePickerActivity::class.java)
|
||||
startActivity(intent)
|
||||
@@ -180,6 +187,7 @@ class Navigator @Inject constructor(private val context: Context, private val no
|
||||
GalleryViewModel::class.java -> GalleryViewModel(intent)
|
||||
NotificationPrefsViewModel::class.java -> NotificationPrefsViewModel(intent)
|
||||
SettingsViewModel::class.java -> SettingsViewModel()
|
||||
BlockedViewModel::class.java -> BlockedViewModel()
|
||||
ThemePickerViewModel::class.java -> ThemePickerViewModel()
|
||||
else -> throw IllegalArgumentException("Invalid ViewModel class. If this is a new ViewModel, please add it to Navigator.kt")
|
||||
} as T
|
||||
|
||||
@@ -50,8 +50,11 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
}
|
||||
|
||||
init {
|
||||
if (!isInEditMode) {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
||||
View.inflate(context, R.layout.avatar_view, this)
|
||||
appComponent.inject(this)
|
||||
|
||||
setBackgroundResource(R.drawable.circle)
|
||||
clipToOutline = true
|
||||
@@ -59,28 +62,31 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
colors.theme
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> background.setTint(color) }
|
||||
|
||||
colors.textPrimaryOnTheme
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> icon.setTint(color) }
|
||||
if (!isInEditMode) {
|
||||
colors.theme
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> background.setTint(color) }
|
||||
|
||||
clicks()
|
||||
.autoDisposable(scope())
|
||||
.subscribe {
|
||||
if (contact?.lookupKey.isNullOrEmpty()) {
|
||||
contact?.numbers?.firstOrNull()?.let { number ->
|
||||
navigator.addContact(number.address)
|
||||
colors.textPrimaryOnTheme
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> icon.setTint(color) }
|
||||
|
||||
clicks()
|
||||
.autoDisposable(scope())
|
||||
.subscribe {
|
||||
if (contact?.lookupKey.isNullOrEmpty()) {
|
||||
contact?.numbers?.firstOrNull()?.let { number ->
|
||||
navigator.addContact(number.address)
|
||||
}
|
||||
} else {
|
||||
val key = contact?.lookupKey
|
||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, key)
|
||||
ContactsContract.QuickContact.showQuickContact(context, this@AvatarView, uri,
|
||||
ContactsContract.QuickContact.MODE_MEDIUM, null)
|
||||
}
|
||||
} else {
|
||||
val key = contact?.lookupKey
|
||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, key)
|
||||
ContactsContract.QuickContact.showQuickContact(context, this@AvatarView, uri,
|
||||
ContactsContract.QuickContact.MODE_MEDIUM, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinishInflate() {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
package presentation.feature.blocked
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.os.Bundle
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.di.appComponent
|
||||
import common.util.extensions.setVisible
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.blocked_activity.*
|
||||
import presentation.common.base.QkThemedActivity
|
||||
import javax.inject.Inject
|
||||
|
||||
class BlockedActivity : QkThemedActivity<BlockedViewModel>(), BlockedView {
|
||||
|
||||
@Inject lateinit var blockedAdapter: BlockedAdapter
|
||||
|
||||
override val viewModelClass = BlockedViewModel::class
|
||||
override val unblockIntent by lazy { blockedAdapter.unblock }
|
||||
override val confirmUnblockIntent: Subject<Unit> = PublishSubject.create()
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.blocked_activity)
|
||||
setTitle(R.string.blocked_title)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
viewModel.bindView(this)
|
||||
|
||||
colors.background
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> window.decorView.setBackgroundColor(color) }
|
||||
|
||||
conversations.adapter = blockedAdapter
|
||||
}
|
||||
|
||||
override fun render(state: BlockedState) {
|
||||
blockedAdapter.flowable = state.data
|
||||
empty.setVisible(state.empty)
|
||||
}
|
||||
|
||||
override fun showUnblockDialog() {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.blocked_unblock_dialog_title)
|
||||
.setMessage(R.string.blocked_unblock_dialog_message)
|
||||
.setPositiveButton(R.string.button_unblock, { _, _ -> confirmUnblockIntent.onNext(Unit) })
|
||||
.setNegativeButton(R.string.button_cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
package presentation.feature.blocked
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.moez.QKSMS.R
|
||||
import data.model.Contact
|
||||
import data.model.Conversation
|
||||
import data.model.PhoneNumber
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import kotlinx.android.synthetic.main.blocked_list_item.view.*
|
||||
import presentation.common.base.FlowableAdapter
|
||||
import presentation.common.base.QkViewHolder
|
||||
import javax.inject.Inject
|
||||
|
||||
class BlockedAdapter @Inject constructor(private val context: Context) : FlowableAdapter<Conversation>() {
|
||||
|
||||
val unblock: PublishSubject<Long> = PublishSubject.create()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): QkViewHolder {
|
||||
return QkViewHolder(LayoutInflater.from(context).inflate(R.layout.blocked_list_item, parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||
val conversation = getItem(position)
|
||||
val view = holder.itemView
|
||||
|
||||
view.setOnClickListener { unblock.onNext(conversation.id) }
|
||||
|
||||
view.avatars.contacts = conversation.recipients.map { recipient ->
|
||||
recipient.contact ?: Contact().apply { numbers.add(PhoneNumber().apply { address = recipient.address }) }
|
||||
}
|
||||
|
||||
view.title.text = conversation.getTitle()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
package presentation.feature.blocked
|
||||
|
||||
import data.model.Conversation
|
||||
import io.reactivex.Flowable
|
||||
|
||||
data class BlockedState(
|
||||
val data: Flowable<List<Conversation>>? = null,
|
||||
val empty: Boolean = false
|
||||
)
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
package presentation.feature.blocked
|
||||
|
||||
import io.reactivex.Observable
|
||||
import presentation.common.base.QkView
|
||||
|
||||
interface BlockedView : QkView<BlockedState> {
|
||||
|
||||
val unblockIntent: Observable<Long>
|
||||
val confirmUnblockIntent: Observable<Unit>
|
||||
|
||||
fun showUnblockDialog()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
package presentation.feature.blocked
|
||||
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.di.appComponent
|
||||
import data.repository.MessageRepository
|
||||
import interactor.MarkUnblocked
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
import presentation.common.base.QkViewModel
|
||||
import javax.inject.Inject
|
||||
|
||||
class BlockedViewModel : QkViewModel<BlockedView, BlockedState>(BlockedState()) {
|
||||
|
||||
@Inject lateinit var markUnblocked: MarkUnblocked
|
||||
@Inject lateinit var messageRepo: MessageRepository
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
|
||||
val conversations = messageRepo.getBlockedConversations()
|
||||
.doOnNext { conversations -> newState { it.copy(empty = conversations.isEmpty()) } }
|
||||
|
||||
newState { it.copy(data = conversations) }
|
||||
}
|
||||
|
||||
override fun bindView(view: BlockedView) {
|
||||
super.bindView(view)
|
||||
|
||||
// Show confirm unblock conversation dialog
|
||||
view.unblockIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.showUnblockDialog() }
|
||||
|
||||
// Unblock conversation
|
||||
view.confirmUnblockIntent
|
||||
.withLatestFrom(view.unblockIntent, { _, threadId -> threadId })
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { threadId -> markUnblocked.execute(threadId) }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.di.appComponent
|
||||
import common.util.extensions.setVisible
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import kotlinx.android.synthetic.main.conversation_info_activity.*
|
||||
import presentation.common.Navigator
|
||||
@@ -36,6 +37,7 @@ class ConversationInfoActivity : QkThemedActivity<ConversationInfoViewModel>(),
|
||||
override val viewModelClass = ConversationInfoViewModel::class
|
||||
override val notificationsIntent by lazy { notifications.clicks() }
|
||||
override val archiveIntent by lazy { archive.clicks() }
|
||||
override val blockIntent by lazy { block.clicks() }
|
||||
override val deleteIntent by lazy { delete.clicks() }
|
||||
override val confirmDeleteIntent: PublishSubject<Unit> = PublishSubject.create()
|
||||
|
||||
@@ -77,11 +79,19 @@ class ConversationInfoActivity : QkThemedActivity<ConversationInfoViewModel>(),
|
||||
|
||||
recipientAdapter.data = state.recipients
|
||||
|
||||
notifications.setVisible(!state.blocked)
|
||||
|
||||
archive.setVisible(!state.blocked)
|
||||
archive.title = getString(when (state.archived) {
|
||||
true -> R.string.info_unarchive
|
||||
false -> R.string.info_archive
|
||||
})
|
||||
|
||||
block.title = getString(when (state.blocked) {
|
||||
true -> R.string.info_unblock
|
||||
false -> R.string.info_block
|
||||
})
|
||||
|
||||
mediaAdapter.data = state.media
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import data.model.Recipient
|
||||
data class ConversationInfoState(
|
||||
val recipients: List<Recipient> = listOf(),
|
||||
val archived: Boolean = false,
|
||||
val blocked: Boolean = false,
|
||||
val media: List<MmsPart> = ArrayList(),
|
||||
val hasError: Boolean = false
|
||||
)
|
||||
@@ -25,6 +25,7 @@ interface ConversationInfoView : QkView<ConversationInfoState> {
|
||||
|
||||
val notificationsIntent: Observable<Unit>
|
||||
val archiveIntent: Observable<Unit>
|
||||
val blockIntent: Observable<Unit>
|
||||
val deleteIntent: Observable<Unit>
|
||||
val confirmDeleteIntent: Observable<Unit>
|
||||
|
||||
|
||||
+24
-7
@@ -20,17 +20,13 @@ package presentation.feature.conversationinfo
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.di.appComponent
|
||||
import common.util.extensions.asObservable
|
||||
import common.util.extensions.makeToast
|
||||
import data.model.Conversation
|
||||
import data.repository.MessageRepository
|
||||
import interactor.DeleteConversation
|
||||
import interactor.MarkArchived
|
||||
import interactor.MarkUnarchived
|
||||
import interactor.*
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
@@ -45,6 +41,8 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
||||
@Inject lateinit var messageRepo: MessageRepository
|
||||
@Inject lateinit var markArchived: MarkArchived
|
||||
@Inject lateinit var markUnarchived: MarkUnarchived
|
||||
@Inject lateinit var markBlocked: MarkBlocked
|
||||
@Inject lateinit var markUnblocked: MarkUnblocked
|
||||
@Inject lateinit var navigator: Navigator
|
||||
@Inject lateinit var deleteConversation: DeleteConversation
|
||||
|
||||
@@ -67,6 +65,8 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
||||
|
||||
disposables += markArchived
|
||||
disposables += markUnarchived
|
||||
disposables += markBlocked
|
||||
disposables += markUnblocked
|
||||
disposables += deleteConversation
|
||||
|
||||
// Update the recipients whenever they change
|
||||
@@ -81,6 +81,12 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
||||
.distinctUntilChanged()
|
||||
.subscribe { archived -> newState { it.copy(archived = archived) } }
|
||||
|
||||
// Update the view's blocked state whenever it changes
|
||||
disposables += conversation
|
||||
.map { conversation -> conversation.blocked }
|
||||
.distinctUntilChanged()
|
||||
.subscribe { blocked -> newState { it.copy(blocked = blocked) } }
|
||||
|
||||
// Load the attachments from the conversation
|
||||
disposables += messageRepo.getPartsForConversation(threadId)
|
||||
.map { parts -> parts.filter { part -> part.isImage() } }
|
||||
@@ -103,8 +109,19 @@ class ConversationInfoViewModel(intent: Intent) : QkViewModel<ConversationInfoVi
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversation ->
|
||||
when (conversation.archived) {
|
||||
true -> markUnarchived.execute(conversation.id, { context.makeToast(R.string.toast_unarchived) })
|
||||
false -> markArchived.execute(conversation.id, { context.makeToast(R.string.toast_archived) })
|
||||
true -> markUnarchived.execute(conversation.id)
|
||||
false -> markArchived.execute(conversation.id)
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle the blocked state of the conversation
|
||||
view.blockIntent
|
||||
.withLatestFrom(conversation, { _, conversation -> conversation })
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversation ->
|
||||
when (conversation.blocked) {
|
||||
true -> markUnblocked.execute(conversation.id)
|
||||
false -> markBlocked.execute(conversation.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
||||
inbox.clicks().map { DrawerItem.INBOX },
|
||||
archived.clicks().map { DrawerItem.ARCHIVED },
|
||||
scheduled.clicks().map { DrawerItem.SCHEDULED },
|
||||
blocked.clicks().map { DrawerItem.BLOCKED },
|
||||
settings.clicks().map { DrawerItem.SETTINGS },
|
||||
plus.clicks().map { DrawerItem.PLUS },
|
||||
help.clicks().map { DrawerItem.HELP }))
|
||||
@@ -111,7 +110,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
||||
drawer.clicks().subscribe()
|
||||
|
||||
scheduled.isEnabled = false
|
||||
blocked.isEnabled = false
|
||||
|
||||
colors.background
|
||||
.doOnNext { color -> window.decorView.setBackgroundColor(color) }
|
||||
@@ -151,7 +149,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
||||
.doOnNext { tintList -> inboxIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> archivedIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> scheduledIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> blockedIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> settingsIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> plusIcon.imageTintList = tintList }
|
||||
.doOnNext { tintList -> helpIcon.imageTintList = tintList }
|
||||
@@ -163,7 +160,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
||||
.doOnNext { color -> inbox.background = rowBackground(color) }
|
||||
.doOnNext { color -> archived.background = rowBackground(color) }
|
||||
.doOnNext { color -> scheduled.background = rowBackground(color) }
|
||||
.doOnNext { color -> blocked.background = rowBackground(color) }
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
|
||||
@@ -197,22 +193,24 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
||||
when (state.page) {
|
||||
is Inbox -> {
|
||||
if (!inbox.isSelected) toolbarSearch.text = null
|
||||
if (recyclerView.adapter != conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||
if (conversationsAdapter.flowable != state.page.data) conversationsAdapter.flowable = state.page.data
|
||||
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||
conversationsAdapter.flowable = state.page.data
|
||||
itemTouchHelper.attachToRecyclerView(recyclerView)
|
||||
menuItemAdapter.data = state.page.menu
|
||||
empty.setText(R.string.inbox_empty_text)
|
||||
empty.setVisible(state.page.empty && !state.syncing)
|
||||
compose.setVisible(true)
|
||||
}
|
||||
|
||||
is Archived -> {
|
||||
if (!archived.isSelected) toolbarSearch.setText(R.string.title_archived)
|
||||
if (recyclerView.adapter != conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||
if (conversationsAdapter.flowable != state.page.data) conversationsAdapter.flowable = state.page.data
|
||||
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||
conversationsAdapter.flowable = state.page.data
|
||||
itemTouchHelper.attachToRecyclerView(null)
|
||||
menuItemAdapter.data = state.page.menu
|
||||
empty.setText(R.string.archived_empty_text)
|
||||
empty.setVisible(state.page.empty && !state.syncing)
|
||||
compose.setVisible(true)
|
||||
}
|
||||
|
||||
is Scheduled -> {
|
||||
@@ -222,15 +220,7 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
||||
menuItemAdapter.data = ArrayList()
|
||||
empty.setText(R.string.scheduled_empty_text)
|
||||
empty.setVisible(state.page.empty && !state.syncing)
|
||||
}
|
||||
|
||||
is Blocked -> {
|
||||
if (!blocked.isSelected) toolbarSearch.setText(R.string.title_blocked)
|
||||
recyclerView.adapter = null
|
||||
itemTouchHelper.attachToRecyclerView(null)
|
||||
menuItemAdapter.data = ArrayList()
|
||||
empty.setText(R.string.blocked_empty_text)
|
||||
empty.setVisible(state.page.empty && !state.syncing)
|
||||
compose.setVisible(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,8 +235,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
||||
archivedIcon.isSelected = state.page is Archived
|
||||
scheduled.isSelected = state.page is Scheduled
|
||||
scheduledIcon.isSelected = state.page is Scheduled
|
||||
blocked.isSelected = state.page is Blocked
|
||||
blockedIcon.isSelected = state.page is Blocked
|
||||
|
||||
if (drawerLayout.isDrawerOpen(Gravity.START) && !state.drawerOpen) drawerLayout.closeDrawer(Gravity.START)
|
||||
else if (!drawerLayout.isDrawerVisible(Gravity.START) && state.drawerOpen) drawerLayout.openDrawer(Gravity.START)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package presentation.feature.main
|
||||
|
||||
import data.model.Conversation
|
||||
import data.model.InboxItem
|
||||
import data.model.MenuItem
|
||||
import io.reactivex.Flowable
|
||||
@@ -43,9 +44,5 @@ data class Archived(
|
||||
val menu: List<MenuItem> = ArrayList()) : MainPage()
|
||||
|
||||
data class Scheduled(
|
||||
val data: Any? = null,
|
||||
val empty: Boolean = false) : MainPage()
|
||||
|
||||
data class Blocked(
|
||||
val data: Any? = null,
|
||||
val empty: Boolean = false) : MainPage()
|
||||
@@ -19,7 +19,6 @@
|
||||
package presentation.feature.main
|
||||
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.Subject
|
||||
import presentation.common.base.QkView
|
||||
|
||||
interface MainView : QkView<MainState> {
|
||||
@@ -31,10 +30,10 @@ interface MainView : QkView<MainState> {
|
||||
val drawerItemIntent: Observable<DrawerItem>
|
||||
val conversationClickIntent: Observable<Long>
|
||||
val conversationLongClickIntent: Observable<Long>
|
||||
val conversationMenuItemIntent: Subject<Int>
|
||||
val confirmDeleteIntent: Subject<Unit>
|
||||
val conversationMenuItemIntent: Observable<Int>
|
||||
val confirmDeleteIntent: Observable<Unit>
|
||||
val swipeConversationIntent: Observable<Int>
|
||||
val undoSwipeConversationIntent: Subject<Unit>
|
||||
val undoSwipeConversationIntent: Observable<Unit>
|
||||
|
||||
fun clearSearch()
|
||||
fun showDeleteDialog()
|
||||
|
||||
@@ -158,7 +158,6 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
||||
DrawerItem.INBOX -> newState { it.copy(page = Inbox(data = conversations)) }
|
||||
DrawerItem.ARCHIVED -> newState { it.copy(page = Archived(archivedConversations)) }
|
||||
DrawerItem.SCHEDULED -> newState { it.copy(page = Scheduled()) }
|
||||
DrawerItem.BLOCKED -> newState { it.copy(page = Blocked()) }
|
||||
else -> {
|
||||
} // Do nothing
|
||||
}
|
||||
|
||||
@@ -122,6 +122,8 @@ class SettingsViewModel : QkViewModel<SettingsView, SettingsState>(SettingsState
|
||||
|
||||
R.id.notifications -> navigator.showNotificationSettings()
|
||||
|
||||
R.id.blocked -> navigator.showBlockedConversations()
|
||||
|
||||
R.id.delivery -> prefs.delivery.set(!prefs.delivery.get())
|
||||
|
||||
R.id.unicode -> prefs.unicode.set(!prefs.unicode.get())
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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/>.
|
||||
-->
|
||||
<android.support.constraint.ConstraintLayout 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"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<presentation.common.widget.QkTextView
|
||||
android:id="@+id/empty"
|
||||
style="@style/TextSecondary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:gravity="center"
|
||||
android:padding="56dp"
|
||||
android:text="@string/blocked_empty"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/conversations"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
tools:listitem="@layout/blocked_list_item" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ab_shadow"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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/>.
|
||||
-->
|
||||
<android.support.constraint.ConstraintLayout 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"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<presentation.common.widget.GroupAvatarView
|
||||
android:id="@+id/avatars"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintEnd_toStartOf="@id/title"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<presentation.common.widget.QkTextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextPrimary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@id/avatars"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -17,89 +17,102 @@
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.constraint.ConstraintLayout 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"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/toolbar" />
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar">
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recipients"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
|
||||
tools:layout_height="72dp"
|
||||
tools:listitem="@layout/conversation_recipient_list_item" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recipients"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp"
|
||||
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
|
||||
tools:layout_height="72dp"
|
||||
tools:listitem="@layout/conversation_recipient_list_item" />
|
||||
<presentation.common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="8dp" />
|
||||
|
||||
<presentation.common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="8dp" />
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/notifications"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_notifications_black_24dp"
|
||||
app:title="@string/info_notifications" />
|
||||
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/notifications"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_notifications_black_24dp"
|
||||
app:title="@string/info_notifications" />
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/archive"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_folder_black_24dp"
|
||||
app:title="@string/info_archive" />
|
||||
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/archive"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_folder_black_24dp"
|
||||
app:title="@string/info_archive" />
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/block"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_block_black_24dp"
|
||||
app:title="@string/info_block" />
|
||||
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/delete"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_delete_black_24dp"
|
||||
app:title="@string/info_delete" />
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/delete"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:icon="@drawable/ic_delete_black_24dp"
|
||||
app:title="@string/info_delete" />
|
||||
|
||||
<presentation.common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginTop="8dp" />
|
||||
<presentation.common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginTop="8dp" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/media"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:nestedScrollingEnabled="false"
|
||||
app:layoutManager="android.support.v7.widget.GridLayoutManager"
|
||||
app:spanCount="3"
|
||||
tools:listitem="@layout/conversation_media_list_item" />
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/media"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:nestedScrollingEnabled="false"
|
||||
app:layoutManager="android.support.v7.widget.GridLayoutManager"
|
||||
app:spanCount="3"
|
||||
tools:listitem="@layout/conversation_media_list_item" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ab_shadow" />
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/ab_shadow"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
@@ -71,22 +71,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/blocked"
|
||||
style="@style/DrawerRow"
|
||||
android:alpha="0.5">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/blockedIcon"
|
||||
style="@style/DrawerIcon"
|
||||
android:src="@drawable/ic_block_black_24dp" />
|
||||
|
||||
<presentation.common.widget.QkTextView
|
||||
style="@style/DrawerText"
|
||||
android:text="@string/drawer_blocked" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<presentation.common.widget.Separator
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
|
||||
@@ -95,6 +95,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/settings_notifications_title" />
|
||||
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/blocked"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:title="@string/settings_blocking_title" />
|
||||
|
||||
<presentation.common.widget.PreferenceView
|
||||
android:id="@+id/delivery"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
<string name="title_archived">Archived</string>
|
||||
<string name="title_scheduled">Scheduled</string>
|
||||
<string name="title_blocked">Blocked</string>
|
||||
<string name="title_settings">Settings</string>
|
||||
<string name="title_notification_prefs">Notifications</string>
|
||||
<string name="title_theme">Theme</string>
|
||||
@@ -62,7 +61,6 @@
|
||||
<string name="inbox_empty_text">Your conversations will appear here</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="blocked_empty_text">Your blocked senders will appear here</string>
|
||||
|
||||
<string name="dialog_delete_title">Delete</string>
|
||||
<string name="dialog_delete_message">Are you sure you would like to delete this conversation?</string>
|
||||
@@ -71,6 +69,8 @@
|
||||
<string name="info_notifications">Notifications</string>
|
||||
<string name="info_archive">Archive</string>
|
||||
<string name="info_unarchive">Unarchive</string>
|
||||
<string name="info_block">Block</string>
|
||||
<string name="info_unblock">Unblock</string>
|
||||
<string name="info_delete">Delete conversation</string>
|
||||
|
||||
<string name="settings_default_sms_title">Default SMS app</string>
|
||||
@@ -82,9 +82,10 @@
|
||||
<string name="settings_night_end_title">End time</string>
|
||||
<string name="settings_auto_emoji_title">Automatic emoji</string>
|
||||
<string name="settings_auto_emoji_summary">Convert text like :) to an emoji like 🙂</string>
|
||||
<string name="settings_notifications_title">Message notifications</string>
|
||||
<string name="settings_notifications_title">Notifications</string>
|
||||
<string name="settings_vibration_title">Vibration</string>
|
||||
<string name="settings_ringtone_title">Sound</string>
|
||||
<string name="settings_blocking_title">Blocked</string>
|
||||
<string name="settings_delivery_title">Delivery confirmations</string>
|
||||
<string name="settings_delivery_summary">Confirm that messages were sent successfully</string>
|
||||
<string name="settings_unicode_title">Strip accents</string>
|
||||
@@ -94,6 +95,11 @@
|
||||
<string name="settings_sync_title">Sync messages</string>
|
||||
<string name="settings_sync_summary">Re-sync your messages with the native Android SMS database</string>
|
||||
|
||||
<string name="blocked_title">Blocked</string>
|
||||
<string name="blocked_empty">Your blocked conversations will appear here</string>
|
||||
<string name="blocked_unblock_dialog_title">Unblock</string>
|
||||
<string name="blocked_unblock_dialog_message">Would you like to unblock this conversation?</string>
|
||||
|
||||
<string name="qksms_plus_description_title">Support development, unlock everything</string>
|
||||
<string name="qksms_plus_description_summary">You can save a starving developer for just %s</string>
|
||||
<string name="qksms_plus_upgrade">Unlock for %1$s %2$s</string>
|
||||
@@ -133,12 +139,12 @@
|
||||
<string name="button_yes">Yes</string>
|
||||
<string name="button_cancel">Cancel</string>
|
||||
<string name="button_delete">Delete</string>
|
||||
<string name="button_unblock">Unblock</string>
|
||||
<string name="button_undo">Undo</string>
|
||||
<string name="button_more">More</string>
|
||||
|
||||
<string name="toast_copied">Copied</string>
|
||||
<string name="toast_archived">Archived conversation</string>
|
||||
<string name="toast_unarchived">Moved to inbox</string>
|
||||
<string name="toast_qksms_plus">You must unlock QKSMS+ to use this</string>
|
||||
|
||||
<string name="notification_message_failed_title">Message not sent</string>
|
||||
|
||||
Reference in New Issue
Block a user