mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-16 19:18:52 +01:00
#1064 - Show radio button for appropriate dialogs
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
package common
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.support.annotation.ArrayRes
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
@@ -28,9 +29,9 @@ import com.moez.QKSMS.R
|
||||
import common.base.QkAdapter
|
||||
import common.base.QkViewHolder
|
||||
import common.util.Colors
|
||||
import common.util.extensions.setTint
|
||||
import common.util.extensions.setVisible
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
@@ -66,8 +67,15 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val view = LayoutInflater.from(context).inflate(R.layout.menu_list_item, parent, false)
|
||||
|
||||
disposables += colors.theme
|
||||
.subscribe { view.check.setTint(it) }
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_selected),
|
||||
intArrayOf(-android.R.attr.state_selected))
|
||||
|
||||
disposables += Observables
|
||||
.combineLatest(colors.theme, colors.textTertiary, { theme, textSecondary ->
|
||||
ColorStateList(states, intArrayOf(theme, textSecondary))
|
||||
})
|
||||
.subscribe { view.check.imageTintList = it }
|
||||
|
||||
return QkViewHolder(view)
|
||||
}
|
||||
@@ -79,7 +87,8 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
|
||||
view.clicks().subscribe { menuItemClicks.onNext(menuItem.actionId) }
|
||||
|
||||
view.title.text = menuItem.title
|
||||
view.check.setVisible(menuItem.actionId == selectedItem)
|
||||
view.check.isSelected = (menuItem.actionId == selectedItem)
|
||||
view.check.setVisible(selectedItem != null)
|
||||
}
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
|
||||
@@ -90,7 +90,8 @@ class NotificationPrefsActivity : QkThemedActivity<NotificationPrefsViewModel>()
|
||||
}
|
||||
|
||||
notifications.checkbox.isChecked = state.notificationsEnabled
|
||||
notificationPreviews.summary = state.notificationPreviewSummary
|
||||
notificationPreviews.summary = state.previewSummary
|
||||
previewModeDialog.adapter.selectedItem = state.previewId
|
||||
vibration.checkbox.isChecked = state.vibrationEnabled
|
||||
ringtone.summary = state.ringtoneName
|
||||
qkreply.checkbox.isChecked = state.qkReplyEnabled
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
package feature.notificationprefs
|
||||
|
||||
import android.os.Build
|
||||
import util.Preferences
|
||||
|
||||
data class NotificationPrefsState(
|
||||
val conversationTitle: String = "",
|
||||
val notificationsEnabled: Boolean = true,
|
||||
val notificationPreviewSummary: String = "",
|
||||
val previewSummary: String = "",
|
||||
val previewId: Int = Preferences.NOTIFICATION_PREVIEWS_ALL,
|
||||
val vibrationEnabled: Boolean = true,
|
||||
val ringtoneName: String = "",
|
||||
val qkReplyEnabled: Boolean = Build.VERSION.SDK_INT < Build.VERSION_CODES.N,
|
||||
|
||||
@@ -48,6 +48,7 @@ class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefs
|
||||
private val threadId = intent.extras?.getLong("threadId") ?: 0L
|
||||
|
||||
private val notifications: Preference<Boolean>
|
||||
private val previews: Preference<Int>
|
||||
private val vibration: Preference<Boolean>
|
||||
private val ringtone: Preference<String>
|
||||
|
||||
@@ -55,6 +56,7 @@ class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefs
|
||||
appComponent.inject(this)
|
||||
|
||||
notifications = prefs.notifications(threadId)
|
||||
previews = prefs.notificationPreviews(threadId)
|
||||
vibration = prefs.vibration(threadId)
|
||||
ringtone = prefs.ringtone(threadId)
|
||||
|
||||
@@ -67,9 +69,11 @@ class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefs
|
||||
disposables += notifications.asObservable()
|
||||
.subscribe { enabled -> newState { it.copy(notificationsEnabled = enabled) } }
|
||||
|
||||
val notificationPreviewLabels = context.resources.getStringArray(R.array.notification_preview_options)
|
||||
disposables += prefs.notificationPreviews().asObservable()
|
||||
.subscribe { nightMode -> newState { it.copy(notificationPreviewSummary = notificationPreviewLabels[nightMode]) } }
|
||||
val previewLabels = context.resources.getStringArray(R.array.notification_preview_options)
|
||||
disposables += previews.asObservable()
|
||||
.subscribe { previewId ->
|
||||
newState { it.copy(previewSummary = previewLabels[previewId], previewId = previewId) }
|
||||
}
|
||||
|
||||
disposables += vibration.asObservable()
|
||||
.subscribe { enabled -> newState { it.copy(vibrationEnabled = enabled) } }
|
||||
@@ -111,7 +115,7 @@ class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefs
|
||||
|
||||
view.previewModeSelectedIntent
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { prefs.notificationPreviews().set(it) }
|
||||
.subscribe { previews.set(it) }
|
||||
|
||||
view.ringtoneSelectedIntent
|
||||
.autoDisposable(view.scope())
|
||||
|
||||
@@ -108,6 +108,7 @@ class SettingsActivity : QkThemedActivity<SettingsViewModel>(), SettingsView {
|
||||
|
||||
themePreview.setBackgroundTint(state.theme)
|
||||
night.summary = state.nightModeSummary
|
||||
nightModeDialog.adapter.selectedItem = state.nightModeId
|
||||
nightStart.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||
nightStart.summary = state.nightStart
|
||||
nightEnd.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||
@@ -120,6 +121,7 @@ class SettingsActivity : QkThemedActivity<SettingsViewModel>(), SettingsView {
|
||||
delivery.checkbox.isChecked = state.deliveryEnabled
|
||||
|
||||
textSize.summary = state.textSizeSummary
|
||||
textSizeDialog.adapter.selectedItem = state.textSizeId
|
||||
systemFont.checkbox.isChecked = state.systemFontEnabled
|
||||
|
||||
unicode.checkbox.isChecked = state.stripUnicodeEnabled
|
||||
|
||||
@@ -33,6 +33,7 @@ data class SettingsState(
|
||||
val notificationsEnabled: Boolean = true,
|
||||
val deliveryEnabled: Boolean = false,
|
||||
val textSizeSummary: String = "",
|
||||
val textSizeId: Int = Preferences.TEXT_SIZE_NORMAL,
|
||||
val systemFontEnabled: Boolean = false,
|
||||
val splitSmsEnabled: Boolean = false,
|
||||
val stripUnicodeEnabled: Boolean = false,
|
||||
|
||||
@@ -86,7 +86,9 @@ class SettingsViewModel : QkViewModel<SettingsView, SettingsState>(SettingsState
|
||||
|
||||
val textSizeLabels = context.resources.getStringArray(R.array.text_sizes)
|
||||
disposables += prefs.textSize.asObservable()
|
||||
.subscribe { textSize -> newState { it.copy(textSizeSummary = textSizeLabels[textSize]) } }
|
||||
.subscribe { textSize ->
|
||||
newState { it.copy(textSizeSummary = textSizeLabels[textSize], textSizeId = textSize) }
|
||||
}
|
||||
|
||||
disposables += prefs.systemFont.asObservable()
|
||||
.subscribe { enabled -> newState { it.copy(systemFontEnabled = enabled) } }
|
||||
|
||||
Reference in New Issue
Block a user