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