forked from upstream-mirrors/quik
#1064 - Show radio button for appropriate dialogs
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.support.annotation.ArrayRes
|
import android.support.annotation.ArrayRes
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -28,9 +29,9 @@ import com.moez.QKSMS.R
|
|||||||
import common.base.QkAdapter
|
import common.base.QkAdapter
|
||||||
import common.base.QkViewHolder
|
import common.base.QkViewHolder
|
||||||
import common.util.Colors
|
import common.util.Colors
|
||||||
import common.util.extensions.setTint
|
|
||||||
import common.util.extensions.setVisible
|
import common.util.extensions.setVisible
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
import io.reactivex.rxkotlin.Observables
|
||||||
import io.reactivex.rxkotlin.plusAssign
|
import io.reactivex.rxkotlin.plusAssign
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
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 {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
val view = LayoutInflater.from(context).inflate(R.layout.menu_list_item, parent, false)
|
val view = LayoutInflater.from(context).inflate(R.layout.menu_list_item, parent, false)
|
||||||
|
|
||||||
disposables += colors.theme
|
val states = arrayOf(
|
||||||
.subscribe { view.check.setTint(it) }
|
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)
|
return QkViewHolder(view)
|
||||||
}
|
}
|
||||||
@@ -79,7 +87,8 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
|
|||||||
view.clicks().subscribe { menuItemClicks.onNext(menuItem.actionId) }
|
view.clicks().subscribe { menuItemClicks.onNext(menuItem.actionId) }
|
||||||
|
|
||||||
view.title.text = menuItem.title
|
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) {
|
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ class NotificationPrefsActivity : QkThemedActivity<NotificationPrefsViewModel>()
|
|||||||
}
|
}
|
||||||
|
|
||||||
notifications.checkbox.isChecked = state.notificationsEnabled
|
notifications.checkbox.isChecked = state.notificationsEnabled
|
||||||
notificationPreviews.summary = state.notificationPreviewSummary
|
notificationPreviews.summary = state.previewSummary
|
||||||
|
previewModeDialog.adapter.selectedItem = state.previewId
|
||||||
vibration.checkbox.isChecked = state.vibrationEnabled
|
vibration.checkbox.isChecked = state.vibrationEnabled
|
||||||
ringtone.summary = state.ringtoneName
|
ringtone.summary = state.ringtoneName
|
||||||
qkreply.checkbox.isChecked = state.qkReplyEnabled
|
qkreply.checkbox.isChecked = state.qkReplyEnabled
|
||||||
|
|||||||
@@ -19,11 +19,13 @@
|
|||||||
package feature.notificationprefs
|
package feature.notificationprefs
|
||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import util.Preferences
|
||||||
|
|
||||||
data class NotificationPrefsState(
|
data class NotificationPrefsState(
|
||||||
val conversationTitle: String = "",
|
val conversationTitle: String = "",
|
||||||
val notificationsEnabled: Boolean = true,
|
val notificationsEnabled: Boolean = true,
|
||||||
val notificationPreviewSummary: String = "",
|
val previewSummary: String = "",
|
||||||
|
val previewId: Int = Preferences.NOTIFICATION_PREVIEWS_ALL,
|
||||||
val vibrationEnabled: Boolean = true,
|
val vibrationEnabled: Boolean = true,
|
||||||
val ringtoneName: String = "",
|
val ringtoneName: String = "",
|
||||||
val qkReplyEnabled: Boolean = Build.VERSION.SDK_INT < Build.VERSION_CODES.N,
|
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 threadId = intent.extras?.getLong("threadId") ?: 0L
|
||||||
|
|
||||||
private val notifications: Preference<Boolean>
|
private val notifications: Preference<Boolean>
|
||||||
|
private val previews: Preference<Int>
|
||||||
private val vibration: Preference<Boolean>
|
private val vibration: Preference<Boolean>
|
||||||
private val ringtone: Preference<String>
|
private val ringtone: Preference<String>
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefs
|
|||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
|
|
||||||
notifications = prefs.notifications(threadId)
|
notifications = prefs.notifications(threadId)
|
||||||
|
previews = prefs.notificationPreviews(threadId)
|
||||||
vibration = prefs.vibration(threadId)
|
vibration = prefs.vibration(threadId)
|
||||||
ringtone = prefs.ringtone(threadId)
|
ringtone = prefs.ringtone(threadId)
|
||||||
|
|
||||||
@@ -67,9 +69,11 @@ class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefs
|
|||||||
disposables += notifications.asObservable()
|
disposables += notifications.asObservable()
|
||||||
.subscribe { enabled -> newState { it.copy(notificationsEnabled = enabled) } }
|
.subscribe { enabled -> newState { it.copy(notificationsEnabled = enabled) } }
|
||||||
|
|
||||||
val notificationPreviewLabels = context.resources.getStringArray(R.array.notification_preview_options)
|
val previewLabels = context.resources.getStringArray(R.array.notification_preview_options)
|
||||||
disposables += prefs.notificationPreviews().asObservable()
|
disposables += previews.asObservable()
|
||||||
.subscribe { nightMode -> newState { it.copy(notificationPreviewSummary = notificationPreviewLabels[nightMode]) } }
|
.subscribe { previewId ->
|
||||||
|
newState { it.copy(previewSummary = previewLabels[previewId], previewId = previewId) }
|
||||||
|
}
|
||||||
|
|
||||||
disposables += vibration.asObservable()
|
disposables += vibration.asObservable()
|
||||||
.subscribe { enabled -> newState { it.copy(vibrationEnabled = enabled) } }
|
.subscribe { enabled -> newState { it.copy(vibrationEnabled = enabled) } }
|
||||||
@@ -111,7 +115,7 @@ class NotificationPrefsViewModel(intent: Intent) : QkViewModel<NotificationPrefs
|
|||||||
|
|
||||||
view.previewModeSelectedIntent
|
view.previewModeSelectedIntent
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { prefs.notificationPreviews().set(it) }
|
.subscribe { previews.set(it) }
|
||||||
|
|
||||||
view.ringtoneSelectedIntent
|
view.ringtoneSelectedIntent
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class SettingsActivity : QkThemedActivity<SettingsViewModel>(), SettingsView {
|
|||||||
|
|
||||||
themePreview.setBackgroundTint(state.theme)
|
themePreview.setBackgroundTint(state.theme)
|
||||||
night.summary = state.nightModeSummary
|
night.summary = state.nightModeSummary
|
||||||
|
nightModeDialog.adapter.selectedItem = state.nightModeId
|
||||||
nightStart.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
nightStart.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||||
nightStart.summary = state.nightStart
|
nightStart.summary = state.nightStart
|
||||||
nightEnd.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
nightEnd.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||||
@@ -120,6 +121,7 @@ class SettingsActivity : QkThemedActivity<SettingsViewModel>(), SettingsView {
|
|||||||
delivery.checkbox.isChecked = state.deliveryEnabled
|
delivery.checkbox.isChecked = state.deliveryEnabled
|
||||||
|
|
||||||
textSize.summary = state.textSizeSummary
|
textSize.summary = state.textSizeSummary
|
||||||
|
textSizeDialog.adapter.selectedItem = state.textSizeId
|
||||||
systemFont.checkbox.isChecked = state.systemFontEnabled
|
systemFont.checkbox.isChecked = state.systemFontEnabled
|
||||||
|
|
||||||
unicode.checkbox.isChecked = state.stripUnicodeEnabled
|
unicode.checkbox.isChecked = state.stripUnicodeEnabled
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ data class SettingsState(
|
|||||||
val notificationsEnabled: Boolean = true,
|
val notificationsEnabled: Boolean = true,
|
||||||
val deliveryEnabled: Boolean = false,
|
val deliveryEnabled: Boolean = false,
|
||||||
val textSizeSummary: String = "",
|
val textSizeSummary: String = "",
|
||||||
|
val textSizeId: Int = Preferences.TEXT_SIZE_NORMAL,
|
||||||
val systemFontEnabled: Boolean = false,
|
val systemFontEnabled: Boolean = false,
|
||||||
val splitSmsEnabled: Boolean = false,
|
val splitSmsEnabled: Boolean = false,
|
||||||
val stripUnicodeEnabled: 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)
|
val textSizeLabels = context.resources.getStringArray(R.array.text_sizes)
|
||||||
disposables += prefs.textSize.asObservable()
|
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()
|
disposables += prefs.systemFont.asObservable()
|
||||||
.subscribe { enabled -> newState { it.copy(systemFontEnabled = enabled) } }
|
.subscribe { enabled -> newState { it.copy(systemFontEnabled = enabled) } }
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5 5,-2.24 5,-5 -2.24,-5 -5,-5zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:drawable="@drawable/ic_radio_button_checked_black_24dp" android:state_selected="true" />
|
||||||
|
|
||||||
|
<item android:drawable="@drawable/ic_radio_button_unchecked_black_24dp" />
|
||||||
|
|
||||||
|
</selector>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
~ Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||||
~
|
~
|
||||||
~ This file is part of QKSMS.
|
~ This file is part of QKSMS.
|
||||||
@@ -18,12 +17,21 @@
|
|||||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/ripple"
|
android:background="@drawable/ripple"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/check"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:src="@drawable/radio_button"
|
||||||
|
tools:tint="@color/textTertiary" />
|
||||||
|
|
||||||
<common.widget.QkTextView
|
<common.widget.QkTextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
style="@style/TextPrimary"
|
style="@style/TextPrimary"
|
||||||
@@ -33,13 +41,7 @@
|
|||||||
android:paddingBottom="12dp"
|
android:paddingBottom="12dp"
|
||||||
android:paddingLeft="24dp"
|
android:paddingLeft="24dp"
|
||||||
android:paddingRight="24dp"
|
android:paddingRight="24dp"
|
||||||
android:paddingTop="12dp" />
|
android:paddingTop="12dp"
|
||||||
|
tools:text="Testing" />
|
||||||
<ImageView
|
|
||||||
android:id="@+id/check"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:layout_marginRight="24dp"
|
|
||||||
android:src="@drawable/ic_check_white_24dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user