forked from upstream-mirrors/quik
Revert "Implement ViewBinding"
This reverts commit 37d8c45379.
# Conflicts:
# build.gradle
# presentation/src/main/java/com/moez/QKSMS/common/widget/AvatarView.kt
# presentation/src/main/java/com/moez/QKSMS/common/widget/TextInputDialog.kt
# presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeActivity.kt
# presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt
# presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationInfoController.kt
# presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt
# presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt
# presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt
This commit is contained in:
@@ -22,22 +22,21 @@ import android.os.Bundle
|
||||
import com.bluelinelabs.conductor.Conductor
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
||||
import com.moez.QKSMS.databinding.ContainerActivityBinding
|
||||
import dagger.android.AndroidInjection
|
||||
import kotlinx.android.synthetic.main.container_activity.*
|
||||
|
||||
class SettingsActivity : QkThemedActivity() {
|
||||
|
||||
private val binding by viewBinding(ContainerActivityBinding::inflate)
|
||||
private lateinit var router: Router
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(binding.root)
|
||||
setContentView(R.layout.container_activity)
|
||||
|
||||
router = Conductor.attachRouter(this, binding.container, savedInstanceState)
|
||||
router = Conductor.attachRouter(this, container, savedInstanceState)
|
||||
if (!router.hasRootController()) {
|
||||
router.setRoot(RouterTransaction.with(SettingsController()))
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.moez.QKSMS.common.util.extensions.setVisible
|
||||
import com.moez.QKSMS.common.widget.PreferenceView
|
||||
import com.moez.QKSMS.common.widget.QkSwitch
|
||||
import com.moez.QKSMS.common.widget.TextInputDialog
|
||||
import com.moez.QKSMS.databinding.SettingsControllerBinding
|
||||
import com.moez.QKSMS.feature.settings.about.AboutController
|
||||
import com.moez.QKSMS.feature.settings.autodelete.AutoDeleteDialog
|
||||
import com.moez.QKSMS.feature.settings.swipe.SwipeActionsController
|
||||
@@ -59,12 +58,14 @@ import io.reactivex.subjects.Subject
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.android.synthetic.main.settings_controller.*
|
||||
import kotlinx.android.synthetic.main.settings_controller.view.*
|
||||
import kotlinx.android.synthetic.main.settings_switch_widget.view.*
|
||||
import kotlinx.android.synthetic.main.settings_theme_widget.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
class SettingsController : QkController<SettingsView, SettingsState, SettingsPresenter, SettingsControllerBinding>(
|
||||
SettingsControllerBinding::inflate
|
||||
), SettingsView {
|
||||
class SettingsController : QkController<SettingsView, SettingsState, SettingsPresenter>(), SettingsView {
|
||||
|
||||
@Inject lateinit var context: Context
|
||||
@Inject lateinit var colors: Colors
|
||||
@@ -88,11 +89,12 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
||||
private val signatureSubject: Subject<String> = PublishSubject.create()
|
||||
private val autoDeleteSubject: Subject<Int> = PublishSubject.create()
|
||||
|
||||
private val progressAnimator by lazy { ObjectAnimator.ofInt(binding.syncingProgress, "progress", 0, 0) }
|
||||
private val progressAnimator by lazy { ObjectAnimator.ofInt(syncingProgress, "progress", 0, 0) }
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||
layoutRes = R.layout.settings_controller
|
||||
|
||||
colors.themeObservable()
|
||||
.autoDisposable(scope())
|
||||
@@ -100,7 +102,7 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
||||
}
|
||||
|
||||
override fun onViewCreated() {
|
||||
binding.preferences.postDelayed({ binding.preferences.animateLayoutChanges = true }, 100)
|
||||
preferences.postDelayed({ preferences?.animateLayoutChanges = true }, 100)
|
||||
|
||||
when (Build.VERSION.SDK_INT >= 29) {
|
||||
true -> nightModeDialog.adapter.setData(R.array.night_modes)
|
||||
@@ -112,7 +114,7 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
||||
sendDelayDialog.adapter.setData(R.array.delayed_sending_labels)
|
||||
mmsSizeDialog.adapter.setData(R.array.mms_sizes, R.array.mms_sizes_ids)
|
||||
|
||||
binding.about.summary = context.getString(R.string.settings_version, BuildConfig.VERSION_NAME)
|
||||
about.summary = context.getString(R.string.settings_version, BuildConfig.VERSION_NAME)
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
@@ -122,13 +124,13 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
||||
showBackButton(true)
|
||||
}
|
||||
|
||||
override fun preferenceClicks(): Observable<PreferenceView> = (0 until binding.preferences.childCount)
|
||||
.map { index -> binding.preferences.getChildAt(index) }
|
||||
override fun preferenceClicks(): Observable<PreferenceView> = (0 until preferences.childCount)
|
||||
.map { index -> preferences.getChildAt(index) }
|
||||
.mapNotNull { view -> view as? PreferenceView }
|
||||
.map { preference -> preference.clicks().map { preference } }
|
||||
.let { preferences -> Observable.merge(preferences) }
|
||||
|
||||
override fun aboutLongClicks(): Observable<*> = binding.about.longClicks()
|
||||
override fun aboutLongClicks(): Observable<*> = about.longClicks()
|
||||
|
||||
override fun viewQksmsPlusClicks(): Observable<*> = viewQksmsPlusSubject
|
||||
|
||||
@@ -149,64 +151,63 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
||||
override fun mmsSizeSelected(): Observable<Int> = mmsSizeDialog.adapter.menuItemClicks
|
||||
|
||||
override fun render(state: SettingsState) {
|
||||
binding.theme.widget<View>().setBackgroundTint(state.theme)
|
||||
binding.night.summary = state.nightModeSummary
|
||||
themePreview.setBackgroundTint(state.theme)
|
||||
night.summary = state.nightModeSummary
|
||||
nightModeDialog.adapter.selectedItem = state.nightModeId
|
||||
binding.nightStart.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||
binding.nightStart.summary = state.nightStart
|
||||
binding.nightEnd.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||
binding.nightEnd.summary = state.nightEnd
|
||||
nightStart.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||
nightStart.summary = state.nightStart
|
||||
nightEnd.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||
nightEnd.summary = state.nightEnd
|
||||
|
||||
binding.black.setVisible(state.nightModeId != Preferences.NIGHT_MODE_OFF)
|
||||
binding.black.widget<QkSwitch>().isChecked = state.black
|
||||
black.setVisible(state.nightModeId != Preferences.NIGHT_MODE_OFF)
|
||||
black.checkbox.isChecked = state.black
|
||||
|
||||
binding.autoEmoji.widget<QkSwitch>().isChecked = state.autoEmojiEnabled
|
||||
autoEmoji.checkbox.isChecked = state.autoEmojiEnabled
|
||||
|
||||
binding.delayed.summary = state.sendDelaySummary
|
||||
delayed.summary = state.sendDelaySummary
|
||||
sendDelayDialog.adapter.selectedItem = state.sendDelayId
|
||||
|
||||
binding.delivery.widget<QkSwitch>().isChecked = state.deliveryEnabled
|
||||
delivery.checkbox.isChecked = state.deliveryEnabled
|
||||
|
||||
binding.signature.summary = state.signature.takeIf { it.isNotBlank() }
|
||||
signature.summary = state.signature.takeIf { it.isNotBlank() }
|
||||
?: context.getString(R.string.settings_signature_summary)
|
||||
|
||||
binding.textSize.summary = state.textSizeSummary
|
||||
textSize.summary = state.textSizeSummary
|
||||
textSizeDialog.adapter.selectedItem = state.textSizeId
|
||||
|
||||
binding.autoColor.widget<QkSwitch>().isChecked = state.autoColor
|
||||
autoColor.checkbox.isChecked = state.autoColor
|
||||
|
||||
binding.systemFont.widget<QkSwitch>().isChecked = state.systemFontEnabled
|
||||
systemFont.checkbox.isChecked = state.systemFontEnabled
|
||||
|
||||
binding.unicode.widget<QkSwitch>().isChecked = state.stripUnicodeEnabled
|
||||
binding.mobileOnly.widget<QkSwitch>().isChecked = state.mobileOnly
|
||||
unicode.checkbox.isChecked = state.stripUnicodeEnabled
|
||||
mobileOnly.checkbox.isChecked = state.mobileOnly
|
||||
|
||||
binding.autoDelete.summary = when (state.autoDelete) {
|
||||
autoDelete.summary = when (state.autoDelete) {
|
||||
0 -> context.getString(R.string.settings_auto_delete_never)
|
||||
else -> context.resources.getQuantityString(
|
||||
R.plurals.settings_auto_delete_summary, state.autoDelete, state.autoDelete)
|
||||
}
|
||||
|
||||
binding.longAsMms.widget<QkSwitch>().isChecked = state.longAsMms
|
||||
longAsMms.checkbox.isChecked = state.longAsMms
|
||||
|
||||
binding.mmsSize.summary = state.maxMmsSizeSummary
|
||||
mmsSize.summary = state.maxMmsSizeSummary
|
||||
mmsSizeDialog.adapter.selectedItem = state.maxMmsSizeId
|
||||
|
||||
when (state.syncProgress) {
|
||||
is SyncRepository.SyncProgress.Idle -> binding.syncingProgress.isVisible = false
|
||||
is SyncRepository.SyncProgress.Idle -> syncingProgress.isVisible = false
|
||||
|
||||
is SyncRepository.SyncProgress.Running -> {
|
||||
binding.syncingProgress.isVisible = true
|
||||
binding.syncingProgress.max = state.syncProgress.max
|
||||
progressAnimator.apply { setIntValues(binding.syncingProgress.progress, state.syncProgress.progress) }
|
||||
.start()
|
||||
binding.syncingProgress.isIndeterminate = state.syncProgress.indeterminate
|
||||
syncingProgress.isVisible = true
|
||||
syncingProgress.max = state.syncProgress.max
|
||||
progressAnimator.apply { setIntValues(syncingProgress.progress, state.syncProgress.progress) }.start()
|
||||
syncingProgress.isIndeterminate = state.syncProgress.indeterminate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun showQksmsPlusSnackbar() {
|
||||
view?.run {
|
||||
Snackbar.make(binding.root, R.string.toast_qksms_plus, Snackbar.LENGTH_LONG).run {
|
||||
Snackbar.make(contentView, R.string.toast_qksms_plus, Snackbar.LENGTH_LONG).run {
|
||||
setAction(R.string.button_more) { viewQksmsPlusSubject.onNext(Unit) }
|
||||
setActionTextColor(colors.theme().theme)
|
||||
show()
|
||||
|
||||
@@ -24,23 +24,22 @@ import com.moez.QKSMS.BuildConfig
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.base.QkController
|
||||
import com.moez.QKSMS.common.widget.PreferenceView
|
||||
import com.moez.QKSMS.databinding.AboutControllerBinding
|
||||
import com.moez.QKSMS.injection.appComponent
|
||||
import io.reactivex.Observable
|
||||
import kotlinx.android.synthetic.main.about_controller.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AboutController : QkController<AboutView, Unit, AboutPresenter, AboutControllerBinding>(
|
||||
AboutControllerBinding::inflate
|
||||
), AboutView {
|
||||
class AboutController : QkController<AboutView, Unit, AboutPresenter>(), AboutView {
|
||||
|
||||
@Inject override lateinit var presenter: AboutPresenter
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
layoutRes = R.layout.about_controller
|
||||
}
|
||||
|
||||
override fun onViewCreated() {
|
||||
binding.version.summary = BuildConfig.VERSION_NAME
|
||||
version.summary = BuildConfig.VERSION_NAME
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
@@ -50,8 +49,8 @@ class AboutController : QkController<AboutView, Unit, AboutPresenter, AboutContr
|
||||
showBackButton(true)
|
||||
}
|
||||
|
||||
override fun preferenceClicks(): Observable<PreferenceView> = (0 until binding.preferences.childCount)
|
||||
.map { index -> binding.preferences.getChildAt(index) }
|
||||
override fun preferenceClicks(): Observable<PreferenceView> = (0 until preferences.childCount)
|
||||
.map { index -> preferences.getChildAt(index) }
|
||||
.mapNotNull { view -> view as? PreferenceView }
|
||||
.map { preference -> preference.clicks().map { preference } }
|
||||
.let { preferences -> Observable.merge(preferences) }
|
||||
|
||||
+7
-6
@@ -20,29 +20,30 @@ package com.moez.QKSMS.feature.settings.autodelete
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.DialogInterface
|
||||
import android.view.LayoutInflater
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.databinding.SettingsAutoDeleteDialogBinding
|
||||
import kotlinx.android.synthetic.main.settings_auto_delete_dialog.view.*
|
||||
|
||||
class AutoDeleteDialog(context: Activity, listener: (Int) -> Unit) : AlertDialog(context) {
|
||||
|
||||
private val binding = SettingsAutoDeleteDialogBinding.inflate(context.layoutInflater)
|
||||
private val layout = LayoutInflater.from(context).inflate(R.layout.settings_auto_delete_dialog, null)
|
||||
|
||||
init {
|
||||
setView(binding.root)
|
||||
setView(layout)
|
||||
setTitle(R.string.settings_auto_delete)
|
||||
setMessage(context.getString(R.string.settings_auto_delete_dialog_message))
|
||||
setButton(DialogInterface.BUTTON_NEUTRAL, context.getString(R.string.button_cancel)) { _, _ -> }
|
||||
setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.settings_auto_delete_never)) { _, _ -> listener(0) }
|
||||
setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.button_save)) { _, _ ->
|
||||
listener(binding.field.text.toString().toIntOrNull() ?: 0)
|
||||
listener(layout.field.text.toString().toIntOrNull() ?: 0)
|
||||
}
|
||||
}
|
||||
|
||||
fun setExpiry(days: Int): AutoDeleteDialog {
|
||||
when (days) {
|
||||
0 -> binding.field.text = null
|
||||
else -> binding.field.setText(days.toString())
|
||||
0 -> layout.field.text = null
|
||||
else -> layout.field.setText(days.toString())
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
+17
-20
@@ -28,20 +28,16 @@ import com.moez.QKSMS.common.util.Colors
|
||||
import com.moez.QKSMS.common.util.extensions.animateLayoutChanges
|
||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||
import com.moez.QKSMS.common.util.extensions.setTint
|
||||
import com.moez.QKSMS.databinding.SwipeActionsControllerBinding
|
||||
import com.moez.QKSMS.injection.appComponent
|
||||
import com.uber.autodispose.android.autoDisposable
|
||||
import com.uber.autodispose.android.lifecycle.autoDisposable
|
||||
import com.uber.autodispose.android.lifecycle.scope
|
||||
import com.uber.autodispose.autoDisposable
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.swipe_actions_controller.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class SwipeActionsController :
|
||||
QkController<SwipeActionsView, SwipeActionsState, SwipeActionsPresenter, SwipeActionsControllerBinding>(
|
||||
SwipeActionsControllerBinding::inflate), SwipeActionsView {
|
||||
class SwipeActionsController : QkController<SwipeActionsView, SwipeActionsState, SwipeActionsPresenter>(), SwipeActionsView {
|
||||
|
||||
@Inject override lateinit var presenter: SwipeActionsPresenter
|
||||
@Inject lateinit var actionsDialog: QkDialog
|
||||
@@ -54,24 +50,25 @@ class SwipeActionsController :
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
layoutRes = R.layout.swipe_actions_controller
|
||||
|
||||
actionsDialog.adapter.setData(R.array.settings_swipe_actions)
|
||||
}
|
||||
|
||||
override fun onViewCreated() {
|
||||
colors.theme().let { theme ->
|
||||
binding.rightIcon.setBackgroundTint(theme.theme)
|
||||
binding.rightIcon.setTint(theme.textPrimary)
|
||||
binding.leftIcon.setBackgroundTint(theme.theme)
|
||||
binding.leftIcon.setTint(theme.textPrimary)
|
||||
rightIcon.setBackgroundTint(theme.theme)
|
||||
rightIcon.setTint(theme.textPrimary)
|
||||
leftIcon.setBackgroundTint(theme.theme)
|
||||
leftIcon.setTint(theme.textPrimary)
|
||||
}
|
||||
|
||||
binding.right.postDelayed({ binding.right.animateLayoutChanges = true }, 100)
|
||||
binding.left.postDelayed({ binding.left.animateLayoutChanges = true }, 100)
|
||||
right.postDelayed({ right?.animateLayoutChanges = true }, 100)
|
||||
left.postDelayed({ left?.animateLayoutChanges = true }, 100)
|
||||
|
||||
Observable.merge(
|
||||
binding.right.clicks().map { SwipeActionsView.Action.RIGHT },
|
||||
binding.left.clicks().map { SwipeActionsView.Action.LEFT })
|
||||
right.clicks().map { SwipeActionsView.Action.RIGHT },
|
||||
left.clicks().map { SwipeActionsView.Action.LEFT })
|
||||
.autoDisposable(scope())
|
||||
.subscribe(actionClicks)
|
||||
}
|
||||
@@ -93,13 +90,13 @@ class SwipeActionsController :
|
||||
}
|
||||
|
||||
override fun render(state: SwipeActionsState) {
|
||||
binding.rightIcon.isVisible = state.rightIcon != 0
|
||||
binding.rightIcon.setImageResource(state.rightIcon)
|
||||
binding.rightLabel.text = state.rightLabel
|
||||
rightIcon.isVisible = state.rightIcon != 0
|
||||
rightIcon.setImageResource(state.rightIcon)
|
||||
rightLabel.text = state.rightLabel
|
||||
|
||||
binding.leftIcon.isVisible = state.leftIcon != 0
|
||||
binding.leftIcon.setImageResource(state.leftIcon)
|
||||
binding.leftLabel.text = state.leftLabel
|
||||
leftIcon.isVisible = state.leftIcon != 0
|
||||
leftIcon.setImageResource(state.leftIcon)
|
||||
leftLabel.text = state.leftLabel
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user