forked from upstream-mirrors/quik
Formatting
This commit is contained in:
@@ -34,4 +34,4 @@ class ActiveConversationManagerImpl @Inject constructor() : ActiveConversationMa
|
||||
return threadId
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,4 +29,4 @@ interface ActiveConversationManager {
|
||||
|
||||
fun getActiveConversation(): Long?
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.moez.QKSMS.common.Navigator
|
||||
import com.moez.QKSMS.common.base.QkViewModel
|
||||
import com.moez.QKSMS.common.util.BillingManager
|
||||
import com.moez.QKSMS.common.util.ClipboardUtils
|
||||
import com.moez.QKSMS.common.util.Colors
|
||||
import com.moez.QKSMS.common.util.MessageDetailsFormatter
|
||||
import com.moez.QKSMS.common.util.extensions.makeToast
|
||||
import com.moez.QKSMS.compat.SubscriptionManagerCompat
|
||||
@@ -78,7 +77,6 @@ class ComposeViewModel @Inject constructor(
|
||||
@Named("addresses") private val addresses: List<String>,
|
||||
@Named("text") private val sharedText: String,
|
||||
@Named("attachments") private val sharedAttachments: Attachments,
|
||||
private val colors: Colors,
|
||||
private val contactRepo: ContactRepository,
|
||||
private val context: Context,
|
||||
private val activeConversationManager: ActiveConversationManager,
|
||||
@@ -449,21 +447,22 @@ class ComposeViewModel @Inject constructor(
|
||||
.subscribe { message -> cancelMessage.execute(message.id) }
|
||||
|
||||
// Set the current conversation
|
||||
Observables.combineLatest(
|
||||
view.activityVisibleIntent.distinctUntilChanged(),
|
||||
conversation.mapNotNull { conversation ->
|
||||
conversation.takeIf { it.isValid }?.id
|
||||
}.distinctUntilChanged())
|
||||
{ visible, threadId ->
|
||||
when (visible) {
|
||||
true -> {
|
||||
activeConversationManager.setActiveConversation(threadId)
|
||||
markRead.execute(listOf(threadId))
|
||||
}
|
||||
Observables
|
||||
.combineLatest(
|
||||
view.activityVisibleIntent.distinctUntilChanged(),
|
||||
conversation.mapNotNull { conversation ->
|
||||
conversation.takeIf { it.isValid }?.id
|
||||
}.distinctUntilChanged())
|
||||
{ visible, threadId ->
|
||||
when (visible) {
|
||||
true -> {
|
||||
activeConversationManager.setActiveConversation(threadId)
|
||||
markRead.execute(listOf(threadId))
|
||||
}
|
||||
|
||||
false -> activeConversationManager.setActiveConversation(null)
|
||||
}
|
||||
}
|
||||
false -> activeConversationManager.setActiveConversation(null)
|
||||
}
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
|
||||
-8
@@ -45,10 +45,6 @@ class ConversationsAdapter @Inject constructor(
|
||||
private val phoneNumberUtils: PhoneNumberUtils
|
||||
) : QkRealmAdapter<Conversation>() {
|
||||
|
||||
init {
|
||||
setHasStableIds(true)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val view = layoutInflater.inflate(R.layout.conversation_list_item, parent, false)
|
||||
@@ -113,10 +109,6 @@ class ConversationsAdapter @Inject constructor(
|
||||
holder.unread.setTint(colors.theme(recipient).theme)
|
||||
}
|
||||
|
||||
override fun getItemId(index: Int): Long {
|
||||
return getItem(index)!!.id
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (getItem(position)?.unread == false) 0 else 1
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.jakewharton.rxbinding2.widget.textChanges
|
||||
@@ -150,8 +149,8 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
homeIntent.onNext(Unit)
|
||||
}
|
||||
|
||||
recyclerView.setHasFixedSize(true)
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
itemTouchCallback.adapter = conversationsAdapter
|
||||
conversationsAdapter.autoScrollToStart(recyclerView)
|
||||
|
||||
// Don't allow clicks to pass through the drawer layout
|
||||
drawer.clicks().autoDisposable(scope()).subscribe()
|
||||
@@ -161,8 +160,10 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
.autoDisposable(scope())
|
||||
.subscribe { theme ->
|
||||
// Set the color for the drawer icons
|
||||
val states = arrayOf(intArrayOf(android.R.attr.state_activated),
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_activated),
|
||||
intArrayOf(-android.R.attr.state_activated))
|
||||
|
||||
resolveThemeColor(android.R.attr.textColorSecondary)
|
||||
.let { textSecondary -> ColorStateList(states, intArrayOf(theme.theme, textSecondary)) }
|
||||
.let { tintList ->
|
||||
@@ -185,9 +186,6 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
compose.setTint(theme.textPrimary)
|
||||
}
|
||||
|
||||
itemTouchCallback.adapter = conversationsAdapter
|
||||
conversationsAdapter.autoScrollToStart(recyclerView)
|
||||
|
||||
// These theme attributes don't apply themselves on API 21
|
||||
if (Build.VERSION.SDK_INT <= 22) {
|
||||
toolbarSearch.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
||||
@@ -286,10 +284,11 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
inbox.isActivated = state.page is Inbox
|
||||
archived.isActivated = state.page is Archived
|
||||
|
||||
if (drawerLayout.isDrawerOpen(GravityCompat.START) && !state.drawerOpen) drawerLayout.closeDrawer(
|
||||
GravityCompat.START)
|
||||
else if (!drawerLayout.isDrawerVisible(GravityCompat.START) && state.drawerOpen) drawerLayout.openDrawer(
|
||||
GravityCompat.START)
|
||||
if (drawerLayout.isDrawerOpen(GravityCompat.START) && !state.drawerOpen) {
|
||||
drawerLayout.closeDrawer(GravityCompat.START)
|
||||
} else if (!drawerLayout.isDrawerVisible(GravityCompat.START) && state.drawerOpen) {
|
||||
drawerLayout.openDrawer(GravityCompat.START)
|
||||
}
|
||||
|
||||
when (state.syncing) {
|
||||
is SyncRepository.SyncProgress.Idle -> {
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbar"
|
||||
tools:listitem="@layout/conversation_list_item" />
|
||||
|
||||
Reference in New Issue
Block a user