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,22 @@ 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 BackupActivity : 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(BackupController()))
|
||||
}
|
||||
|
||||
@@ -20,37 +20,42 @@ package com.moez.QKSMS.feature.backup
|
||||
|
||||
import android.content.Context
|
||||
import android.text.format.Formatter
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.base.FlowableAdapter
|
||||
import com.moez.QKSMS.common.base.QkViewHolder
|
||||
import com.moez.QKSMS.common.util.DateFormatter
|
||||
import com.moez.QKSMS.databinding.BackupListItemBinding
|
||||
import com.moez.QKSMS.model.BackupFile
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.backup_list_item.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class BackupAdapter @Inject constructor(
|
||||
private val context: Context,
|
||||
private val dateFormatter: DateFormatter
|
||||
) : FlowableAdapter<BackupFile, BackupListItemBinding>() {
|
||||
) : FlowableAdapter<BackupFile>() {
|
||||
|
||||
val backupSelected: Subject<BackupFile> = PublishSubject.create()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<BackupListItemBinding> {
|
||||
return QkViewHolder(parent, BackupListItemBinding::inflate).apply {
|
||||
binding.root.setOnClickListener { backupSelected.onNext(getItem(adapterPosition)) }
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val view = layoutInflater.inflate(R.layout.backup_list_item, parent, false)
|
||||
|
||||
return QkViewHolder(view).apply {
|
||||
view.setOnClickListener { backupSelected.onNext(getItem(adapterPosition)) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: QkViewHolder<BackupListItemBinding>, position: Int) {
|
||||
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||
val backup = getItem(position)
|
||||
|
||||
val count = backup.messages
|
||||
|
||||
holder.binding.title.text = dateFormatter.getDetailedTimestamp(backup.date)
|
||||
holder.binding.messages.text = context.resources.getQuantityString(R.plurals.backup_message_count, count, count)
|
||||
holder.binding.size.text = Formatter.formatFileSize(context, backup.size)
|
||||
holder.title.text = dateFormatter.getDetailedTimestamp(backup.date)
|
||||
holder.messages.text = context.resources.getQuantityString(R.plurals.backup_message_count, count, count)
|
||||
holder.size.text = Formatter.formatFileSize(context, backup.size)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Typeface
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.app.ActivityCompat
|
||||
@@ -37,19 +36,18 @@ import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||
import com.moez.QKSMS.common.util.extensions.setPositiveButton
|
||||
import com.moez.QKSMS.common.util.extensions.setTint
|
||||
import com.moez.QKSMS.common.widget.PreferenceView
|
||||
import com.moez.QKSMS.databinding.BackupControllerBinding
|
||||
import com.moez.QKSMS.databinding.BackupListDialogBinding
|
||||
import com.moez.QKSMS.injection.appComponent
|
||||
import com.moez.QKSMS.model.BackupFile
|
||||
import com.moez.QKSMS.repository.BackupRepository
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.backup_controller.*
|
||||
import kotlinx.android.synthetic.main.backup_list_dialog.view.*
|
||||
import kotlinx.android.synthetic.main.preference_view.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class BackupController : QkController<BackupView, BackupState, BackupPresenter, BackupControllerBinding>(
|
||||
BackupControllerBinding::inflate
|
||||
), BackupView {
|
||||
class BackupController : QkController<BackupView, BackupState, BackupPresenter>(), BackupView {
|
||||
|
||||
@Inject lateinit var adapter: BackupAdapter
|
||||
@Inject lateinit var dateFormatter: DateFormatter
|
||||
@@ -60,11 +58,11 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
||||
private val stopRestoreSubject: Subject<Unit> = PublishSubject.create()
|
||||
|
||||
private val backupFilesDialog by lazy {
|
||||
val binding = BackupListDialogBinding.inflate(LayoutInflater.from(activity))
|
||||
val view = View.inflate(activity, R.layout.backup_list_dialog, null)
|
||||
.apply { files.adapter = adapter.apply { emptyView = empty } }
|
||||
|
||||
AlertDialog.Builder(activity!!)
|
||||
.setView(binding.root)
|
||||
.setView(view)
|
||||
.setCancelable(true)
|
||||
.create()
|
||||
}
|
||||
@@ -89,6 +87,7 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
layoutRes = R.layout.backup_controller
|
||||
}
|
||||
|
||||
override fun onAttach(view: View) {
|
||||
@@ -102,17 +101,17 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
||||
super.onViewCreated()
|
||||
|
||||
themedActivity?.colors?.theme()?.let { theme ->
|
||||
binding.progressBar.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
||||
binding.progressBar.progressTintList = ColorStateList.valueOf(theme.theme)
|
||||
binding.fab.setBackgroundTint(theme.theme)
|
||||
binding.fabIcon.setTint(theme.textPrimary)
|
||||
binding.fabLabel.setTextColor(theme.textPrimary)
|
||||
progressBar.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
||||
progressBar.progressTintList = ColorStateList.valueOf(theme.theme)
|
||||
fab.setBackgroundTint(theme.theme)
|
||||
fabIcon.setTint(theme.textPrimary)
|
||||
fabLabel.setTextColor(theme.textPrimary)
|
||||
}
|
||||
|
||||
// Make the list titles bold
|
||||
binding.linearLayout.children
|
||||
.mapNotNull { view -> view as? PreferenceView }
|
||||
.map { preferenceView -> preferenceView.binding.titleView }
|
||||
linearLayout.children
|
||||
.mapNotNull { it as? PreferenceView }
|
||||
.map { it.titleView }
|
||||
.forEach { it.setTypeface(it.typeface, Typeface.BOLD) }
|
||||
}
|
||||
|
||||
@@ -124,51 +123,51 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
||||
override fun render(state: BackupState) {
|
||||
when {
|
||||
state.backupProgress.running -> {
|
||||
binding.progressIcon.setImageResource(R.drawable.ic_file_upload_black_24dp)
|
||||
binding.progressTitle.setText(R.string.backup_backing_up)
|
||||
binding.progressSummary.text = state.backupProgress.getLabel(activity!!)
|
||||
binding.progressSummary.isVisible = binding.progressSummary.text.isNotEmpty()
|
||||
binding.progressCancel.isVisible = false
|
||||
progressIcon.setImageResource(R.drawable.ic_file_upload_black_24dp)
|
||||
progressTitle.setText(R.string.backup_backing_up)
|
||||
progressSummary.text = state.backupProgress.getLabel(activity!!)
|
||||
progressSummary.isVisible = progressSummary.text.isNotEmpty()
|
||||
progressCancel.isVisible = false
|
||||
val running = (state.backupProgress as? BackupRepository.Progress.Running)
|
||||
binding.progressBar.isVisible = state.backupProgress.indeterminate || running?.max ?: 0 > 0
|
||||
binding.progressBar.isIndeterminate = state.backupProgress.indeterminate
|
||||
binding.progressBar.max = running?.max ?: 0
|
||||
binding.progressBar.progress = running?.count ?: 0
|
||||
binding.progress.isVisible = true
|
||||
binding.fab.isVisible = false
|
||||
progressBar.isVisible = state.backupProgress.indeterminate || running?.max ?: 0 > 0
|
||||
progressBar.isIndeterminate = state.backupProgress.indeterminate
|
||||
progressBar.max = running?.max ?: 0
|
||||
progressBar.progress = running?.count ?: 0
|
||||
progress.isVisible = true
|
||||
fab.isVisible = false
|
||||
}
|
||||
|
||||
state.restoreProgress.running -> {
|
||||
binding.progressIcon.setImageResource(R.drawable.ic_file_download_black_24dp)
|
||||
binding.progressTitle.setText(R.string.backup_restoring)
|
||||
binding.progressSummary.text = state.restoreProgress.getLabel(activity!!)
|
||||
binding.progressSummary.isVisible = binding.progressSummary.text.isNotEmpty()
|
||||
binding.progressCancel.isVisible = true
|
||||
progressIcon.setImageResource(R.drawable.ic_file_download_black_24dp)
|
||||
progressTitle.setText(R.string.backup_restoring)
|
||||
progressSummary.text = state.restoreProgress.getLabel(activity!!)
|
||||
progressSummary.isVisible = progressSummary.text.isNotEmpty()
|
||||
progressCancel.isVisible = true
|
||||
val running = (state.restoreProgress as? BackupRepository.Progress.Running)
|
||||
binding.progressBar.isVisible = state.restoreProgress.indeterminate || running?.max ?: 0 > 0
|
||||
binding.progressBar.isIndeterminate = state.restoreProgress.indeterminate
|
||||
binding.progressBar.max = running?.max ?: 0
|
||||
binding.progressBar.progress = running?.count ?: 0
|
||||
binding.progress.isVisible = true
|
||||
binding.fab.isVisible = false
|
||||
progressBar.isVisible = state.restoreProgress.indeterminate || running?.max ?: 0 > 0
|
||||
progressBar.isIndeterminate = state.restoreProgress.indeterminate
|
||||
progressBar.max = running?.max ?: 0
|
||||
progressBar.progress = running?.count ?: 0
|
||||
progress.isVisible = true
|
||||
fab.isVisible = false
|
||||
}
|
||||
|
||||
else -> {
|
||||
binding.progress.isVisible = false
|
||||
binding.fab.isVisible = true
|
||||
progress.isVisible = false
|
||||
fab.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
binding.backup.summary = state.lastBackup
|
||||
backup.summary = state.lastBackup
|
||||
|
||||
adapter.data = state.backups
|
||||
|
||||
binding.fabIcon.setImageResource(when (state.upgraded) {
|
||||
fabIcon.setImageResource(when (state.upgraded) {
|
||||
true -> R.drawable.ic_file_upload_black_24dp
|
||||
false -> R.drawable.ic_star_black_24dp
|
||||
})
|
||||
|
||||
binding.fabLabel.setText(when (state.upgraded) {
|
||||
fabLabel.setText(when (state.upgraded) {
|
||||
true -> R.string.backup_now
|
||||
false -> R.string.title_qksms_plus
|
||||
})
|
||||
@@ -176,18 +175,18 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
||||
|
||||
override fun activityVisible(): Observable<*> = activityVisibleSubject
|
||||
|
||||
override fun restoreClicks(): Observable<*> = binding.restore.clicks()
|
||||
override fun restoreClicks(): Observable<*> = restore.clicks()
|
||||
|
||||
override fun restoreFileSelected(): Observable<BackupFile> = adapter.backupSelected
|
||||
.doOnNext { backupFilesDialog.dismiss() }
|
||||
|
||||
override fun restoreConfirmed(): Observable<*> = confirmRestoreSubject
|
||||
|
||||
override fun stopRestoreClicks(): Observable<*> = binding.progressCancel.clicks()
|
||||
override fun stopRestoreClicks(): Observable<*> = progressCancel.clicks()
|
||||
|
||||
override fun stopRestoreConfirmed(): Observable<*> = stopRestoreSubject
|
||||
|
||||
override fun fabClicks(): Observable<*> = binding.fab.clicks()
|
||||
override fun fabClicks(): Observable<*> = fab.clicks()
|
||||
|
||||
override fun requestStoragePermission() {
|
||||
ActivityCompat.requestPermissions(activity!!, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 0)
|
||||
|
||||
Reference in New Issue
Block a user