forked from upstream-mirrors/quik
@@ -153,10 +153,6 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
.autoDisposable(scope())
|
||||
.subscribe()
|
||||
|
||||
allThemes
|
||||
.autoDisposable(scope())
|
||||
.subscribe { messageList.scrapViews() }
|
||||
|
||||
window.callback = ComposeWindowCallback(window.callback, this)
|
||||
|
||||
// These theme attributes don't apply themselves on API 21
|
||||
@@ -299,6 +295,10 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
startActivityForResult(intent, SelectContactRequestCode)
|
||||
}
|
||||
|
||||
override fun themeChanged() {
|
||||
messageList.scrapViews()
|
||||
}
|
||||
|
||||
override fun showKeyboard() {
|
||||
message.postDelayed({
|
||||
message.showKeyboard()
|
||||
|
||||
@@ -62,6 +62,7 @@ interface ComposeView : QkView<ComposeState> {
|
||||
fun requestStoragePermission()
|
||||
fun requestSmsPermission()
|
||||
fun showContacts(sharing: Boolean, chips: List<Chip>)
|
||||
fun themeChanged()
|
||||
fun showKeyboard()
|
||||
fun requestCamera()
|
||||
fun requestGallery()
|
||||
|
||||
@@ -394,6 +394,13 @@ class ComposeViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe(view::scrollToMessage)
|
||||
|
||||
// Theme changes
|
||||
prefs.keyChanges
|
||||
.filter { key -> key.contains("theme") }
|
||||
.doOnNext { view.themeChanged() }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
// Retry sending
|
||||
view.messageClickIntent
|
||||
.mapNotNull(messageRepo::getMessage)
|
||||
|
||||
@@ -183,7 +183,7 @@ class MessagesAdapter @Inject constructor(
|
||||
|
||||
val theme = when (message.isOutgoingMessage()) {
|
||||
true -> colors.theme()
|
||||
false -> colors.theme(contactCache[message.address]?.id ?: 0)
|
||||
false -> colors.theme(contactCache[message.address])
|
||||
}
|
||||
|
||||
// Update the selected state
|
||||
@@ -232,8 +232,7 @@ class MessagesAdapter @Inject constructor(
|
||||
|
||||
// Bind the avatar and bubble colour
|
||||
if (!message.isMe()) {
|
||||
view.avatar.recipientId = contactCache[message.address]?.id ?: 0
|
||||
view.avatar.setContact(contactCache[message.address]?.contact)
|
||||
view.avatar.setRecipient(contactCache[message.address])
|
||||
view.avatar.setVisible(!canGroup(message, next), View.INVISIBLE)
|
||||
|
||||
view.body.setTextColor(theme.textPrimary)
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.moez.QKSMS.common.base.QkViewHolder
|
||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||
import com.moez.QKSMS.model.Recipient
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import kotlinx.android.synthetic.main.contact_chip.*
|
||||
import kotlinx.android.synthetic.main.contact_chip.view.*
|
||||
@@ -60,7 +61,7 @@ class ChipsAdapter @Inject constructor() : QkAdapter<Chip>() {
|
||||
val chip = getItem(position)
|
||||
val view = holder.containerView
|
||||
|
||||
view.avatar.setContact(chip.contact)
|
||||
view.avatar.setRecipient(Recipient(id = -1, contact = chip.contact))
|
||||
view.name.text = chip.contact?.name?.takeIf { it.isNotBlank() } ?: chip.address
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import com.moez.QKSMS.common.util.Colors
|
||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||
import com.moez.QKSMS.common.util.extensions.setTint
|
||||
import com.moez.QKSMS.injection.appComponent
|
||||
import com.moez.QKSMS.model.Recipient
|
||||
import kotlinx.android.synthetic.main.contact_chip_detailed.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -54,7 +55,7 @@ class DetailedChipView(context: Context) : RelativeLayout(context) {
|
||||
}
|
||||
|
||||
fun setChip(chip: Chip) {
|
||||
avatar.setContact(chip.contact)
|
||||
avatar.setRecipient(Recipient(id = -1, contact = chip.contact))
|
||||
name.text = chip.contact?.name?.takeIf { it.isNotBlank() } ?: chip.address
|
||||
info.text = chip.address
|
||||
}
|
||||
|
||||
+2
-3
@@ -59,8 +59,7 @@ class ConversationRecipientAdapter @Inject constructor(
|
||||
val recipient = getItem(position) ?: return
|
||||
val view = holder.containerView
|
||||
|
||||
view.avatar.recipientId = recipient.id
|
||||
view.avatar.setContact(recipient.contact)
|
||||
view.avatar.setRecipient(recipient)
|
||||
|
||||
view.name.text = recipient.contact?.name ?: recipient.address
|
||||
|
||||
@@ -69,7 +68,7 @@ class ConversationRecipientAdapter @Inject constructor(
|
||||
|
||||
view.add.setVisible(recipient.contact == null)
|
||||
|
||||
val theme = colors.theme(recipient.id)
|
||||
val theme = colors.theme(recipient)
|
||||
view.theme.setTint(theme.theme)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ class ConversationsAdapter @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
view.unread.setTint(colors.theme(recipient?.id ?: 0).theme)
|
||||
view.unread.setTint(colors.theme(recipient).theme)
|
||||
}
|
||||
|
||||
override fun getItemId(index: Int): Long {
|
||||
|
||||
@@ -83,7 +83,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||
|
||||
override val onNewIntentIntent: Subject<Intent> = PublishSubject.create()
|
||||
override val activityResumedIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val activityResumedIntent: Subject<Boolean> = PublishSubject.create()
|
||||
override val queryChangedIntent by lazy { toolbarSearch.textChanges() }
|
||||
override val composeIntent by lazy { compose.clicks() }
|
||||
override val drawerOpenIntent: Observable<Boolean> by lazy {
|
||||
@@ -182,10 +182,6 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
compose.setTint(theme.textPrimary)
|
||||
}
|
||||
|
||||
allThemes
|
||||
.autoDisposable(scope())
|
||||
.subscribe { recyclerView.scrapViews() }
|
||||
|
||||
itemTouchCallback.adapter = conversationsAdapter
|
||||
conversationsAdapter.autoScrollToStart(recyclerView)
|
||||
|
||||
@@ -330,7 +326,12 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
activityResumedIntent.onNext(Unit)
|
||||
activityResumedIntent.onNext(true)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
activityResumedIntent.onNext(false)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -366,6 +367,10 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
conversationsAdapter.clearSelection()
|
||||
}
|
||||
|
||||
override fun themeChanged() {
|
||||
recyclerView.scrapViews()
|
||||
}
|
||||
|
||||
override fun showBlockingDialog(conversations: List<Long>, block: Boolean) {
|
||||
blockingDialog.show(this, conversations, block)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.reactivex.Observable
|
||||
interface MainView : QkView<MainState> {
|
||||
|
||||
val onNewIntentIntent: Observable<Intent>
|
||||
val activityResumedIntent: Observable<*>
|
||||
val activityResumedIntent: Observable<Boolean>
|
||||
val queryChangedIntent: Observable<CharSequence>
|
||||
val composeIntent: Observable<Unit>
|
||||
val drawerOpenIntent: Observable<Boolean>
|
||||
@@ -47,6 +47,7 @@ interface MainView : QkView<MainState> {
|
||||
fun requestPermissions()
|
||||
fun clearSearch()
|
||||
fun clearSelection()
|
||||
fun themeChanged()
|
||||
fun showBlockingDialog(conversations: List<Long>, block: Boolean)
|
||||
fun showDeleteDialog(conversations: List<Long>)
|
||||
fun showChangelog(changelog: ChangelogManager.Changelog)
|
||||
|
||||
@@ -131,6 +131,7 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
val permissions = view.activityResumedIntent
|
||||
.filter { resumed -> resumed }
|
||||
.observeOn(Schedulers.io())
|
||||
.map { Triple(permissionManager.isDefaultSms(), permissionManager.hasReadSms(), permissionManager.hasContacts()) }
|
||||
.distinctUntilChanged()
|
||||
@@ -202,6 +203,20 @@ class MainViewModel @Inject constructor(
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { data -> newState { copy(page = Searching(loading = false, data = data)) } }
|
||||
|
||||
view.activityResumedIntent
|
||||
.filter { resumed -> !resumed }
|
||||
.switchMap {
|
||||
// Take until the activity is resumed
|
||||
prefs.keyChanges
|
||||
.filter { key -> key.contains("theme") }
|
||||
.map { true }
|
||||
.mergeWith(prefs.autoColor.asObservable())
|
||||
.doOnNext { view.themeChanged() }
|
||||
.takeUntil(view.activityResumedIntent.filter { resumed -> resumed })
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
view.composeIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { navigator.showCompose() }
|
||||
|
||||
@@ -161,6 +161,9 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
||||
|
||||
textSize.summary = state.textSizeSummary
|
||||
textSizeDialog.adapter.selectedItem = state.textSizeId
|
||||
|
||||
autoColor.checkbox.isChecked = state.autoColor
|
||||
|
||||
systemFont.checkbox.isChecked = state.systemFontEnabled
|
||||
|
||||
unicode.checkbox.isChecked = state.stripUnicodeEnabled
|
||||
|
||||
@@ -100,6 +100,9 @@ class SettingsPresenter @Inject constructor(
|
||||
newState { copy(textSizeSummary = textSizeLabels[textSize], textSizeId = textSize) }
|
||||
}
|
||||
|
||||
disposables += prefs.autoColor.asObservable()
|
||||
.subscribe { autoColor -> newState { copy(autoColor = autoColor) } }
|
||||
|
||||
disposables += prefs.systemFont.asObservable()
|
||||
.subscribe { enabled -> newState { copy(systemFontEnabled = enabled) } }
|
||||
|
||||
@@ -164,6 +167,8 @@ class SettingsPresenter @Inject constructor(
|
||||
|
||||
R.id.textSize -> view.showTextSizePicker()
|
||||
|
||||
R.id.autoColor -> prefs.autoColor.set(!prefs.autoColor.get())
|
||||
|
||||
R.id.systemFont -> prefs.systemFont.set(!prefs.systemFont.get())
|
||||
|
||||
R.id.unicode -> prefs.unicode.set(!prefs.unicode.get())
|
||||
|
||||
@@ -28,6 +28,7 @@ data class SettingsState(
|
||||
val nightStart: String = "",
|
||||
val nightEnd: String = "",
|
||||
val black: Boolean = false,
|
||||
val autoColor: Boolean = true,
|
||||
val autoEmojiEnabled: Boolean = true,
|
||||
val notificationsEnabled: Boolean = true,
|
||||
val sendDelaySummary: String = "",
|
||||
|
||||
Reference in New Issue
Block a user