forked from upstream-mirrors/quik
Move blocked conversations to separate activity
This commit is contained in:
@@ -67,6 +67,7 @@
|
|||||||
android:theme="@style/AppThemeBlack" />
|
android:theme="@style/AppThemeBlack" />
|
||||||
<activity android:name="presentation.feature.conversationinfo.ConversationInfoActivity" />
|
<activity android:name="presentation.feature.conversationinfo.ConversationInfoActivity" />
|
||||||
<activity android:name="presentation.feature.notificationprefs.NotificationPrefsActivity" />
|
<activity android:name="presentation.feature.notificationprefs.NotificationPrefsActivity" />
|
||||||
|
<activity android:name="presentation.feature.blocked.BlockedActivity" />
|
||||||
|
|
||||||
<receiver android:name="presentation.receiver.DefaultSmsChangedReceiver">
|
<receiver android:name="presentation.receiver.DefaultSmsChangedReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import common.QKApplication
|
|||||||
import common.util.ContactImageLoader
|
import common.util.ContactImageLoader
|
||||||
import dagger.Component
|
import dagger.Component
|
||||||
import presentation.common.widget.*
|
import presentation.common.widget.*
|
||||||
|
import presentation.feature.blocked.BlockedActivity
|
||||||
|
import presentation.feature.blocked.BlockedViewModel
|
||||||
import presentation.feature.compose.ComposeActivity
|
import presentation.feature.compose.ComposeActivity
|
||||||
import presentation.feature.compose.ComposeViewModel
|
import presentation.feature.compose.ComposeViewModel
|
||||||
import presentation.feature.compose.DetailedChipView
|
import presentation.feature.compose.DetailedChipView
|
||||||
@@ -31,10 +33,10 @@ import presentation.feature.gallery.GalleryActivity
|
|||||||
import presentation.feature.gallery.GalleryViewModel
|
import presentation.feature.gallery.GalleryViewModel
|
||||||
import presentation.feature.main.MainActivity
|
import presentation.feature.main.MainActivity
|
||||||
import presentation.feature.main.MainViewModel
|
import presentation.feature.main.MainViewModel
|
||||||
import presentation.feature.plus.PlusActivity
|
|
||||||
import presentation.feature.plus.PlusViewModel
|
|
||||||
import presentation.feature.notificationprefs.NotificationPrefsActivity
|
import presentation.feature.notificationprefs.NotificationPrefsActivity
|
||||||
import presentation.feature.notificationprefs.NotificationPrefsViewModel
|
import presentation.feature.notificationprefs.NotificationPrefsViewModel
|
||||||
|
import presentation.feature.plus.PlusActivity
|
||||||
|
import presentation.feature.plus.PlusViewModel
|
||||||
import presentation.feature.settings.SettingsActivity
|
import presentation.feature.settings.SettingsActivity
|
||||||
import presentation.feature.settings.SettingsViewModel
|
import presentation.feature.settings.SettingsViewModel
|
||||||
import presentation.feature.setup.SetupActivity
|
import presentation.feature.setup.SetupActivity
|
||||||
@@ -52,6 +54,7 @@ interface AppComponent {
|
|||||||
|
|
||||||
fun inject(activity: MainActivity)
|
fun inject(activity: MainActivity)
|
||||||
fun inject(activity: SetupActivity)
|
fun inject(activity: SetupActivity)
|
||||||
|
fun inject(activity: BlockedActivity)
|
||||||
fun inject(activity: ComposeActivity)
|
fun inject(activity: ComposeActivity)
|
||||||
fun inject(activity: ConversationInfoActivity)
|
fun inject(activity: ConversationInfoActivity)
|
||||||
fun inject(activity: GalleryActivity)
|
fun inject(activity: GalleryActivity)
|
||||||
@@ -84,6 +87,7 @@ interface AppComponent {
|
|||||||
|
|
||||||
fun inject(viewModel: MainViewModel)
|
fun inject(viewModel: MainViewModel)
|
||||||
fun inject(viewModel: SetupViewModel)
|
fun inject(viewModel: SetupViewModel)
|
||||||
|
fun inject(viewModel: BlockedViewModel)
|
||||||
fun inject(viewModel: ComposeViewModel)
|
fun inject(viewModel: ComposeViewModel)
|
||||||
fun inject(viewModel: ConversationInfoViewModel)
|
fun inject(viewModel: ConversationInfoViewModel)
|
||||||
fun inject(viewModel: GalleryViewModel)
|
fun inject(viewModel: GalleryViewModel)
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import android.provider.ContactsContract
|
|||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import common.util.NotificationManager
|
import common.util.NotificationManager
|
||||||
|
import presentation.feature.blocked.BlockedActivity
|
||||||
|
import presentation.feature.blocked.BlockedViewModel
|
||||||
import presentation.feature.compose.ComposeActivity
|
import presentation.feature.compose.ComposeActivity
|
||||||
import presentation.feature.compose.ComposeViewModel
|
import presentation.feature.compose.ComposeViewModel
|
||||||
import presentation.feature.conversationinfo.ConversationInfoActivity
|
import presentation.feature.conversationinfo.ConversationInfoActivity
|
||||||
@@ -111,6 +113,11 @@ class Navigator @Inject constructor(private val context: Context, private val no
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showBlockedConversations() {
|
||||||
|
val intent = Intent(context, BlockedActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
|
||||||
fun showThemePicker() {
|
fun showThemePicker() {
|
||||||
val intent = Intent(context, ThemePickerActivity::class.java)
|
val intent = Intent(context, ThemePickerActivity::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
@@ -165,6 +172,7 @@ class Navigator @Inject constructor(private val context: Context, private val no
|
|||||||
GalleryViewModel::class.java -> GalleryViewModel(intent)
|
GalleryViewModel::class.java -> GalleryViewModel(intent)
|
||||||
NotificationPrefsViewModel::class.java -> NotificationPrefsViewModel(intent)
|
NotificationPrefsViewModel::class.java -> NotificationPrefsViewModel(intent)
|
||||||
SettingsViewModel::class.java -> SettingsViewModel()
|
SettingsViewModel::class.java -> SettingsViewModel()
|
||||||
|
BlockedViewModel::class.java -> BlockedViewModel()
|
||||||
ThemePickerViewModel::class.java -> ThemePickerViewModel()
|
ThemePickerViewModel::class.java -> ThemePickerViewModel()
|
||||||
else -> throw IllegalArgumentException("Invalid ViewModel class. If this is a new ViewModel, please add it to Navigator.kt")
|
else -> throw IllegalArgumentException("Invalid ViewModel class. If this is a new ViewModel, please add it to Navigator.kt")
|
||||||
} as T
|
} as T
|
||||||
|
|||||||
@@ -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()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
class BlockedAdapter @Inject constructor(private val context: Context) : FlowableAdapter<Conversation>() {
|
class BlockedAdapter @Inject constructor(private val context: Context) : FlowableAdapter<Conversation>() {
|
||||||
|
|
||||||
val unblock = PublishSubject.create<Long>()
|
val unblock: PublishSubject<Long> = PublishSubject.create()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): QkViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(LayoutInflater.from(context).inflate(R.layout.blocked_list_item, parent, false))
|
return QkViewHolder(LayoutInflater.from(context).inflate(R.layout.blocked_list_item, parent, false))
|
||||||
|
|||||||
@@ -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) }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -51,7 +51,6 @@ import kotlinx.android.synthetic.main.toolbar_search.*
|
|||||||
import presentation.common.MenuItemAdapter
|
import presentation.common.MenuItemAdapter
|
||||||
import presentation.common.Navigator
|
import presentation.common.Navigator
|
||||||
import presentation.common.base.QkThemedActivity
|
import presentation.common.base.QkThemedActivity
|
||||||
import presentation.feature.blocked.BlockedAdapter
|
|
||||||
import presentation.feature.conversations.ConversationItemTouchCallback
|
import presentation.feature.conversations.ConversationItemTouchCallback
|
||||||
import presentation.feature.conversations.ConversationsAdapter
|
import presentation.feature.conversations.ConversationsAdapter
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -59,7 +58,6 @@ import javax.inject.Inject
|
|||||||
class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
||||||
|
|
||||||
@Inject lateinit var navigator: Navigator
|
@Inject lateinit var navigator: Navigator
|
||||||
@Inject lateinit var blockedAdapter: BlockedAdapter
|
|
||||||
@Inject lateinit var conversationsAdapter: ConversationsAdapter
|
@Inject lateinit var conversationsAdapter: ConversationsAdapter
|
||||||
@Inject lateinit var itemTouchCallback: ConversationItemTouchCallback
|
@Inject lateinit var itemTouchCallback: ConversationItemTouchCallback
|
||||||
@Inject lateinit var menuItemAdapter: MenuItemAdapter
|
@Inject lateinit var menuItemAdapter: MenuItemAdapter
|
||||||
@@ -74,7 +72,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
inbox.clicks().map { DrawerItem.INBOX },
|
inbox.clicks().map { DrawerItem.INBOX },
|
||||||
archived.clicks().map { DrawerItem.ARCHIVED },
|
archived.clicks().map { DrawerItem.ARCHIVED },
|
||||||
scheduled.clicks().map { DrawerItem.SCHEDULED },
|
scheduled.clicks().map { DrawerItem.SCHEDULED },
|
||||||
blocked.clicks().map { DrawerItem.BLOCKED },
|
|
||||||
settings.clicks().map { DrawerItem.SETTINGS },
|
settings.clicks().map { DrawerItem.SETTINGS },
|
||||||
plus.clicks().map { DrawerItem.PLUS },
|
plus.clicks().map { DrawerItem.PLUS },
|
||||||
help.clicks().map { DrawerItem.HELP }))
|
help.clicks().map { DrawerItem.HELP }))
|
||||||
@@ -83,8 +80,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
override val conversationLongClickIntent by lazy { conversationsAdapter.longClicks }
|
override val conversationLongClickIntent by lazy { conversationsAdapter.longClicks }
|
||||||
override val conversationMenuItemIntent by lazy { menuItemAdapter.menuItemClicks }
|
override val conversationMenuItemIntent by lazy { menuItemAdapter.menuItemClicks }
|
||||||
override val confirmDeleteIntent: Subject<Unit> = PublishSubject.create()
|
override val confirmDeleteIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val unblockIntent by lazy { blockedAdapter.unblock }
|
|
||||||
override val confirmUnblockIntent: 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()
|
||||||
|
|
||||||
@@ -154,7 +149,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
.doOnNext { tintList -> inboxIcon.imageTintList = tintList }
|
.doOnNext { tintList -> inboxIcon.imageTintList = tintList }
|
||||||
.doOnNext { tintList -> archivedIcon.imageTintList = tintList }
|
.doOnNext { tintList -> archivedIcon.imageTintList = tintList }
|
||||||
.doOnNext { tintList -> scheduledIcon.imageTintList = tintList }
|
.doOnNext { tintList -> scheduledIcon.imageTintList = tintList }
|
||||||
.doOnNext { tintList -> blockedIcon.imageTintList = tintList }
|
|
||||||
.doOnNext { tintList -> settingsIcon.imageTintList = tintList }
|
.doOnNext { tintList -> settingsIcon.imageTintList = tintList }
|
||||||
.doOnNext { tintList -> plusIcon.imageTintList = tintList }
|
.doOnNext { tintList -> plusIcon.imageTintList = tintList }
|
||||||
.doOnNext { tintList -> helpIcon.imageTintList = tintList }
|
.doOnNext { tintList -> helpIcon.imageTintList = tintList }
|
||||||
@@ -166,7 +160,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
.doOnNext { color -> inbox.background = rowBackground(color) }
|
.doOnNext { color -> inbox.background = rowBackground(color) }
|
||||||
.doOnNext { color -> archived.background = rowBackground(color) }
|
.doOnNext { color -> archived.background = rowBackground(color) }
|
||||||
.doOnNext { color -> scheduled.background = rowBackground(color) }
|
.doOnNext { color -> scheduled.background = rowBackground(color) }
|
||||||
.doOnNext { color -> blocked.background = rowBackground(color) }
|
|
||||||
.autoDisposable(scope())
|
.autoDisposable(scope())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
|
|
||||||
@@ -229,17 +222,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
empty.setVisible(state.page.empty && !state.syncing)
|
empty.setVisible(state.page.empty && !state.syncing)
|
||||||
compose.setVisible(false)
|
compose.setVisible(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
is Blocked -> {
|
|
||||||
if (!blocked.isSelected) toolbarSearch.setText(R.string.title_blocked)
|
|
||||||
if (recyclerView.adapter != blockedAdapter) recyclerView.adapter = blockedAdapter
|
|
||||||
blockedAdapter.flowable = state.page.data
|
|
||||||
itemTouchHelper.attachToRecyclerView(null)
|
|
||||||
menuItemAdapter.data = ArrayList()
|
|
||||||
empty.setText(R.string.blocked_empty_text)
|
|
||||||
empty.setVisible(state.page.empty && !state.syncing)
|
|
||||||
compose.setVisible(false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
when (state.page is Inbox && state.page.showArchivedSnackbar) {
|
when (state.page is Inbox && state.page.showArchivedSnackbar) {
|
||||||
@@ -253,8 +235,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
archivedIcon.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
|
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)
|
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)
|
||||||
@@ -287,15 +267,6 @@ class MainActivity : QkThemedActivity<MainViewModel>(), MainView {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showUnblockDialog() {
|
|
||||||
AlertDialog.Builder(this)
|
|
||||||
.setTitle(R.string.dialog_unblock_title)
|
|
||||||
.setMessage(R.string.dialog_unblock_message)
|
|
||||||
.setPositiveButton(R.string.button_unblock, { _, _ -> confirmUnblockIntent.onNext(Unit) })
|
|
||||||
.setNegativeButton(R.string.button_cancel, null)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
menuInflater.inflate(R.menu.main, menu)
|
menuInflater.inflate(R.menu.main, menu)
|
||||||
return super.onCreateOptionsMenu(menu)
|
return super.onCreateOptionsMenu(menu)
|
||||||
|
|||||||
@@ -45,8 +45,4 @@ data class Archived(
|
|||||||
|
|
||||||
data class Scheduled(
|
data class Scheduled(
|
||||||
val data: Any? = null,
|
val data: Any? = null,
|
||||||
val empty: Boolean = false) : MainPage()
|
|
||||||
|
|
||||||
data class Blocked(
|
|
||||||
val data: Flowable<List<Conversation>>? = null,
|
|
||||||
val empty: Boolean = false) : MainPage()
|
val empty: Boolean = false) : MainPage()
|
||||||
@@ -32,14 +32,11 @@ interface MainView : QkView<MainState> {
|
|||||||
val conversationLongClickIntent: Observable<Long>
|
val conversationLongClickIntent: Observable<Long>
|
||||||
val conversationMenuItemIntent: Observable<Int>
|
val conversationMenuItemIntent: Observable<Int>
|
||||||
val confirmDeleteIntent: Observable<Unit>
|
val confirmDeleteIntent: Observable<Unit>
|
||||||
val unblockIntent: Observable<Long>
|
|
||||||
val confirmUnblockIntent: Observable<Unit>
|
|
||||||
val swipeConversationIntent: Observable<Int>
|
val swipeConversationIntent: Observable<Int>
|
||||||
val undoSwipeConversationIntent: Observable<Unit>
|
val undoSwipeConversationIntent: Observable<Unit>
|
||||||
|
|
||||||
fun clearSearch()
|
fun clearSearch()
|
||||||
fun showDeleteDialog()
|
fun showDeleteDialog()
|
||||||
fun showUnblockDialog()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
@Inject lateinit var deleteConversation: DeleteConversation
|
@Inject lateinit var deleteConversation: DeleteConversation
|
||||||
@Inject lateinit var markArchived: MarkArchived
|
@Inject lateinit var markArchived: MarkArchived
|
||||||
@Inject lateinit var markUnarchived: MarkUnarchived
|
@Inject lateinit var markUnarchived: MarkUnarchived
|
||||||
@Inject lateinit var markUnblocked: MarkUnblocked
|
|
||||||
@Inject lateinit var partialSync: PartialSync
|
@Inject lateinit var partialSync: PartialSync
|
||||||
|
|
||||||
private val conversations by lazy {
|
private val conversations by lazy {
|
||||||
@@ -75,16 +74,6 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private val blockedConversations by lazy {
|
|
||||||
messageRepo.getBlockedConversations()
|
|
||||||
.withLatestFrom(state.toFlowable(), { conversations, state ->
|
|
||||||
(state.page as? Blocked)?.let { page ->
|
|
||||||
newState { it.copy(page = page.copy(empty = conversations.isEmpty())) }
|
|
||||||
}
|
|
||||||
conversations
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private val menuArchive by lazy { MenuItem(context.getString(R.string.menu_archive), 0) }
|
private val menuArchive by lazy { MenuItem(context.getString(R.string.menu_archive), 0) }
|
||||||
private val menuUnarchive by lazy { MenuItem(context.getString(R.string.menu_unarchive), 1) }
|
private val menuUnarchive by lazy { MenuItem(context.getString(R.string.menu_unarchive), 1) }
|
||||||
private val menuDelete by lazy { MenuItem(context.getString(R.string.menu_delete), 2) }
|
private val menuDelete by lazy { MenuItem(context.getString(R.string.menu_delete), 2) }
|
||||||
@@ -169,7 +158,6 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
DrawerItem.INBOX -> newState { it.copy(page = Inbox(data = conversations)) }
|
DrawerItem.INBOX -> newState { it.copy(page = Inbox(data = conversations)) }
|
||||||
DrawerItem.ARCHIVED -> newState { it.copy(page = Archived(archivedConversations)) }
|
DrawerItem.ARCHIVED -> newState { it.copy(page = Archived(archivedConversations)) }
|
||||||
DrawerItem.SCHEDULED -> newState { it.copy(page = Scheduled()) }
|
DrawerItem.SCHEDULED -> newState { it.copy(page = Scheduled()) }
|
||||||
DrawerItem.BLOCKED -> newState { it.copy(page = Blocked(blockedConversations)) }
|
|
||||||
else -> {
|
else -> {
|
||||||
} // Do nothing
|
} // Do nothing
|
||||||
}
|
}
|
||||||
@@ -259,17 +247,6 @@ class MainViewModel : QkViewModel<MainView, MainState>(MainState()) {
|
|||||||
.withLatestFrom(swipedConversation, { _, threadId -> threadId })
|
.withLatestFrom(swipedConversation, { _, threadId -> threadId })
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { threadId -> markUnarchived.execute(threadId) }
|
.subscribe { threadId -> markUnarchived.execute(threadId) }
|
||||||
|
|
||||||
// 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)}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -122,6 +122,8 @@ class SettingsViewModel : QkViewModel<SettingsView, SettingsState>(SettingsState
|
|||||||
|
|
||||||
R.id.notifications -> navigator.showNotificationSettings()
|
R.id.notifications -> navigator.showNotificationSettings()
|
||||||
|
|
||||||
|
R.id.blocked -> navigator.showBlockedConversations()
|
||||||
|
|
||||||
R.id.delivery -> prefs.delivery.set(!prefs.delivery.get())
|
R.id.delivery -> prefs.delivery.set(!prefs.delivery.get())
|
||||||
|
|
||||||
R.id.unicode -> prefs.unicode.set(!prefs.unicode.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>
|
||||||
@@ -47,6 +47,6 @@
|
|||||||
app:layout_constraintHorizontal_bias="0"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
app:layout_constraintStart_toEndOf="@id/avatars"
|
app:layout_constraintStart_toEndOf="@id/avatars"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="Moez Bhatti" />
|
tools:text="@tools:sample/full_names" />
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
@@ -55,21 +55,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/blocked"
|
|
||||||
style="@style/DrawerRow">
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/scheduled"
|
android:id="@+id/scheduled"
|
||||||
style="@style/DrawerRow"
|
style="@style/DrawerRow"
|
||||||
|
|||||||
@@ -95,6 +95,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:title="@string/settings_notifications_title" />
|
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
|
<presentation.common.widget.PreferenceView
|
||||||
android:id="@+id/delivery"
|
android:id="@+id/delivery"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
<string name="title_archived">Archived</string>
|
<string name="title_archived">Archived</string>
|
||||||
<string name="title_scheduled">Scheduled</string>
|
<string name="title_scheduled">Scheduled</string>
|
||||||
<string name="title_blocked">Blocked</string>
|
|
||||||
<string name="title_settings">Settings</string>
|
<string name="title_settings">Settings</string>
|
||||||
<string name="title_notification_prefs">Notifications</string>
|
<string name="title_notification_prefs">Notifications</string>
|
||||||
<string name="title_theme">Theme</string>
|
<string name="title_theme">Theme</string>
|
||||||
@@ -62,12 +61,9 @@
|
|||||||
<string name="inbox_empty_text">Your conversations will appear here</string>
|
<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="archived_empty_text">Your archived conversations will appear here</string>
|
||||||
<string name="scheduled_empty_text">Your scheduled messages will appear here</string>
|
<string name="scheduled_empty_text">Your scheduled messages will appear here</string>
|
||||||
<string name="blocked_empty_text">Your blocked conversations 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>
|
||||||
<string name="dialog_unblock_title">Unblock</string>
|
|
||||||
<string name="dialog_unblock_message">Would you like to unblock this conversation?</string>
|
|
||||||
|
|
||||||
<string name="info_title">Details</string>
|
<string name="info_title">Details</string>
|
||||||
<string name="info_notifications">Notifications</string>
|
<string name="info_notifications">Notifications</string>
|
||||||
@@ -86,9 +82,10 @@
|
|||||||
<string name="settings_night_end_title">End time</string>
|
<string name="settings_night_end_title">End time</string>
|
||||||
<string name="settings_auto_emoji_title">Automatic emoji</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_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_vibration_title">Vibration</string>
|
||||||
<string name="settings_ringtone_title">Sound</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_title">Delivery confirmations</string>
|
||||||
<string name="settings_delivery_summary">Confirm that messages were sent successfully</string>
|
<string name="settings_delivery_summary">Confirm that messages were sent successfully</string>
|
||||||
<string name="settings_unicode_title">Strip accents</string>
|
<string name="settings_unicode_title">Strip accents</string>
|
||||||
@@ -98,6 +95,11 @@
|
|||||||
<string name="settings_sync_title">Sync messages</string>
|
<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="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_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_description_summary">You can save a starving developer for just %s</string>
|
||||||
<string name="qksms_plus_upgrade">Unlock for %1$s %2$s</string>
|
<string name="qksms_plus_upgrade">Unlock for %1$s %2$s</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user