mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 05:38:52 +01:00
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:
+1
-1
@@ -41,7 +41,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.6.3'
|
classpath 'com.android.tools.build:gradle:3.5.4'
|
||||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
|
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
|
||||||
classpath 'com.google.gms:google-services:4.2.0'
|
classpath 'com.google.gms:google-services:4.2.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
#Tue Mar 03 19:56:50 EST 2020
|
#Tue Dec 03 23:30:52 EST 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'realm-android' // Realm needs to be before Kotlin or the build will fail
|
apply plugin: 'realm-android' // Realm needs to be before Kotlin or the build will fail
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -69,10 +70,6 @@ android {
|
|||||||
noAnalytics { dimension "analytics" }
|
noAnalytics { dimension "analytics" }
|
||||||
}
|
}
|
||||||
|
|
||||||
viewBinding {
|
|
||||||
enabled = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (System.getenv("CI") == "true") {
|
if (System.getenv("CI") == "true") {
|
||||||
signingConfigs.release.storeFile = file("../keystore")
|
signingConfigs.release.storeFile = file("../keystore")
|
||||||
signingConfigs.release.storePassword = System.getenv("keystore_password")
|
signingConfigs.release.storePassword = System.getenv("keystore_password")
|
||||||
@@ -81,6 +78,10 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
androidExtensions {
|
||||||
|
experimental = true
|
||||||
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
noAnalyticsDebug
|
noAnalyticsDebug
|
||||||
noAnalyticsRelease
|
noAnalyticsRelease
|
||||||
|
|||||||
@@ -20,26 +20,26 @@ package com.moez.QKSMS.common
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.ArrayRes
|
import androidx.annotation.ArrayRes
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.databinding.MenuListItemBinding
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.menu_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.menu_list_item.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
data class MenuItem(val title: String, val actionId: Int)
|
data class MenuItem(val title: String, val actionId: Int)
|
||||||
|
|
||||||
class MenuItemAdapter @Inject constructor(
|
class MenuItemAdapter @Inject constructor(private val context: Context, private val colors: Colors) : QkAdapter<MenuItem>() {
|
||||||
private val context: Context,
|
|
||||||
private val colors: Colors
|
|
||||||
) : QkAdapter<MenuItem, MenuListItemBinding>() {
|
|
||||||
|
|
||||||
val menuItemClicks: Subject<Int> = PublishSubject.create()
|
val menuItemClicks: Subject<Int> = PublishSubject.create()
|
||||||
|
|
||||||
@@ -47,13 +47,13 @@ class MenuItemAdapter @Inject constructor(
|
|||||||
|
|
||||||
var selectedItem: Int? = null
|
var selectedItem: Int? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
val old = data.map { it.actionId }.indexOfFirst { it == field }.takeIf { it != -1 }
|
val old = data.map { it.actionId }.indexOfFirst { it == field }
|
||||||
val new = data.map { it.actionId }.indexOfFirst { it == value }.takeIf { it != -1 }
|
val new = data.map { it.actionId }.indexOfFirst { it == value }
|
||||||
|
|
||||||
field = value
|
field = value
|
||||||
|
|
||||||
old?.let(::notifyItemChanged)
|
old.let { notifyItemChanged(it) }
|
||||||
new?.let(::notifyItemChanged)
|
new.let { notifyItemChanged(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setData(@ArrayRes titles: Int, @ArrayRes values: Int = -1) {
|
fun setData(@ArrayRes titles: Int, @ArrayRes values: Int = -1) {
|
||||||
@@ -63,28 +63,31 @@ class MenuItemAdapter @Inject constructor(
|
|||||||
.mapIndexed { index, title -> MenuItem(title, valueInts?.getOrNull(index) ?: index) }
|
.mapIndexed { index, title -> MenuItem(title, valueInts?.getOrNull(index) ?: index) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<MenuListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, MenuListItemBinding::inflate).apply {
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
val states = arrayOf(
|
val view = layoutInflater.inflate(R.layout.menu_list_item, parent, false)
|
||||||
intArrayOf(android.R.attr.state_activated),
|
|
||||||
intArrayOf(-android.R.attr.state_activated))
|
|
||||||
|
|
||||||
val text = parent.context.resolveThemeColor(android.R.attr.textColorTertiary)
|
val states = arrayOf(
|
||||||
binding.check.imageTintList = ColorStateList(states, intArrayOf(colors.theme().theme, text))
|
intArrayOf(android.R.attr.state_activated),
|
||||||
|
intArrayOf(-android.R.attr.state_activated))
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
val text = parent.context.resolveThemeColor(android.R.attr.textColorTertiary)
|
||||||
|
view.check.imageTintList = ColorStateList(states, intArrayOf(colors.theme().theme, text))
|
||||||
|
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
|
view.setOnClickListener {
|
||||||
val menuItem = getItem(adapterPosition)
|
val menuItem = getItem(adapterPosition)
|
||||||
menuItemClicks.onNext(menuItem.actionId)
|
menuItemClicks.onNext(menuItem.actionId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<MenuListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val menuItem = getItem(position)
|
val menuItem = getItem(position)
|
||||||
|
|
||||||
holder.binding.title.text = menuItem.title
|
holder.title.text = menuItem.title
|
||||||
holder.binding.check.isActivated = (menuItem.actionId == selectedItem)
|
holder.check.isActivated = (menuItem.actionId == selectedItem)
|
||||||
holder.binding.check.setVisible(selectedItem != null)
|
holder.check.setVisible(selectedItem != null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package com.moez.QKSMS.common.base
|
|||||||
|
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ import io.reactivex.disposables.Disposable
|
|||||||
* Base RecyclerView.Adapter that provides some convenience when creating a new Adapter, such as
|
* Base RecyclerView.Adapter that provides some convenience when creating a new Adapter, such as
|
||||||
* data list handing and item animations
|
* data list handing and item animations
|
||||||
*/
|
*/
|
||||||
abstract class FlowableAdapter<T, Binding: ViewBinding> : QkAdapter<T, Binding>() {
|
abstract class FlowableAdapter<T> : QkAdapter<T>() {
|
||||||
|
|
||||||
var flowable: Flowable<List<T>>? = null
|
var flowable: Flowable<List<T>>? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -22,20 +22,14 @@ import android.annotation.SuppressLint
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.Toolbar
|
|
||||||
import com.moez.QKSMS.R
|
|
||||||
import com.moez.QKSMS.common.widget.QkTextView
|
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
|
||||||
abstract class QkActivity : AppCompatActivity() {
|
abstract class QkActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val toolbar by lazy { findViewById<Toolbar>(R.id.toolbar)!! }
|
|
||||||
|
|
||||||
protected val menu: Subject<Menu> = BehaviorSubject.create()
|
protected val menu: Subject<Menu> = BehaviorSubject.create()
|
||||||
protected val toolbarTitle by lazy { findViewById<QkTextView>(R.id.toolbarTitle) }
|
|
||||||
|
|
||||||
@SuppressLint("InlinedApi")
|
@SuppressLint("InlinedApi")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -53,8 +47,8 @@ abstract class QkActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setContentView(view: View?) {
|
override fun setContentView(layoutResID: Int) {
|
||||||
super.setContentView(view)
|
super.setContentView(layoutResID)
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
title = title // The title may have been set before layout inflation
|
title = title // The title may have been set before layout inflation
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.view.View
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
@@ -31,7 +30,7 @@ import io.reactivex.subjects.Subject
|
|||||||
* Base RecyclerView.Adapter that provides some convenience when creating a new Adapter, such as
|
* Base RecyclerView.Adapter that provides some convenience when creating a new Adapter, such as
|
||||||
* data list handing and item animations
|
* data list handing and item animations
|
||||||
*/
|
*/
|
||||||
abstract class QkAdapter<T, Binding: ViewBinding> : RecyclerView.Adapter<QkViewHolder<Binding>>() {
|
abstract class QkAdapter<T> : RecyclerView.Adapter<QkViewHolder>() {
|
||||||
|
|
||||||
var data: List<T> = ArrayList()
|
var data: List<T> = ArrayList()
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -21,17 +21,15 @@ package com.moez.QKSMS.common.base
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.annotation.LayoutRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.widget.Toolbar
|
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.bluelinelabs.conductor.archlifecycle.LifecycleController
|
import com.bluelinelabs.conductor.archlifecycle.LifecycleController
|
||||||
import com.moez.QKSMS.R
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import com.moez.QKSMS.common.widget.QkTextView
|
import kotlinx.android.synthetic.*
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.view.*
|
||||||
|
|
||||||
abstract class QkController<ViewContract : QkViewContract<State>, State, Presenter : QkPresenter<ViewContract, State>, Binding : ViewBinding>(
|
abstract class QkController<ViewContract : QkViewContract<State>, State, Presenter : QkPresenter<ViewContract, State>> : LifecycleController(), LayoutContainer {
|
||||||
private val bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> Binding
|
|
||||||
) : LifecycleController() {
|
|
||||||
|
|
||||||
abstract var presenter: Presenter
|
abstract var presenter: Presenter
|
||||||
|
|
||||||
@@ -41,15 +39,16 @@ abstract class QkController<ViewContract : QkViewContract<State>, State, Present
|
|||||||
protected val themedActivity: QkThemedActivity?
|
protected val themedActivity: QkThemedActivity?
|
||||||
get() = activity as? QkThemedActivity
|
get() = activity as? QkThemedActivity
|
||||||
|
|
||||||
private val toolbar by lazy { view?.findViewById<Toolbar>(R.id.toolbar) }
|
override var containerView: View? = null
|
||||||
private val toolbarTitle by lazy { view?.findViewById<QkTextView>(R.id.toolbarTitle) }
|
|
||||||
|
|
||||||
lateinit var binding: Binding
|
@LayoutRes
|
||||||
|
var layoutRes: Int = 0
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||||
binding = bindingInflater(inflater, container, false)
|
return inflater.inflate(layoutRes, container, false).also {
|
||||||
onViewCreated()
|
containerView = it
|
||||||
return binding.root
|
onViewCreated()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun onViewCreated() {
|
open fun onViewCreated() {
|
||||||
@@ -61,13 +60,18 @@ abstract class QkController<ViewContract : QkViewContract<State>, State, Present
|
|||||||
|
|
||||||
fun setTitle(title: CharSequence?) {
|
fun setTitle(title: CharSequence?) {
|
||||||
activity?.title = title
|
activity?.title = title
|
||||||
toolbarTitle?.text = title
|
view?.toolbarTitle?.text = title
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showBackButton(show: Boolean) {
|
fun showBackButton(show: Boolean) {
|
||||||
appCompatActivity?.supportActionBar?.setDisplayHomeAsUpEnabled(show)
|
appCompatActivity?.supportActionBar?.setDisplayHomeAsUpEnabled(show)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView(view: View) {
|
||||||
|
containerView = null
|
||||||
|
clearFindViewByIdCache()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
presenter.onCleared()
|
presenter.onCleared()
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package com.moez.QKSMS.common.base
|
|||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
@@ -31,8 +30,7 @@ import io.realm.RealmRecyclerViewAdapter
|
|||||||
import io.realm.RealmResults
|
import io.realm.RealmResults
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
abstract class QkRealmAdapter<T : RealmModel, Binding : ViewBinding>
|
abstract class QkRealmAdapter<T : RealmModel> : RealmRecyclerViewAdapter<T, QkViewHolder>(null, true) {
|
||||||
: RealmRecyclerViewAdapter<T, QkViewHolder<Binding>>(null, true) {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This view can be set, and the adapter will automatically control the visibility of this view
|
* This view can be set, and the adapter will automatically control the visibility of this view
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
|||||||
import io.reactivex.rxkotlin.Observables
|
import io.reactivex.rxkotlin.Observables
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -133,7 +134,7 @@ abstract class QkThemedActivity : QkActivity() {
|
|||||||
|
|
||||||
// Set the color for the overflow and navigation icon
|
// Set the color for the overflow and navigation icon
|
||||||
val textSecondary = resolveThemeColor(android.R.attr.textColorSecondary)
|
val textSecondary = resolveThemeColor(android.R.attr.textColorSecondary)
|
||||||
toolbar.overflowIcon = toolbar.overflowIcon?.apply { setTint(textSecondary) }
|
toolbar?.overflowIcon = toolbar?.overflowIcon?.apply { setTint(textSecondary) }
|
||||||
|
|
||||||
// Update the colours of the menu items
|
// Update the colours of the menu items
|
||||||
Observables.combineLatest(menu, theme) { menu, theme ->
|
Observables.combineLatest(menu, theme) { menu, theme ->
|
||||||
|
|||||||
@@ -18,16 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.common.base
|
package com.moez.QKSMS.common.base
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewbinding.ViewBinding
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
|
|
||||||
class QkViewHolder<T : ViewBinding>(val binding: T) : RecyclerView.ViewHolder(binding.root) {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
parent: ViewGroup,
|
|
||||||
bindingInflator: (LayoutInflater, ViewGroup, Boolean) -> T
|
|
||||||
) : this(bindingInflator(LayoutInflater.from(parent.context), parent, false))
|
|
||||||
|
|
||||||
|
class QkViewHolder(view: View) : RecyclerView.ViewHolder(view), LayoutContainer {
|
||||||
|
override val containerView: View = view
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,7 @@ package com.moez.QKSMS.common.util.extensions
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
|
|
||||||
fun Activity.dismissKeyboard() {
|
fun Activity.dismissKeyboard() {
|
||||||
window.currentFocus?.let { focus ->
|
window.currentFocus?.let { focus ->
|
||||||
@@ -33,9 +30,3 @@ fun Activity.dismissKeyboard() {
|
|||||||
focus.clearFocus()
|
focus.clearFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <T : ViewBinding> AppCompatActivity.viewBinding(
|
|
||||||
crossinline bindingInflater: (LayoutInflater) -> T
|
|
||||||
): Lazy<T> = lazy(LazyThreadSafetyMode.NONE) {
|
|
||||||
bindingInflater(layoutInflater)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import android.content.Context
|
|||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -32,7 +31,6 @@ import android.widget.EditText
|
|||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
|
||||||
var ViewGroup.animateLayoutChanges: Boolean
|
var ViewGroup.animateLayoutChanges: Boolean
|
||||||
@@ -125,7 +123,3 @@ fun RecyclerView.scrapViews() {
|
|||||||
recycledViewPool.clear()
|
recycledViewPool.clear()
|
||||||
adapter?.notifyDataSetChanged()
|
adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <T : ViewBinding> ViewGroup.viewBinding(crossinline bindingInflater: (LayoutInflater, ViewGroup) -> T): T {
|
|
||||||
return bindingInflater(LayoutInflater.from(context), this)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,17 +20,17 @@ package com.moez.QKSMS.common.widget
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.Navigator
|
import com.moez.QKSMS.common.Navigator
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.AvatarViewBinding
|
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
import com.moez.QKSMS.util.GlideApp
|
import com.moez.QKSMS.util.GlideApp
|
||||||
|
import kotlinx.android.synthetic.main.avatar_view.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AvatarView @JvmOverloads constructor(
|
class AvatarView @JvmOverloads constructor(
|
||||||
@@ -39,21 +39,21 @@ class AvatarView @JvmOverloads constructor(
|
|||||||
|
|
||||||
@Inject lateinit var colors: Colors
|
@Inject lateinit var colors: Colors
|
||||||
@Inject lateinit var navigator: Navigator
|
@Inject lateinit var navigator: Navigator
|
||||||
private lateinit var theme: Colors.Theme
|
|
||||||
|
|
||||||
private val binding = viewBinding(AvatarViewBinding::inflate)
|
|
||||||
|
|
||||||
private var lookupKey: String? = null
|
private var lookupKey: String? = null
|
||||||
private var fullName: String? = null
|
private var fullName: String? = null
|
||||||
private var photoUri: String? = null
|
private var photoUri: String? = null
|
||||||
private var lastUpdated: Long? = null
|
private var lastUpdated: Long? = null
|
||||||
|
private var theme: Colors.Theme
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (!isInEditMode) {
|
if (!isInEditMode) {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
theme = colors.theme()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
theme = colors.theme()
|
||||||
|
|
||||||
|
View.inflate(context, R.layout.avatar_view, this)
|
||||||
setBackgroundResource(R.drawable.circle)
|
setBackgroundResource(R.drawable.circle)
|
||||||
clipToOutline = true
|
clipToOutline = true
|
||||||
}
|
}
|
||||||
@@ -81,8 +81,8 @@ class AvatarView @JvmOverloads constructor(
|
|||||||
private fun updateView() {
|
private fun updateView() {
|
||||||
// Apply theme
|
// Apply theme
|
||||||
setBackgroundTint(theme.theme)
|
setBackgroundTint(theme.theme)
|
||||||
binding.initial.setTextColor(theme.textPrimary)
|
initial.setTextColor(theme.textPrimary)
|
||||||
binding.icon.setTint(theme.textPrimary)
|
icon.setTint(theme.textPrimary)
|
||||||
|
|
||||||
val initials = fullName
|
val initials = fullName
|
||||||
?.substringBefore(',')
|
?.substringBefore(',')
|
||||||
@@ -93,18 +93,18 @@ class AvatarView @JvmOverloads constructor(
|
|||||||
.map { initial -> initial.toString() }
|
.map { initial -> initial.toString() }
|
||||||
|
|
||||||
if (initials.isNotEmpty()) {
|
if (initials.isNotEmpty()) {
|
||||||
binding.initial.text = if (initials.size > 1) initials.first() + initials.last() else initials.first()
|
initial.text = if (initials.size > 1) initials.first() + initials.last() else initials.first()
|
||||||
binding.icon.visibility = GONE
|
icon.visibility = GONE
|
||||||
} else {
|
} else {
|
||||||
binding.initial.text = null
|
initial.text = null
|
||||||
binding.icon.visibility = VISIBLE
|
icon.visibility = VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.photo.setImageDrawable(null)
|
photo.setImageDrawable(null)
|
||||||
photoUri?.let { photoUri ->
|
photoUri?.let { photoUri ->
|
||||||
GlideApp.with(binding.photo)
|
GlideApp.with(photo)
|
||||||
.load(photoUri)
|
.load(photoUri)
|
||||||
.into(binding.photo)
|
.into(photo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,16 @@ package com.moez.QKSMS.common.widget
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.util.extensions.getColorCompat
|
import com.moez.QKSMS.common.util.extensions.getColorCompat
|
||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.GroupAvatarViewBinding
|
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
|
import kotlinx.android.synthetic.main.group_avatar_view.view.*
|
||||||
|
|
||||||
class GroupAvatarView @JvmOverloads constructor(
|
class GroupAvatarView @JvmOverloads constructor(
|
||||||
context: Context, attrs: AttributeSet? = null
|
context: Context, attrs: AttributeSet? = null
|
||||||
@@ -40,7 +41,9 @@ class GroupAvatarView @JvmOverloads constructor(
|
|||||||
updateView()
|
updateView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val binding = viewBinding(GroupAvatarViewBinding::inflate)
|
init {
|
||||||
|
View.inflate(context, R.layout.group_avatar_view, this)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onFinishInflate() {
|
override fun onFinishInflate() {
|
||||||
super.onFinishInflate()
|
super.onFinishInflate()
|
||||||
@@ -51,18 +54,18 @@ class GroupAvatarView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateView() {
|
private fun updateView() {
|
||||||
binding.avatar1Frame.setBackgroundTint(when (recipients.size > 1) {
|
avatar1Frame.setBackgroundTint(when (recipients.size > 1) {
|
||||||
true -> context.resolveThemeColor(android.R.attr.windowBackground)
|
true -> context.resolveThemeColor(android.R.attr.windowBackground)
|
||||||
false -> context.getColorCompat(android.R.color.transparent)
|
false -> context.getColorCompat(android.R.color.transparent)
|
||||||
})
|
})
|
||||||
binding.avatar1Frame.updateLayoutParams<LayoutParams> {
|
avatar1Frame.updateLayoutParams<LayoutParams> {
|
||||||
matchConstraintPercentWidth = if (recipients.size > 1) 0.75f else 1.0f
|
matchConstraintPercentWidth = if (recipients.size > 1) 0.75f else 1.0f
|
||||||
}
|
}
|
||||||
binding.avatar2.isVisible = recipients.size > 1
|
avatar2.isVisible = recipients.size > 1
|
||||||
|
|
||||||
|
|
||||||
recipients.getOrNull(0).run(binding.avatar1::setRecipient)
|
recipients.getOrNull(0).run(avatar1::setRecipient)
|
||||||
recipients.getOrNull(1).run(binding.avatar2::setRecipient)
|
recipients.getOrNull(1).run(avatar2::setRecipient)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ import android.view.LayoutInflater
|
|||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.viewpager.widget.ViewPager
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.forEach
|
import com.moez.QKSMS.common.util.extensions.forEach
|
||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.databinding.TabViewBinding
|
|
||||||
import com.moez.QKSMS.extensions.Optional
|
import com.moez.QKSMS.extensions.Optional
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import com.moez.QKSMS.repository.ConversationRepository
|
import com.moez.QKSMS.repository.ConversationRepository
|
||||||
@@ -36,6 +36,7 @@ import com.uber.autodispose.android.ViewScopeProvider
|
|||||||
import com.uber.autodispose.autoDisposable
|
import com.uber.autodispose.autoDisposable
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.tab_view.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class PagerTitleView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) {
|
class PagerTitleView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) {
|
||||||
@@ -65,11 +66,11 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
removeAllViews()
|
removeAllViews()
|
||||||
|
|
||||||
pager?.adapter?.count?.forEach { position ->
|
pager?.adapter?.count?.forEach { position ->
|
||||||
val binding = TabViewBinding.inflate(LayoutInflater.from(context), this, false)
|
val view = LayoutInflater.from(context).inflate(R.layout.tab_view, this, false)
|
||||||
binding.label.text = pager?.adapter?.getPageTitle(position)
|
view.label.text = pager?.adapter?.getPageTitle(position)
|
||||||
binding.root.setOnClickListener { pager?.currentItem = position }
|
view.setOnClickListener { pager?.currentItem = position }
|
||||||
|
|
||||||
addView(binding.root)
|
addView(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
childCount.forEach { index ->
|
childCount.forEach { index ->
|
||||||
|
|||||||
@@ -28,9 +28,8 @@ import com.moez.QKSMS.R
|
|||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeAttribute
|
import com.moez.QKSMS.common.util.extensions.resolveThemeAttribute
|
||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColorStateList
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColorStateList
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.PreferenceViewBinding
|
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
|
import kotlinx.android.synthetic.main.preference_view.view.*
|
||||||
|
|
||||||
class PreferenceView @JvmOverloads constructor(
|
class PreferenceView @JvmOverloads constructor(
|
||||||
context: Context, attrs: AttributeSet? = null
|
context: Context, attrs: AttributeSet? = null
|
||||||
@@ -43,7 +42,7 @@ class PreferenceView @JvmOverloads constructor(
|
|||||||
if (isInEditMode) {
|
if (isInEditMode) {
|
||||||
findViewById<TextView>(R.id.titleView).text = value
|
findViewById<TextView>(R.id.titleView).text = value
|
||||||
} else {
|
} else {
|
||||||
binding.titleView.text = value
|
titleView.text = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,23 +57,22 @@ class PreferenceView @JvmOverloads constructor(
|
|||||||
setVisible(value?.isNotEmpty() == true)
|
setVisible(value?.isNotEmpty() == true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.summaryView.text = value
|
summaryView.text = value
|
||||||
binding.summaryView.setVisible(value?.isNotEmpty() == true)
|
summaryView.setVisible(value?.isNotEmpty() == true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val binding: PreferenceViewBinding = viewBinding(PreferenceViewBinding::inflate)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (!isInEditMode) {
|
if (!isInEditMode) {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View.inflate(context, R.layout.preference_view, this)
|
||||||
setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground))
|
setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground))
|
||||||
orientation = HORIZONTAL
|
orientation = HORIZONTAL
|
||||||
gravity = Gravity.CENTER_VERTICAL
|
gravity = Gravity.CENTER_VERTICAL
|
||||||
|
|
||||||
binding.icon.imageTintList = context.resolveThemeColorStateList(android.R.attr.textColorSecondary)
|
icon.imageTintList = context.resolveThemeColorStateList(android.R.attr.textColorSecondary)
|
||||||
|
|
||||||
context.obtainStyledAttributes(attrs, R.styleable.PreferenceView).run {
|
context.obtainStyledAttributes(attrs, R.styleable.PreferenceView).run {
|
||||||
title = getString(R.styleable.PreferenceView_title)
|
title = getString(R.styleable.PreferenceView_title)
|
||||||
@@ -82,21 +80,17 @@ class PreferenceView @JvmOverloads constructor(
|
|||||||
|
|
||||||
// If there's a custom view used for the preference's widget, inflate it
|
// If there's a custom view used for the preference's widget, inflate it
|
||||||
getResourceId(R.styleable.PreferenceView_widget, -1).takeIf { it != -1 }?.let { id ->
|
getResourceId(R.styleable.PreferenceView_widget, -1).takeIf { it != -1 }?.let { id ->
|
||||||
View.inflate(context, id, binding.widgetFrame)
|
View.inflate(context, id, widgetFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an icon is being used, set up the icon view
|
// If an icon is being used, set up the icon view
|
||||||
getResourceId(R.styleable.PreferenceView_icon, -1).takeIf { it != -1 }?.let { id ->
|
getResourceId(R.styleable.PreferenceView_icon, -1).takeIf { it != -1 }?.let { id ->
|
||||||
binding.icon.setVisible(true)
|
icon.setVisible(true)
|
||||||
binding.icon.setImageResource(id)
|
icon.setImageResource(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
recycle()
|
recycle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : View> widget(): T {
|
}
|
||||||
return binding.widgetFrame.getChildAt(0) as T
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -19,15 +19,17 @@
|
|||||||
package com.moez.QKSMS.common.widget
|
package com.moez.QKSMS.common.widget
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.view.LayoutInflater
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.databinding.QkDialogBinding
|
import kotlinx.android.synthetic.main.qk_dialog.view.*
|
||||||
|
|
||||||
class QkDialog(private val context: Activity) : AlertDialog(context) {
|
class QkDialog(private val context: Activity) : AlertDialog(context) {
|
||||||
|
|
||||||
private val binding = QkDialogBinding.inflate(context.layoutInflater)
|
private val view = LayoutInflater.from(context).inflate(R.layout.qk_dialog, null)
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
var titleRes: Int? = null
|
var titleRes: Int? = null
|
||||||
@@ -39,8 +41,8 @@ class QkDialog(private val context: Activity) : AlertDialog(context) {
|
|||||||
var title: String? = null
|
var title: String? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
binding.title.text = value
|
view.title.text = value
|
||||||
binding.title.isVisible = !value.isNullOrBlank()
|
view.title.isVisible = !value.isNullOrBlank()
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
@@ -53,15 +55,15 @@ class QkDialog(private val context: Activity) : AlertDialog(context) {
|
|||||||
var subtitle: String? = null
|
var subtitle: String? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
binding.subtitle.text = value
|
view.subtitle.text = value
|
||||||
binding.subtitle.isVisible = !value.isNullOrBlank()
|
view.subtitle.isVisible = !value.isNullOrBlank()
|
||||||
}
|
}
|
||||||
|
|
||||||
var adapter: QkAdapter<*, *>? = null
|
var adapter: QkAdapter<*>? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
binding.list.isVisible = value != null
|
view.list.isVisible = value != null
|
||||||
binding.list.adapter = value
|
view.list.adapter = value
|
||||||
}
|
}
|
||||||
|
|
||||||
var positiveButtonListener: (() -> Unit)? = null
|
var positiveButtonListener: (() -> Unit)? = null
|
||||||
@@ -70,9 +72,9 @@ class QkDialog(private val context: Activity) : AlertDialog(context) {
|
|||||||
var positiveButton: Int? = null
|
var positiveButton: Int? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
value?.run(binding.positiveButton::setText)
|
value?.run(view.positiveButton::setText)
|
||||||
binding.positiveButton.isVisible = value != null
|
view.positiveButton.isVisible = value != null
|
||||||
binding.positiveButton.setOnClickListener {
|
view.positiveButton.setOnClickListener {
|
||||||
positiveButtonListener?.invoke() ?: dismiss()
|
positiveButtonListener?.invoke() ?: dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,9 +85,9 @@ class QkDialog(private val context: Activity) : AlertDialog(context) {
|
|||||||
var negativeButton: Int? = null
|
var negativeButton: Int? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
value?.run(binding.negativeButton::setText)
|
value?.run(view.negativeButton::setText)
|
||||||
binding.negativeButton.isVisible = value != null
|
view.negativeButton.isVisible = value != null
|
||||||
binding.negativeButton.setOnClickListener {
|
view.negativeButton.setOnClickListener {
|
||||||
negativeButtonListener?.invoke() ?: dismiss()
|
negativeButtonListener?.invoke() ?: dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +99,7 @@ class QkDialog(private val context: Activity) : AlertDialog(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setView(binding.root)
|
setView(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,8 @@ import com.moez.QKSMS.common.util.extensions.forwardTouches
|
|||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeAttribute
|
import com.moez.QKSMS.common.util.extensions.resolveThemeAttribute
|
||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.RadioPreferenceViewBinding
|
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
|
import kotlinx.android.synthetic.main.radio_preference_view.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class RadioPreferenceView @JvmOverloads constructor(
|
class RadioPreferenceView @JvmOverloads constructor(
|
||||||
@@ -48,7 +47,7 @@ class RadioPreferenceView @JvmOverloads constructor(
|
|||||||
if (isInEditMode) {
|
if (isInEditMode) {
|
||||||
findViewById<TextView>(R.id.titleView).text = value
|
findViewById<TextView>(R.id.titleView).text = value
|
||||||
} else {
|
} else {
|
||||||
binding.titleView.text = value
|
titleView.text = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,18 +62,17 @@ class RadioPreferenceView @JvmOverloads constructor(
|
|||||||
setVisible(value?.isNotEmpty() == true)
|
setVisible(value?.isNotEmpty() == true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.summaryView.text = value
|
summaryView.text = value
|
||||||
binding.summaryView.setVisible(value?.isNotEmpty() == true)
|
summaryView.setVisible(value?.isNotEmpty() == true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val binding: RadioPreferenceViewBinding = viewBinding(RadioPreferenceViewBinding::inflate)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (!isInEditMode) {
|
if (!isInEditMode) {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View.inflate(context, R.layout.radio_preference_view, this)
|
||||||
setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground))
|
setBackgroundResource(context.resolveThemeAttribute(R.attr.selectableItemBackground))
|
||||||
|
|
||||||
val states = arrayOf(
|
val states = arrayOf(
|
||||||
@@ -86,8 +84,8 @@ class RadioPreferenceView @JvmOverloads constructor(
|
|||||||
false -> colors.theme().theme
|
false -> colors.theme().theme
|
||||||
}
|
}
|
||||||
val textSecondary = context.resolveThemeColor(android.R.attr.textColorTertiary)
|
val textSecondary = context.resolveThemeColor(android.R.attr.textColorTertiary)
|
||||||
binding.radioButton.buttonTintList = ColorStateList(states, intArrayOf(themeColor, textSecondary))
|
radioButton.buttonTintList = ColorStateList(states, intArrayOf(themeColor, textSecondary))
|
||||||
binding.radioButton.forwardTouches(this)
|
radioButton.forwardTouches(this)
|
||||||
|
|
||||||
context.obtainStyledAttributes(attrs, R.styleable.RadioPreferenceView)?.run {
|
context.obtainStyledAttributes(attrs, R.styleable.RadioPreferenceView)?.run {
|
||||||
title = getString(R.styleable.RadioPreferenceView_title)
|
title = getString(R.styleable.RadioPreferenceView_title)
|
||||||
@@ -95,11 +93,11 @@ class RadioPreferenceView @JvmOverloads constructor(
|
|||||||
|
|
||||||
// If there's a custom view used for the preference's widget, inflate it
|
// If there's a custom view used for the preference's widget, inflate it
|
||||||
getResourceId(R.styleable.RadioPreferenceView_widget, -1).takeIf { it != -1 }?.let { id ->
|
getResourceId(R.styleable.RadioPreferenceView_widget, -1).takeIf { it != -1 }?.let { id ->
|
||||||
View.inflate(context, id, binding.widgetFrame)
|
View.inflate(context, id, widgetFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
recycle()
|
recycle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,27 +20,28 @@ package com.moez.QKSMS.common.widget
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
|
import android.view.LayoutInflater
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.databinding.TextInputDialogBinding
|
import kotlinx.android.synthetic.main.text_input_dialog.view.*
|
||||||
|
|
||||||
class TextInputDialog(context: Activity, hint: String, listener: (String) -> Unit) : AlertDialog(context) {
|
class TextInputDialog(context: Activity, hint: String, listener: (String) -> Unit) : AlertDialog(context) {
|
||||||
|
|
||||||
private val binding = TextInputDialogBinding.inflate(context.layoutInflater)
|
private val layout = LayoutInflater.from(context).inflate(R.layout.text_input_dialog, null)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
binding.field.hint = hint
|
layout.field.hint = hint
|
||||||
|
|
||||||
setView(binding.root)
|
setView(layout)
|
||||||
setButton(DialogInterface.BUTTON_NEUTRAL, context.getString(R.string.button_cancel)) { _, _ -> }
|
setButton(DialogInterface.BUTTON_NEUTRAL, context.getString(R.string.button_cancel)) { _, _ -> }
|
||||||
setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.button_delete)) { _, _ -> listener("") }
|
setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.button_delete)) { _, _ -> listener("") }
|
||||||
setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.button_save)) { _, _ ->
|
setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.button_save)) { _, _ ->
|
||||||
listener(binding.field.text.toString())
|
listener(layout.field.text.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setText(text: String): TextInputDialog {
|
fun setText(text: String): TextInputDialog {
|
||||||
binding.field.setText(text)
|
layout.field.setText(text)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,22 +22,22 @@ import android.os.Bundle
|
|||||||
import com.bluelinelabs.conductor.Conductor
|
import com.bluelinelabs.conductor.Conductor
|
||||||
import com.bluelinelabs.conductor.Router
|
import com.bluelinelabs.conductor.Router
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
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 dagger.android.AndroidInjection
|
||||||
|
import kotlinx.android.synthetic.main.container_activity.*
|
||||||
|
|
||||||
|
|
||||||
class BackupActivity : QkThemedActivity() {
|
class BackupActivity : QkThemedActivity() {
|
||||||
|
|
||||||
private val binding by viewBinding(ContainerActivityBinding::inflate)
|
|
||||||
private lateinit var router: Router
|
private lateinit var router: Router
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
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()) {
|
if (!router.hasRootController()) {
|
||||||
router.setRoot(RouterTransaction.with(BackupController()))
|
router.setRoot(RouterTransaction.with(BackupController()))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,37 +20,42 @@ package com.moez.QKSMS.feature.backup
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.format.Formatter
|
import android.text.format.Formatter
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.FlowableAdapter
|
import com.moez.QKSMS.common.base.FlowableAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.DateFormatter
|
import com.moez.QKSMS.common.util.DateFormatter
|
||||||
import com.moez.QKSMS.databinding.BackupListItemBinding
|
|
||||||
import com.moez.QKSMS.model.BackupFile
|
import com.moez.QKSMS.model.BackupFile
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.backup_list_item.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BackupAdapter @Inject constructor(
|
class BackupAdapter @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val dateFormatter: DateFormatter
|
private val dateFormatter: DateFormatter
|
||||||
) : FlowableAdapter<BackupFile, BackupListItemBinding>() {
|
) : FlowableAdapter<BackupFile>() {
|
||||||
|
|
||||||
val backupSelected: Subject<BackupFile> = PublishSubject.create()
|
val backupSelected: Subject<BackupFile> = PublishSubject.create()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<BackupListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, BackupListItemBinding::inflate).apply {
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
binding.root.setOnClickListener { backupSelected.onNext(getItem(adapterPosition)) }
|
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 backup = getItem(position)
|
||||||
|
|
||||||
val count = backup.messages
|
val count = backup.messages
|
||||||
|
|
||||||
holder.binding.title.text = dateFormatter.getDetailedTimestamp(backup.date)
|
holder.title.text = dateFormatter.getDetailedTimestamp(backup.date)
|
||||||
holder.binding.messages.text = context.resources.getQuantityString(R.plurals.backup_message_count, count, count)
|
holder.messages.text = context.resources.getQuantityString(R.plurals.backup_message_count, count, count)
|
||||||
holder.binding.size.text = Formatter.formatFileSize(context, backup.size)
|
holder.size.text = Formatter.formatFileSize(context, backup.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,6 @@ import android.Manifest
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.app.ActivityCompat
|
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.setPositiveButton
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.widget.PreferenceView
|
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.injection.appComponent
|
||||||
import com.moez.QKSMS.model.BackupFile
|
import com.moez.QKSMS.model.BackupFile
|
||||||
import com.moez.QKSMS.repository.BackupRepository
|
import com.moez.QKSMS.repository.BackupRepository
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
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
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BackupController : QkController<BackupView, BackupState, BackupPresenter, BackupControllerBinding>(
|
class BackupController : QkController<BackupView, BackupState, BackupPresenter>(), BackupView {
|
||||||
BackupControllerBinding::inflate
|
|
||||||
), BackupView {
|
|
||||||
|
|
||||||
@Inject lateinit var adapter: BackupAdapter
|
@Inject lateinit var adapter: BackupAdapter
|
||||||
@Inject lateinit var dateFormatter: DateFormatter
|
@Inject lateinit var dateFormatter: DateFormatter
|
||||||
@@ -60,11 +58,11 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
|||||||
private val stopRestoreSubject: Subject<Unit> = PublishSubject.create()
|
private val stopRestoreSubject: Subject<Unit> = PublishSubject.create()
|
||||||
|
|
||||||
private val backupFilesDialog by lazy {
|
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 } }
|
.apply { files.adapter = adapter.apply { emptyView = empty } }
|
||||||
|
|
||||||
AlertDialog.Builder(activity!!)
|
AlertDialog.Builder(activity!!)
|
||||||
.setView(binding.root)
|
.setView(view)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.create()
|
.create()
|
||||||
}
|
}
|
||||||
@@ -89,6 +87,7 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
|
layoutRes = R.layout.backup_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
@@ -102,17 +101,17 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
|||||||
super.onViewCreated()
|
super.onViewCreated()
|
||||||
|
|
||||||
themedActivity?.colors?.theme()?.let { theme ->
|
themedActivity?.colors?.theme()?.let { theme ->
|
||||||
binding.progressBar.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
progressBar.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
||||||
binding.progressBar.progressTintList = ColorStateList.valueOf(theme.theme)
|
progressBar.progressTintList = ColorStateList.valueOf(theme.theme)
|
||||||
binding.fab.setBackgroundTint(theme.theme)
|
fab.setBackgroundTint(theme.theme)
|
||||||
binding.fabIcon.setTint(theme.textPrimary)
|
fabIcon.setTint(theme.textPrimary)
|
||||||
binding.fabLabel.setTextColor(theme.textPrimary)
|
fabLabel.setTextColor(theme.textPrimary)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the list titles bold
|
// Make the list titles bold
|
||||||
binding.linearLayout.children
|
linearLayout.children
|
||||||
.mapNotNull { view -> view as? PreferenceView }
|
.mapNotNull { it as? PreferenceView }
|
||||||
.map { preferenceView -> preferenceView.binding.titleView }
|
.map { it.titleView }
|
||||||
.forEach { it.setTypeface(it.typeface, Typeface.BOLD) }
|
.forEach { it.setTypeface(it.typeface, Typeface.BOLD) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,51 +123,51 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
|||||||
override fun render(state: BackupState) {
|
override fun render(state: BackupState) {
|
||||||
when {
|
when {
|
||||||
state.backupProgress.running -> {
|
state.backupProgress.running -> {
|
||||||
binding.progressIcon.setImageResource(R.drawable.ic_file_upload_black_24dp)
|
progressIcon.setImageResource(R.drawable.ic_file_upload_black_24dp)
|
||||||
binding.progressTitle.setText(R.string.backup_backing_up)
|
progressTitle.setText(R.string.backup_backing_up)
|
||||||
binding.progressSummary.text = state.backupProgress.getLabel(activity!!)
|
progressSummary.text = state.backupProgress.getLabel(activity!!)
|
||||||
binding.progressSummary.isVisible = binding.progressSummary.text.isNotEmpty()
|
progressSummary.isVisible = progressSummary.text.isNotEmpty()
|
||||||
binding.progressCancel.isVisible = false
|
progressCancel.isVisible = false
|
||||||
val running = (state.backupProgress as? BackupRepository.Progress.Running)
|
val running = (state.backupProgress as? BackupRepository.Progress.Running)
|
||||||
binding.progressBar.isVisible = state.backupProgress.indeterminate || running?.max ?: 0 > 0
|
progressBar.isVisible = state.backupProgress.indeterminate || running?.max ?: 0 > 0
|
||||||
binding.progressBar.isIndeterminate = state.backupProgress.indeterminate
|
progressBar.isIndeterminate = state.backupProgress.indeterminate
|
||||||
binding.progressBar.max = running?.max ?: 0
|
progressBar.max = running?.max ?: 0
|
||||||
binding.progressBar.progress = running?.count ?: 0
|
progressBar.progress = running?.count ?: 0
|
||||||
binding.progress.isVisible = true
|
progress.isVisible = true
|
||||||
binding.fab.isVisible = false
|
fab.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
state.restoreProgress.running -> {
|
state.restoreProgress.running -> {
|
||||||
binding.progressIcon.setImageResource(R.drawable.ic_file_download_black_24dp)
|
progressIcon.setImageResource(R.drawable.ic_file_download_black_24dp)
|
||||||
binding.progressTitle.setText(R.string.backup_restoring)
|
progressTitle.setText(R.string.backup_restoring)
|
||||||
binding.progressSummary.text = state.restoreProgress.getLabel(activity!!)
|
progressSummary.text = state.restoreProgress.getLabel(activity!!)
|
||||||
binding.progressSummary.isVisible = binding.progressSummary.text.isNotEmpty()
|
progressSummary.isVisible = progressSummary.text.isNotEmpty()
|
||||||
binding.progressCancel.isVisible = true
|
progressCancel.isVisible = true
|
||||||
val running = (state.restoreProgress as? BackupRepository.Progress.Running)
|
val running = (state.restoreProgress as? BackupRepository.Progress.Running)
|
||||||
binding.progressBar.isVisible = state.restoreProgress.indeterminate || running?.max ?: 0 > 0
|
progressBar.isVisible = state.restoreProgress.indeterminate || running?.max ?: 0 > 0
|
||||||
binding.progressBar.isIndeterminate = state.restoreProgress.indeterminate
|
progressBar.isIndeterminate = state.restoreProgress.indeterminate
|
||||||
binding.progressBar.max = running?.max ?: 0
|
progressBar.max = running?.max ?: 0
|
||||||
binding.progressBar.progress = running?.count ?: 0
|
progressBar.progress = running?.count ?: 0
|
||||||
binding.progress.isVisible = true
|
progress.isVisible = true
|
||||||
binding.fab.isVisible = false
|
fab.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
binding.progress.isVisible = false
|
progress.isVisible = false
|
||||||
binding.fab.isVisible = true
|
fab.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.backup.summary = state.lastBackup
|
backup.summary = state.lastBackup
|
||||||
|
|
||||||
adapter.data = state.backups
|
adapter.data = state.backups
|
||||||
|
|
||||||
binding.fabIcon.setImageResource(when (state.upgraded) {
|
fabIcon.setImageResource(when (state.upgraded) {
|
||||||
true -> R.drawable.ic_file_upload_black_24dp
|
true -> R.drawable.ic_file_upload_black_24dp
|
||||||
false -> R.drawable.ic_star_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
|
true -> R.string.backup_now
|
||||||
false -> R.string.title_qksms_plus
|
false -> R.string.title_qksms_plus
|
||||||
})
|
})
|
||||||
@@ -176,18 +175,18 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter,
|
|||||||
|
|
||||||
override fun activityVisible(): Observable<*> = activityVisibleSubject
|
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
|
override fun restoreFileSelected(): Observable<BackupFile> = adapter.backupSelected
|
||||||
.doOnNext { backupFilesDialog.dismiss() }
|
.doOnNext { backupFilesDialog.dismiss() }
|
||||||
|
|
||||||
override fun restoreConfirmed(): Observable<*> = confirmRestoreSubject
|
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 stopRestoreConfirmed(): Observable<*> = stopRestoreSubject
|
||||||
|
|
||||||
override fun fabClicks(): Observable<*> = binding.fab.clicks()
|
override fun fabClicks(): Observable<*> = fab.clicks()
|
||||||
|
|
||||||
override fun requestStoragePermission() {
|
override fun requestStoragePermission() {
|
||||||
ActivityCompat.requestPermissions(activity!!, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 0)
|
ActivityCompat.requestPermissions(activity!!, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), 0)
|
||||||
|
|||||||
@@ -22,22 +22,21 @@ import android.os.Bundle
|
|||||||
import com.bluelinelabs.conductor.Conductor
|
import com.bluelinelabs.conductor.Conductor
|
||||||
import com.bluelinelabs.conductor.Router
|
import com.bluelinelabs.conductor.Router
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
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 dagger.android.AndroidInjection
|
||||||
|
import kotlinx.android.synthetic.main.container_activity.*
|
||||||
|
|
||||||
class BlockingActivity : QkThemedActivity() {
|
class BlockingActivity : QkThemedActivity() {
|
||||||
|
|
||||||
private val binding by viewBinding(ContainerActivityBinding::inflate)
|
|
||||||
private lateinit var router: Router
|
private lateinit var router: Router
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
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()) {
|
if (!router.hasRootController()) {
|
||||||
router.setRoot(RouterTransaction.with(BlockingController()))
|
router.setRoot(RouterTransaction.with(BlockingController()))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,22 +26,20 @@ import com.moez.QKSMS.common.QkChangeHandler
|
|||||||
import com.moez.QKSMS.common.base.QkController
|
import com.moez.QKSMS.common.base.QkController
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.animateLayoutChanges
|
import com.moez.QKSMS.common.util.extensions.animateLayoutChanges
|
||||||
import com.moez.QKSMS.common.widget.QkSwitch
|
|
||||||
import com.moez.QKSMS.databinding.BlockingControllerBinding
|
|
||||||
import com.moez.QKSMS.feature.blocking.manager.BlockingManagerController
|
import com.moez.QKSMS.feature.blocking.manager.BlockingManagerController
|
||||||
import com.moez.QKSMS.feature.blocking.messages.BlockedMessagesController
|
import com.moez.QKSMS.feature.blocking.messages.BlockedMessagesController
|
||||||
import com.moez.QKSMS.feature.blocking.numbers.BlockedNumbersController
|
import com.moez.QKSMS.feature.blocking.numbers.BlockedNumbersController
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
|
import kotlinx.android.synthetic.main.blocking_controller.*
|
||||||
|
import kotlinx.android.synthetic.main.settings_switch_widget.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BlockingController : QkController<BlockingView, BlockingState, BlockingPresenter, BlockingControllerBinding>(
|
class BlockingController : QkController<BlockingView, BlockingState, BlockingPresenter>(), BlockingView {
|
||||||
BlockingControllerBinding::inflate
|
|
||||||
), BlockingView {
|
|
||||||
|
|
||||||
override val blockingManagerIntent by lazy { binding.blockingManager.clicks() }
|
override val blockingManagerIntent by lazy { blockingManager.clicks() }
|
||||||
override val blockedNumbersIntent by lazy { binding.blockedNumbers.clicks() }
|
override val blockedNumbersIntent by lazy { blockedNumbers.clicks() }
|
||||||
override val blockedMessagesIntent by lazy { binding.blockedMessages.clicks() }
|
override val blockedMessagesIntent by lazy { blockedMessages.clicks() }
|
||||||
override val dropClickedIntent by lazy { binding.drop.clicks() }
|
override val dropClickedIntent by lazy { drop.clicks() }
|
||||||
|
|
||||||
@Inject lateinit var colors: Colors
|
@Inject lateinit var colors: Colors
|
||||||
@Inject override lateinit var presenter: BlockingPresenter
|
@Inject override lateinit var presenter: BlockingPresenter
|
||||||
@@ -49,11 +47,12 @@ class BlockingController : QkController<BlockingView, BlockingState, BlockingPre
|
|||||||
init {
|
init {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
retainViewMode = RetainViewMode.RETAIN_DETACH
|
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||||
|
layoutRes = R.layout.blocking_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated() {
|
override fun onViewCreated() {
|
||||||
super.onViewCreated()
|
super.onViewCreated()
|
||||||
binding.parent.postDelayed({ binding.parent.animateLayoutChanges = true }, 100)
|
parent.postDelayed({ parent?.animateLayoutChanges = true }, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
@@ -64,9 +63,9 @@ class BlockingController : QkController<BlockingView, BlockingState, BlockingPre
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: BlockingState) {
|
override fun render(state: BlockingState) {
|
||||||
binding.blockingManager.summary = state.blockingManager
|
blockingManager.summary = state.blockingManager
|
||||||
binding.drop.widget<QkSwitch>().isChecked = state.dropEnabled
|
drop.checkbox.isChecked = state.dropEnabled
|
||||||
binding.blockedMessages.isEnabled = !state.dropEnabled
|
blockedMessages.isEnabled = !state.dropEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openBlockedNumbers() {
|
override fun openBlockedNumbers() {
|
||||||
|
|||||||
+14
-11
@@ -7,16 +7,18 @@ import androidx.core.view.isVisible
|
|||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkController
|
import com.moez.QKSMS.common.base.QkController
|
||||||
import com.moez.QKSMS.databinding.BlockingManagerControllerBinding
|
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import com.moez.QKSMS.util.Preferences
|
import com.moez.QKSMS.util.Preferences
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
|
import kotlinx.android.synthetic.main.blocking_manager_controller.*
|
||||||
|
import kotlinx.android.synthetic.main.blocking_manager_list_option.view.*
|
||||||
|
import kotlinx.android.synthetic.main.radio_preference_view.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BlockingManagerController : QkController<BlockingManagerView, BlockingManagerState, BlockingManagerPresenter,
|
class BlockingManagerController : QkController<BlockingManagerView, BlockingManagerState, BlockingManagerPresenter>(),
|
||||||
BlockingManagerControllerBinding>(BlockingManagerControllerBinding::inflate), BlockingManagerView {
|
BlockingManagerView {
|
||||||
|
|
||||||
@Inject override lateinit var presenter: BlockingManagerPresenter
|
@Inject override lateinit var presenter: BlockingManagerPresenter
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ class BlockingManagerController : QkController<BlockingManagerView, BlockingMana
|
|||||||
init {
|
init {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
retainViewMode = RetainViewMode.RETAIN_DETACH
|
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||||
|
layoutRes = R.layout.blocking_manager_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
@@ -39,19 +42,19 @@ class BlockingManagerController : QkController<BlockingManagerView, BlockingMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: BlockingManagerState) {
|
override fun render(state: BlockingManagerState) {
|
||||||
binding.qksms.binding.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_QKSMS
|
qksms.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_QKSMS
|
||||||
|
|
||||||
binding.callControl.binding.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_CC
|
callControl.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_CC
|
||||||
binding.callControl.binding.widgetFrame.isVisible = !state.callControlInstalled
|
callControl.install.isVisible = !state.callControlInstalled
|
||||||
|
|
||||||
binding.shouldIAnswer.binding.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_SIA
|
shouldIAnswer.radioButton.isChecked = state.blockingManager == Preferences.BLOCKING_MANAGER_SIA
|
||||||
binding.shouldIAnswer.binding.widgetFrame.isVisible = !state.siaInstalled
|
shouldIAnswer.install.isVisible = !state.siaInstalled
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun activityResumed(): Observable<*> = activityResumedSubject
|
override fun activityResumed(): Observable<*> = activityResumedSubject
|
||||||
override fun qksmsClicked(): Observable<*> = binding.qksms.clicks()
|
override fun qksmsClicked(): Observable<*> = qksms.clicks()
|
||||||
override fun callControlClicked(): Observable<*> = binding.callControl.clicks()
|
override fun callControlClicked(): Observable<*> = callControl.clicks()
|
||||||
override fun siaClicked(): Observable<*> = binding.shouldIAnswer.clicks()
|
override fun siaClicked(): Observable<*> = shouldIAnswer.clicks()
|
||||||
|
|
||||||
override fun showCopyDialog(manager: String): Single<Boolean> = Single.create { emitter ->
|
override fun showCopyDialog(manager: String): Single<Boolean> = Single.create { emitter ->
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
|
|||||||
+27
-24
@@ -20,6 +20,7 @@ package com.moez.QKSMS.feature.blocking.messages
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
@@ -27,63 +28,65 @@ import com.moez.QKSMS.common.base.QkRealmAdapter
|
|||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.DateFormatter
|
import com.moez.QKSMS.common.util.DateFormatter
|
||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.databinding.BlockedListItemBinding
|
|
||||||
import com.moez.QKSMS.model.Conversation
|
import com.moez.QKSMS.model.Conversation
|
||||||
import com.moez.QKSMS.util.Preferences
|
import com.moez.QKSMS.util.Preferences
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
|
import kotlinx.android.synthetic.main.blocked_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.blocked_list_item.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BlockedMessagesAdapter @Inject constructor(
|
class BlockedMessagesAdapter @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val dateFormatter: DateFormatter
|
private val dateFormatter: DateFormatter
|
||||||
) : QkRealmAdapter<Conversation, BlockedListItemBinding>() {
|
) : QkRealmAdapter<Conversation>() {
|
||||||
|
|
||||||
val clicks: PublishSubject<Long> = PublishSubject.create()
|
val clicks: PublishSubject<Long> = PublishSubject.create()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<BlockedListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, BlockedListItemBinding::inflate).apply {
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.blocked_list_item, parent, false)
|
||||||
if (viewType == 0) {
|
|
||||||
binding.title.setTypeface(binding.title.typeface, Typeface.BOLD)
|
|
||||||
binding.date.setTypeface(binding.date.typeface, Typeface.BOLD)
|
|
||||||
binding.date.setTextColor(parent.context.resolveThemeColor(android.R.attr.textColorPrimary))
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
if (viewType == 0) {
|
||||||
|
view.title.setTypeface(view.title.typeface, Typeface.BOLD)
|
||||||
|
view.date.setTypeface(view.date.typeface, Typeface.BOLD)
|
||||||
|
view.date.setTextColor(view.context.resolveThemeColor(android.R.attr.textColorPrimary))
|
||||||
|
}
|
||||||
|
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
|
view.setOnClickListener {
|
||||||
val conversation = getItem(adapterPosition) ?: return@setOnClickListener
|
val conversation = getItem(adapterPosition) ?: return@setOnClickListener
|
||||||
when (toggleSelection(conversation.id, false)) {
|
when (toggleSelection(conversation.id, false)) {
|
||||||
true -> binding.root.isActivated = isSelected(conversation.id)
|
true -> view.isActivated = isSelected(conversation.id)
|
||||||
false -> clicks.onNext(conversation.id)
|
false -> clicks.onNext(conversation.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
view.setOnLongClickListener {
|
||||||
binding.root.setOnLongClickListener {
|
|
||||||
val conversation = getItem(adapterPosition) ?: return@setOnLongClickListener true
|
val conversation = getItem(adapterPosition) ?: return@setOnLongClickListener true
|
||||||
toggleSelection(conversation.id)
|
toggleSelection(conversation.id)
|
||||||
binding.root.isActivated = isSelected(conversation.id)
|
view.isActivated = isSelected(conversation.id)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<BlockedListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val conversation = getItem(position) ?: return
|
val conversation = getItem(position) ?: return
|
||||||
|
|
||||||
holder.binding.root.isActivated = isSelected(conversation.id)
|
holder.containerView.isActivated = isSelected(conversation.id)
|
||||||
|
|
||||||
holder.binding.avatars.recipients = conversation.recipients
|
holder.avatars.recipients = conversation.recipients
|
||||||
holder.binding.title.collapseEnabled = conversation.recipients.size > 1
|
holder.title.collapseEnabled = conversation.recipients.size > 1
|
||||||
holder.binding.title.text = conversation.getTitle()
|
holder.title.text = conversation.getTitle()
|
||||||
holder.binding.date.text = dateFormatter.getConversationTimestamp(conversation.date)
|
holder.date.text = dateFormatter.getConversationTimestamp(conversation.date)
|
||||||
|
|
||||||
holder.binding.blocker.text = when (conversation.blockingClient) {
|
holder.blocker.text = when (conversation.blockingClient) {
|
||||||
Preferences.BLOCKING_MANAGER_CC -> context.getString(R.string.blocking_manager_call_control_title)
|
Preferences.BLOCKING_MANAGER_CC -> context.getString(R.string.blocking_manager_call_control_title)
|
||||||
Preferences.BLOCKING_MANAGER_SIA -> context.getString(R.string.blocking_manager_sia_title)
|
Preferences.BLOCKING_MANAGER_SIA -> context.getString(R.string.blocking_manager_sia_title)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.binding.reason.text = conversation.blockReason
|
holder.reason.text = conversation.blockReason
|
||||||
holder.binding.blocker.isVisible = holder.binding.blocker.text.isNotEmpty()
|
holder.blocker.isVisible = holder.blocker.text.isNotEmpty()
|
||||||
holder.binding.reason.isVisible = holder.binding.blocker.text.isNotEmpty()
|
holder.reason.isVisible = holder.blocker.text.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int {
|
override fun getItemViewType(position: Int): Int {
|
||||||
|
|||||||
+7
-5
@@ -27,15 +27,16 @@ import android.view.View
|
|||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkController
|
import com.moez.QKSMS.common.base.QkController
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.databinding.BlockedMessagesControllerBinding
|
|
||||||
import com.moez.QKSMS.feature.blocking.BlockingDialog
|
import com.moez.QKSMS.feature.blocking.BlockingDialog
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.blocked_messages_controller.*
|
||||||
|
import kotlinx.android.synthetic.main.container_activity.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BlockedMessagesController : QkController<BlockedMessagesView, BlockedMessagesState, BlockedMessagesPresenter,
|
class BlockedMessagesController : QkController<BlockedMessagesView, BlockedMessagesState, BlockedMessagesPresenter>(),
|
||||||
BlockedMessagesControllerBinding>(BlockedMessagesControllerBinding::inflate), BlockedMessagesView {
|
BlockedMessagesView {
|
||||||
|
|
||||||
override val menuReadyIntent: Subject<Unit> = PublishSubject.create()
|
override val menuReadyIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
||||||
@@ -53,12 +54,13 @@ class BlockedMessagesController : QkController<BlockedMessagesView, BlockedMessa
|
|||||||
init {
|
init {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
retainViewMode = RetainViewMode.RETAIN_DETACH
|
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||||
|
layoutRes = R.layout.blocked_messages_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated() {
|
override fun onViewCreated() {
|
||||||
super.onViewCreated()
|
super.onViewCreated()
|
||||||
blockedMessagesAdapter.emptyView = binding.empty
|
blockedMessagesAdapter.emptyView = empty
|
||||||
binding.conversations.adapter = blockedMessagesAdapter
|
conversations.adapter = blockedMessagesAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
|
|||||||
+11
-7
@@ -18,31 +18,35 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.blocking.numbers
|
package com.moez.QKSMS.feature.blocking.numbers
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkRealmAdapter
|
import com.moez.QKSMS.common.base.QkRealmAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.databinding.BlockedNumberListItemBinding
|
|
||||||
import com.moez.QKSMS.model.BlockedNumber
|
import com.moez.QKSMS.model.BlockedNumber
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.blocked_number_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.blocked_number_list_item.view.*
|
||||||
|
|
||||||
class BlockedNumbersAdapter : QkRealmAdapter<BlockedNumber, BlockedNumberListItemBinding>() {
|
class BlockedNumbersAdapter : QkRealmAdapter<BlockedNumber>() {
|
||||||
|
|
||||||
val unblockAddress: Subject<Long> = PublishSubject.create()
|
val unblockAddress: Subject<Long> = PublishSubject.create()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<BlockedNumberListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, BlockedNumberListItemBinding::inflate).apply {
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.blocked_number_list_item, parent, false)
|
||||||
binding.unblock.setOnClickListener {
|
return QkViewHolder(view).apply {
|
||||||
|
containerView.unblock.setOnClickListener {
|
||||||
val number = getItem(adapterPosition) ?: return@setOnClickListener
|
val number = getItem(adapterPosition) ?: return@setOnClickListener
|
||||||
unblockAddress.onNext(number.id)
|
unblockAddress.onNext(number.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<BlockedNumberListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val item = getItem(position)!!
|
val item = getItem(position)!!
|
||||||
|
|
||||||
holder.binding.number.text = item.address
|
holder.number.text = item.address
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-13
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.blocking.numbers
|
package com.moez.QKSMS.feature.blocking.numbers
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
@@ -26,17 +27,17 @@ import com.moez.QKSMS.common.base.QkController
|
|||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.databinding.BlockedNumbersAddDialogBinding
|
|
||||||
import com.moez.QKSMS.databinding.BlockedNumbersControllerBinding
|
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import com.moez.QKSMS.util.PhoneNumberUtils
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.blocked_numbers_add_dialog.view.*
|
||||||
|
import kotlinx.android.synthetic.main.blocked_numbers_controller.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BlockedNumbersController : QkController<BlockedNumbersView, BlockedNumbersState, BlockedNumbersPresenter,
|
class BlockedNumbersController : QkController<BlockedNumbersView, BlockedNumbersState, BlockedNumbersPresenter>(),
|
||||||
BlockedNumbersControllerBinding>(BlockedNumbersControllerBinding::inflate), BlockedNumbersView {
|
BlockedNumbersView {
|
||||||
|
|
||||||
@Inject override lateinit var presenter: BlockedNumbersPresenter
|
@Inject override lateinit var presenter: BlockedNumbersPresenter
|
||||||
@Inject lateinit var colors: Colors
|
@Inject lateinit var colors: Colors
|
||||||
@@ -48,6 +49,7 @@ class BlockedNumbersController : QkController<BlockedNumbersView, BlockedNumbers
|
|||||||
init {
|
init {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
retainViewMode = RetainViewMode.RETAIN_DETACH
|
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||||
|
layoutRes = R.layout.blocked_numbers_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
@@ -59,10 +61,10 @@ class BlockedNumbersController : QkController<BlockedNumbersView, BlockedNumbers
|
|||||||
|
|
||||||
override fun onViewCreated() {
|
override fun onViewCreated() {
|
||||||
super.onViewCreated()
|
super.onViewCreated()
|
||||||
binding.add.setBackgroundTint(colors.theme().theme)
|
add.setBackgroundTint(colors.theme().theme)
|
||||||
binding.add.setTint(colors.theme().textPrimary)
|
add.setTint(colors.theme().textPrimary)
|
||||||
adapter.emptyView = binding.empty
|
adapter.emptyView = empty
|
||||||
binding.numbers.adapter = adapter
|
numbers.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: BlockedNumbersState) {
|
override fun render(state: BlockedNumbersState) {
|
||||||
@@ -70,16 +72,16 @@ class BlockedNumbersController : QkController<BlockedNumbersView, BlockedNumbers
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun unblockAddress(): Observable<Long> = adapter.unblockAddress
|
override fun unblockAddress(): Observable<Long> = adapter.unblockAddress
|
||||||
override fun addAddress(): Observable<*> = binding.add.clicks()
|
override fun addAddress(): Observable<*> = add.clicks()
|
||||||
override fun saveAddress(): Observable<String> = saveAddressSubject
|
override fun saveAddress(): Observable<String> = saveAddressSubject
|
||||||
|
|
||||||
override fun showAddDialog() {
|
override fun showAddDialog() {
|
||||||
val binding = BlockedNumbersAddDialogBinding.inflate(activity?.layoutInflater!!)
|
val layout = LayoutInflater.from(activity).inflate(R.layout.blocked_numbers_add_dialog, null)
|
||||||
val textWatcher = BlockedNumberTextWatcher(binding.input, phoneNumberUtils)
|
val textWatcher = BlockedNumberTextWatcher(layout.input, phoneNumberUtils)
|
||||||
val dialog = AlertDialog.Builder(activity!!)
|
val dialog = AlertDialog.Builder(activity!!)
|
||||||
.setView(binding.root)
|
.setView(layout)
|
||||||
.setPositiveButton(R.string.blocked_numbers_dialog_block) { _, _ ->
|
.setPositiveButton(R.string.blocked_numbers_dialog_block) { _, _ ->
|
||||||
saveAddressSubject.onNext(binding.input.text.toString())
|
saveAddressSubject.onNext(layout.input.text.toString())
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.button_cancel) { _, _ -> }
|
.setNegativeButton(R.string.button_cancel) { _, _ -> }
|
||||||
.setOnDismissListener { textWatcher.dispose() }
|
.setOnDismissListener { textWatcher.dispose() }
|
||||||
|
|||||||
@@ -20,16 +20,15 @@ package com.moez.QKSMS.feature.changelog
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.databinding.ChangelogListItemBinding
|
|
||||||
import com.moez.QKSMS.manager.ChangelogManager
|
import com.moez.QKSMS.manager.ChangelogManager
|
||||||
|
import kotlinx.android.synthetic.main.changelog_list_item.*
|
||||||
|
|
||||||
class ChangelogAdapter(
|
class ChangelogAdapter(private val context: Context) : QkAdapter<ChangelogAdapter.ChangelogItem>() {
|
||||||
private val context: Context
|
|
||||||
) : QkAdapter<ChangelogAdapter.ChangelogItem, ChangelogListItemBinding>() {
|
|
||||||
|
|
||||||
data class ChangelogItem(val type: Int, val label: String)
|
data class ChangelogItem(val type: Int, val label: String)
|
||||||
|
|
||||||
@@ -53,18 +52,19 @@ class ChangelogAdapter(
|
|||||||
data = changes
|
data = changes
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ChangelogListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, ChangelogListItemBinding::inflate).apply {
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.changelog_list_item, parent, false)
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
if (viewType == 0) {
|
if (viewType == 0) {
|
||||||
binding.changelogItem.setTypeface(binding.changelogItem.typeface, Typeface.BOLD)
|
changelogItem.setTypeface(changelogItem.typeface, Typeface.BOLD)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ChangelogListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val item = getItem(position)
|
val item = getItem(position)
|
||||||
|
|
||||||
holder.binding.changelogItem.text = item.label
|
holder.changelogItem.text = item.label
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int {
|
override fun getItemViewType(position: Int): Int {
|
||||||
|
|||||||
@@ -18,14 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.changelog
|
package com.moez.QKSMS.feature.changelog
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.moez.QKSMS.BuildConfig
|
import com.moez.QKSMS.BuildConfig
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.databinding.ChangelogDialogBinding
|
|
||||||
import com.moez.QKSMS.feature.main.MainActivity
|
import com.moez.QKSMS.feature.main.MainActivity
|
||||||
import com.moez.QKSMS.manager.ChangelogManager
|
import com.moez.QKSMS.manager.ChangelogManager
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.changelog_dialog.view.*
|
||||||
|
|
||||||
class ChangelogDialog(activity: MainActivity) {
|
class ChangelogDialog(activity: MainActivity) {
|
||||||
|
|
||||||
@@ -35,17 +36,17 @@ class ChangelogDialog(activity: MainActivity) {
|
|||||||
private val adapter = ChangelogAdapter(activity)
|
private val adapter = ChangelogAdapter(activity)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val binding = ChangelogDialogBinding.inflate(activity.layoutInflater)
|
val layout = LayoutInflater.from(activity).inflate(R.layout.changelog_dialog, null)
|
||||||
|
|
||||||
dialog = AlertDialog.Builder(activity)
|
dialog = AlertDialog.Builder(activity)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setView(binding.root)
|
.setView(layout)
|
||||||
.create()
|
.create()
|
||||||
|
|
||||||
binding.version.text = activity.getString(R.string.changelog_version, BuildConfig.VERSION_NAME)
|
layout.version.text = activity.getString(R.string.changelog_version, BuildConfig.VERSION_NAME)
|
||||||
binding.changelog.adapter = adapter
|
layout.changelog.adapter = adapter
|
||||||
binding.more.setOnClickListener { dialog.dismiss(); moreClicks.onNext(Unit) }
|
layout.more.setOnClickListener { dialog.dismiss(); moreClicks.onNext(Unit) }
|
||||||
binding.dismiss.setOnClickListener { dialog.dismiss() }
|
layout.dismiss.setOnClickListener { dialog.dismiss() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun show(changelog: ChangelogManager.Changelog) {
|
fun show(changelog: ChangelogManager.Changelog) {
|
||||||
|
|||||||
@@ -19,13 +19,12 @@
|
|||||||
package com.moez.QKSMS.feature.compose
|
package com.moez.QKSMS.feature.compose
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.databinding.AttachmentContactListItemBinding
|
|
||||||
import com.moez.QKSMS.databinding.AttachmentImageListItemBinding
|
|
||||||
import com.moez.QKSMS.extensions.mapNotNull
|
import com.moez.QKSMS.extensions.mapNotNull
|
||||||
import com.moez.QKSMS.model.Attachment
|
import com.moez.QKSMS.model.Attachment
|
||||||
import ezvcard.Ezvcard
|
import ezvcard.Ezvcard
|
||||||
@@ -34,11 +33,14 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
|||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.attachment_contact_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.attachment_image_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.attachment_image_list_item.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AttachmentAdapter @Inject constructor(
|
class AttachmentAdapter @Inject constructor(
|
||||||
private val context: Context
|
private val context: Context
|
||||||
) : QkAdapter<Attachment, ViewBinding>() {
|
) : QkAdapter<Attachment>() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val VIEW_TYPE_IMAGE = 0
|
private const val VIEW_TYPE_IMAGE = 0
|
||||||
@@ -47,42 +49,38 @@ class AttachmentAdapter @Inject constructor(
|
|||||||
|
|
||||||
val attachmentDeleted: Subject<Attachment> = PublishSubject.create()
|
val attachmentDeleted: Subject<Attachment> = PublishSubject.create()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ViewBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
val holder: QkViewHolder<ViewBinding> = when (viewType) {
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
VIEW_TYPE_IMAGE -> QkViewHolder(parent, AttachmentImageListItemBinding::inflate)
|
val view = when (viewType) {
|
||||||
VIEW_TYPE_CONTACT -> QkViewHolder(parent, AttachmentContactListItemBinding::inflate)
|
VIEW_TYPE_IMAGE -> inflater.inflate(R.layout.attachment_image_list_item, parent, false)
|
||||||
|
.apply { thumbnailBounds.clipToOutline = true }
|
||||||
|
|
||||||
|
VIEW_TYPE_CONTACT -> inflater.inflate(R.layout.attachment_contact_list_item, parent, false)
|
||||||
|
|
||||||
else -> null!! // Impossible
|
else -> null!! // Impossible
|
||||||
}
|
}
|
||||||
|
|
||||||
return holder.apply {
|
return QkViewHolder(view).apply {
|
||||||
if (binding is AttachmentImageListItemBinding) {
|
view.setOnClickListener {
|
||||||
binding.thumbnailBounds.clipToOutline = true
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
|
||||||
val attachment = getItem(adapterPosition)
|
val attachment = getItem(adapterPosition)
|
||||||
attachmentDeleted.onNext(attachment)
|
attachmentDeleted.onNext(attachment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ViewBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val attachment = getItem(position)
|
val attachment = getItem(position)
|
||||||
|
|
||||||
when {
|
when (attachment) {
|
||||||
attachment is Attachment.Image && holder.binding is AttachmentImageListItemBinding -> {
|
is Attachment.Image -> Glide.with(context)
|
||||||
Glide.with(context)
|
.load(attachment.getUri())
|
||||||
.load(attachment.getUri())
|
.into(holder.thumbnail)
|
||||||
.into(holder.binding.thumbnail)
|
|
||||||
}
|
|
||||||
|
|
||||||
attachment is Attachment.Contact && holder.binding is AttachmentContactListItemBinding -> {
|
is Attachment.Contact -> Observable.just(attachment.vCard)
|
||||||
Observable.just(attachment.vCard)
|
.mapNotNull { vCard -> Ezvcard.parse(vCard).first() }
|
||||||
.mapNotNull { vCard -> Ezvcard.parse(vCard).first() }
|
.subscribeOn(Schedulers.computation())
|
||||||
.subscribeOn(Schedulers.computation())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.subscribe { vcard -> holder.name?.text = vcard.formattedName.value }
|
||||||
.subscribe { vcard -> holder.binding.name.text = vcard.formattedName.value }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
|||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.util.extensions.showKeyboard
|
import com.moez.QKSMS.common.util.extensions.showKeyboard
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.ComposeActivityBinding
|
|
||||||
import com.moez.QKSMS.feature.compose.editing.ChipsAdapter
|
import com.moez.QKSMS.feature.compose.editing.ChipsAdapter
|
||||||
import com.moez.QKSMS.feature.contacts.ContactsActivity
|
import com.moez.QKSMS.feature.contacts.ContactsActivity
|
||||||
import com.moez.QKSMS.model.Attachment
|
import com.moez.QKSMS.model.Attachment
|
||||||
@@ -67,6 +65,7 @@ import dagger.android.AndroidInjection
|
|||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.compose_activity.*
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -95,29 +94,28 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
override val chipDeletedIntent: Subject<Recipient> by lazy { chipsAdapter.chipDeleted }
|
override val chipDeletedIntent: Subject<Recipient> by lazy { chipsAdapter.chipDeleted }
|
||||||
override val menuReadyIntent: Observable<Unit> = menu.map { Unit }
|
override val menuReadyIntent: Observable<Unit> = menu.map { Unit }
|
||||||
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
||||||
override val sendAsGroupIntent by lazy { binding.sendAsGroupBackground.clicks() }
|
override val sendAsGroupIntent by lazy { sendAsGroupBackground.clicks() }
|
||||||
override val messageClickIntent: Subject<Long> by lazy { messageAdapter.clicks }
|
override val messageClickIntent: Subject<Long> by lazy { messageAdapter.clicks }
|
||||||
override val messagePartClickIntent: Subject<Long> by lazy { messageAdapter.partClicks }
|
override val messagePartClickIntent: Subject<Long> by lazy { messageAdapter.partClicks }
|
||||||
override val messagesSelectedIntent by lazy { messageAdapter.selectionChanges }
|
override val messagesSelectedIntent by lazy { messageAdapter.selectionChanges }
|
||||||
override val cancelSendingIntent: Subject<Long> by lazy { messageAdapter.cancelSending }
|
override val cancelSendingIntent: Subject<Long> by lazy { messageAdapter.cancelSending }
|
||||||
override val attachmentDeletedIntent: Subject<Attachment> by lazy { attachmentAdapter.attachmentDeleted }
|
override val attachmentDeletedIntent: Subject<Attachment> by lazy { attachmentAdapter.attachmentDeleted }
|
||||||
override val textChangedIntent by lazy { binding.message.textChanges() }
|
override val textChangedIntent by lazy { message.textChanges() }
|
||||||
override val attachIntent by lazy { Observable.merge(binding.attach.clicks(), binding.attachingBackground.clicks()) }
|
override val attachIntent by lazy { Observable.merge(attach.clicks(), attachingBackground.clicks()) }
|
||||||
override val cameraIntent by lazy { Observable.merge(binding.camera.clicks(), binding.cameraLabel.clicks()) }
|
override val cameraIntent by lazy { Observable.merge(camera.clicks(), cameraLabel.clicks()) }
|
||||||
override val galleryIntent by lazy { Observable.merge(binding.gallery.clicks(), binding.galleryLabel.clicks()) }
|
override val galleryIntent by lazy { Observable.merge(gallery.clicks(), galleryLabel.clicks()) }
|
||||||
override val scheduleIntent by lazy { Observable.merge(binding.schedule.clicks(), binding.scheduleLabel.clicks()) }
|
override val scheduleIntent by lazy { Observable.merge(schedule.clicks(), scheduleLabel.clicks()) }
|
||||||
override val attachContactIntent by lazy { Observable.merge(binding.contact.clicks(), binding.contactLabel.clicks()) }
|
override val attachContactIntent by lazy { Observable.merge(contact.clicks(), contactLabel.clicks()) }
|
||||||
override val attachmentSelectedIntent: Subject<Uri> = PublishSubject.create()
|
override val attachmentSelectedIntent: Subject<Uri> = PublishSubject.create()
|
||||||
override val contactSelectedIntent: Subject<Uri> = PublishSubject.create()
|
override val contactSelectedIntent: Subject<Uri> = PublishSubject.create()
|
||||||
override val inputContentIntent by lazy { binding.message.inputContentSelected }
|
override val inputContentIntent by lazy { message.inputContentSelected }
|
||||||
override val scheduleSelectedIntent: Subject<Long> = PublishSubject.create()
|
override val scheduleSelectedIntent: Subject<Long> = PublishSubject.create()
|
||||||
override val changeSimIntent by lazy { binding.sim.clicks() }
|
override val changeSimIntent by lazy { sim.clicks() }
|
||||||
override val scheduleCancelIntent by lazy { binding.scheduledCancel.clicks() }
|
override val scheduleCancelIntent by lazy { scheduledCancel.clicks() }
|
||||||
override val sendIntent by lazy { binding.send.clicks() }
|
override val sendIntent by lazy { send.clicks() }
|
||||||
override val viewQksmsPlusIntent: Subject<Unit> = PublishSubject.create()
|
override val viewQksmsPlusIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
|
override val backPressedIntent: Subject<Unit> = PublishSubject.create()
|
||||||
|
|
||||||
private val binding by viewBinding(ComposeActivityBinding::inflate)
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ComposeViewModel::class.java] }
|
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ComposeViewModel::class.java] }
|
||||||
|
|
||||||
private var cameraDestination: Uri? = null
|
private var cameraDestination: Uri? = null
|
||||||
@@ -125,33 +123,33 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(binding.root)
|
setContentView(R.layout.compose_activity)
|
||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
|
|
||||||
binding.contentView.layoutTransition = LayoutTransition().apply {
|
contentView.layoutTransition = LayoutTransition().apply {
|
||||||
disableTransitionType(LayoutTransition.CHANGING)
|
disableTransitionType(LayoutTransition.CHANGING)
|
||||||
}
|
}
|
||||||
|
|
||||||
chipsAdapter.view = binding.chips
|
chipsAdapter.view = chips
|
||||||
|
|
||||||
binding.chips.itemAnimator = null
|
chips.itemAnimator = null
|
||||||
binding.chips.layoutManager = FlexboxLayoutManager(this)
|
chips.layoutManager = FlexboxLayoutManager(this)
|
||||||
|
|
||||||
messageAdapter.autoScrollToStart(binding.messageList)
|
messageAdapter.autoScrollToStart(messageList)
|
||||||
messageAdapter.emptyView = binding.messagesEmpty
|
messageAdapter.emptyView = messagesEmpty
|
||||||
|
|
||||||
binding.messageList.setHasFixedSize(true)
|
messageList.setHasFixedSize(true)
|
||||||
binding.messageList.adapter = messageAdapter
|
messageList.adapter = messageAdapter
|
||||||
|
|
||||||
binding.attachments.adapter = attachmentAdapter
|
attachments.adapter = attachmentAdapter
|
||||||
|
|
||||||
binding.message.supportsInputContent = true
|
message.supportsInputContent = true
|
||||||
|
|
||||||
theme
|
theme
|
||||||
.doOnNext { binding.loading.setTint(it.theme) }
|
.doOnNext { loading.setTint(it.theme) }
|
||||||
.doOnNext { binding.attach.setBackgroundTint(it.theme) }
|
.doOnNext { attach.setBackgroundTint(it.theme) }
|
||||||
.doOnNext { binding.attach.setTint(it.textPrimary) }
|
.doOnNext { attach.setTint(it.textPrimary) }
|
||||||
.doOnNext { messageAdapter.theme = it }
|
.doOnNext { messageAdapter.theme = it }
|
||||||
.autoDisposable(scope())
|
.autoDisposable(scope())
|
||||||
.subscribe()
|
.subscribe()
|
||||||
@@ -160,7 +158,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
|
|
||||||
// These theme attributes don't apply themselves on API 21
|
// These theme attributes don't apply themselves on API 21
|
||||||
if (Build.VERSION.SDK_INT <= 22) {
|
if (Build.VERSION.SDK_INT <= 22) {
|
||||||
binding.messageBackground.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
messageBackground.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,59 +186,59 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
else -> state.conversationtitle
|
else -> state.conversationtitle
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.toolbarSubtitle.setVisible(state.query.isNotEmpty())
|
toolbarSubtitle.setVisible(state.query.isNotEmpty())
|
||||||
binding.toolbarSubtitle.text = getString(R.string.compose_subtitle_results, state.searchSelectionPosition,
|
toolbarSubtitle.text = getString(R.string.compose_subtitle_results, state.searchSelectionPosition,
|
||||||
state.searchResults)
|
state.searchResults)
|
||||||
|
|
||||||
binding.toolbarTitle.setVisible(!state.editingMode)
|
toolbarTitle.setVisible(!state.editingMode)
|
||||||
binding.chips.setVisible(state.editingMode)
|
chips.setVisible(state.editingMode)
|
||||||
binding.composeBar.setVisible(!state.loading)
|
composeBar.setVisible(!state.loading)
|
||||||
|
|
||||||
// Don't set the adapters unless needed
|
// Don't set the adapters unless needed
|
||||||
if (state.editingMode && binding.chips.adapter == null) binding.chips.adapter = chipsAdapter
|
if (state.editingMode && chips.adapter == null) chips.adapter = chipsAdapter
|
||||||
|
|
||||||
binding.toolbar.menu.findItem(R.id.add)?.isVisible = state.editingMode
|
toolbar.menu.findItem(R.id.add)?.isVisible = state.editingMode
|
||||||
binding.toolbar.menu.findItem(R.id.call)?.isVisible = !state.editingMode && state.selectedMessages == 0
|
toolbar.menu.findItem(R.id.call)?.isVisible = !state.editingMode && state.selectedMessages == 0
|
||||||
&& state.query.isEmpty()
|
&& state.query.isEmpty()
|
||||||
binding.toolbar.menu.findItem(R.id.info)?.isVisible = !state.editingMode && state.selectedMessages == 0
|
toolbar.menu.findItem(R.id.info)?.isVisible = !state.editingMode && state.selectedMessages == 0
|
||||||
&& state.query.isEmpty()
|
&& state.query.isEmpty()
|
||||||
binding.toolbar.menu.findItem(R.id.copy)?.isVisible = !state.editingMode && state.selectedMessages > 0
|
toolbar.menu.findItem(R.id.copy)?.isVisible = !state.editingMode && state.selectedMessages > 0
|
||||||
binding.toolbar.menu.findItem(R.id.details)?.isVisible = !state.editingMode && state.selectedMessages == 1
|
toolbar.menu.findItem(R.id.details)?.isVisible = !state.editingMode && state.selectedMessages == 1
|
||||||
binding.toolbar.menu.findItem(R.id.delete)?.isVisible = !state.editingMode && state.selectedMessages > 0
|
toolbar.menu.findItem(R.id.delete)?.isVisible = !state.editingMode && state.selectedMessages > 0
|
||||||
binding.toolbar.menu.findItem(R.id.forward)?.isVisible = !state.editingMode && state.selectedMessages == 1
|
toolbar.menu.findItem(R.id.forward)?.isVisible = !state.editingMode && state.selectedMessages == 1
|
||||||
binding.toolbar.menu.findItem(R.id.previous)?.isVisible = state.selectedMessages == 0 && state.query.isNotEmpty()
|
toolbar.menu.findItem(R.id.previous)?.isVisible = state.selectedMessages == 0 && state.query.isNotEmpty()
|
||||||
binding.toolbar.menu.findItem(R.id.next)?.isVisible = state.selectedMessages == 0 && state.query.isNotEmpty()
|
toolbar.menu.findItem(R.id.next)?.isVisible = state.selectedMessages == 0 && state.query.isNotEmpty()
|
||||||
binding.toolbar.menu.findItem(R.id.clear)?.isVisible = state.selectedMessages == 0 && state.query.isNotEmpty()
|
toolbar.menu.findItem(R.id.clear)?.isVisible = state.selectedMessages == 0 && state.query.isNotEmpty()
|
||||||
|
|
||||||
chipsAdapter.data = state.selectedChips
|
chipsAdapter.data = state.selectedChips
|
||||||
|
|
||||||
binding.loading.setVisible(state.loading)
|
loading.setVisible(state.loading)
|
||||||
|
|
||||||
binding.sendAsGroup.setVisible(state.editingMode && state.selectedChips.size >= 2)
|
sendAsGroup.setVisible(state.editingMode && state.selectedChips.size >= 2)
|
||||||
binding.sendAsGroupSwitch.isChecked = state.sendAsGroup
|
sendAsGroupSwitch.isChecked = state.sendAsGroup
|
||||||
|
|
||||||
binding.messageList.setVisible(!state.editingMode || state.sendAsGroup || state.selectedChips.size == 1)
|
messageList.setVisible(!state.editingMode || state.sendAsGroup || state.selectedChips.size == 1)
|
||||||
messageAdapter.data = state.messages
|
messageAdapter.data = state.messages
|
||||||
messageAdapter.highlight = state.searchSelectionId
|
messageAdapter.highlight = state.searchSelectionId
|
||||||
|
|
||||||
binding.scheduledGroup.isVisible = state.scheduled != 0L
|
scheduledGroup.isVisible = state.scheduled != 0L
|
||||||
binding.scheduledTime.text = dateFormatter.getScheduledTimestamp(state.scheduled)
|
scheduledTime.text = dateFormatter.getScheduledTimestamp(state.scheduled)
|
||||||
|
|
||||||
binding.attachments.setVisible(state.attachments.isNotEmpty())
|
attachments.setVisible(state.attachments.isNotEmpty())
|
||||||
attachmentAdapter.data = state.attachments
|
attachmentAdapter.data = state.attachments
|
||||||
|
|
||||||
binding.attach.animate().rotation(if (state.attaching) 135f else 0f).start()
|
attach.animate().rotation(if (state.attaching) 135f else 0f).start()
|
||||||
binding.attaching.isVisible = state.attaching
|
attaching.isVisible = state.attaching
|
||||||
|
|
||||||
binding.counter.text = state.remaining
|
counter.text = state.remaining
|
||||||
binding.counter.setVisible(binding.counter.text.isNotBlank())
|
counter.setVisible(counter.text.isNotBlank())
|
||||||
|
|
||||||
binding.sim.setVisible(state.subscription != null)
|
sim.setVisible(state.subscription != null)
|
||||||
binding.sim.contentDescription = getString(R.string.compose_sim_cd, state.subscription?.displayName)
|
sim.contentDescription = getString(R.string.compose_sim_cd, state.subscription?.displayName)
|
||||||
binding.simIndex.text = state.subscription?.simSlotIndex?.plus(1)?.toString()
|
simIndex.text = state.subscription?.simSlotIndex?.plus(1)?.toString()
|
||||||
|
|
||||||
binding.send.isEnabled = state.canSend
|
send.isEnabled = state.canSend
|
||||||
binding.send.imageAlpha = if (state.canSend) 255 else 128
|
send.imageAlpha = if (state.canSend) 255 else 128
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSelection() = messageAdapter.clearSelection()
|
override fun clearSelection() = messageAdapter.clearSelection()
|
||||||
@@ -282,7 +280,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show()
|
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show()
|
||||||
|
|
||||||
// On some devices, the keyboard can cover the date picker
|
// On some devices, the keyboard can cover the date picker
|
||||||
binding.message.hideKeyboard()
|
message.hideKeyboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun requestContact() {
|
override fun requestContact() {
|
||||||
@@ -293,7 +291,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showContacts(sharing: Boolean, chips: List<Recipient>) {
|
override fun showContacts(sharing: Boolean, chips: List<Recipient>) {
|
||||||
binding.message.hideKeyboard()
|
message.hideKeyboard()
|
||||||
val serialized = HashMap(chips.associate { chip -> chip.address to chip.contact?.lookupKey })
|
val serialized = HashMap(chips.associate { chip -> chip.address to chip.contact?.lookupKey })
|
||||||
val intent = Intent(this, ContactsActivity::class.java)
|
val intent = Intent(this, ContactsActivity::class.java)
|
||||||
.putExtra(ContactsActivity.SharingKey, sharing)
|
.putExtra(ContactsActivity.SharingKey, sharing)
|
||||||
@@ -302,12 +300,12 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun themeChanged() {
|
override fun themeChanged() {
|
||||||
binding.messageList.scrapViews()
|
messageList.scrapViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showKeyboard() {
|
override fun showKeyboard() {
|
||||||
binding.message.postDelayed({
|
message.postDelayed({
|
||||||
binding.message.showKeyboard()
|
message.showKeyboard()
|
||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,19 +330,19 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun setDraft(draft: String) {
|
override fun setDraft(draft: String) {
|
||||||
binding.message.setText(draft)
|
message.setText(draft)
|
||||||
binding.message.setSelection(draft.length)
|
message.setSelection(draft.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun scrollToMessage(id: Long) {
|
override fun scrollToMessage(id: Long) {
|
||||||
messageAdapter.data?.second
|
messageAdapter.data?.second
|
||||||
?.indexOfLast { message -> message.id == id }
|
?.indexOfLast { message -> message.id == id }
|
||||||
?.takeIf { position -> position != -1 }
|
?.takeIf { position -> position != -1 }
|
||||||
?.let(binding.messageList::scrollToPosition)
|
?.let(messageList::scrollToPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showQksmsPlusSnackbar(message: Int) {
|
override fun showQksmsPlusSnackbar(message: Int) {
|
||||||
Snackbar.make(binding.contentView, message, Snackbar.LENGTH_LONG).run {
|
Snackbar.make(contentView, message, Snackbar.LENGTH_LONG).run {
|
||||||
setAction(R.string.button_more) { viewQksmsPlusIntent.onNext(Unit) }
|
setAction(R.string.button_more) { viewQksmsPlusIntent.onNext(Unit) }
|
||||||
setActionTextColor(colors.theme().theme)
|
setActionTextColor(colors.theme().theme)
|
||||||
show()
|
show()
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import com.moez.QKSMS.common.util.extensions.setPadding
|
|||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.compat.SubscriptionManagerCompat
|
import com.moez.QKSMS.compat.SubscriptionManagerCompat
|
||||||
import com.moez.QKSMS.databinding.MessageListItemInBinding
|
|
||||||
import com.moez.QKSMS.extensions.isSmil
|
import com.moez.QKSMS.extensions.isSmil
|
||||||
import com.moez.QKSMS.extensions.isText
|
import com.moez.QKSMS.extensions.isText
|
||||||
import com.moez.QKSMS.feature.compose.BubbleUtils.canGroup
|
import com.moez.QKSMS.feature.compose.BubbleUtils.canGroup
|
||||||
@@ -60,6 +59,15 @@ import com.moez.QKSMS.util.Preferences
|
|||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
import io.realm.RealmResults
|
import io.realm.RealmResults
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.*
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.attachments
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.body
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.sim
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.simIndex
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.status
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.timestamp
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.view.*
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_out.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -74,7 +82,7 @@ class MessagesAdapter @Inject constructor(
|
|||||||
private val phoneNumberUtils: PhoneNumberUtils,
|
private val phoneNumberUtils: PhoneNumberUtils,
|
||||||
private val prefs: Preferences,
|
private val prefs: Preferences,
|
||||||
private val textViewStyler: TextViewStyler
|
private val textViewStyler: TextViewStyler
|
||||||
) : QkRealmAdapter<Message, MessageListItemInBinding>() {
|
) : QkRealmAdapter<Message>() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val VIEW_TYPE_MESSAGE_IN = 0
|
private const val VIEW_TYPE_MESSAGE_IN = 0
|
||||||
@@ -130,7 +138,7 @@ class MessagesAdapter @Inject constructor(
|
|||||||
* this a unique viewType even though it uses the same view, so that regular messages
|
* this a unique viewType even though it uses the same view, so that regular messages
|
||||||
* don't need clipToOutline set to true, and they don't need to worry about images
|
* don't need clipToOutline set to true, and they don't need to worry about images
|
||||||
*/
|
*/
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<MessageListItemInBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
|
|
||||||
// Use the parent's context to inflate the layout, otherwise link clicks will crash the app
|
// Use the parent's context to inflate the layout, otherwise link clicks will crash the app
|
||||||
val layoutInflater = LayoutInflater.from(parent.context)
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
@@ -144,26 +152,24 @@ class MessagesAdapter @Inject constructor(
|
|||||||
view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false)
|
view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val binding = MessageListItemInBinding.bind(view)
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
binding.body.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
|
view.body.hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
val partsAdapter = partsAdapterProvider.get()
|
val partsAdapter = partsAdapterProvider.get()
|
||||||
partsAdapter.clicks.subscribe(partClicks)
|
partsAdapter.clicks.subscribe(partClicks)
|
||||||
binding.attachments.adapter = partsAdapter
|
view.attachments.adapter = partsAdapter
|
||||||
binding.attachments.setRecycledViewPool(partsViewPool)
|
view.attachments.setRecycledViewPool(partsViewPool)
|
||||||
binding.body.forwardTouches(view)
|
view.body.forwardTouches(view)
|
||||||
|
|
||||||
return QkViewHolder(binding).apply {
|
return QkViewHolder(view).apply {
|
||||||
view.setOnClickListener {
|
view.setOnClickListener {
|
||||||
val message = getItem(adapterPosition) ?: return@setOnClickListener
|
val message = getItem(adapterPosition) ?: return@setOnClickListener
|
||||||
when (toggleSelection(message.id, false)) {
|
when (toggleSelection(message.id, false)) {
|
||||||
true -> view.isActivated = isSelected(message.id)
|
true -> view.isActivated = isSelected(message.id)
|
||||||
false -> {
|
false -> {
|
||||||
clicks.onNext(message.id)
|
clicks.onNext(message.id)
|
||||||
expanded[message.id] = binding.status.visibility != View.VISIBLE
|
expanded[message.id] = view.status.visibility != View.VISIBLE
|
||||||
notifyItemChanged(adapterPosition)
|
notifyItemChanged(adapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,7 +183,7 @@ class MessagesAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<MessageListItemInBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val message = getItem(position) ?: return
|
val message = getItem(position) ?: return
|
||||||
val previous = if (position == 0) null else getItem(position - 1)
|
val previous = if (position == 0) null else getItem(position - 1)
|
||||||
val next = if (position == itemCount - 1) null else getItem(position + 1)
|
val next = if (position == itemCount - 1) null else getItem(position + 1)
|
||||||
@@ -188,10 +194,10 @@ class MessagesAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the selected state
|
// Update the selected state
|
||||||
holder.binding.root.isActivated = isSelected(message.id) || highlight == message.id
|
holder.containerView.isActivated = isSelected(message.id) || highlight == message.id
|
||||||
|
|
||||||
// Bind the cancel view
|
// Bind the cancel view
|
||||||
holder.binding.cancel.let { cancel ->
|
holder.cancel?.let { cancel ->
|
||||||
val isCancellable = message.isSending() && message.date > System.currentTimeMillis()
|
val isCancellable = message.isSending() && message.date > System.currentTimeMillis()
|
||||||
cancel.setVisible(isCancellable)
|
cancel.setVisible(isCancellable)
|
||||||
cancel.clicks().subscribe { cancelSending.onNext(message.id) }
|
cancel.clicks().subscribe { cancelSending.onNext(message.id) }
|
||||||
@@ -219,25 +225,26 @@ class MessagesAdapter @Inject constructor(
|
|||||||
val timeSincePrevious = TimeUnit.MILLISECONDS.toMinutes(message.date - (previous?.date ?: 0))
|
val timeSincePrevious = TimeUnit.MILLISECONDS.toMinutes(message.date - (previous?.date ?: 0))
|
||||||
val subscription = subs.find { sub -> sub.subscriptionId == message.subId }
|
val subscription = subs.find { sub -> sub.subscriptionId == message.subId }
|
||||||
|
|
||||||
holder.binding.timestamp.text = dateFormatter.getMessageTimestamp(message.date)
|
holder.timestamp.text = dateFormatter.getMessageTimestamp(message.date)
|
||||||
holder.binding.simIndex.text = subscription?.simSlotIndex?.plus(1)?.toString()
|
holder.simIndex.text = subscription?.simSlotIndex?.plus(1)?.toString()
|
||||||
|
|
||||||
holder.binding.timestamp.setVisible(timeSincePrevious >= BubbleUtils.TIMESTAMP_THRESHOLD
|
holder.timestamp.setVisible(timeSincePrevious >= BubbleUtils.TIMESTAMP_THRESHOLD
|
||||||
|| message.subId != previous?.subId && subscription != null)
|
|| message.subId != previous?.subId && subscription != null)
|
||||||
holder.binding.sim.setVisible(message.subId != previous?.subId && subscription != null && subs.size > 1)
|
|
||||||
holder.binding.simIndex.setVisible(message.subId != previous?.subId && subscription != null && subs.size > 1)
|
holder.sim.setVisible(message.subId != previous?.subId && subscription != null && subs.size > 1)
|
||||||
|
holder.simIndex.setVisible(message.subId != previous?.subId && subscription != null && subs.size > 1)
|
||||||
|
|
||||||
// Bind the grouping
|
// Bind the grouping
|
||||||
val media = message.parts.filter { !it.isSmil() && !it.isText() }
|
val media = message.parts.filter { !it.isSmil() && !it.isText() }
|
||||||
holder.binding.root.setPadding(bottom = if (canGroup(message, next)) 0 else 16.dpToPx(context))
|
holder.containerView.setPadding(bottom = if (canGroup(message, next)) 0 else 16.dpToPx(context))
|
||||||
|
|
||||||
// Bind the avatar and bubble colour
|
// Bind the avatar and bubble colour
|
||||||
if (!message.isMe()) {
|
if (!message.isMe()) {
|
||||||
holder.binding.avatar.setRecipient(contactCache[message.address])
|
holder.avatar.setRecipient(contactCache[message.address])
|
||||||
holder.binding.avatar.setVisible(!canGroup(message, next), View.INVISIBLE)
|
holder.avatar.setVisible(!canGroup(message, next), View.INVISIBLE)
|
||||||
|
|
||||||
holder.binding.body.setTextColor(theme.textPrimary)
|
holder.body.setTextColor(theme.textPrimary)
|
||||||
holder.binding.body.setBackgroundTint(theme.theme)
|
holder.body.setBackgroundTint(theme.theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind the body text
|
// Bind the body text
|
||||||
@@ -263,29 +270,29 @@ class MessagesAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val emojiOnly = messageText.isNotBlank() && messageText.matches(EMOJI_REGEX)
|
val emojiOnly = messageText.isNotBlank() && messageText.matches(EMOJI_REGEX)
|
||||||
textViewStyler.setTextSize(holder.binding.body, when (emojiOnly) {
|
textViewStyler.setTextSize(holder.body, when (emojiOnly) {
|
||||||
true -> TextViewStyler.SIZE_EMOJI
|
true -> TextViewStyler.SIZE_EMOJI
|
||||||
false -> TextViewStyler.SIZE_PRIMARY
|
false -> TextViewStyler.SIZE_PRIMARY
|
||||||
})
|
})
|
||||||
|
|
||||||
holder.binding.body.text = messageText
|
holder.body.text = messageText
|
||||||
holder.binding.body.setVisible(message.isSms() || messageText.isNotBlank())
|
holder.body.setVisible(message.isSms() || messageText.isNotBlank())
|
||||||
holder.binding.body.setBackgroundResource(getBubble(
|
holder.body.setBackgroundResource(getBubble(
|
||||||
emojiOnly = emojiOnly,
|
emojiOnly = emojiOnly,
|
||||||
canGroupWithPrevious = canGroup(message, previous) || media.isNotEmpty(),
|
canGroupWithPrevious = canGroup(message, previous) || media.isNotEmpty(),
|
||||||
canGroupWithNext = canGroup(message, next),
|
canGroupWithNext = canGroup(message, next),
|
||||||
isMe = message.isMe()))
|
isMe = message.isMe()))
|
||||||
|
|
||||||
// Bind the attachments
|
// Bind the attachments
|
||||||
val partsAdapter = holder.binding.attachments.adapter as PartsAdapter
|
val partsAdapter = holder.attachments.adapter as PartsAdapter
|
||||||
partsAdapter.theme = theme
|
partsAdapter.theme = theme
|
||||||
partsAdapter.setData(message, previous, next, holder)
|
partsAdapter.setData(message, previous, next, holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindStatus(holder: QkViewHolder<MessageListItemInBinding>, message: Message, next: Message?) {
|
private fun bindStatus(holder: QkViewHolder, message: Message, next: Message?) {
|
||||||
val age = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - message.date)
|
val age = TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - message.date)
|
||||||
|
|
||||||
holder.binding.status.text = when {
|
holder.status.text = when {
|
||||||
message.isSending() -> context.getString(R.string.message_status_sending)
|
message.isSending() -> context.getString(R.string.message_status_sending)
|
||||||
message.isDelivered() -> context.getString(R.string.message_status_delivered,
|
message.isDelivered() -> context.getString(R.string.message_status_delivered,
|
||||||
dateFormatter.getTimestamp(message.dateSent))
|
dateFormatter.getTimestamp(message.dateSent))
|
||||||
@@ -299,7 +306,7 @@ class MessagesAdapter @Inject constructor(
|
|||||||
else -> dateFormatter.getTimestamp(message.date)
|
else -> dateFormatter.getTimestamp(message.date)
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.binding.status.setVisible(when {
|
holder.status.setVisible(when {
|
||||||
expanded[message.id] == true -> true
|
expanded[message.id] == true -> true
|
||||||
message.isSending() -> true
|
message.isSending() -> true
|
||||||
message.isFailedMessage() -> true
|
message.isFailedMessage() -> true
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package com.moez.QKSMS.feature.compose.editing
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@@ -29,35 +30,37 @@ import com.moez.QKSMS.common.base.QkViewHolder
|
|||||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.databinding.ContactChipBinding
|
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
|
import kotlinx.android.synthetic.main.contact_chip.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ChipsAdapter @Inject constructor() : QkAdapter<Recipient, ContactChipBinding>() {
|
class ChipsAdapter @Inject constructor() : QkAdapter<Recipient>() {
|
||||||
|
|
||||||
var view: RecyclerView? = null
|
var view: RecyclerView? = null
|
||||||
val chipDeleted: PublishSubject<Recipient> = PublishSubject.create<Recipient>()
|
val chipDeleted: PublishSubject<Recipient> = PublishSubject.create<Recipient>()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ContactChipBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, ContactChipBinding::inflate).apply {
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
|
val view = inflater.inflate(R.layout.contact_chip, parent, false)
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
// These theme attributes don't apply themselves on API 21
|
// These theme attributes don't apply themselves on API 21
|
||||||
if (Build.VERSION.SDK_INT <= 22) {
|
if (Build.VERSION.SDK_INT <= 22) {
|
||||||
binding.content.setBackgroundTint(parent.context.resolveThemeColor(R.attr.bubbleColor))
|
content.setBackgroundTint(view.context.resolveThemeColor(R.attr.bubbleColor))
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
view.setOnClickListener {
|
||||||
val chip = getItem(adapterPosition)
|
val chip = getItem(adapterPosition)
|
||||||
showDetailedChip(parent.context, chip)
|
showDetailedChip(view.context, chip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ContactChipBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val recipient = getItem(position)
|
val recipient = getItem(position)
|
||||||
|
|
||||||
holder.binding.avatar.setRecipient(recipient)
|
holder.avatar.setRecipient(recipient)
|
||||||
holder.binding.name.text = recipient.contact?.name?.takeIf { it.isNotBlank() } ?: recipient.address
|
holder.name.text = recipient.contact?.name?.takeIf { it.isNotBlank() } ?: recipient.address
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,9 +76,8 @@ class ChipsAdapter @Inject constructor() : QkAdapter<Recipient, ContactChipBindi
|
|||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT)
|
ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
|
|
||||||
layoutParams.topMargin = 32.dpToPx(context)
|
layoutParams.topMargin = 24.dpToPx(context)
|
||||||
layoutParams.marginStart = 56.dpToPx(context)
|
layoutParams.marginStart = 56.dpToPx(context)
|
||||||
layoutParams.marginEnd = 8.dpToPx(context)
|
|
||||||
|
|
||||||
rootView.addView(detailedChipView, layoutParams)
|
rootView.addView(detailedChipView, layoutParams)
|
||||||
detailedChipView.show()
|
detailedChipView.show()
|
||||||
|
|||||||
+63
-58
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.compose.editing
|
package com.moez.QKSMS.feature.compose.editing
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@@ -27,7 +28,6 @@ import com.moez.QKSMS.common.base.QkViewHolder
|
|||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.forwardTouches
|
import com.moez.QKSMS.common.util.extensions.forwardTouches
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.databinding.ContactListItemBinding
|
|
||||||
import com.moez.QKSMS.extensions.associateByNotNull
|
import com.moez.QKSMS.extensions.associateByNotNull
|
||||||
import com.moez.QKSMS.model.Contact
|
import com.moez.QKSMS.model.Contact
|
||||||
import com.moez.QKSMS.model.ContactGroup
|
import com.moez.QKSMS.model.ContactGroup
|
||||||
@@ -38,12 +38,14 @@ import io.reactivex.disposables.CompositeDisposable
|
|||||||
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
|
||||||
|
import kotlinx.android.synthetic.main.contact_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.contact_list_item.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ComposeItemAdapter @Inject constructor(
|
class ComposeItemAdapter @Inject constructor(
|
||||||
private val colors: Colors,
|
private val colors: Colors,
|
||||||
private val conversationRepo: ConversationRepository
|
private val conversationRepo: ConversationRepository
|
||||||
) : QkAdapter<ComposeItem, ContactListItemBinding>() {
|
) : QkAdapter<ComposeItem>() {
|
||||||
|
|
||||||
val clicks: Subject<ComposeItem> = PublishSubject.create()
|
val clicks: Subject<ComposeItem> = PublishSubject.create()
|
||||||
val longClicks: Subject<ComposeItem> = PublishSubject.create()
|
val longClicks: Subject<ComposeItem> = PublishSubject.create()
|
||||||
@@ -57,19 +59,22 @@ class ComposeItemAdapter @Inject constructor(
|
|||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ContactListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, ContactListItemBinding::inflate).apply {
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
binding.icon.setTint(colors.theme().theme)
|
val view = layoutInflater.inflate(R.layout.contact_list_item, parent, false)
|
||||||
|
|
||||||
binding.numbers.setRecycledViewPool(numbersViewPool)
|
view.icon.setTint(colors.theme().theme)
|
||||||
binding.numbers.adapter = PhoneNumberAdapter()
|
|
||||||
binding.numbers.forwardTouches(binding.root)
|
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
view.numbers.setRecycledViewPool(numbersViewPool)
|
||||||
|
view.numbers.adapter = PhoneNumberAdapter()
|
||||||
|
view.numbers.forwardTouches(view)
|
||||||
|
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
|
view.setOnClickListener {
|
||||||
val item = getItem(adapterPosition)
|
val item = getItem(adapterPosition)
|
||||||
clicks.onNext(item)
|
clicks.onNext(item)
|
||||||
}
|
}
|
||||||
binding.root.setOnLongClickListener {
|
view.setOnLongClickListener {
|
||||||
val item = getItem(adapterPosition)
|
val item = getItem(adapterPosition)
|
||||||
longClicks.onNext(item)
|
longClicks.onNext(item)
|
||||||
true
|
true
|
||||||
@@ -77,7 +82,7 @@ class ComposeItemAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ContactListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val prevItem = if (position > 0) getItem(position - 1) else null
|
val prevItem = if (position > 0) getItem(position - 1) else null
|
||||||
val item = getItem(position)
|
val item = getItem(position)
|
||||||
|
|
||||||
@@ -90,92 +95,92 @@ class ComposeItemAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindNew(holder: QkViewHolder<ContactListItemBinding>, contact: Contact) {
|
private fun bindNew(holder: QkViewHolder, contact: Contact) {
|
||||||
holder.binding.index.isVisible = false
|
holder.index.isVisible = false
|
||||||
|
|
||||||
holder.binding.icon.isVisible = false
|
holder.icon.isVisible = false
|
||||||
|
|
||||||
holder.binding.avatar.recipients = listOf(createRecipient(contact))
|
holder.avatar.recipients = listOf(createRecipient(contact))
|
||||||
|
|
||||||
holder.binding.title.text = contact.numbers.joinToString { it.address }
|
holder.title.text = contact.numbers.joinToString { it.address }
|
||||||
|
|
||||||
holder.binding.subtitle.isVisible = false
|
holder.subtitle.isVisible = false
|
||||||
|
|
||||||
holder.binding.numbers.isVisible = false
|
holder.numbers.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindRecent(holder: QkViewHolder<ContactListItemBinding>, conversation: Conversation, prev: ComposeItem?) {
|
private fun bindRecent(holder: QkViewHolder, conversation: Conversation, prev: ComposeItem?) {
|
||||||
holder.binding.index.isVisible = false
|
holder.index.isVisible = false
|
||||||
|
|
||||||
holder.binding.icon.isVisible = prev !is ComposeItem.Recent
|
holder.icon.isVisible = prev !is ComposeItem.Recent
|
||||||
holder.binding.icon.setImageResource(R.drawable.ic_history_black_24dp)
|
holder.icon.setImageResource(R.drawable.ic_history_black_24dp)
|
||||||
|
|
||||||
holder.binding.avatar.recipients = conversation.recipients
|
holder.avatar.recipients = conversation.recipients
|
||||||
|
|
||||||
holder.binding.title.text = conversation.getTitle()
|
holder.title.text = conversation.getTitle()
|
||||||
|
|
||||||
holder.binding.subtitle.isVisible = conversation.recipients.size > 1 && conversation.name.isBlank()
|
holder.subtitle.isVisible = conversation.recipients.size > 1 && conversation.name.isBlank()
|
||||||
holder.binding.subtitle.text = conversation.recipients.joinToString(", ") { recipient ->
|
holder.subtitle.text = conversation.recipients.joinToString(", ") { recipient ->
|
||||||
recipient.contact?.name ?: recipient.address
|
recipient.contact?.name ?: recipient.address
|
||||||
}
|
}
|
||||||
holder.binding.subtitle.collapseEnabled = conversation.recipients.size > 1
|
holder.subtitle.collapseEnabled = conversation.recipients.size > 1
|
||||||
|
|
||||||
holder.binding.numbers.isVisible = conversation.recipients.size == 1
|
holder.numbers.isVisible = conversation.recipients.size == 1
|
||||||
(holder.binding.numbers.adapter as PhoneNumberAdapter).data = conversation.recipients
|
(holder.numbers.adapter as PhoneNumberAdapter).data = conversation.recipients
|
||||||
.mapNotNull { recipient -> recipient.contact }
|
.mapNotNull { recipient -> recipient.contact }
|
||||||
.flatMap { contact -> contact.numbers }
|
.flatMap { contact -> contact.numbers }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindStarred(holder: QkViewHolder<ContactListItemBinding>, contact: Contact, prev: ComposeItem?) {
|
private fun bindStarred(holder: QkViewHolder, contact: Contact, prev: ComposeItem?) {
|
||||||
holder.binding.index.isVisible = false
|
holder.index.isVisible = false
|
||||||
|
|
||||||
holder.binding.icon.isVisible = prev !is ComposeItem.Starred
|
holder.icon.isVisible = prev !is ComposeItem.Starred
|
||||||
holder.binding.icon.setImageResource(R.drawable.ic_star_black_24dp)
|
holder.icon.setImageResource(R.drawable.ic_star_black_24dp)
|
||||||
|
|
||||||
holder.binding.avatar.recipients = listOf(createRecipient(contact))
|
holder.avatar.recipients = listOf(createRecipient(contact))
|
||||||
|
|
||||||
holder.binding.title.text = contact.name
|
holder.title.text = contact.name
|
||||||
|
|
||||||
holder.binding.subtitle.isVisible = false
|
holder.subtitle.isVisible = false
|
||||||
|
|
||||||
holder.binding.numbers.isVisible = true
|
holder.numbers.isVisible = true
|
||||||
(holder.binding.numbers.adapter as PhoneNumberAdapter).data = contact.numbers
|
(holder.numbers.adapter as PhoneNumberAdapter).data = contact.numbers
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindGroup(holder: QkViewHolder<ContactListItemBinding>, group: ContactGroup, prev: ComposeItem?) {
|
private fun bindGroup(holder: QkViewHolder, group: ContactGroup, prev: ComposeItem?) {
|
||||||
holder.binding.index.isVisible = false
|
holder.index.isVisible = false
|
||||||
|
|
||||||
holder.binding.icon.isVisible = prev !is ComposeItem.Group
|
holder.icon.isVisible = prev !is ComposeItem.Group
|
||||||
holder.binding.icon.setImageResource(R.drawable.ic_people_black_24dp)
|
holder.icon.setImageResource(R.drawable.ic_people_black_24dp)
|
||||||
|
|
||||||
holder.binding.avatar.recipients = group.contacts.map(::createRecipient)
|
holder.avatar.recipients = group.contacts.map(::createRecipient)
|
||||||
|
|
||||||
holder.binding.title.text = group.title
|
holder.title.text = group.title
|
||||||
|
|
||||||
holder.binding.subtitle.isVisible = true
|
holder.subtitle.isVisible = true
|
||||||
holder.binding.subtitle.text = group.contacts.joinToString(", ") { it.name }
|
holder.subtitle.text = group.contacts.joinToString(", ") { it.name }
|
||||||
holder.binding.subtitle.collapseEnabled = group.contacts.size > 1
|
holder.subtitle.collapseEnabled = group.contacts.size > 1
|
||||||
|
|
||||||
holder.binding.numbers.isVisible = false
|
holder.numbers.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindPerson(holder: QkViewHolder<ContactListItemBinding>, contact: Contact, prev: ComposeItem?) {
|
private fun bindPerson(holder: QkViewHolder, contact: Contact, prev: ComposeItem?) {
|
||||||
holder.binding.index.isVisible = true
|
holder.index.isVisible = true
|
||||||
holder.binding.index.text = if (contact.name.getOrNull(0)?.isLetter() == true) contact.name[0].toString() else "#"
|
holder.index.text = if (contact.name.getOrNull(0)?.isLetter() == true) contact.name[0].toString() else "#"
|
||||||
holder.binding.index.isVisible = prev !is ComposeItem.Person ||
|
holder.index.isVisible = prev !is ComposeItem.Person ||
|
||||||
(contact.name[0].isLetter() && !contact.name[0].equals(prev.value.name[0], ignoreCase = true)) ||
|
(contact.name[0].isLetter() && !contact.name[0].equals(prev.value.name[0], ignoreCase = true)) ||
|
||||||
(!contact.name[0].isLetter() && prev.value.name[0].isLetter())
|
(!contact.name[0].isLetter() && prev.value.name[0].isLetter())
|
||||||
|
|
||||||
holder.binding.icon.isVisible = false
|
holder.icon.isVisible = false
|
||||||
|
|
||||||
holder.binding.avatar.recipients = listOf(createRecipient(contact))
|
holder.avatar.recipients = listOf(createRecipient(contact))
|
||||||
|
|
||||||
holder.binding.title.text = contact.name
|
holder.title.text = contact.name
|
||||||
|
|
||||||
holder.binding.subtitle.isVisible = false
|
holder.subtitle.isVisible = false
|
||||||
|
|
||||||
holder.binding.numbers.isVisible = true
|
holder.numbers.isVisible = true
|
||||||
(holder.binding.numbers.adapter as PhoneNumberAdapter).data = contact.numbers
|
(holder.numbers.adapter as PhoneNumberAdapter).data = contact.numbers
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createRecipient(contact: Contact): Recipient {
|
private fun createRecipient(contact: Contact): Recipient {
|
||||||
|
|||||||
+14
-23
@@ -19,53 +19,44 @@
|
|||||||
package com.moez.QKSMS.feature.compose.editing
|
package com.moez.QKSMS.feature.compose.editing
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.animation.AlphaAnimation
|
import android.view.animation.AlphaAnimation
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import android.widget.RelativeLayout
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.ContactChipDetailedBinding
|
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
|
import kotlinx.android.synthetic.main.contact_chip_detailed.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class DetailedChipView(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(context, attrs) {
|
class DetailedChipView(context: Context) : RelativeLayout(context) {
|
||||||
|
|
||||||
@Inject lateinit var colors: Colors
|
@Inject lateinit var colors: Colors
|
||||||
|
|
||||||
private val binding = viewBinding(ContactChipDetailedBinding::inflate)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (!isInEditMode) {
|
View.inflate(context, R.layout.contact_chip_detailed, this)
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
setOnClickListener { hide() }
|
setOnClickListener { hide() }
|
||||||
setBackgroundResource(R.drawable.rounded_rectangle_2dp)
|
|
||||||
|
|
||||||
elevation = 8.dpToPx(context) .toFloat()
|
visibility = View.GONE
|
||||||
// updateLayoutParams<LinearLayout.LayoutParams> { setMargins(8.dpToPx(context) ) }
|
|
||||||
|
|
||||||
isFocusable = true
|
isFocusable = true
|
||||||
isFocusableInTouchMode = true
|
isFocusableInTouchMode = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setRecipient(recipient: Recipient) {
|
fun setRecipient(recipient: Recipient) {
|
||||||
binding.avatar.setRecipient(recipient)
|
avatar.setRecipient(recipient)
|
||||||
binding.name.text = recipient.contact?.name?.takeIf { it.isNotBlank() } ?: recipient.address
|
name.text = recipient.contact?.name?.takeIf { it.isNotBlank() } ?: recipient.address
|
||||||
binding.info.text = recipient.address
|
info.text = recipient.address
|
||||||
|
|
||||||
colors.theme(recipient).let { theme ->
|
colors.theme(recipient).let { theme ->
|
||||||
setBackgroundTint(theme.theme)
|
card.setBackgroundTint(theme.theme)
|
||||||
binding.name.setTextColor(theme.textPrimary)
|
name.setTextColor(theme.textPrimary)
|
||||||
binding.info.setTextColor(theme.textTertiary)
|
info.setTextColor(theme.textTertiary)
|
||||||
binding.delete.setTint(theme.textPrimary)
|
delete.setTint(theme.textPrimary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +77,7 @@ class DetailedChipView(context: Context, attrs: AttributeSet? = null) : Constrai
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setOnDeleteListener(listener: (View) -> Unit) {
|
fun setOnDeleteListener(listener: (View) -> Unit) {
|
||||||
binding.delete.setOnClickListener(listener)
|
delete.setOnClickListener(listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-8
@@ -18,23 +18,27 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.compose.editing
|
package com.moez.QKSMS.feature.compose.editing
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.databinding.ContactNumberListItemBinding
|
|
||||||
import com.moez.QKSMS.model.PhoneNumber
|
import com.moez.QKSMS.model.PhoneNumber
|
||||||
|
import kotlinx.android.synthetic.main.contact_number_list_item.*
|
||||||
|
|
||||||
class PhoneNumberAdapter : QkAdapter<PhoneNumber, ContactNumberListItemBinding>() {
|
class PhoneNumberAdapter : QkAdapter<PhoneNumber>() {
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ContactNumberListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, ContactNumberListItemBinding::inflate)
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
|
val view = inflater.inflate(R.layout.contact_number_list_item, parent, false)
|
||||||
|
return QkViewHolder(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ContactNumberListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val number = getItem(position)
|
val number = getItem(position)
|
||||||
|
|
||||||
holder.binding.address.text = number.address
|
holder.address.text = number.address
|
||||||
holder.binding.type.text = number.type
|
holder.type.text = number.type
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun areItemsTheSame(old: PhoneNumber, new: PhoneNumber): Boolean {
|
override fun areItemsTheSame(old: PhoneNumber, new: PhoneNumber): Boolean {
|
||||||
@@ -45,4 +49,4 @@ class PhoneNumberAdapter : QkAdapter<PhoneNumber, ContactNumberListItemBinding>(
|
|||||||
return old.type == new.type && old.address == new.address
|
return old.type == new.type && old.address == new.address
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+15
-10
@@ -19,21 +19,24 @@
|
|||||||
package com.moez.QKSMS.feature.compose.editing
|
package com.moez.QKSMS.feature.compose.editing
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.extensions.forwardTouches
|
import com.moez.QKSMS.common.util.extensions.forwardTouches
|
||||||
import com.moez.QKSMS.databinding.PhoneNumberListItemBinding
|
|
||||||
import com.moez.QKSMS.extensions.Optional
|
import com.moez.QKSMS.extensions.Optional
|
||||||
import com.moez.QKSMS.model.PhoneNumber
|
import com.moez.QKSMS.model.PhoneNumber
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.phone_number_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.radio_preference_view.*
|
||||||
|
import kotlinx.android.synthetic.main.radio_preference_view.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class PhoneNumberPickerAdapter @Inject constructor(
|
class PhoneNumberPickerAdapter @Inject constructor(
|
||||||
private val context: Context
|
private val context: Context
|
||||||
) : QkAdapter<PhoneNumber, PhoneNumberListItemBinding>() {
|
) : QkAdapter<PhoneNumber>() {
|
||||||
|
|
||||||
val selectedItemChanges: Subject<Optional<Long>> = BehaviorSubject.create()
|
val selectedItemChanges: Subject<Optional<Long>> = BehaviorSubject.create()
|
||||||
|
|
||||||
@@ -45,23 +48,25 @@ class PhoneNumberPickerAdapter @Inject constructor(
|
|||||||
selectedItemChanges.onNext(Optional(value))
|
selectedItemChanges.onNext(Optional(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<PhoneNumberListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, PhoneNumberListItemBinding::inflate).apply {
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
binding.number.binding.radioButton.forwardTouches(itemView)
|
val view = inflater.inflate(R.layout.phone_number_list_item, parent, false)
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
|
radioButton.forwardTouches(itemView)
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
view.setOnClickListener {
|
||||||
val phoneNumber = getItem(adapterPosition)
|
val phoneNumber = getItem(adapterPosition)
|
||||||
selectedItem = phoneNumber.id
|
selectedItem = phoneNumber.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<PhoneNumberListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val phoneNumber = getItem(position)
|
val phoneNumber = getItem(position)
|
||||||
|
|
||||||
holder.binding.number.binding.radioButton.isChecked = phoneNumber.id == selectedItem
|
holder.number.radioButton.isChecked = phoneNumber.id == selectedItem
|
||||||
holder.binding.number.binding.titleView.text = phoneNumber.address
|
holder.number.titleView.text = phoneNumber.address
|
||||||
holder.binding.number.binding.summaryView.text = when (phoneNumber.isDefault) {
|
holder.number.summaryView.text = when (phoneNumber.isDefault) {
|
||||||
true -> context.getString(R.string.compose_number_picker_default, phoneNumber.type)
|
true -> context.getString(R.string.compose_number_picker_default, phoneNumber.type)
|
||||||
false -> phoneNumber.type
|
false -> phoneNumber.type
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,37 +28,35 @@ import com.moez.QKSMS.common.util.Colors
|
|||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.databinding.MmsFileListItemBinding
|
|
||||||
import com.moez.QKSMS.feature.compose.BubbleUtils
|
import com.moez.QKSMS.feature.compose.BubbleUtils
|
||||||
import com.moez.QKSMS.model.Message
|
import com.moez.QKSMS.model.Message
|
||||||
import com.moez.QKSMS.model.MmsPart
|
import com.moez.QKSMS.model.MmsPart
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import kotlinx.android.synthetic.main.mms_file_list_item.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FileBinder @Inject constructor(
|
class FileBinder @Inject constructor(colors: Colors, private val context: Context) : PartBinder() {
|
||||||
colors: Colors,
|
|
||||||
private val context: Context
|
|
||||||
) : PartBinder<MmsFileListItemBinding>(MmsFileListItemBinding::inflate) {
|
|
||||||
|
|
||||||
|
override val partLayout = R.layout.mms_file_list_item
|
||||||
override var theme = colors.theme()
|
override var theme = colors.theme()
|
||||||
|
|
||||||
// This is the last binder we check. If we're here, we can bind the part
|
// This is the last binder we check. If we're here, we can bind the part
|
||||||
override fun canBindPart(part: MmsPart) = true
|
override fun canBindPart(part: MmsPart) = true
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
override fun bindPartInternal(
|
override fun bindPart(
|
||||||
holder: QkViewHolder<MmsFileListItemBinding>,
|
holder: QkViewHolder,
|
||||||
part: MmsPart,
|
part: MmsPart,
|
||||||
message: Message,
|
message: Message,
|
||||||
canGroupWithPrevious: Boolean,
|
canGroupWithPrevious: Boolean,
|
||||||
canGroupWithNext: Boolean
|
canGroupWithNext: Boolean
|
||||||
) {
|
) {
|
||||||
BubbleUtils.getBubble(false, canGroupWithPrevious, canGroupWithNext, message.isMe())
|
BubbleUtils.getBubble(false, canGroupWithPrevious, canGroupWithNext, message.isMe())
|
||||||
.let(holder.binding.fileBackground::setBackgroundResource)
|
.let(holder.fileBackground::setBackgroundResource)
|
||||||
|
|
||||||
holder.binding.root.setOnClickListener { clicks.onNext(part.id) }
|
holder.containerView.setOnClickListener { clicks.onNext(part.id) }
|
||||||
|
|
||||||
Observable.just(part.getUri())
|
Observable.just(part.getUri())
|
||||||
.map(context.contentResolver::openInputStream)
|
.map(context.contentResolver::openInputStream)
|
||||||
@@ -73,23 +71,23 @@ class FileBinder @Inject constructor(
|
|||||||
}
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe { size -> holder.binding.size.text = size }
|
.subscribe { size -> holder.size.text = size }
|
||||||
|
|
||||||
holder.binding.filename.text = part.name
|
holder.filename.text = part.name
|
||||||
|
|
||||||
val params = holder.binding.fileBackground.layoutParams as FrameLayout.LayoutParams
|
val params = holder.fileBackground.layoutParams as FrameLayout.LayoutParams
|
||||||
if (!message.isMe()) {
|
if (!message.isMe()) {
|
||||||
holder.binding.fileBackground.layoutParams = params.apply { gravity = Gravity.START }
|
holder.fileBackground.layoutParams = params.apply { gravity = Gravity.START }
|
||||||
holder.binding.fileBackground.setBackgroundTint(theme.theme)
|
holder.fileBackground.setBackgroundTint(theme.theme)
|
||||||
holder.binding.icon.setTint(theme.textPrimary)
|
holder.icon.setTint(theme.textPrimary)
|
||||||
holder.binding.filename.setTextColor(theme.textPrimary)
|
holder.filename.setTextColor(theme.textPrimary)
|
||||||
holder.binding.size.setTextColor(theme.textTertiary)
|
holder.size.setTextColor(theme.textTertiary)
|
||||||
} else {
|
} else {
|
||||||
holder.binding.fileBackground.layoutParams = params.apply { gravity = Gravity.END }
|
holder.fileBackground.layoutParams = params.apply { gravity = Gravity.END }
|
||||||
holder.binding.fileBackground.setBackgroundTint(holder.binding.root.context.resolveThemeColor(R.attr.bubbleColor))
|
holder.fileBackground.setBackgroundTint(holder.containerView.context.resolveThemeColor(R.attr.bubbleColor))
|
||||||
holder.binding.icon.setTint(holder.binding.root.context.resolveThemeColor(android.R.attr.textColorSecondary))
|
holder.icon.setTint(holder.containerView.context.resolveThemeColor(android.R.attr.textColorSecondary))
|
||||||
holder.binding.filename.setTextColor(holder.binding.root.context.resolveThemeColor(android.R.attr.textColorPrimary))
|
holder.filename.setTextColor(holder.containerView.context.resolveThemeColor(android.R.attr.textColorPrimary))
|
||||||
holder.binding.size.setTextColor(holder.binding.root.context.resolveThemeColor(android.R.attr.textColorTertiary))
|
holder.size.setTextColor(holder.containerView.context.resolveThemeColor(android.R.attr.textColorTertiary))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,45 +19,44 @@
|
|||||||
package com.moez.QKSMS.feature.compose.part
|
package com.moez.QKSMS.feature.compose.part
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.widget.BubbleImageView
|
import com.moez.QKSMS.common.widget.BubbleImageView
|
||||||
import com.moez.QKSMS.databinding.MmsPreviewListItemBinding
|
|
||||||
import com.moez.QKSMS.extensions.isImage
|
import com.moez.QKSMS.extensions.isImage
|
||||||
import com.moez.QKSMS.extensions.isVideo
|
import com.moez.QKSMS.extensions.isVideo
|
||||||
import com.moez.QKSMS.model.Message
|
import com.moez.QKSMS.model.Message
|
||||||
import com.moez.QKSMS.model.MmsPart
|
import com.moez.QKSMS.model.MmsPart
|
||||||
import com.moez.QKSMS.util.GlideApp
|
import com.moez.QKSMS.util.GlideApp
|
||||||
|
import kotlinx.android.synthetic.main.mms_preview_list_item.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MediaBinder @Inject constructor(
|
class MediaBinder @Inject constructor(colors: Colors, private val context: Context) : PartBinder() {
|
||||||
colors: Colors,
|
|
||||||
private val context: Context
|
|
||||||
) : PartBinder<MmsPreviewListItemBinding>(MmsPreviewListItemBinding::inflate) {
|
|
||||||
|
|
||||||
|
override val partLayout = R.layout.mms_preview_list_item
|
||||||
override var theme = colors.theme()
|
override var theme = colors.theme()
|
||||||
|
|
||||||
override fun canBindPart(part: MmsPart) = part.isImage() || part.isVideo()
|
override fun canBindPart(part: MmsPart) = part.isImage() || part.isVideo()
|
||||||
|
|
||||||
override fun bindPartInternal(
|
override fun bindPart(
|
||||||
holder: QkViewHolder<MmsPreviewListItemBinding>,
|
holder: QkViewHolder,
|
||||||
part: MmsPart,
|
part: MmsPart,
|
||||||
message: Message,
|
message: Message,
|
||||||
canGroupWithPrevious: Boolean,
|
canGroupWithPrevious: Boolean,
|
||||||
canGroupWithNext: Boolean
|
canGroupWithNext: Boolean
|
||||||
) {
|
) {
|
||||||
holder.binding.video.setVisible(part.isVideo())
|
holder.video.setVisible(part.isVideo())
|
||||||
holder.binding.root.setOnClickListener { clicks.onNext(part.id) }
|
holder.containerView.setOnClickListener { clicks.onNext(part.id) }
|
||||||
|
|
||||||
holder.binding.thumbnail.bubbleStyle = when {
|
holder.thumbnail.bubbleStyle = when {
|
||||||
!canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_FIRST else BubbleImageView.Style.IN_FIRST
|
!canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_FIRST else BubbleImageView.Style.IN_FIRST
|
||||||
canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_MIDDLE else BubbleImageView.Style.IN_MIDDLE
|
canGroupWithPrevious && canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_MIDDLE else BubbleImageView.Style.IN_MIDDLE
|
||||||
canGroupWithPrevious && !canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_LAST else BubbleImageView.Style.IN_LAST
|
canGroupWithPrevious && !canGroupWithNext -> if (message.isMe()) BubbleImageView.Style.OUT_LAST else BubbleImageView.Style.IN_LAST
|
||||||
else -> BubbleImageView.Style.ONLY
|
else -> BubbleImageView.Style.ONLY
|
||||||
}
|
}
|
||||||
|
|
||||||
GlideApp.with(context).load(part.getUri()).fitCenter().into(holder.binding.thumbnail)
|
GlideApp.with(context).load(part.getUri()).fitCenter().into(holder.thumbnail)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,9 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.compose.part
|
package com.moez.QKSMS.feature.compose.part
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.model.Message
|
import com.moez.QKSMS.model.Message
|
||||||
@@ -28,36 +25,18 @@ import com.moez.QKSMS.model.MmsPart
|
|||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
|
||||||
abstract class PartBinder<Binding : ViewBinding>(
|
abstract class PartBinder {
|
||||||
val bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> Binding
|
|
||||||
) {
|
|
||||||
|
|
||||||
val clicks: Subject<Long> = PublishSubject.create()
|
val clicks: Subject<Long> = PublishSubject.create()
|
||||||
|
|
||||||
|
abstract val partLayout: Int
|
||||||
|
|
||||||
abstract var theme: Colors.Theme
|
abstract var theme: Colors.Theme
|
||||||
|
|
||||||
fun <T: ViewBinding> bindPart(
|
|
||||||
holder: QkViewHolder<T>,
|
|
||||||
part: MmsPart,
|
|
||||||
message: Message,
|
|
||||||
canGroupWithPrevious: Boolean,
|
|
||||||
canGroupWithNext: Boolean
|
|
||||||
): Boolean {
|
|
||||||
val castHolder = holder as? QkViewHolder<Binding>
|
|
||||||
|
|
||||||
if (!canBindPart(part) || castHolder == null) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
bindPartInternal(castHolder, part, message, canGroupWithPrevious, canGroupWithNext)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract fun canBindPart(part: MmsPart): Boolean
|
abstract fun canBindPart(part: MmsPart): Boolean
|
||||||
|
|
||||||
protected abstract fun bindPartInternal(
|
abstract fun bindPart(
|
||||||
holder: QkViewHolder<Binding>,
|
holder: QkViewHolder,
|
||||||
part: MmsPart,
|
part: MmsPart,
|
||||||
message: Message,
|
message: Message,
|
||||||
canGroupWithPrevious: Boolean,
|
canGroupWithPrevious: Boolean,
|
||||||
|
|||||||
@@ -18,20 +18,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.feature.compose.part
|
package com.moez.QKSMS.feature.compose.part
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.forwardTouches
|
import com.moez.QKSMS.common.util.extensions.forwardTouches
|
||||||
import com.moez.QKSMS.databinding.MessageListItemInBinding
|
|
||||||
import com.moez.QKSMS.extensions.isSmil
|
import com.moez.QKSMS.extensions.isSmil
|
||||||
import com.moez.QKSMS.extensions.isText
|
import com.moez.QKSMS.extensions.isText
|
||||||
import com.moez.QKSMS.feature.compose.BubbleUtils.canGroup
|
import com.moez.QKSMS.feature.compose.BubbleUtils.canGroup
|
||||||
import com.moez.QKSMS.model.Message
|
import com.moez.QKSMS.model.Message
|
||||||
import com.moez.QKSMS.model.MmsPart
|
import com.moez.QKSMS.model.MmsPart
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
|
import kotlinx.android.synthetic.main.message_list_item_in.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class PartsAdapter @Inject constructor(
|
class PartsAdapter @Inject constructor(
|
||||||
@@ -39,7 +39,7 @@ class PartsAdapter @Inject constructor(
|
|||||||
fileBinder: FileBinder,
|
fileBinder: FileBinder,
|
||||||
mediaBinder: MediaBinder,
|
mediaBinder: MediaBinder,
|
||||||
vCardBinder: VCardBinder
|
vCardBinder: VCardBinder
|
||||||
) : QkAdapter<MmsPart, ViewBinding>() {
|
) : QkAdapter<MmsPart>() {
|
||||||
|
|
||||||
private val partBinders = listOf(mediaBinder, vCardBinder, fileBinder)
|
private val partBinders = listOf(mediaBinder, vCardBinder, fileBinder)
|
||||||
|
|
||||||
@@ -54,31 +54,34 @@ class PartsAdapter @Inject constructor(
|
|||||||
private lateinit var message: Message
|
private lateinit var message: Message
|
||||||
private var previous: Message? = null
|
private var previous: Message? = null
|
||||||
private var next: Message? = null
|
private var next: Message? = null
|
||||||
private var holder: QkViewHolder<MessageListItemInBinding>? = null
|
private var holder: QkViewHolder? = null
|
||||||
private var bodyVisible: Boolean = true
|
private var bodyVisible: Boolean = true
|
||||||
|
|
||||||
fun setData(message: Message, previous: Message?, next: Message?, holder: QkViewHolder<MessageListItemInBinding>) {
|
fun setData(message: Message, previous: Message?, next: Message?, holder: QkViewHolder) {
|
||||||
this.message = message
|
this.message = message
|
||||||
this.previous = previous
|
this.previous = previous
|
||||||
this.next = next
|
this.next = next
|
||||||
this.holder = holder
|
this.holder = holder
|
||||||
this.bodyVisible = holder.binding.body.visibility == View.VISIBLE
|
this.bodyVisible = holder.body.visibility == View.VISIBLE
|
||||||
this.data = message.parts.filter { !it.isSmil() && !it.isText() }
|
this.data = message.parts.filter { !it.isSmil() && !it.isText() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ViewBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, partBinders[viewType].bindingInflater).apply {
|
val layout = partBinders.getOrNull(viewType)?.partLayout ?: 0
|
||||||
holder?.binding?.root?.let(binding.root::forwardTouches)
|
val view = LayoutInflater.from(parent.context).inflate(layout, parent, false)
|
||||||
}
|
holder?.containerView?.let(view::forwardTouches)
|
||||||
|
return QkViewHolder(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ViewBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val part = data[position]
|
val part = data[position]
|
||||||
|
|
||||||
val canGroupWithPrevious = canGroup(message, previous) || position > 0
|
val canGroupWithPrevious = canGroup(message, previous) || position > 0
|
||||||
val canGroupWithNext = canGroup(message, next) || position < itemCount - 1 || bodyVisible
|
val canGroupWithNext = canGroup(message, next) || position < itemCount - 1 || bodyVisible
|
||||||
|
|
||||||
partBinders.find { binder -> binder.bindPart(holder, part, message, canGroupWithPrevious, canGroupWithNext) }
|
partBinders
|
||||||
|
.firstOrNull { it.canBindPart(part) }
|
||||||
|
?.bindPart(holder, part, message, canGroupWithPrevious, canGroupWithNext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int {
|
override fun getItemViewType(position: Int): Int {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.moez.QKSMS.common.util.Colors
|
|||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.databinding.MmsVcardListItemBinding
|
|
||||||
import com.moez.QKSMS.extensions.isVCard
|
import com.moez.QKSMS.extensions.isVCard
|
||||||
import com.moez.QKSMS.extensions.mapNotNull
|
import com.moez.QKSMS.extensions.mapNotNull
|
||||||
import com.moez.QKSMS.feature.compose.BubbleUtils
|
import com.moez.QKSMS.feature.compose.BubbleUtils
|
||||||
@@ -37,49 +36,48 @@ import ezvcard.Ezvcard
|
|||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import kotlinx.android.synthetic.main.mms_vcard_list_item.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class VCardBinder @Inject constructor(
|
class VCardBinder @Inject constructor(colors: Colors, private val context: Context) : PartBinder() {
|
||||||
colors: Colors,
|
|
||||||
private val context: Context
|
|
||||||
) : PartBinder<MmsVcardListItemBinding>(MmsVcardListItemBinding::inflate) {
|
|
||||||
|
|
||||||
|
override val partLayout = R.layout.mms_vcard_list_item
|
||||||
override var theme = colors.theme()
|
override var theme = colors.theme()
|
||||||
|
|
||||||
override fun canBindPart(part: MmsPart) = part.isVCard()
|
override fun canBindPart(part: MmsPart) = part.isVCard()
|
||||||
|
|
||||||
override fun bindPartInternal(
|
override fun bindPart(
|
||||||
holder: QkViewHolder<MmsVcardListItemBinding>,
|
holder: QkViewHolder,
|
||||||
part: MmsPart,
|
part: MmsPart,
|
||||||
message: Message,
|
message: Message,
|
||||||
canGroupWithPrevious: Boolean,
|
canGroupWithPrevious: Boolean,
|
||||||
canGroupWithNext: Boolean
|
canGroupWithNext: Boolean
|
||||||
) {
|
) {
|
||||||
BubbleUtils.getBubble(false, canGroupWithPrevious, canGroupWithNext, message.isMe())
|
BubbleUtils.getBubble(false, canGroupWithPrevious, canGroupWithNext, message.isMe())
|
||||||
.let(holder.binding.vCardBackground::setBackgroundResource)
|
.let(holder.vCardBackground::setBackgroundResource)
|
||||||
|
|
||||||
holder.binding.root.setOnClickListener { clicks.onNext(part.id) }
|
holder.containerView.setOnClickListener { clicks.onNext(part.id) }
|
||||||
|
|
||||||
Observable.just(part.getUri())
|
Observable.just(part.getUri())
|
||||||
.map(context.contentResolver::openInputStream)
|
.map(context.contentResolver::openInputStream)
|
||||||
.mapNotNull { inputStream -> inputStream.use { Ezvcard.parse(it).first() } }
|
.mapNotNull { inputStream -> inputStream.use { Ezvcard.parse(it).first() } }
|
||||||
.subscribeOn(Schedulers.computation())
|
.subscribeOn(Schedulers.computation())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe { vcard -> holder.binding.name?.text = vcard.formattedName.value }
|
.subscribe { vcard -> holder.name?.text = vcard.formattedName.value }
|
||||||
|
|
||||||
val params = holder.binding.vCardBackground.layoutParams as FrameLayout.LayoutParams
|
val params = holder.vCardBackground.layoutParams as FrameLayout.LayoutParams
|
||||||
if (!message.isMe()) {
|
if (!message.isMe()) {
|
||||||
holder.binding.vCardBackground.layoutParams = params.apply { gravity = Gravity.START }
|
holder.vCardBackground.layoutParams = params.apply { gravity = Gravity.START }
|
||||||
holder.binding.vCardBackground.setBackgroundTint(theme.theme)
|
holder.vCardBackground.setBackgroundTint(theme.theme)
|
||||||
holder.binding.vCardAvatar.setTint(theme.textPrimary)
|
holder.vCardAvatar.setTint(theme.textPrimary)
|
||||||
holder.binding.name.setTextColor(theme.textPrimary)
|
holder.name.setTextColor(theme.textPrimary)
|
||||||
holder.binding.label.setTextColor(theme.textTertiary)
|
holder.label.setTextColor(theme.textTertiary)
|
||||||
} else {
|
} else {
|
||||||
holder.binding.vCardBackground.layoutParams = params.apply { gravity = Gravity.END }
|
holder.vCardBackground.layoutParams = params.apply { gravity = Gravity.END }
|
||||||
holder.binding.vCardBackground.setBackgroundTint(holder.binding.root.context.resolveThemeColor(R.attr.bubbleColor))
|
holder.vCardBackground.setBackgroundTint(holder.containerView.context.resolveThemeColor(R.attr.bubbleColor))
|
||||||
holder.binding.vCardAvatar.setTint(holder.binding.root.context.resolveThemeColor(android.R.attr.textColorSecondary))
|
holder.vCardAvatar.setTint(holder.containerView.context.resolveThemeColor(android.R.attr.textColorSecondary))
|
||||||
holder.binding.name.setTextColor(holder.binding.root.context.resolveThemeColor(android.R.attr.textColorPrimary))
|
holder.name.setTextColor(holder.containerView.context.resolveThemeColor(android.R.attr.textColorPrimary))
|
||||||
holder.binding.label.setTextColor(holder.binding.root.context.resolveThemeColor(android.R.attr.textColorTertiary))
|
holder.label.setTextColor(holder.containerView.context.resolveThemeColor(android.R.attr.textColorTertiary))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ import com.moez.QKSMS.common.util.extensions.hideKeyboard
|
|||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.showKeyboard
|
import com.moez.QKSMS.common.util.extensions.showKeyboard
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.common.widget.QkDialog
|
import com.moez.QKSMS.common.widget.QkDialog
|
||||||
import com.moez.QKSMS.databinding.ContactsActivityBinding
|
|
||||||
import com.moez.QKSMS.extensions.Optional
|
import com.moez.QKSMS.extensions.Optional
|
||||||
import com.moez.QKSMS.feature.compose.editing.ComposeItem
|
import com.moez.QKSMS.feature.compose.editing.ComposeItem
|
||||||
import com.moez.QKSMS.feature.compose.editing.ComposeItemAdapter
|
import com.moez.QKSMS.feature.compose.editing.ComposeItemAdapter
|
||||||
@@ -46,6 +44,7 @@ import dagger.android.AndroidInjection
|
|||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.contacts_activity.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ContactsActivity : QkThemedActivity(), ContactsContract {
|
class ContactsActivity : QkThemedActivity(), ContactsContract {
|
||||||
@@ -59,15 +58,14 @@ class ContactsActivity : QkThemedActivity(), ContactsContract {
|
|||||||
@Inject lateinit var phoneNumberAdapter: PhoneNumberPickerAdapter
|
@Inject lateinit var phoneNumberAdapter: PhoneNumberPickerAdapter
|
||||||
@Inject lateinit var viewModelFactory: ViewModelFactory
|
@Inject lateinit var viewModelFactory: ViewModelFactory
|
||||||
|
|
||||||
override val queryChangedIntent: Observable<CharSequence> by lazy { binding.search.textChanges() }
|
override val queryChangedIntent: Observable<CharSequence> by lazy { search.textChanges() }
|
||||||
override val queryClearedIntent: Observable<*> by lazy { binding.cancel.clicks() }
|
override val queryClearedIntent: Observable<*> by lazy { cancel.clicks() }
|
||||||
override val queryEditorActionIntent: Observable<Int> by lazy { binding.search.editorActions() }
|
override val queryEditorActionIntent: Observable<Int> by lazy { search.editorActions() }
|
||||||
override val composeItemPressedIntent: Subject<ComposeItem> by lazy { contactsAdapter.clicks }
|
override val composeItemPressedIntent: Subject<ComposeItem> by lazy { contactsAdapter.clicks }
|
||||||
override val composeItemLongPressedIntent: Subject<ComposeItem> by lazy { contactsAdapter.longClicks }
|
override val composeItemLongPressedIntent: Subject<ComposeItem> by lazy { contactsAdapter.longClicks }
|
||||||
override val phoneNumberSelectedIntent: Subject<Optional<Long>> by lazy { phoneNumberAdapter.selectedItemChanges }
|
override val phoneNumberSelectedIntent: Subject<Optional<Long>> by lazy { phoneNumberAdapter.selectedItemChanges }
|
||||||
override val phoneNumberActionIntent: Subject<PhoneNumberAction> = PublishSubject.create()
|
override val phoneNumberActionIntent: Subject<PhoneNumberAction> = PublishSubject.create()
|
||||||
|
|
||||||
private val binding by viewBinding(ContactsActivityBinding::inflate)
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ContactsViewModel::class.java] }
|
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ContactsViewModel::class.java] }
|
||||||
|
|
||||||
private val phoneNumberDialog by lazy {
|
private val phoneNumberDialog by lazy {
|
||||||
@@ -85,20 +83,20 @@ class ContactsActivity : QkThemedActivity(), ContactsContract {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(binding.root)
|
setContentView(R.layout.contacts_activity)
|
||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
|
|
||||||
binding.contacts.adapter = contactsAdapter
|
contacts.adapter = contactsAdapter
|
||||||
|
|
||||||
// These theme attributes don't apply themselves on API 21
|
// These theme attributes don't apply themselves on API 21
|
||||||
if (Build.VERSION.SDK_INT <= 22) {
|
if (Build.VERSION.SDK_INT <= 22) {
|
||||||
binding.search.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
search.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: ContactsState) {
|
override fun render(state: ContactsState) {
|
||||||
binding.cancel.isVisible = state.query.length > 1
|
cancel.isVisible = state.query.length > 1
|
||||||
|
|
||||||
contactsAdapter.data = state.composeItems
|
contactsAdapter.data = state.composeItems
|
||||||
|
|
||||||
@@ -112,17 +110,17 @@ class ContactsActivity : QkThemedActivity(), ContactsContract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun clearQuery() {
|
override fun clearQuery() {
|
||||||
binding.search.text = null
|
search.text = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openKeyboard() {
|
override fun openKeyboard() {
|
||||||
binding.search.postDelayed({
|
search.postDelayed({
|
||||||
binding.search.showKeyboard()
|
search.showKeyboard()
|
||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun finish(result: HashMap<String, String?>) {
|
override fun finish(result: HashMap<String, String?>) {
|
||||||
binding.search.hideKeyboard()
|
search.hideKeyboard()
|
||||||
val intent = Intent().putExtra(ChipsKey, result)
|
val intent = Intent().putExtra(ChipsKey, result)
|
||||||
setResult(Activity.RESULT_OK, intent)
|
setResult(Activity.RESULT_OK, intent)
|
||||||
finish()
|
finish()
|
||||||
|
|||||||
+4
-5
@@ -22,22 +22,21 @@ import android.os.Bundle
|
|||||||
import com.bluelinelabs.conductor.Conductor
|
import com.bluelinelabs.conductor.Conductor
|
||||||
import com.bluelinelabs.conductor.Router
|
import com.bluelinelabs.conductor.Router
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
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 dagger.android.AndroidInjection
|
||||||
|
import kotlinx.android.synthetic.main.container_activity.*
|
||||||
|
|
||||||
class ConversationInfoActivity : QkThemedActivity() {
|
class ConversationInfoActivity : QkThemedActivity() {
|
||||||
|
|
||||||
private val binding by viewBinding(ContainerActivityBinding::inflate)
|
|
||||||
private lateinit var router: Router
|
private lateinit var router: Router
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
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()) {
|
if (!router.hasRootController()) {
|
||||||
val threadId = intent.extras?.getLong("threadId") ?: 0L
|
val threadId = intent.extras?.getLong("threadId") ?: 0L
|
||||||
router.setRoot(RouterTransaction.with(ConversationInfoController(threadId)))
|
router.setRoot(RouterTransaction.with(ConversationInfoController(threadId)))
|
||||||
|
|||||||
+55
-62
@@ -1,9 +1,9 @@
|
|||||||
package com.moez.QKSMS.feature.conversationinfo
|
package com.moez.QKSMS.feature.conversationinfo
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
@@ -11,20 +11,20 @@ import com.moez.QKSMS.common.base.QkViewHolder
|
|||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.databinding.ConversationInfoSettingsBinding
|
|
||||||
import com.moez.QKSMS.databinding.ConversationMediaListItemBinding
|
|
||||||
import com.moez.QKSMS.databinding.ConversationRecipientListItemBinding
|
|
||||||
import com.moez.QKSMS.extensions.isVideo
|
import com.moez.QKSMS.extensions.isVideo
|
||||||
import com.moez.QKSMS.feature.conversationinfo.ConversationInfoItem.*
|
import com.moez.QKSMS.feature.conversationinfo.ConversationInfoItem.*
|
||||||
import com.moez.QKSMS.util.GlideApp
|
import com.moez.QKSMS.util.GlideApp
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.conversation_info_settings.*
|
||||||
|
import kotlinx.android.synthetic.main.conversation_media_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.conversation_recipient_list_item.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ConversationInfoAdapter @Inject constructor(
|
class ConversationInfoAdapter @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val colors: Colors
|
private val colors: Colors
|
||||||
) : QkAdapter<ConversationInfoItem, ViewBinding>() {
|
) : QkAdapter<ConversationInfoItem>() {
|
||||||
|
|
||||||
val recipientClicks: Subject<Long> = PublishSubject.create()
|
val recipientClicks: Subject<Long> = PublishSubject.create()
|
||||||
val recipientLongClicks: Subject<Long> = PublishSubject.create()
|
val recipientLongClicks: Subject<Long> = PublishSubject.create()
|
||||||
@@ -36,97 +36,90 @@ class ConversationInfoAdapter @Inject constructor(
|
|||||||
val deleteClicks: Subject<Unit> = PublishSubject.create()
|
val deleteClicks: Subject<Unit> = PublishSubject.create()
|
||||||
val mediaClicks: Subject<Long> = PublishSubject.create()
|
val mediaClicks: Subject<Long> = PublishSubject.create()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ViewBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
val holder: QkViewHolder<ViewBinding> = when (viewType) {
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
0 -> QkViewHolder(parent, ConversationRecipientListItemBinding::inflate)
|
return when (viewType) {
|
||||||
1 -> QkViewHolder(parent, ConversationInfoSettingsBinding::inflate)
|
0 -> QkViewHolder(inflater.inflate(R.layout.conversation_recipient_list_item, parent, false)).apply {
|
||||||
2 -> QkViewHolder(parent, ConversationMediaListItemBinding::inflate)
|
itemView.setOnClickListener {
|
||||||
else -> throw IllegalStateException()
|
val item = getItem(adapterPosition) as? ConversationInfoRecipient
|
||||||
}
|
item?.value?.id?.run(recipientClicks::onNext)
|
||||||
|
|
||||||
return holder.apply {
|
|
||||||
when (binding) {
|
|
||||||
is ConversationRecipientListItemBinding -> {
|
|
||||||
itemView.setOnClickListener {
|
|
||||||
val item = getItem(adapterPosition) as? ConversationInfoRecipient
|
|
||||||
item?.value?.id?.run(recipientClicks::onNext)
|
|
||||||
}
|
|
||||||
|
|
||||||
itemView.setOnLongClickListener {
|
|
||||||
val item = getItem(adapterPosition) as? ConversationInfoRecipient
|
|
||||||
item?.value?.id?.run(recipientLongClicks::onNext)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.theme.setOnClickListener {
|
|
||||||
val item = getItem(adapterPosition) as? ConversationInfoRecipient
|
|
||||||
item?.value?.id?.run(themeClicks::onNext)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is ConversationInfoSettingsBinding -> {
|
itemView.setOnLongClickListener {
|
||||||
binding.groupName.clicks().subscribe(nameClicks)
|
val item = getItem(adapterPosition) as? ConversationInfoRecipient
|
||||||
binding.notifications.clicks().subscribe(notificationClicks)
|
item?.value?.id?.run(recipientLongClicks::onNext)
|
||||||
binding.archive.clicks().subscribe(archiveClicks)
|
true
|
||||||
binding.block.clicks().subscribe(blockClicks)
|
|
||||||
binding.delete.clicks().subscribe(deleteClicks)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is ConversationMediaListItemBinding -> {
|
theme.setOnClickListener {
|
||||||
itemView.setOnClickListener {
|
val item = getItem(adapterPosition) as? ConversationInfoRecipient
|
||||||
val item = getItem(adapterPosition) as? ConversationInfoMedia
|
item?.value?.id?.run(themeClicks::onNext)
|
||||||
item?.value?.id?.run(mediaClicks::onNext)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1 -> QkViewHolder(inflater.inflate(R.layout.conversation_info_settings, parent, false)).apply {
|
||||||
|
groupName.clicks().subscribe(nameClicks)
|
||||||
|
notifications.clicks().subscribe(notificationClicks)
|
||||||
|
archive.clicks().subscribe(archiveClicks)
|
||||||
|
block.clicks().subscribe(blockClicks)
|
||||||
|
delete.clicks().subscribe(deleteClicks)
|
||||||
|
}
|
||||||
|
|
||||||
|
2 -> QkViewHolder(inflater.inflate(R.layout.conversation_media_list_item, parent, false)).apply {
|
||||||
|
itemView.setOnClickListener {
|
||||||
|
val item = getItem(adapterPosition) as? ConversationInfoMedia
|
||||||
|
item?.value?.id?.run(mediaClicks::onNext)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ViewBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val item = getItem(position)
|
when (val item = getItem(position)) {
|
||||||
when {
|
is ConversationInfoRecipient -> {
|
||||||
item is ConversationInfoRecipient && holder.binding is ConversationRecipientListItemBinding -> {
|
|
||||||
val recipient = item.value
|
val recipient = item.value
|
||||||
holder.binding.avatar.setRecipient(recipient)
|
holder.avatar.setRecipient(recipient)
|
||||||
|
|
||||||
holder.binding.name.text = recipient.contact?.name ?: recipient.address
|
holder.name.text = recipient.contact?.name ?: recipient.address
|
||||||
|
|
||||||
holder.binding.address.text = recipient.address
|
holder.address.text = recipient.address
|
||||||
holder.binding.address.setVisible(recipient.contact != null)
|
holder.address.setVisible(recipient.contact != null)
|
||||||
|
|
||||||
holder.binding.add.setVisible(recipient.contact == null)
|
holder.add.setVisible(recipient.contact == null)
|
||||||
|
|
||||||
val theme = colors.theme(recipient)
|
val theme = colors.theme(recipient)
|
||||||
holder.binding.theme.setTint(theme.theme)
|
holder.theme.setTint(theme.theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
item is ConversationInfoSettings && holder.binding is ConversationInfoSettingsBinding -> {
|
is ConversationInfoSettings -> {
|
||||||
holder.binding.groupName.isVisible = item.recipients.size > 1
|
holder.groupName.isVisible = item.recipients.size > 1
|
||||||
holder.binding.groupName.summary = item.name
|
holder.groupName.summary = item.name
|
||||||
|
|
||||||
holder.binding.notifications.isEnabled = !item.blocked
|
holder.notifications.isEnabled = !item.blocked
|
||||||
|
|
||||||
holder.binding.archive.isEnabled = !item.blocked
|
holder.archive.isEnabled = !item.blocked
|
||||||
holder.binding.archive.title = context.getString(when (item.archived) {
|
holder.archive.title = context.getString(when (item.archived) {
|
||||||
true -> R.string.info_unarchive
|
true -> R.string.info_unarchive
|
||||||
false -> R.string.info_archive
|
false -> R.string.info_archive
|
||||||
})
|
})
|
||||||
|
|
||||||
holder.binding.block.title = context.getString(when (item.blocked) {
|
holder.block.title = context.getString(when (item.blocked) {
|
||||||
true -> R.string.info_unblock
|
true -> R.string.info_unblock
|
||||||
false -> R.string.info_block
|
false -> R.string.info_block
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
item is ConversationInfoMedia && holder.binding is ConversationMediaListItemBinding -> {
|
is ConversationInfoMedia -> {
|
||||||
val part = item.value
|
val part = item.value
|
||||||
|
|
||||||
GlideApp.with(context)
|
GlideApp.with(context)
|
||||||
.load(part.getUri())
|
.load(part.getUri())
|
||||||
.fitCenter()
|
.fitCenter()
|
||||||
.into(holder.binding.thumbnail)
|
.into(holder.thumbnail)
|
||||||
|
|
||||||
holder.binding.video.isVisible = part.isVideo()
|
holder.video.isVisible = part.isVideo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-7
@@ -28,7 +28,6 @@ import com.moez.QKSMS.common.QkChangeHandler
|
|||||||
import com.moez.QKSMS.common.base.QkController
|
import com.moez.QKSMS.common.base.QkController
|
||||||
import com.moez.QKSMS.common.util.extensions.scrapViews
|
import com.moez.QKSMS.common.util.extensions.scrapViews
|
||||||
import com.moez.QKSMS.common.widget.TextInputDialog
|
import com.moez.QKSMS.common.widget.TextInputDialog
|
||||||
import com.moez.QKSMS.databinding.ConversationInfoControllerBinding
|
|
||||||
import com.moez.QKSMS.feature.blocking.BlockingDialog
|
import com.moez.QKSMS.feature.blocking.BlockingDialog
|
||||||
import com.moez.QKSMS.feature.conversationinfo.injection.ConversationInfoModule
|
import com.moez.QKSMS.feature.conversationinfo.injection.ConversationInfoModule
|
||||||
import com.moez.QKSMS.feature.themepicker.ThemePickerController
|
import com.moez.QKSMS.feature.themepicker.ThemePickerController
|
||||||
@@ -38,12 +37,12 @@ import com.uber.autodispose.autoDisposable
|
|||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.conversation_info_controller.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ConversationInfoController(
|
class ConversationInfoController(
|
||||||
val threadId: Long = 0
|
val threadId: Long = 0
|
||||||
) : QkController<ConversationInfoView, ConversationInfoState, ConversationInfoPresenter,
|
) : QkController<ConversationInfoView, ConversationInfoState, ConversationInfoPresenter>(), ConversationInfoView {
|
||||||
ConversationInfoControllerBinding>(ConversationInfoControllerBinding::inflate), ConversationInfoView {
|
|
||||||
|
|
||||||
@Inject override lateinit var presenter: ConversationInfoPresenter
|
@Inject override lateinit var presenter: ConversationInfoPresenter
|
||||||
@Inject lateinit var blockingDialog: BlockingDialog
|
@Inject lateinit var blockingDialog: BlockingDialog
|
||||||
@@ -63,12 +62,14 @@ class ConversationInfoController(
|
|||||||
.conversationInfoModule(ConversationInfoModule(this))
|
.conversationInfoModule(ConversationInfoModule(this))
|
||||||
.build()
|
.build()
|
||||||
.inject(this)
|
.inject(this)
|
||||||
|
|
||||||
|
layoutRes = R.layout.conversation_info_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated() {
|
override fun onViewCreated() {
|
||||||
binding.recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
binding.recyclerView.addItemDecoration(GridSpacingItemDecoration(adapter, activity!!))
|
recyclerView.addItemDecoration(GridSpacingItemDecoration(adapter, activity!!))
|
||||||
binding.recyclerView.layoutManager = GridLayoutManager(activity, 3).apply {
|
recyclerView.layoutManager = GridLayoutManager(activity, 3).apply {
|
||||||
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||||
override fun getSpanSize(position: Int): Int = if (adapter.getItemViewType(position) == 2) 1 else 3
|
override fun getSpanSize(position: Int): Int = if (adapter.getItemViewType(position) == 2) 1 else 3
|
||||||
}
|
}
|
||||||
@@ -76,7 +77,7 @@ class ConversationInfoController(
|
|||||||
|
|
||||||
themedActivity?.theme
|
themedActivity?.theme
|
||||||
?.autoDisposable(scope())
|
?.autoDisposable(scope())
|
||||||
?.subscribe { binding.recyclerView.scrapViews() }
|
?.subscribe { recyclerView.scrapViews() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
|
|||||||
+31
-28
@@ -35,9 +35,10 @@ import com.moez.QKSMS.common.util.Colors
|
|||||||
import com.moez.QKSMS.common.util.DateFormatter
|
import com.moez.QKSMS.common.util.DateFormatter
|
||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.databinding.ConversationListItemBinding
|
|
||||||
import com.moez.QKSMS.model.Conversation
|
import com.moez.QKSMS.model.Conversation
|
||||||
import com.moez.QKSMS.util.PhoneNumberUtils
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
|
import kotlinx.android.synthetic.main.conversation_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.conversation_list_item.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ConversationsAdapter @Inject constructor(
|
class ConversationsAdapter @Inject constructor(
|
||||||
@@ -46,48 +47,50 @@ class ConversationsAdapter @Inject constructor(
|
|||||||
private val dateFormatter: DateFormatter,
|
private val dateFormatter: DateFormatter,
|
||||||
private val navigator: Navigator,
|
private val navigator: Navigator,
|
||||||
private val phoneNumberUtils: PhoneNumberUtils
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
) : QkRealmAdapter<Conversation, ConversationListItemBinding>() {
|
) : QkRealmAdapter<Conversation>() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// This is how we access the threadId for the swipe actions
|
// This is how we access the threadId for the swipe actions
|
||||||
setHasStableIds(true)
|
setHasStableIds(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ConversationListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, ConversationListItemBinding::inflate).apply {
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
if (viewType == 1) {
|
val view = layoutInflater.inflate(R.layout.conversation_list_item, parent, false)
|
||||||
val textColorPrimary = parent.context.resolveThemeColor(android.R.attr.textColorPrimary)
|
|
||||||
|
|
||||||
binding.title.setTypeface(binding.title.typeface, Typeface.BOLD)
|
if (viewType == 1) {
|
||||||
|
val textColorPrimary = parent.context.resolveThemeColor(android.R.attr.textColorPrimary)
|
||||||
|
|
||||||
binding.snippet.setTypeface(binding.snippet.typeface, Typeface.BOLD)
|
view.title.setTypeface(view.title.typeface, Typeface.BOLD)
|
||||||
binding.snippet.setTextColor(textColorPrimary)
|
|
||||||
binding.snippet.maxLines = 5
|
|
||||||
|
|
||||||
binding.unread.isVisible = true
|
view.snippet.setTypeface(view.snippet.typeface, Typeface.BOLD)
|
||||||
|
view.snippet.setTextColor(textColorPrimary)
|
||||||
|
view.snippet.maxLines = 5
|
||||||
|
|
||||||
binding.date.setTypeface(binding.date.typeface, Typeface.BOLD)
|
view.unread.isVisible = true
|
||||||
binding.date.setTextColor(textColorPrimary)
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
view.date.setTypeface(view.date.typeface, Typeface.BOLD)
|
||||||
|
view.date.setTextColor(textColorPrimary)
|
||||||
|
}
|
||||||
|
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
|
view.setOnClickListener {
|
||||||
val conversation = getItem(adapterPosition) ?: return@setOnClickListener
|
val conversation = getItem(adapterPosition) ?: return@setOnClickListener
|
||||||
when (toggleSelection(conversation.id, false)) {
|
when (toggleSelection(conversation.id, false)) {
|
||||||
true -> binding.root.isActivated = isSelected(conversation.id)
|
true -> view.isActivated = isSelected(conversation.id)
|
||||||
false -> navigator.showConversation(conversation.id)
|
false -> navigator.showConversation(conversation.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
view.setOnLongClickListener {
|
||||||
binding.root.setOnLongClickListener {
|
|
||||||
val conversation = getItem(adapterPosition) ?: return@setOnLongClickListener true
|
val conversation = getItem(adapterPosition) ?: return@setOnLongClickListener true
|
||||||
toggleSelection(conversation.id)
|
toggleSelection(conversation.id)
|
||||||
binding.root.isActivated = isSelected(conversation.id)
|
view.isActivated = isSelected(conversation.id)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ConversationListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val conversation = getItem(position) ?: return
|
val conversation = getItem(position) ?: return
|
||||||
|
|
||||||
// If the last message wasn't incoming, then the colour doesn't really matter anyway
|
// If the last message wasn't incoming, then the colour doesn't really matter anyway
|
||||||
@@ -100,24 +103,24 @@ class ConversationsAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
val theme = colors.theme(recipient).theme
|
val theme = colors.theme(recipient).theme
|
||||||
|
|
||||||
holder.binding.root.isActivated = isSelected(conversation.id)
|
holder.containerView.isActivated = isSelected(conversation.id)
|
||||||
|
|
||||||
holder.binding.avatars.recipients = conversation.recipients
|
holder.avatars.recipients = conversation.recipients
|
||||||
holder.binding.title.collapseEnabled = conversation.recipients.size > 1
|
holder.title.collapseEnabled = conversation.recipients.size > 1
|
||||||
holder.binding.title.text = buildSpannedString {
|
holder.title.text = buildSpannedString {
|
||||||
append(conversation.getTitle())
|
append(conversation.getTitle())
|
||||||
if (conversation.draft.isNotEmpty()) {
|
if (conversation.draft.isNotEmpty()) {
|
||||||
color(theme) { append(" " + context.getString(R.string.main_draft)) }
|
color(theme) { append(" " + context.getString(R.string.main_draft)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
holder.binding.date.text = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp)
|
holder.date.text = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp)
|
||||||
holder.binding.snippet.text = when {
|
holder.snippet.text = when {
|
||||||
conversation.draft.isNotEmpty() -> conversation.draft
|
conversation.draft.isNotEmpty() -> conversation.draft
|
||||||
conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet)
|
conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet)
|
||||||
else -> conversation.snippet
|
else -> conversation.snippet
|
||||||
}
|
}
|
||||||
holder.binding.pinned.isVisible = conversation.pinned
|
holder.pinned.isVisible = conversation.pinned
|
||||||
holder.binding.unread.setTint(theme)
|
holder.unread.setTint(theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemId(position: Int): Long {
|
override fun getItemId(position: Int): Long {
|
||||||
|
|||||||
@@ -33,13 +33,12 @@ import com.moez.QKSMS.R
|
|||||||
import com.moez.QKSMS.common.base.QkActivity
|
import com.moez.QKSMS.common.base.QkActivity
|
||||||
import com.moez.QKSMS.common.util.DateFormatter
|
import com.moez.QKSMS.common.util.DateFormatter
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.GalleryActivityBinding
|
|
||||||
import com.moez.QKSMS.model.MmsPart
|
import com.moez.QKSMS.model.MmsPart
|
||||||
import dagger.android.AndroidInjection
|
import dagger.android.AndroidInjection
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.gallery_activity.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GalleryActivity : QkActivity(), GalleryView {
|
class GalleryActivity : QkActivity(), GalleryView {
|
||||||
@@ -50,21 +49,20 @@ class GalleryActivity : QkActivity(), GalleryView {
|
|||||||
|
|
||||||
val partId by lazy { intent.getLongExtra("partId", 0L) }
|
val partId by lazy { intent.getLongExtra("partId", 0L) }
|
||||||
|
|
||||||
private val binding by viewBinding(GalleryActivityBinding::inflate)
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[GalleryViewModel::class.java] }
|
|
||||||
private val optionsItemSubject: Subject<Int> = PublishSubject.create()
|
private val optionsItemSubject: Subject<Int> = PublishSubject.create()
|
||||||
private val pageChangedSubject: Subject<MmsPart> = PublishSubject.create()
|
private val pageChangedSubject: Subject<MmsPart> = PublishSubject.create()
|
||||||
|
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[GalleryViewModel::class.java] }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_YES
|
delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_YES
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(binding.root)
|
setContentView(R.layout.gallery_activity)
|
||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
|
|
||||||
binding.pager.adapter = pagerAdapter
|
pager.adapter = pagerAdapter
|
||||||
binding.pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
this@GalleryActivity.onPageSelected(position)
|
this@GalleryActivity.onPageSelected(position)
|
||||||
}
|
}
|
||||||
@@ -76,7 +74,7 @@ class GalleryActivity : QkActivity(), GalleryView {
|
|||||||
?.indexOfFirst { part -> part.id == partId }
|
?.indexOfFirst { part -> part.id == partId }
|
||||||
?.let { index ->
|
?.let { index ->
|
||||||
onPageSelected(index)
|
onPageSelected(index)
|
||||||
binding.pager.setCurrentItem(index, false)
|
pager.setCurrentItem(index, false)
|
||||||
pagerAdapter.unregisterAdapterDataObserver(this)
|
pagerAdapter.unregisterAdapterDataObserver(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,15 +82,15 @@ class GalleryActivity : QkActivity(), GalleryView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onPageSelected(position: Int) {
|
fun onPageSelected(position: Int) {
|
||||||
binding.toolbarSubtitle.text = pagerAdapter.getItem(position)?.messages?.firstOrNull()?.date
|
toolbarSubtitle.text = pagerAdapter.getItem(position)?.messages?.firstOrNull()?.date
|
||||||
?.let(dateFormatter::getDetailedTimestamp)
|
?.let(dateFormatter::getDetailedTimestamp)
|
||||||
binding.toolbarSubtitle.isVisible = binding.toolbarTitle.text.isNotBlank()
|
toolbarSubtitle.isVisible = toolbarTitle.text.isNotBlank()
|
||||||
|
|
||||||
pagerAdapter.getItem(position)?.run(pageChangedSubject::onNext)
|
pagerAdapter.getItem(position)?.run(pageChangedSubject::onNext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: GalleryState) {
|
override fun render(state: GalleryState) {
|
||||||
binding.toolbar.setVisible(state.navigationVisible)
|
toolbar.setVisible(state.navigationVisible)
|
||||||
|
|
||||||
title = state.title
|
title = state.title
|
||||||
pagerAdapter.updateData(state.parts)
|
pagerAdapter.updateData(state.parts)
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
package com.moez.QKSMS.feature.gallery
|
package com.moez.QKSMS.feature.gallery
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.viewbinding.ViewBinding
|
|
||||||
import com.google.android.exoplayer2.ExoPlayer
|
import com.google.android.exoplayer2.ExoPlayer
|
||||||
import com.google.android.exoplayer2.ExoPlayerFactory
|
import com.google.android.exoplayer2.ExoPlayerFactory
|
||||||
import com.google.android.exoplayer2.source.ExtractorMediaSource
|
import com.google.android.exoplayer2.source.ExtractorMediaSource
|
||||||
@@ -30,23 +30,22 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
|
|||||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
|
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
|
||||||
import com.google.android.exoplayer2.util.Util
|
import com.google.android.exoplayer2.util.Util
|
||||||
import com.google.android.mms.ContentType
|
import com.google.android.mms.ContentType
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkRealmAdapter
|
import com.moez.QKSMS.common.base.QkRealmAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.databinding.GalleryImagePageBinding
|
|
||||||
import com.moez.QKSMS.databinding.GalleryInvalidPageBinding
|
|
||||||
import com.moez.QKSMS.databinding.GalleryVideoPageBinding
|
|
||||||
import com.moez.QKSMS.extensions.isImage
|
import com.moez.QKSMS.extensions.isImage
|
||||||
import com.moez.QKSMS.extensions.isVideo
|
import com.moez.QKSMS.extensions.isVideo
|
||||||
import com.moez.QKSMS.model.MmsPart
|
import com.moez.QKSMS.model.MmsPart
|
||||||
import com.moez.QKSMS.util.GlideApp
|
import com.moez.QKSMS.util.GlideApp
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.gallery_image_page.*
|
||||||
|
import kotlinx.android.synthetic.main.gallery_image_page.view.*
|
||||||
|
import kotlinx.android.synthetic.main.gallery_video_page.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class GalleryPagerAdapter @Inject constructor(
|
class GalleryPagerAdapter @Inject constructor(private val context: Context) : QkRealmAdapter<MmsPart>() {
|
||||||
private val context: Context
|
|
||||||
) : QkRealmAdapter<MmsPart, ViewBinding>() {
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val VIEW_TYPE_INVALID = 0
|
private const val VIEW_TYPE_INVALID = 0
|
||||||
@@ -59,61 +58,60 @@ class GalleryPagerAdapter @Inject constructor(
|
|||||||
private val contentResolver = context.contentResolver
|
private val contentResolver = context.contentResolver
|
||||||
private val exoPlayers = Collections.newSetFromMap(WeakHashMap<ExoPlayer?, Boolean>())
|
private val exoPlayers = Collections.newSetFromMap(WeakHashMap<ExoPlayer?, Boolean>())
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ViewBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
val holder: QkViewHolder<ViewBinding> = when (viewType) {
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
VIEW_TYPE_IMAGE -> QkViewHolder(parent, GalleryImagePageBinding::inflate)
|
return QkViewHolder(when (viewType) {
|
||||||
VIEW_TYPE_VIDEO -> QkViewHolder(parent, GalleryVideoPageBinding::inflate)
|
VIEW_TYPE_IMAGE -> inflater.inflate(R.layout.gallery_image_page, parent, false).apply {
|
||||||
else -> QkViewHolder(parent, GalleryInvalidPageBinding::inflate)
|
|
||||||
}
|
|
||||||
|
|
||||||
return holder.apply {
|
|
||||||
if (binding is GalleryImagePageBinding) {
|
|
||||||
// When calling the public setter, it doesn't allow the midscale to be the same as the
|
// When calling the public setter, it doesn't allow the midscale to be the same as the
|
||||||
// maxscale or the minscale. We don't want 3 levels and we don't want to modify the library
|
// maxscale or the minscale. We don't want 3 levels and we don't want to modify the library
|
||||||
// so let's celebrate the invention of reflection!
|
// so let's celebrate the invention of reflection!
|
||||||
binding.image.attacher.run {
|
image.attacher.run {
|
||||||
javaClass.getDeclaredField("mMinScale").run {
|
javaClass.getDeclaredField("mMinScale").run {
|
||||||
isAccessible = true
|
isAccessible = true
|
||||||
setFloat(binding.image.attacher, 1f)
|
setFloat(image.attacher, 1f)
|
||||||
}
|
}
|
||||||
javaClass.getDeclaredField("mMidScale").run {
|
javaClass.getDeclaredField("mMidScale").run {
|
||||||
isAccessible = true
|
isAccessible = true
|
||||||
setFloat(binding.image.attacher, 1f)
|
setFloat(image.attacher, 1f)
|
||||||
}
|
}
|
||||||
javaClass.getDeclaredField("mMaxScale").run {
|
javaClass.getDeclaredField("mMaxScale").run {
|
||||||
isAccessible = true
|
isAccessible = true
|
||||||
setFloat(binding.image.attacher, 3f)
|
setFloat(image.attacher, 3f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.root.setOnClickListener(clicks::onNext)
|
VIEW_TYPE_VIDEO -> inflater.inflate(R.layout.gallery_video_page, parent, false)
|
||||||
}
|
|
||||||
|
else -> inflater.inflate(R.layout.gallery_invalid_page, parent, false)
|
||||||
|
|
||||||
|
}.apply { setOnClickListener(clicks::onNext) })
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ViewBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val part = getItem(position) ?: return
|
val part = getItem(position) ?: return
|
||||||
when {
|
when (getItemViewType(position)) {
|
||||||
getItemViewType(position) == VIEW_TYPE_IMAGE && holder.binding is GalleryImagePageBinding -> {
|
VIEW_TYPE_IMAGE -> {
|
||||||
// We need to explicitly request a gif from glide for animations to work
|
// We need to explicitly request a gif from glide for animations to work
|
||||||
when (part.getUri().let(contentResolver::getType)) {
|
when (part.getUri().let(contentResolver::getType)) {
|
||||||
ContentType.IMAGE_GIF -> GlideApp.with(context)
|
ContentType.IMAGE_GIF -> GlideApp.with(context)
|
||||||
.asGif()
|
.asGif()
|
||||||
.load(part.getUri())
|
.load(part.getUri())
|
||||||
.into(holder.binding.image)
|
.into(holder.image)
|
||||||
|
|
||||||
else -> GlideApp.with(context)
|
else -> GlideApp.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(part.getUri())
|
.load(part.getUri())
|
||||||
.into(holder.binding.image)
|
.into(holder.image)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getItemViewType(position) == VIEW_TYPE_VIDEO && holder.binding is GalleryVideoPageBinding -> {
|
VIEW_TYPE_VIDEO -> {
|
||||||
val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory(null)
|
val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory(null)
|
||||||
val trackSelector = DefaultTrackSelector(videoTrackSelectionFactory)
|
val trackSelector = DefaultTrackSelector(videoTrackSelectionFactory)
|
||||||
val exoPlayer = ExoPlayerFactory.newSimpleInstance(context, trackSelector)
|
val exoPlayer = ExoPlayerFactory.newSimpleInstance(context, trackSelector)
|
||||||
holder.binding.video.player = exoPlayer
|
holder.video.player = exoPlayer
|
||||||
exoPlayers.add(exoPlayer)
|
exoPlayers.add(exoPlayer)
|
||||||
|
|
||||||
val dataSourceFactory = DefaultDataSourceFactory(context, Util.getUserAgent(context, "QKSMS"))
|
val dataSourceFactory = DefaultDataSourceFactory(context, Util.getUserAgent(context, "QKSMS"))
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ import android.view.Gravity
|
|||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewStub
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.view.GravityCompat
|
import androidx.core.view.GravityCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
@@ -50,8 +52,6 @@ import com.moez.QKSMS.common.util.extensions.scrapViews
|
|||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.MainActivityBinding
|
|
||||||
import com.moez.QKSMS.feature.blocking.BlockingDialog
|
import com.moez.QKSMS.feature.blocking.BlockingDialog
|
||||||
import com.moez.QKSMS.feature.changelog.ChangelogDialog
|
import com.moez.QKSMS.feature.changelog.ChangelogDialog
|
||||||
import com.moez.QKSMS.feature.conversations.ConversationItemTouchCallback
|
import com.moez.QKSMS.feature.conversations.ConversationItemTouchCallback
|
||||||
@@ -65,6 +65,10 @@ import io.reactivex.Observable
|
|||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.drawer_view.*
|
||||||
|
import kotlinx.android.synthetic.main.main_activity.*
|
||||||
|
import kotlinx.android.synthetic.main.main_permission_hint.*
|
||||||
|
import kotlinx.android.synthetic.main.main_syncing.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MainActivity : QkThemedActivity(), MainView {
|
class MainActivity : QkThemedActivity(), MainView {
|
||||||
@@ -80,10 +84,10 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
|
|
||||||
override val onNewIntentIntent: Subject<Intent> = PublishSubject.create()
|
override val onNewIntentIntent: Subject<Intent> = PublishSubject.create()
|
||||||
override val activityResumedIntent: Subject<Boolean> = PublishSubject.create()
|
override val activityResumedIntent: Subject<Boolean> = PublishSubject.create()
|
||||||
override val queryChangedIntent by lazy { binding.toolbarSearch.textChanges() }
|
override val queryChangedIntent by lazy { toolbarSearch.textChanges() }
|
||||||
override val composeIntent by lazy { binding.compose.clicks() }
|
override val composeIntent by lazy { compose.clicks() }
|
||||||
override val drawerOpenIntent: Observable<Boolean> by lazy {
|
override val drawerOpenIntent: Observable<Boolean> by lazy {
|
||||||
binding.drawerLayout
|
drawerLayout
|
||||||
.drawerOpen(Gravity.START)
|
.drawerOpen(Gravity.START)
|
||||||
.doOnNext { dismissKeyboard() }
|
.doOnNext { dismissKeyboard() }
|
||||||
}
|
}
|
||||||
@@ -91,32 +95,31 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
override val navigationIntent: Observable<NavItem> by lazy {
|
override val navigationIntent: Observable<NavItem> by lazy {
|
||||||
Observable.merge(listOf(
|
Observable.merge(listOf(
|
||||||
backPressedSubject,
|
backPressedSubject,
|
||||||
binding.drawer.inbox.clicks().map { NavItem.INBOX },
|
inbox.clicks().map { NavItem.INBOX },
|
||||||
binding.drawer.archived.clicks().map { NavItem.ARCHIVED },
|
archived.clicks().map { NavItem.ARCHIVED },
|
||||||
binding.drawer.backup.clicks().map { NavItem.BACKUP },
|
backup.clicks().map { NavItem.BACKUP },
|
||||||
binding.drawer.scheduled.clicks().map { NavItem.SCHEDULED },
|
scheduled.clicks().map { NavItem.SCHEDULED },
|
||||||
binding.drawer.blocking.clicks().map { NavItem.BLOCKING },
|
blocking.clicks().map { NavItem.BLOCKING },
|
||||||
binding.drawer.settings.clicks().map { NavItem.SETTINGS },
|
settings.clicks().map { NavItem.SETTINGS },
|
||||||
binding.drawer.plus.clicks().map { NavItem.PLUS },
|
plus.clicks().map { NavItem.PLUS },
|
||||||
binding.drawer.help.clicks().map { NavItem.HELP },
|
help.clicks().map { NavItem.HELP },
|
||||||
binding.drawer.invite.clicks().map { NavItem.INVITE }))
|
invite.clicks().map { NavItem.INVITE }))
|
||||||
}
|
}
|
||||||
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
override val optionsItemIntent: Subject<Int> = PublishSubject.create()
|
||||||
override val plusBannerIntent by lazy { binding.drawer.plusBanner.clicks() }
|
override val plusBannerIntent by lazy { plusBanner.clicks() }
|
||||||
override val dismissRatingIntent by lazy { binding.drawer.rateDismiss.clicks() }
|
override val dismissRatingIntent by lazy { rateDismiss.clicks() }
|
||||||
override val rateIntent by lazy { binding.drawer.rateOkay.clicks() }
|
override val rateIntent by lazy { rateOkay.clicks() }
|
||||||
override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges }
|
override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges }
|
||||||
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
|
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
|
||||||
override val swipeConversationIntent by lazy { itemTouchCallback.swipes }
|
override val swipeConversationIntent by lazy { itemTouchCallback.swipes }
|
||||||
override val changelogMoreIntent by lazy { changelogDialog.moreClicks }
|
override val changelogMoreIntent by lazy { changelogDialog.moreClicks }
|
||||||
override val undoArchiveIntent: Subject<Unit> = PublishSubject.create()
|
override val undoArchiveIntent: Subject<Unit> = PublishSubject.create()
|
||||||
override val snackbarButtonIntent by lazy { binding.snackbar.button.clicks() }
|
override val snackbarButtonIntent: Subject<Unit> = PublishSubject.create()
|
||||||
|
|
||||||
private val binding by viewBinding(MainActivityBinding::inflate)
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[MainViewModel::class.java] }
|
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[MainViewModel::class.java] }
|
||||||
private val toggle by lazy { ActionBarDrawerToggle(this, binding.drawerLayout, binding.toolbar, R.string.main_drawer_open_cd, 0) }
|
private val toggle by lazy { ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.main_drawer_open_cd, 0) }
|
||||||
private val itemTouchHelper by lazy { ItemTouchHelper(itemTouchCallback) }
|
private val itemTouchHelper by lazy { ItemTouchHelper(itemTouchCallback) }
|
||||||
private val progressAnimator by lazy { ObjectAnimator.ofInt(binding.syncing.progress, "progress", 0, 0) }
|
private val progressAnimator by lazy { ObjectAnimator.ofInt(syncingProgress, "progress", 0, 0) }
|
||||||
private val changelogDialog by lazy { ChangelogDialog(this) }
|
private val changelogDialog by lazy { ChangelogDialog(this) }
|
||||||
private val snackbar by lazy { findViewById<View>(R.id.snackbar) }
|
private val snackbar by lazy { findViewById<View>(R.id.snackbar) }
|
||||||
private val syncing by lazy { findViewById<View>(R.id.syncing) }
|
private val syncing by lazy { findViewById<View>(R.id.syncing) }
|
||||||
@@ -125,21 +128,32 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(binding.root)
|
setContentView(R.layout.main_activity)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
onNewIntentIntent.onNext(intent)
|
onNewIntentIntent.onNext(intent)
|
||||||
|
|
||||||
|
(snackbar as? ViewStub)?.setOnInflateListener { _, _ ->
|
||||||
|
snackbarButton.clicks()
|
||||||
|
.autoDisposable(scope(Lifecycle.Event.ON_DESTROY))
|
||||||
|
.subscribe(snackbarButtonIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
(syncing as? ViewStub)?.setOnInflateListener { _, _ ->
|
||||||
|
syncingProgress?.progressTintList = ColorStateList.valueOf(theme.blockingFirst().theme)
|
||||||
|
syncingProgress?.indeterminateTintList = ColorStateList.valueOf(theme.blockingFirst().theme)
|
||||||
|
}
|
||||||
|
|
||||||
toggle.syncState()
|
toggle.syncState()
|
||||||
binding.toolbar.setNavigationOnClickListener {
|
toolbar.setNavigationOnClickListener {
|
||||||
dismissKeyboard()
|
dismissKeyboard()
|
||||||
homeIntent.onNext(Unit)
|
homeIntent.onNext(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemTouchCallback.adapter = conversationsAdapter
|
itemTouchCallback.adapter = conversationsAdapter
|
||||||
conversationsAdapter.autoScrollToStart(binding.recyclerView)
|
conversationsAdapter.autoScrollToStart(recyclerView)
|
||||||
|
|
||||||
// Don't allow clicks to pass through the drawer layout
|
// Don't allow clicks to pass through the drawer layout
|
||||||
binding.drawer.root.clicks().autoDisposable(scope()).subscribe()
|
drawer.clicks().autoDisposable(scope()).subscribe()
|
||||||
|
|
||||||
// Set the theme color tint to the recyclerView, progressbar, and FAB
|
// Set the theme color tint to the recyclerView, progressbar, and FAB
|
||||||
theme
|
theme
|
||||||
@@ -153,28 +167,28 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
resolveThemeColor(android.R.attr.textColorSecondary)
|
resolveThemeColor(android.R.attr.textColorSecondary)
|
||||||
.let { textSecondary -> ColorStateList(states, intArrayOf(theme.theme, textSecondary)) }
|
.let { textSecondary -> ColorStateList(states, intArrayOf(theme.theme, textSecondary)) }
|
||||||
.let { tintList ->
|
.let { tintList ->
|
||||||
binding.drawer.inboxIcon.imageTintList = tintList
|
inboxIcon.imageTintList = tintList
|
||||||
binding.drawer.archivedIcon.imageTintList = tintList
|
archivedIcon.imageTintList = tintList
|
||||||
}
|
}
|
||||||
|
|
||||||
// Miscellaneous views
|
// Miscellaneous views
|
||||||
listOf(binding.drawer.plusBadge1, binding.drawer.plusBadge2).forEach { badge ->
|
listOf(plusBadge1, plusBadge2).forEach { badge ->
|
||||||
badge.setBackgroundTint(theme.theme)
|
badge.setBackgroundTint(theme.theme)
|
||||||
badge.setTextColor(theme.textPrimary)
|
badge.setTextColor(theme.textPrimary)
|
||||||
}
|
}
|
||||||
binding.syncing.progress.progressTintList = ColorStateList.valueOf(theme.theme)
|
syncingProgress?.progressTintList = ColorStateList.valueOf(theme.theme)
|
||||||
binding.syncing.progress.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
syncingProgress?.indeterminateTintList = ColorStateList.valueOf(theme.theme)
|
||||||
binding.drawer.plusIcon.setTint(theme.theme)
|
plusIcon.setTint(theme.theme)
|
||||||
binding.drawer.rateIcon.setTint(theme.theme)
|
rateIcon.setTint(theme.theme)
|
||||||
binding.compose.setBackgroundTint(theme.theme)
|
compose.setBackgroundTint(theme.theme)
|
||||||
|
|
||||||
// Set the FAB compose icon color
|
// Set the FAB compose icon color
|
||||||
binding.compose.setTint(theme.textPrimary)
|
compose.setTint(theme.textPrimary)
|
||||||
}
|
}
|
||||||
|
|
||||||
// These theme attributes don't apply themselves on API 21
|
// These theme attributes don't apply themselves on API 21
|
||||||
if (Build.VERSION.SDK_INT <= 22) {
|
if (Build.VERSION.SDK_INT <= 22) {
|
||||||
binding.toolbarSearch.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
toolbarSearch.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,46 +227,46 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.toolbarSearch.setVisible(state.page is Inbox && state.page.selected == 0 || state.page is Searching)
|
toolbarSearch.setVisible(state.page is Inbox && state.page.selected == 0 || state.page is Searching)
|
||||||
binding.toolbarTitle.setVisible(binding.toolbarSearch.visibility != View.VISIBLE)
|
toolbarTitle.setVisible(toolbarSearch.visibility != View.VISIBLE)
|
||||||
|
|
||||||
binding.toolbar.menu.findItem(R.id.archive)?.isVisible = state.page is Inbox && selectedConversations != 0
|
toolbar.menu.findItem(R.id.archive)?.isVisible = state.page is Inbox && selectedConversations != 0
|
||||||
binding.toolbar.menu.findItem(R.id.unarchive)?.isVisible = state.page is Archived && selectedConversations != 0
|
toolbar.menu.findItem(R.id.unarchive)?.isVisible = state.page is Archived && selectedConversations != 0
|
||||||
binding.toolbar.menu.findItem(R.id.delete)?.isVisible = selectedConversations != 0
|
toolbar.menu.findItem(R.id.delete)?.isVisible = selectedConversations != 0
|
||||||
binding.toolbar.menu.findItem(R.id.add)?.isVisible = addContact && selectedConversations != 0
|
toolbar.menu.findItem(R.id.add)?.isVisible = addContact && selectedConversations != 0
|
||||||
binding.toolbar.menu.findItem(R.id.pin)?.isVisible = markPinned && selectedConversations != 0
|
toolbar.menu.findItem(R.id.pin)?.isVisible = markPinned && selectedConversations != 0
|
||||||
binding.toolbar.menu.findItem(R.id.unpin)?.isVisible = !markPinned && selectedConversations != 0
|
toolbar.menu.findItem(R.id.unpin)?.isVisible = !markPinned && selectedConversations != 0
|
||||||
binding.toolbar.menu.findItem(R.id.read)?.isVisible = markRead && selectedConversations != 0
|
toolbar.menu.findItem(R.id.read)?.isVisible = markRead && selectedConversations != 0
|
||||||
binding.toolbar.menu.findItem(R.id.unread)?.isVisible = !markRead && selectedConversations != 0
|
toolbar.menu.findItem(R.id.unread)?.isVisible = !markRead && selectedConversations != 0
|
||||||
binding.toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
|
toolbar.menu.findItem(R.id.block)?.isVisible = selectedConversations != 0
|
||||||
|
|
||||||
listOf(binding.drawer.plusBadge1, binding.drawer.plusBadge2).forEach { badge ->
|
listOf(plusBadge1, plusBadge2).forEach { badge ->
|
||||||
badge.isVisible = drawerBadgesExperiment.variant && !state.upgraded
|
badge.isVisible = drawerBadgesExperiment.variant && !state.upgraded
|
||||||
}
|
}
|
||||||
binding.drawer.plus.isVisible = state.upgraded
|
plus.isVisible = state.upgraded
|
||||||
binding.drawer.plusBanner.isVisible = !state.upgraded
|
plusBanner.isVisible = !state.upgraded
|
||||||
binding.drawer.rateLayout.setVisible(state.showRating)
|
rateLayout.setVisible(state.showRating)
|
||||||
|
|
||||||
binding.compose.setVisible(state.page is Inbox || state.page is Archived)
|
compose.setVisible(state.page is Inbox || state.page is Archived)
|
||||||
conversationsAdapter.emptyView = binding.empty.takeIf { state.page is Inbox || state.page is Archived }
|
conversationsAdapter.emptyView = empty.takeIf { state.page is Inbox || state.page is Archived }
|
||||||
searchAdapter.emptyView = binding.empty.takeIf { state.page is Searching }
|
searchAdapter.emptyView = empty.takeIf { state.page is Searching }
|
||||||
|
|
||||||
when (state.page) {
|
when (state.page) {
|
||||||
is Inbox -> {
|
is Inbox -> {
|
||||||
showBackButton(state.page.selected > 0)
|
showBackButton(state.page.selected > 0)
|
||||||
title = getString(R.string.main_title_selected, state.page.selected)
|
title = getString(R.string.main_title_selected, state.page.selected)
|
||||||
if (binding.recyclerView.adapter !== conversationsAdapter) binding.recyclerView.adapter = conversationsAdapter
|
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||||
conversationsAdapter.updateData(state.page.data)
|
conversationsAdapter.updateData(state.page.data)
|
||||||
itemTouchHelper.attachToRecyclerView(binding.recyclerView)
|
itemTouchHelper.attachToRecyclerView(recyclerView)
|
||||||
binding.empty.setText(R.string.inbox_empty_text)
|
empty.setText(R.string.inbox_empty_text)
|
||||||
}
|
}
|
||||||
|
|
||||||
is Searching -> {
|
is Searching -> {
|
||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
if (binding.recyclerView.adapter !== searchAdapter) binding.recyclerView.adapter = searchAdapter
|
if (recyclerView.adapter !== searchAdapter) recyclerView.adapter = searchAdapter
|
||||||
searchAdapter.data = state.page.data ?: listOf()
|
searchAdapter.data = state.page.data ?: listOf()
|
||||||
itemTouchHelper.attachToRecyclerView(null)
|
itemTouchHelper.attachToRecyclerView(null)
|
||||||
binding.empty.setText(R.string.inbox_search_empty_text)
|
empty.setText(R.string.inbox_search_empty_text)
|
||||||
}
|
}
|
||||||
|
|
||||||
is Archived -> {
|
is Archived -> {
|
||||||
@@ -261,20 +275,20 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
true -> getString(R.string.main_title_selected, state.page.selected)
|
true -> getString(R.string.main_title_selected, state.page.selected)
|
||||||
false -> getString(R.string.title_archived)
|
false -> getString(R.string.title_archived)
|
||||||
}
|
}
|
||||||
if (binding.recyclerView.adapter !== conversationsAdapter) binding.recyclerView.adapter = conversationsAdapter
|
if (recyclerView.adapter !== conversationsAdapter) recyclerView.adapter = conversationsAdapter
|
||||||
conversationsAdapter.updateData(state.page.data)
|
conversationsAdapter.updateData(state.page.data)
|
||||||
itemTouchHelper.attachToRecyclerView(null)
|
itemTouchHelper.attachToRecyclerView(null)
|
||||||
binding.empty.setText(R.string.archived_empty_text)
|
empty.setText(R.string.archived_empty_text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.drawer.inbox.isActivated = state.page is Inbox
|
inbox.isActivated = state.page is Inbox
|
||||||
binding.drawer.archived.isActivated = state.page is Archived
|
archived.isActivated = state.page is Archived
|
||||||
|
|
||||||
if (binding.drawerLayout.isDrawerOpen(GravityCompat.START) && !state.drawerOpen) {
|
if (drawerLayout.isDrawerOpen(GravityCompat.START) && !state.drawerOpen) {
|
||||||
binding.drawerLayout.closeDrawer(GravityCompat.START)
|
drawerLayout.closeDrawer(GravityCompat.START)
|
||||||
} else if (!binding.drawerLayout.isDrawerVisible(GravityCompat.START) && state.drawerOpen) {
|
} else if (!drawerLayout.isDrawerVisible(GravityCompat.START) && state.drawerOpen) {
|
||||||
binding.drawerLayout.openDrawer(GravityCompat.START)
|
drawerLayout.openDrawer(GravityCompat.START)
|
||||||
}
|
}
|
||||||
|
|
||||||
when (state.syncing) {
|
when (state.syncing) {
|
||||||
@@ -285,30 +299,30 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
|
|
||||||
is SyncRepository.SyncProgress.Running -> {
|
is SyncRepository.SyncProgress.Running -> {
|
||||||
syncing.isVisible = true
|
syncing.isVisible = true
|
||||||
binding.syncing.progress.max = state.syncing.max
|
syncingProgress.max = state.syncing.max
|
||||||
progressAnimator.apply { setIntValues(binding.syncing.progress.progress, state.syncing.progress) }.start()
|
progressAnimator.apply { setIntValues(syncingProgress.progress, state.syncing.progress) }.start()
|
||||||
binding.syncing.progress.isIndeterminate = state.syncing.indeterminate
|
syncingProgress.isIndeterminate = state.syncing.indeterminate
|
||||||
snackbar.isVisible = false
|
snackbar.isVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when {
|
when {
|
||||||
!state.defaultSms -> {
|
!state.defaultSms -> {
|
||||||
binding.snackbar.title.setText(R.string.main_default_sms_title)
|
snackbarTitle?.setText(R.string.main_default_sms_title)
|
||||||
binding.snackbar.message.setText(R.string.main_default_sms_message)
|
snackbarMessage?.setText(R.string.main_default_sms_message)
|
||||||
binding.snackbar.button.setText(R.string.main_default_sms_change)
|
snackbarButton?.setText(R.string.main_default_sms_change)
|
||||||
}
|
}
|
||||||
|
|
||||||
!state.smsPermission -> {
|
!state.smsPermission -> {
|
||||||
binding.snackbar.title.setText(R.string.main_permission_required)
|
snackbarTitle?.setText(R.string.main_permission_required)
|
||||||
binding.snackbar.message.setText(R.string.main_permission_sms)
|
snackbarMessage?.setText(R.string.main_permission_sms)
|
||||||
binding.snackbar.button.setText(R.string.main_permission_allow)
|
snackbarButton?.setText(R.string.main_permission_allow)
|
||||||
}
|
}
|
||||||
|
|
||||||
!state.contactPermission -> {
|
!state.contactPermission -> {
|
||||||
binding.snackbar.title.setText(R.string.main_permission_required)
|
snackbarTitle?.setText(R.string.main_permission_required)
|
||||||
binding.snackbar.message.setText(R.string.main_permission_contacts)
|
snackbarMessage?.setText(R.string.main_permission_contacts)
|
||||||
binding.snackbar.button.setText(R.string.main_permission_allow)
|
snackbarButton?.setText(R.string.main_permission_allow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +343,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showBackButton(show: Boolean) {
|
override fun showBackButton(show: Boolean) {
|
||||||
toggle.onDrawerSlide(binding.drawer.root, if (show) 1f else 0f)
|
toggle.onDrawerSlide(drawer, if (show) 1f else 0f)
|
||||||
toggle.drawerArrowDrawable.color = when (show) {
|
toggle.drawerArrowDrawable.color = when (show) {
|
||||||
true -> resolveThemeColor(android.R.attr.textColorSecondary)
|
true -> resolveThemeColor(android.R.attr.textColorSecondary)
|
||||||
false -> resolveThemeColor(android.R.attr.textColorPrimary)
|
false -> resolveThemeColor(android.R.attr.textColorPrimary)
|
||||||
@@ -349,7 +363,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
|
|
||||||
override fun clearSearch() {
|
override fun clearSearch() {
|
||||||
dismissKeyboard()
|
dismissKeyboard()
|
||||||
binding.toolbarSearch.text = null
|
toolbarSearch.text = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearSelection() {
|
override fun clearSelection() {
|
||||||
@@ -357,7 +371,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun themeChanged() {
|
override fun themeChanged() {
|
||||||
binding.recyclerView.scrapViews()
|
recyclerView.scrapViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showBlockingDialog(conversations: List<Long>, block: Boolean) {
|
override fun showBlockingDialog(conversations: List<Long>, block: Boolean) {
|
||||||
@@ -379,7 +393,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showArchivedSnackbar() {
|
override fun showArchivedSnackbar() {
|
||||||
Snackbar.make(binding.drawerLayout, R.string.toast_archived, Snackbar.LENGTH_LONG).apply {
|
Snackbar.make(drawerLayout, R.string.toast_archived, Snackbar.LENGTH_LONG).apply {
|
||||||
setAction(R.string.button_undo) { undoArchiveIntent.onNext(Unit) }
|
setAction(R.string.button_undo) { undoArchiveIntent.onNext(Unit) }
|
||||||
setActionTextColor(colors.theme().theme)
|
setActionTextColor(colors.theme().theme)
|
||||||
show()
|
show()
|
||||||
|
|||||||
@@ -31,9 +31,10 @@ import com.moez.QKSMS.common.base.QkViewHolder
|
|||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
import com.moez.QKSMS.common.util.DateFormatter
|
import com.moez.QKSMS.common.util.DateFormatter
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.databinding.SearchListItemBinding
|
|
||||||
import com.moez.QKSMS.extensions.removeAccents
|
import com.moez.QKSMS.extensions.removeAccents
|
||||||
import com.moez.QKSMS.model.SearchResult
|
import com.moez.QKSMS.model.SearchResult
|
||||||
|
import kotlinx.android.synthetic.main.search_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.search_list_item.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SearchAdapter @Inject constructor(
|
class SearchAdapter @Inject constructor(
|
||||||
@@ -41,24 +42,26 @@ class SearchAdapter @Inject constructor(
|
|||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val dateFormatter: DateFormatter,
|
private val dateFormatter: DateFormatter,
|
||||||
private val navigator: Navigator
|
private val navigator: Navigator
|
||||||
) : QkAdapter<SearchResult, SearchListItemBinding>() {
|
) : QkAdapter<SearchResult>() {
|
||||||
|
|
||||||
private val highlightColor: Int by lazy { colors.theme().highlight }
|
private val highlightColor: Int by lazy { colors.theme().highlight }
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<SearchListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, SearchListItemBinding::inflate).apply {
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
binding.root.setOnClickListener {
|
val view = layoutInflater.inflate(R.layout.search_list_item, parent, false)
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
|
view.setOnClickListener {
|
||||||
val result = getItem(adapterPosition)
|
val result = getItem(adapterPosition)
|
||||||
navigator.showConversation(result.conversation.id, result.query.takeIf { result.messages > 0 })
|
navigator.showConversation(result.conversation.id, result.query.takeIf { result.messages > 0 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<SearchListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val previous = data.getOrNull(position - 1)
|
val previous = data.getOrNull(position - 1)
|
||||||
val result = getItem(position)
|
val result = getItem(position)
|
||||||
|
|
||||||
holder.binding.resultsHeader.setVisible(result.messages > 0 && previous?.messages == 0)
|
holder.resultsHeader.setVisible(result.messages > 0 && previous?.messages == 0)
|
||||||
|
|
||||||
val query = result.query
|
val query = result.query
|
||||||
val title = SpannableString(result.conversation.getTitle())
|
val title = SpannableString(result.conversation.getTitle())
|
||||||
@@ -68,23 +71,23 @@ class SearchAdapter @Inject constructor(
|
|||||||
title.setSpan(BackgroundColorSpan(highlightColor), index, index + query.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
title.setSpan(BackgroundColorSpan(highlightColor), index, index + query.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
index = title.indexOf(query, index + query.length, true)
|
index = title.indexOf(query, index + query.length, true)
|
||||||
}
|
}
|
||||||
holder.binding.title.text = title
|
holder.title.text = title
|
||||||
|
|
||||||
holder.binding.avatars.recipients = result.conversation.recipients
|
holder.avatars.recipients = result.conversation.recipients
|
||||||
|
|
||||||
when (result.messages == 0) {
|
when (result.messages == 0) {
|
||||||
true -> {
|
true -> {
|
||||||
holder.binding.date.setVisible(true)
|
holder.date.setVisible(true)
|
||||||
holder.binding.date.text = dateFormatter.getConversationTimestamp(result.conversation.date)
|
holder.date.text = dateFormatter.getConversationTimestamp(result.conversation.date)
|
||||||
holder.binding.snippet.text = when (result.conversation.me) {
|
holder.snippet.text = when (result.conversation.me) {
|
||||||
true -> context.getString(R.string.main_sender_you, result.conversation.snippet)
|
true -> context.getString(R.string.main_sender_you, result.conversation.snippet)
|
||||||
false -> result.conversation.snippet
|
false -> result.conversation.snippet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
false -> {
|
false -> {
|
||||||
holder.binding.date.setVisible(false)
|
holder.date.setVisible(false)
|
||||||
holder.binding.snippet.text = context.getString(R.string.main_message_results, result.messages)
|
holder.snippet.text = context.getString(R.string.main_message_results, result.messages)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-32
@@ -33,16 +33,15 @@ import com.moez.QKSMS.common.QkDialog
|
|||||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
import com.moez.QKSMS.common.base.QkThemedActivity
|
||||||
import com.moez.QKSMS.common.util.extensions.animateLayoutChanges
|
import com.moez.QKSMS.common.util.extensions.animateLayoutChanges
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.common.widget.PreferenceView
|
import com.moez.QKSMS.common.widget.PreferenceView
|
||||||
import com.moez.QKSMS.common.widget.QkSwitch
|
|
||||||
import com.moez.QKSMS.databinding.NotificationPrefsActivityBinding
|
|
||||||
import com.uber.autodispose.android.lifecycle.scope
|
import com.uber.autodispose.android.lifecycle.scope
|
||||||
import com.uber.autodispose.autoDisposable
|
import com.uber.autodispose.autoDisposable
|
||||||
import dagger.android.AndroidInjection
|
import dagger.android.AndroidInjection
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.notification_prefs_activity.*
|
||||||
|
import kotlinx.android.synthetic.main.settings_switch_widget.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
||||||
@@ -56,7 +55,6 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
|||||||
override val ringtoneSelectedIntent: Subject<String> = PublishSubject.create()
|
override val ringtoneSelectedIntent: Subject<String> = PublishSubject.create()
|
||||||
override val actionsSelectedIntent by lazy { actionsDialog.adapter.menuItemClicks }
|
override val actionsSelectedIntent by lazy { actionsDialog.adapter.menuItemClicks }
|
||||||
|
|
||||||
private val binding by viewBinding(NotificationPrefsActivityBinding::inflate)
|
|
||||||
private val viewModel by lazy {
|
private val viewModel by lazy {
|
||||||
ViewModelProviders.of(this, viewModelFactory)[NotificationPrefsViewModel::class.java]
|
ViewModelProviders.of(this, viewModelFactory)[NotificationPrefsViewModel::class.java]
|
||||||
}
|
}
|
||||||
@@ -64,27 +62,27 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(binding.root)
|
setContentView(R.layout.notification_prefs_activity)
|
||||||
setTitle(R.string.title_notification_prefs)
|
setTitle(R.string.title_notification_prefs)
|
||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
|
|
||||||
binding.preferences.postDelayed({ binding.preferences.animateLayoutChanges = true }, 100)
|
preferences.postDelayed({ preferences?.animateLayoutChanges = true }, 100)
|
||||||
|
|
||||||
val hasOreo = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
val hasOreo = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
|
|
||||||
binding.notificationsO.setVisible(hasOreo)
|
notificationsO.setVisible(hasOreo)
|
||||||
binding.notifications.setVisible(!hasOreo)
|
notifications.setVisible(!hasOreo)
|
||||||
binding.vibration.setVisible(!hasOreo)
|
vibration.setVisible(!hasOreo)
|
||||||
binding.ringtone.setVisible(!hasOreo)
|
ringtone.setVisible(!hasOreo)
|
||||||
|
|
||||||
previewModeDialog.setTitle(R.string.settings_notification_previews_title)
|
previewModeDialog.setTitle(R.string.settings_notification_previews_title)
|
||||||
previewModeDialog.adapter.setData(R.array.notification_preview_options)
|
previewModeDialog.adapter.setData(R.array.notification_preview_options)
|
||||||
actionsDialog.adapter.setData(R.array.notification_actions)
|
actionsDialog.adapter.setData(R.array.notification_actions)
|
||||||
|
|
||||||
// Listen to clicks for all of the preferences
|
// Listen to clicks for all of the preferences
|
||||||
(0 until binding.preferences.childCount)
|
(0 until preferences.childCount)
|
||||||
.map { index -> binding.preferences.getChildAt(index) }
|
.map { index -> preferences.getChildAt(index) }
|
||||||
.mapNotNull { view -> view as? PreferenceView }
|
.mapNotNull { view -> view as? PreferenceView }
|
||||||
.map { preference -> preference.clicks().map { preference } }
|
.map { preference -> preference.clicks().map { preference } }
|
||||||
.let { Observable.merge(it) }
|
.let { Observable.merge(it) }
|
||||||
@@ -97,29 +95,29 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
|||||||
title = state.conversationTitle
|
title = state.conversationTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.notifications.widget<QkSwitch>().isChecked = state.notificationsEnabled
|
notifications.checkbox.isChecked = state.notificationsEnabled
|
||||||
binding.previews.summary = state.previewSummary
|
previews.summary = state.previewSummary
|
||||||
previewModeDialog.adapter.selectedItem = state.previewId
|
previewModeDialog.adapter.selectedItem = state.previewId
|
||||||
binding.wake.widget<QkSwitch>().isChecked = state.wakeEnabled
|
wake.checkbox.isChecked = state.wakeEnabled
|
||||||
binding.vibration.widget<QkSwitch>().isChecked = state.vibrationEnabled
|
vibration.checkbox.isChecked = state.vibrationEnabled
|
||||||
binding.ringtone.summary = state.ringtoneName
|
ringtone.summary = state.ringtoneName
|
||||||
|
|
||||||
binding.actionsDivider.isVisible = state.threadId == 0L
|
actionsDivider.isVisible = state.threadId == 0L
|
||||||
binding.actionsTitle.isVisible = state.threadId == 0L
|
actionsTitle.isVisible = state.threadId == 0L
|
||||||
binding.action1.isVisible = state.threadId == 0L
|
action1.isVisible = state.threadId == 0L
|
||||||
binding.action1.summary = state.action1Summary
|
action1.summary = state.action1Summary
|
||||||
binding.action2.isVisible = state.threadId == 0L
|
action2.isVisible = state.threadId == 0L
|
||||||
binding.action2.summary = state.action2Summary
|
action2.summary = state.action2Summary
|
||||||
binding.action3.isVisible = state.threadId == 0L
|
action3.isVisible = state.threadId == 0L
|
||||||
binding.action3.summary = state.action3Summary
|
action3.summary = state.action3Summary
|
||||||
|
|
||||||
binding.qkreplyDivider.isVisible = state.threadId == 0L
|
qkreplyDivider.isVisible = state.threadId == 0L
|
||||||
binding.qkreplyTitle.isVisible = state.threadId == 0L
|
qkreplyTitle.isVisible = state.threadId == 0L
|
||||||
binding.qkreply.widget<QkSwitch>().isChecked = state.qkReplyEnabled
|
qkreply.checkbox.isChecked = state.qkReplyEnabled
|
||||||
binding.qkreply.isVisible = state.threadId == 0L
|
qkreply.isVisible = state.threadId == 0L
|
||||||
binding.qkreplyTapDismiss.isVisible = state.threadId == 0L
|
qkreplyTapDismiss.isVisible = state.threadId == 0L
|
||||||
binding.qkreplyTapDismiss.isEnabled = state.qkReplyEnabled
|
qkreplyTapDismiss.isEnabled = state.qkReplyEnabled
|
||||||
binding.qkreplyTapDismiss.widget<QkSwitch>().isChecked = state.qkReplyTapDismiss
|
qkreplyTapDismiss.checkbox.isChecked = state.qkReplyTapDismiss
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showPreviewModeDialog() = previewModeDialog.show(this)
|
override fun showPreviewModeDialog() = previewModeDialog.show(this)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import androidx.core.view.children
|
|||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import com.jakewharton.rxbinding2.view.clicks
|
import com.jakewharton.rxbinding2.view.clicks
|
||||||
|
import com.jakewharton.rxbinding2.view.enabled
|
||||||
import com.moez.QKSMS.BuildConfig
|
import com.moez.QKSMS.BuildConfig
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
import com.moez.QKSMS.common.base.QkThemedActivity
|
||||||
@@ -32,12 +33,14 @@ import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
|||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.common.widget.PreferenceView
|
import com.moez.QKSMS.common.widget.PreferenceView
|
||||||
import com.moez.QKSMS.databinding.QksmsPlusActivityBinding
|
|
||||||
import com.moez.QKSMS.feature.plus.experiment.UpgradeButtonExperiment
|
import com.moez.QKSMS.feature.plus.experiment.UpgradeButtonExperiment
|
||||||
import com.moez.QKSMS.manager.BillingManager
|
import com.moez.QKSMS.manager.BillingManager
|
||||||
import dagger.android.AndroidInjection
|
import dagger.android.AndroidInjection
|
||||||
|
import io.reactivex.Observable
|
||||||
|
import kotlinx.android.synthetic.main.collapsing_toolbar.*
|
||||||
|
import kotlinx.android.synthetic.main.preference_view.view.*
|
||||||
|
import kotlinx.android.synthetic.main.qksms_plus_activity.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class PlusActivity : QkThemedActivity(), PlusView {
|
class PlusActivity : QkThemedActivity(), PlusView {
|
||||||
@@ -46,68 +49,67 @@ class PlusActivity : QkThemedActivity(), PlusView {
|
|||||||
@Inject lateinit var upgradeButtonExperiment: UpgradeButtonExperiment
|
@Inject lateinit var upgradeButtonExperiment: UpgradeButtonExperiment
|
||||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||||
|
|
||||||
private val binding by viewBinding(QksmsPlusActivityBinding::inflate)
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[PlusViewModel::class.java] }
|
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[PlusViewModel::class.java] }
|
||||||
|
|
||||||
override val upgradeIntent by lazy { binding.upgrade.clicks() }
|
override val upgradeIntent by lazy { upgrade.clicks() }
|
||||||
override val upgradeDonateIntent by lazy { binding.upgradeDonate.clicks() }
|
override val upgradeDonateIntent by lazy { upgradeDonate.clicks() }
|
||||||
override val donateIntent by lazy { binding.donate.clicks() }
|
override val donateIntent by lazy { donate.clicks() }
|
||||||
override val themeClicks by lazy { binding.themes.clicks() }
|
override val themeClicks by lazy { themes.clicks() }
|
||||||
override val scheduleClicks by lazy { binding.schedule.clicks() }
|
override val scheduleClicks by lazy { schedule.clicks() }
|
||||||
override val backupClicks by lazy { binding.backup.clicks() }
|
override val backupClicks by lazy { backup.clicks() }
|
||||||
override val delayedClicks by lazy { binding.delayed.clicks() }
|
override val delayedClicks by lazy { delayed.clicks() }
|
||||||
override val nightClicks by lazy { binding.night.clicks() }
|
override val nightClicks by lazy { night.clicks() }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(binding.root)
|
setContentView(R.layout.qksms_plus_activity)
|
||||||
setTitle(R.string.title_qksms_plus)
|
setTitle(R.string.title_qksms_plus)
|
||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
|
|
||||||
binding.free.setVisible(false)
|
free.setVisible(false)
|
||||||
|
|
||||||
if (!prefs.systemFont.get()) {
|
if (!prefs.systemFont.get()) {
|
||||||
fontProvider.getLato { lato ->
|
fontProvider.getLato { lato ->
|
||||||
val typeface = Typeface.create(lato, Typeface.BOLD)
|
val typeface = Typeface.create(lato, Typeface.BOLD)
|
||||||
binding.appBarLayout.collapsingToolbar.setCollapsedTitleTypeface(typeface)
|
collapsingToolbar.setCollapsedTitleTypeface(typeface)
|
||||||
binding.appBarLayout.collapsingToolbar.setExpandedTitleTypeface(typeface)
|
collapsingToolbar.setExpandedTitleTypeface(typeface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the list titles bold
|
// Make the list titles bold
|
||||||
binding.linearLayout.children
|
linearLayout.children
|
||||||
.mapNotNull { view -> view as? PreferenceView }
|
.mapNotNull { it as? PreferenceView }
|
||||||
.map { preferenceView -> preferenceView.binding.titleView }
|
.map { it.titleView }
|
||||||
.forEach { it.setTypeface(it.typeface, Typeface.BOLD) }
|
.forEach { it.setTypeface(it.typeface, Typeface.BOLD) }
|
||||||
|
|
||||||
val textPrimary = resolveThemeColor(android.R.attr.textColorPrimary)
|
val textPrimary = resolveThemeColor(android.R.attr.textColorPrimary)
|
||||||
binding.appBarLayout.collapsingToolbar.setCollapsedTitleTextColor(textPrimary)
|
collapsingToolbar.setCollapsedTitleTextColor(textPrimary)
|
||||||
binding.appBarLayout.collapsingToolbar.setExpandedTitleColor(textPrimary)
|
collapsingToolbar.setExpandedTitleColor(textPrimary)
|
||||||
|
|
||||||
val theme = colors.theme().theme
|
val theme = colors.theme().theme
|
||||||
binding.donate.setBackgroundTint(theme)
|
donate.setBackgroundTint(theme)
|
||||||
binding.upgrade.setBackgroundTint(theme)
|
upgrade.setBackgroundTint(theme)
|
||||||
binding.thanksIcon.setTint(theme)
|
thanksIcon.setTint(theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: PlusState) {
|
override fun render(state: PlusState) {
|
||||||
binding.description.text = getString(R.string.qksms_plus_description_summary, state.upgradePrice)
|
description.text = getString(R.string.qksms_plus_description_summary, state.upgradePrice)
|
||||||
binding.upgrade.text = getString(upgradeButtonExperiment.variant, state.upgradePrice, state.currency)
|
upgrade.text = getString(upgradeButtonExperiment.variant, state.upgradePrice, state.currency)
|
||||||
binding.upgradeDonate.text = getString(R.string.qksms_plus_upgrade_donate, state.upgradeDonatePrice, state.currency)
|
upgradeDonate.text = getString(R.string.qksms_plus_upgrade_donate, state.upgradeDonatePrice, state.currency)
|
||||||
|
|
||||||
val fdroid = BuildConfig.FLAVOR == "noAnalytics"
|
val fdroid = BuildConfig.FLAVOR == "noAnalytics"
|
||||||
|
|
||||||
binding.free.setVisible(fdroid)
|
free.setVisible(fdroid)
|
||||||
binding.toUpgrade.setVisible(!fdroid && !state.upgraded)
|
toUpgrade.setVisible(!fdroid && !state.upgraded)
|
||||||
binding.upgraded.setVisible(!fdroid && state.upgraded)
|
upgraded.setVisible(!fdroid && state.upgraded)
|
||||||
|
|
||||||
binding.themes.isEnabled = state.upgraded
|
themes.isEnabled = state.upgraded
|
||||||
binding.schedule.isEnabled = state.upgraded
|
schedule.isEnabled = state.upgraded
|
||||||
binding.backup.isEnabled = state.upgraded
|
backup.isEnabled = state.upgraded
|
||||||
binding.delayed.isEnabled = state.upgraded
|
delayed.isEnabled = state.upgraded
|
||||||
binding.night.isEnabled = state.upgraded
|
night.isEnabled = state.upgraded
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initiatePurchaseFlow(billingManager: BillingManager, sku: String) {
|
override fun initiatePurchaseFlow(billingManager: BillingManager, sku: String) {
|
||||||
|
|||||||
@@ -36,12 +36,11 @@ import com.moez.QKSMS.common.util.extensions.autoScrollToStart
|
|||||||
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
import com.moez.QKSMS.common.util.extensions.resolveThemeColor
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.QkreplyActivityBinding
|
|
||||||
import com.moez.QKSMS.feature.compose.MessagesAdapter
|
import com.moez.QKSMS.feature.compose.MessagesAdapter
|
||||||
import dagger.android.AndroidInjection
|
import dagger.android.AndroidInjection
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.qkreply_activity.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
||||||
@@ -50,11 +49,10 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
|||||||
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
@Inject lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||||
|
|
||||||
override val menuItemIntent: Subject<Int> = PublishSubject.create()
|
override val menuItemIntent: Subject<Int> = PublishSubject.create()
|
||||||
override val textChangedIntent by lazy { binding.message.textChanges() }
|
override val textChangedIntent by lazy { message.textChanges() }
|
||||||
override val changeSimIntent by lazy { binding.sim.clicks() }
|
override val changeSimIntent by lazy { sim.clicks() }
|
||||||
override val sendIntent by lazy { binding.send.clicks() }
|
override val sendIntent by lazy { send.clicks() }
|
||||||
|
|
||||||
private val binding by viewBinding(QkreplyActivityBinding::inflate)
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[QkReplyViewModel::class.java] }
|
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[QkReplyViewModel::class.java] }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -63,27 +61,27 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setFinishOnTouchOutside(prefs.qkreplyTapDismiss.get())
|
setFinishOnTouchOutside(prefs.qkreplyTapDismiss.get())
|
||||||
setContentView(binding.root)
|
setContentView(R.layout.qkreply_activity)
|
||||||
window.setBackgroundDrawable(null)
|
window.setBackgroundDrawable(null)
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
||||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
|
|
||||||
binding.toolbar.clipToOutline = true
|
toolbar.clipToOutline = true
|
||||||
|
|
||||||
binding.messages.adapter = adapter
|
messages.adapter = adapter
|
||||||
binding.messages.adapter?.autoScrollToStart(binding.messages)
|
messages.adapter?.autoScrollToStart(messages)
|
||||||
binding.messages.adapter?.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
messages.adapter?.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||||
override fun onChanged() = binding.messages.scrollToPosition(adapter.itemCount - 1)
|
override fun onChanged() = messages.scrollToPosition(adapter.itemCount - 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
// These theme attributes don't apply themselves on API 21
|
// These theme attributes don't apply themselves on API 21
|
||||||
if (Build.VERSION.SDK_INT <= 22) {
|
if (Build.VERSION.SDK_INT <= 22) {
|
||||||
binding.toolbar.setBackgroundTint(resolveThemeColor(R.attr.colorPrimary))
|
toolbar.setBackgroundTint(resolveThemeColor(R.attr.colorPrimary))
|
||||||
binding.background.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
|
background.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
|
||||||
binding.messageBackground.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
messageBackground.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
|
||||||
binding.composeBackgroundGradient.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
|
composeBackgroundGradient.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
|
||||||
binding.composeBackgroundSolid.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
|
composeBackgroundSolid.setBackgroundTint(resolveThemeColor(android.R.attr.windowBackground))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,24 +94,24 @@ class QkReplyActivity : QkThemedActivity(), QkReplyView {
|
|||||||
|
|
||||||
title = state.title
|
title = state.title
|
||||||
|
|
||||||
binding.toolbar.menu.findItem(R.id.expand)?.isVisible = !state.expanded
|
toolbar.menu.findItem(R.id.expand)?.isVisible = !state.expanded
|
||||||
binding.toolbar.menu.findItem(R.id.collapse)?.isVisible = state.expanded
|
toolbar.menu.findItem(R.id.collapse)?.isVisible = state.expanded
|
||||||
|
|
||||||
adapter.data = state.data
|
adapter.data = state.data
|
||||||
|
|
||||||
binding.counter.text = state.remaining
|
counter.text = state.remaining
|
||||||
binding.counter.setVisible(binding.counter.text.isNotBlank())
|
counter.setVisible(counter.text.isNotBlank())
|
||||||
|
|
||||||
binding.sim.setVisible(state.subscription != null)
|
sim.setVisible(state.subscription != null)
|
||||||
binding.sim.contentDescription = getString(R.string.compose_sim_cd, state.subscription?.displayName)
|
sim.contentDescription = getString(R.string.compose_sim_cd, state.subscription?.displayName)
|
||||||
binding.simIndex.text = "${state.subscription?.simSlotIndex?.plus(1)}"
|
simIndex.text = "${state.subscription?.simSlotIndex?.plus(1)}"
|
||||||
|
|
||||||
binding.send.isEnabled = state.canSend
|
send.isEnabled = state.canSend
|
||||||
binding.send.imageAlpha = if (state.canSend) 255 else 128
|
send.imageAlpha = if (state.canSend) 255 else 128
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setDraft(draft: String) {
|
override fun setDraft(draft: String) {
|
||||||
binding.message.setText(draft)
|
message.setText(draft)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ import com.moez.QKSMS.common.base.QkThemedActivity
|
|||||||
import com.moez.QKSMS.common.util.FontProvider
|
import com.moez.QKSMS.common.util.FontProvider
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.databinding.ScheduledActivityBinding
|
|
||||||
import dagger.android.AndroidInjection
|
import dagger.android.AndroidInjection
|
||||||
|
import kotlinx.android.synthetic.main.collapsing_toolbar.*
|
||||||
|
import kotlinx.android.synthetic.main.scheduled_activity.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
@@ -45,16 +45,15 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView {
|
|||||||
|
|
||||||
override val messageClickIntent by lazy { messageAdapter.clicks }
|
override val messageClickIntent by lazy { messageAdapter.clicks }
|
||||||
override val messageMenuIntent by lazy { dialog.adapter.menuItemClicks }
|
override val messageMenuIntent by lazy { dialog.adapter.menuItemClicks }
|
||||||
override val composeIntent by lazy { binding.compose.clicks() }
|
override val composeIntent by lazy { compose.clicks() }
|
||||||
override val upgradeIntent by lazy { binding.upgrade.clicks() }
|
override val upgradeIntent by lazy { upgrade.clicks() }
|
||||||
|
|
||||||
private val binding by viewBinding(ScheduledActivityBinding::inflate)
|
|
||||||
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ScheduledViewModel::class.java] }
|
private val viewModel by lazy { ViewModelProviders.of(this, viewModelFactory)[ScheduledViewModel::class.java] }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(binding.root)
|
setContentView(R.layout.scheduled_activity)
|
||||||
setTitle(R.string.scheduled_title)
|
setTitle(R.string.scheduled_title)
|
||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
viewModel.bindView(this)
|
viewModel.bindView(this)
|
||||||
@@ -62,33 +61,33 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView {
|
|||||||
if (!prefs.systemFont.get()) {
|
if (!prefs.systemFont.get()) {
|
||||||
fontProvider.getLato { lato ->
|
fontProvider.getLato { lato ->
|
||||||
val typeface = Typeface.create(lato, Typeface.BOLD)
|
val typeface = Typeface.create(lato, Typeface.BOLD)
|
||||||
binding.appBarLayout.collapsingToolbar.setCollapsedTitleTypeface(typeface)
|
collapsingToolbar.setCollapsedTitleTypeface(typeface)
|
||||||
binding.appBarLayout.collapsingToolbar.setExpandedTitleTypeface(typeface)
|
collapsingToolbar.setExpandedTitleTypeface(typeface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.title = getString(R.string.scheduled_options_title)
|
dialog.title = getString(R.string.scheduled_options_title)
|
||||||
dialog.adapter.setData(R.array.scheduled_options)
|
dialog.adapter.setData(R.array.scheduled_options)
|
||||||
|
|
||||||
messageAdapter.emptyView = binding.empty
|
messageAdapter.emptyView = empty
|
||||||
binding.messages.adapter = messageAdapter
|
messages.adapter = messageAdapter
|
||||||
|
|
||||||
colors.theme().let { theme ->
|
colors.theme().let { theme ->
|
||||||
binding.sampleMessage.setBackgroundTint(theme.theme)
|
sampleMessage.setBackgroundTint(theme.theme)
|
||||||
binding.sampleMessage.setTextColor(theme.textPrimary)
|
sampleMessage.setTextColor(theme.textPrimary)
|
||||||
binding.compose.setTint(theme.textPrimary)
|
compose.setTint(theme.textPrimary)
|
||||||
binding.compose.setBackgroundTint(theme.theme)
|
compose.setBackgroundTint(theme.theme)
|
||||||
binding.upgrade.setBackgroundTint(theme.theme)
|
upgrade.setBackgroundTint(theme.theme)
|
||||||
binding.upgradeIcon.setTint(theme.textPrimary)
|
upgradeIcon.setTint(theme.textPrimary)
|
||||||
binding.upgradeLabel.setTextColor(theme.textPrimary)
|
upgradeLabel.setTextColor(theme.textPrimary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: ScheduledState) {
|
override fun render(state: ScheduledState) {
|
||||||
messageAdapter.updateData(state.scheduledMessages)
|
messageAdapter.updateData(state.scheduledMessages)
|
||||||
|
|
||||||
binding.compose.isVisible = state.upgraded
|
compose.isVisible = state.upgraded
|
||||||
binding.upgrade.isVisible = !state.upgraded
|
upgrade.isVisible = !state.upgraded
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showMessageOptions() {
|
override fun showMessageOptions() {
|
||||||
|
|||||||
+19
-14
@@ -20,13 +20,14 @@ package com.moez.QKSMS.feature.scheduled
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkRealmAdapter
|
import com.moez.QKSMS.common.base.QkRealmAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.DateFormatter
|
import com.moez.QKSMS.common.util.DateFormatter
|
||||||
import com.moez.QKSMS.databinding.ScheduledMessageListItemBinding
|
|
||||||
import com.moez.QKSMS.model.Contact
|
import com.moez.QKSMS.model.Contact
|
||||||
import com.moez.QKSMS.model.Recipient
|
import com.moez.QKSMS.model.Recipient
|
||||||
import com.moez.QKSMS.model.ScheduledMessage
|
import com.moez.QKSMS.model.ScheduledMessage
|
||||||
@@ -34,6 +35,8 @@ import com.moez.QKSMS.repository.ContactRepository
|
|||||||
import com.moez.QKSMS.util.PhoneNumberUtils
|
import com.moez.QKSMS.util.PhoneNumberUtils
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.scheduled_message_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.scheduled_message_list_item.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ScheduledMessageAdapter @Inject constructor(
|
class ScheduledMessageAdapter @Inject constructor(
|
||||||
@@ -41,7 +44,7 @@ class ScheduledMessageAdapter @Inject constructor(
|
|||||||
private val contactRepo: ContactRepository,
|
private val contactRepo: ContactRepository,
|
||||||
private val dateFormatter: DateFormatter,
|
private val dateFormatter: DateFormatter,
|
||||||
private val phoneNumberUtils: PhoneNumberUtils
|
private val phoneNumberUtils: PhoneNumberUtils
|
||||||
) : QkRealmAdapter<ScheduledMessage, ScheduledMessageListItemBinding>() {
|
) : QkRealmAdapter<ScheduledMessage>() {
|
||||||
|
|
||||||
private val contacts by lazy { contactRepo.getContacts() }
|
private val contacts by lazy { contactRepo.getContacts() }
|
||||||
private val contactCache = ContactCache()
|
private val contactCache = ContactCache()
|
||||||
@@ -49,34 +52,36 @@ class ScheduledMessageAdapter @Inject constructor(
|
|||||||
|
|
||||||
val clicks: Subject<Long> = PublishSubject.create()
|
val clicks: Subject<Long> = PublishSubject.create()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ScheduledMessageListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, ScheduledMessageListItemBinding::inflate).apply {
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.scheduled_message_list_item, parent, false)
|
||||||
binding.attachments.adapter = ScheduledMessageAttachmentAdapter(context)
|
|
||||||
binding.attachments.setRecycledViewPool(imagesViewPool)
|
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
view.attachments.adapter = ScheduledMessageAttachmentAdapter(context)
|
||||||
|
view.attachments.setRecycledViewPool(imagesViewPool)
|
||||||
|
|
||||||
|
return QkViewHolder(view).apply {
|
||||||
|
view.setOnClickListener {
|
||||||
val message = getItem(adapterPosition) ?: return@setOnClickListener
|
val message = getItem(adapterPosition) ?: return@setOnClickListener
|
||||||
clicks.onNext(message.id)
|
clicks.onNext(message.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ScheduledMessageListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val message = getItem(position) ?: return
|
val message = getItem(position) ?: return
|
||||||
|
|
||||||
// GroupAvatarView only accepts recipients, so map the phone numbers to recipients
|
// GroupAvatarView only accepts recipients, so map the phone numbers to recipients
|
||||||
holder.binding.avatars.recipients = message.recipients.map { address -> Recipient(address = address) }
|
holder.avatars.recipients = message.recipients.map { address -> Recipient(address = address) }
|
||||||
|
|
||||||
holder.binding.recipients.text = message.recipients.joinToString(",") { address ->
|
holder.recipients.text = message.recipients.joinToString(",") { address ->
|
||||||
contactCache[address]?.name?.takeIf { it.isNotBlank() } ?: address
|
contactCache[address]?.name?.takeIf { it.isNotBlank() } ?: address
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.binding.date.text = dateFormatter.getScheduledTimestamp(message.date)
|
holder.date.text = dateFormatter.getScheduledTimestamp(message.date)
|
||||||
holder.binding.body.text = message.body
|
holder.body.text = message.body
|
||||||
|
|
||||||
val adapter = holder.binding.attachments.adapter as ScheduledMessageAttachmentAdapter
|
val adapter = holder.attachments.adapter as ScheduledMessageAttachmentAdapter
|
||||||
adapter.data = message.attachments.map(Uri::parse)
|
adapter.data = message.attachments.map(Uri::parse)
|
||||||
holder.binding.attachments.isVisible = message.attachments.isNotEmpty()
|
holder.attachments.isVisible = message.attachments.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+12
-8
@@ -20,27 +20,31 @@ package com.moez.QKSMS.feature.scheduled
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.databinding.ScheduledMessageImageListItemBinding
|
|
||||||
import com.moez.QKSMS.util.GlideApp
|
import com.moez.QKSMS.util.GlideApp
|
||||||
|
import kotlinx.android.synthetic.main.attachment_image_list_item.view.*
|
||||||
|
import kotlinx.android.synthetic.main.scheduled_message_image_list_item.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ScheduledMessageAttachmentAdapter @Inject constructor(
|
class ScheduledMessageAttachmentAdapter @Inject constructor(
|
||||||
private val context: Context
|
private val context: Context
|
||||||
) : QkAdapter<Uri, ScheduledMessageImageListItemBinding>() {
|
) : QkAdapter<Uri>() {
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ScheduledMessageImageListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, ScheduledMessageImageListItemBinding::inflate).apply {
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.scheduled_message_image_list_item, parent, false)
|
||||||
binding.thumbnail.clipToOutline = true
|
view.thumbnail.clipToOutline = true
|
||||||
}
|
|
||||||
|
return QkViewHolder(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ScheduledMessageImageListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val attachment = getItem(position)
|
val attachment = getItem(position)
|
||||||
|
|
||||||
GlideApp.with(context).load(attachment).into(holder.binding.thumbnail)
|
GlideApp.with(context).load(attachment).into(holder.thumbnail)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,22 +22,21 @@ import android.os.Bundle
|
|||||||
import com.bluelinelabs.conductor.Conductor
|
import com.bluelinelabs.conductor.Conductor
|
||||||
import com.bluelinelabs.conductor.Router
|
import com.bluelinelabs.conductor.Router
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkThemedActivity
|
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 dagger.android.AndroidInjection
|
||||||
|
import kotlinx.android.synthetic.main.container_activity.*
|
||||||
|
|
||||||
class SettingsActivity : QkThemedActivity() {
|
class SettingsActivity : QkThemedActivity() {
|
||||||
|
|
||||||
private val binding by viewBinding(ContainerActivityBinding::inflate)
|
|
||||||
private lateinit var router: Router
|
private lateinit var router: Router
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
AndroidInjection.inject(this)
|
AndroidInjection.inject(this)
|
||||||
super.onCreate(savedInstanceState)
|
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()) {
|
if (!router.hasRootController()) {
|
||||||
router.setRoot(RouterTransaction.with(SettingsController()))
|
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.PreferenceView
|
||||||
import com.moez.QKSMS.common.widget.QkSwitch
|
import com.moez.QKSMS.common.widget.QkSwitch
|
||||||
import com.moez.QKSMS.common.widget.TextInputDialog
|
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.about.AboutController
|
||||||
import com.moez.QKSMS.feature.settings.autodelete.AutoDeleteDialog
|
import com.moez.QKSMS.feature.settings.autodelete.AutoDeleteDialog
|
||||||
import com.moez.QKSMS.feature.settings.swipe.SwipeActionsController
|
import com.moez.QKSMS.feature.settings.swipe.SwipeActionsController
|
||||||
@@ -59,12 +58,14 @@ import io.reactivex.subjects.Subject
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
import kotlinx.coroutines.withContext
|
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 javax.inject.Inject
|
||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
|
|
||||||
class SettingsController : QkController<SettingsView, SettingsState, SettingsPresenter, SettingsControllerBinding>(
|
class SettingsController : QkController<SettingsView, SettingsState, SettingsPresenter>(), SettingsView {
|
||||||
SettingsControllerBinding::inflate
|
|
||||||
), SettingsView {
|
|
||||||
|
|
||||||
@Inject lateinit var context: Context
|
@Inject lateinit var context: Context
|
||||||
@Inject lateinit var colors: Colors
|
@Inject lateinit var colors: Colors
|
||||||
@@ -88,11 +89,12 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
private val signatureSubject: Subject<String> = PublishSubject.create()
|
private val signatureSubject: Subject<String> = PublishSubject.create()
|
||||||
private val autoDeleteSubject: Subject<Int> = 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 {
|
init {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
retainViewMode = RetainViewMode.RETAIN_DETACH
|
retainViewMode = RetainViewMode.RETAIN_DETACH
|
||||||
|
layoutRes = R.layout.settings_controller
|
||||||
|
|
||||||
colors.themeObservable()
|
colors.themeObservable()
|
||||||
.autoDisposable(scope())
|
.autoDisposable(scope())
|
||||||
@@ -100,7 +102,7 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated() {
|
override fun onViewCreated() {
|
||||||
binding.preferences.postDelayed({ binding.preferences.animateLayoutChanges = true }, 100)
|
preferences.postDelayed({ preferences?.animateLayoutChanges = true }, 100)
|
||||||
|
|
||||||
when (Build.VERSION.SDK_INT >= 29) {
|
when (Build.VERSION.SDK_INT >= 29) {
|
||||||
true -> nightModeDialog.adapter.setData(R.array.night_modes)
|
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)
|
sendDelayDialog.adapter.setData(R.array.delayed_sending_labels)
|
||||||
mmsSizeDialog.adapter.setData(R.array.mms_sizes, R.array.mms_sizes_ids)
|
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) {
|
override fun onAttach(view: View) {
|
||||||
@@ -122,13 +124,13 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre
|
|||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun preferenceClicks(): Observable<PreferenceView> = (0 until binding.preferences.childCount)
|
override fun preferenceClicks(): Observable<PreferenceView> = (0 until preferences.childCount)
|
||||||
.map { index -> binding.preferences.getChildAt(index) }
|
.map { index -> preferences.getChildAt(index) }
|
||||||
.mapNotNull { view -> view as? PreferenceView }
|
.mapNotNull { view -> view as? PreferenceView }
|
||||||
.map { preference -> preference.clicks().map { preference } }
|
.map { preference -> preference.clicks().map { preference } }
|
||||||
.let { preferences -> Observable.merge(preferences) }
|
.let { preferences -> Observable.merge(preferences) }
|
||||||
|
|
||||||
override fun aboutLongClicks(): Observable<*> = binding.about.longClicks()
|
override fun aboutLongClicks(): Observable<*> = about.longClicks()
|
||||||
|
|
||||||
override fun viewQksmsPlusClicks(): Observable<*> = viewQksmsPlusSubject
|
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 mmsSizeSelected(): Observable<Int> = mmsSizeDialog.adapter.menuItemClicks
|
||||||
|
|
||||||
override fun render(state: SettingsState) {
|
override fun render(state: SettingsState) {
|
||||||
binding.theme.widget<View>().setBackgroundTint(state.theme)
|
themePreview.setBackgroundTint(state.theme)
|
||||||
binding.night.summary = state.nightModeSummary
|
night.summary = state.nightModeSummary
|
||||||
nightModeDialog.adapter.selectedItem = state.nightModeId
|
nightModeDialog.adapter.selectedItem = state.nightModeId
|
||||||
binding.nightStart.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
nightStart.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||||
binding.nightStart.summary = state.nightStart
|
nightStart.summary = state.nightStart
|
||||||
binding.nightEnd.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
nightEnd.setVisible(state.nightModeId == Preferences.NIGHT_MODE_AUTO)
|
||||||
binding.nightEnd.summary = state.nightEnd
|
nightEnd.summary = state.nightEnd
|
||||||
|
|
||||||
binding.black.setVisible(state.nightModeId != Preferences.NIGHT_MODE_OFF)
|
black.setVisible(state.nightModeId != Preferences.NIGHT_MODE_OFF)
|
||||||
binding.black.widget<QkSwitch>().isChecked = state.black
|
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
|
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)
|
?: context.getString(R.string.settings_signature_summary)
|
||||||
|
|
||||||
binding.textSize.summary = state.textSizeSummary
|
textSize.summary = state.textSizeSummary
|
||||||
textSizeDialog.adapter.selectedItem = state.textSizeId
|
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
|
unicode.checkbox.isChecked = state.stripUnicodeEnabled
|
||||||
binding.mobileOnly.widget<QkSwitch>().isChecked = state.mobileOnly
|
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)
|
0 -> context.getString(R.string.settings_auto_delete_never)
|
||||||
else -> context.resources.getQuantityString(
|
else -> context.resources.getQuantityString(
|
||||||
R.plurals.settings_auto_delete_summary, state.autoDelete, state.autoDelete)
|
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
|
mmsSizeDialog.adapter.selectedItem = state.maxMmsSizeId
|
||||||
|
|
||||||
when (state.syncProgress) {
|
when (state.syncProgress) {
|
||||||
is SyncRepository.SyncProgress.Idle -> binding.syncingProgress.isVisible = false
|
is SyncRepository.SyncProgress.Idle -> syncingProgress.isVisible = false
|
||||||
|
|
||||||
is SyncRepository.SyncProgress.Running -> {
|
is SyncRepository.SyncProgress.Running -> {
|
||||||
binding.syncingProgress.isVisible = true
|
syncingProgress.isVisible = true
|
||||||
binding.syncingProgress.max = state.syncProgress.max
|
syncingProgress.max = state.syncProgress.max
|
||||||
progressAnimator.apply { setIntValues(binding.syncingProgress.progress, state.syncProgress.progress) }
|
progressAnimator.apply { setIntValues(syncingProgress.progress, state.syncProgress.progress) }.start()
|
||||||
.start()
|
syncingProgress.isIndeterminate = state.syncProgress.indeterminate
|
||||||
binding.syncingProgress.isIndeterminate = state.syncProgress.indeterminate
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showQksmsPlusSnackbar() {
|
override fun showQksmsPlusSnackbar() {
|
||||||
view?.run {
|
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) }
|
setAction(R.string.button_more) { viewQksmsPlusSubject.onNext(Unit) }
|
||||||
setActionTextColor(colors.theme().theme)
|
setActionTextColor(colors.theme().theme)
|
||||||
show()
|
show()
|
||||||
|
|||||||
@@ -24,23 +24,22 @@ import com.moez.QKSMS.BuildConfig
|
|||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkController
|
import com.moez.QKSMS.common.base.QkController
|
||||||
import com.moez.QKSMS.common.widget.PreferenceView
|
import com.moez.QKSMS.common.widget.PreferenceView
|
||||||
import com.moez.QKSMS.databinding.AboutControllerBinding
|
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
|
import kotlinx.android.synthetic.main.about_controller.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AboutController : QkController<AboutView, Unit, AboutPresenter, AboutControllerBinding>(
|
class AboutController : QkController<AboutView, Unit, AboutPresenter>(), AboutView {
|
||||||
AboutControllerBinding::inflate
|
|
||||||
), AboutView {
|
|
||||||
|
|
||||||
@Inject override lateinit var presenter: AboutPresenter
|
@Inject override lateinit var presenter: AboutPresenter
|
||||||
|
|
||||||
init {
|
init {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
|
layoutRes = R.layout.about_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated() {
|
override fun onViewCreated() {
|
||||||
binding.version.summary = BuildConfig.VERSION_NAME
|
version.summary = BuildConfig.VERSION_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
@@ -50,8 +49,8 @@ class AboutController : QkController<AboutView, Unit, AboutPresenter, AboutContr
|
|||||||
showBackButton(true)
|
showBackButton(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun preferenceClicks(): Observable<PreferenceView> = (0 until binding.preferences.childCount)
|
override fun preferenceClicks(): Observable<PreferenceView> = (0 until preferences.childCount)
|
||||||
.map { index -> binding.preferences.getChildAt(index) }
|
.map { index -> preferences.getChildAt(index) }
|
||||||
.mapNotNull { view -> view as? PreferenceView }
|
.mapNotNull { view -> view as? PreferenceView }
|
||||||
.map { preference -> preference.clicks().map { preference } }
|
.map { preference -> preference.clicks().map { preference } }
|
||||||
.let { preferences -> Observable.merge(preferences) }
|
.let { preferences -> Observable.merge(preferences) }
|
||||||
|
|||||||
+7
-6
@@ -20,29 +20,30 @@ package com.moez.QKSMS.feature.settings.autodelete
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
|
import android.view.LayoutInflater
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.moez.QKSMS.R
|
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) {
|
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 {
|
init {
|
||||||
setView(binding.root)
|
setView(layout)
|
||||||
setTitle(R.string.settings_auto_delete)
|
setTitle(R.string.settings_auto_delete)
|
||||||
setMessage(context.getString(R.string.settings_auto_delete_dialog_message))
|
setMessage(context.getString(R.string.settings_auto_delete_dialog_message))
|
||||||
setButton(DialogInterface.BUTTON_NEUTRAL, context.getString(R.string.button_cancel)) { _, _ -> }
|
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_NEGATIVE, context.getString(R.string.settings_auto_delete_never)) { _, _ -> listener(0) }
|
||||||
setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.button_save)) { _, _ ->
|
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 {
|
fun setExpiry(days: Int): AutoDeleteDialog {
|
||||||
when (days) {
|
when (days) {
|
||||||
0 -> binding.field.text = null
|
0 -> layout.field.text = null
|
||||||
else -> binding.field.setText(days.toString())
|
else -> layout.field.setText(days.toString())
|
||||||
}
|
}
|
||||||
return this
|
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.animateLayoutChanges
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.databinding.SwipeActionsControllerBinding
|
|
||||||
import com.moez.QKSMS.injection.appComponent
|
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.android.lifecycle.scope
|
||||||
import com.uber.autodispose.autoDisposable
|
import com.uber.autodispose.autoDisposable
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.swipe_actions_controller.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SwipeActionsController :
|
class SwipeActionsController : QkController<SwipeActionsView, SwipeActionsState, SwipeActionsPresenter>(), SwipeActionsView {
|
||||||
QkController<SwipeActionsView, SwipeActionsState, SwipeActionsPresenter, SwipeActionsControllerBinding>(
|
|
||||||
SwipeActionsControllerBinding::inflate), SwipeActionsView {
|
|
||||||
|
|
||||||
@Inject override lateinit var presenter: SwipeActionsPresenter
|
@Inject override lateinit var presenter: SwipeActionsPresenter
|
||||||
@Inject lateinit var actionsDialog: QkDialog
|
@Inject lateinit var actionsDialog: QkDialog
|
||||||
@@ -54,24 +50,25 @@ class SwipeActionsController :
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
appComponent.inject(this)
|
appComponent.inject(this)
|
||||||
|
layoutRes = R.layout.swipe_actions_controller
|
||||||
|
|
||||||
actionsDialog.adapter.setData(R.array.settings_swipe_actions)
|
actionsDialog.adapter.setData(R.array.settings_swipe_actions)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated() {
|
override fun onViewCreated() {
|
||||||
colors.theme().let { theme ->
|
colors.theme().let { theme ->
|
||||||
binding.rightIcon.setBackgroundTint(theme.theme)
|
rightIcon.setBackgroundTint(theme.theme)
|
||||||
binding.rightIcon.setTint(theme.textPrimary)
|
rightIcon.setTint(theme.textPrimary)
|
||||||
binding.leftIcon.setBackgroundTint(theme.theme)
|
leftIcon.setBackgroundTint(theme.theme)
|
||||||
binding.leftIcon.setTint(theme.textPrimary)
|
leftIcon.setTint(theme.textPrimary)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.right.postDelayed({ binding.right.animateLayoutChanges = true }, 100)
|
right.postDelayed({ right?.animateLayoutChanges = true }, 100)
|
||||||
binding.left.postDelayed({ binding.left.animateLayoutChanges = true }, 100)
|
left.postDelayed({ left?.animateLayoutChanges = true }, 100)
|
||||||
|
|
||||||
Observable.merge(
|
Observable.merge(
|
||||||
binding.right.clicks().map { SwipeActionsView.Action.RIGHT },
|
right.clicks().map { SwipeActionsView.Action.RIGHT },
|
||||||
binding.left.clicks().map { SwipeActionsView.Action.LEFT })
|
left.clicks().map { SwipeActionsView.Action.LEFT })
|
||||||
.autoDisposable(scope())
|
.autoDisposable(scope())
|
||||||
.subscribe(actionClicks)
|
.subscribe(actionClicks)
|
||||||
}
|
}
|
||||||
@@ -93,13 +90,13 @@ class SwipeActionsController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun render(state: SwipeActionsState) {
|
override fun render(state: SwipeActionsState) {
|
||||||
binding.rightIcon.isVisible = state.rightIcon != 0
|
rightIcon.isVisible = state.rightIcon != 0
|
||||||
binding.rightIcon.setImageResource(state.rightIcon)
|
rightIcon.setImageResource(state.rightIcon)
|
||||||
binding.rightLabel.text = state.rightLabel
|
rightLabel.text = state.rightLabel
|
||||||
|
|
||||||
binding.leftIcon.isVisible = state.leftIcon != 0
|
leftIcon.isVisible = state.leftIcon != 0
|
||||||
binding.leftIcon.setImageResource(state.leftIcon)
|
leftIcon.setImageResource(state.leftIcon)
|
||||||
binding.leftLabel.text = state.leftLabel
|
leftLabel.text = state.leftLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,14 +23,15 @@ import android.graphics.Color
|
|||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.viewBinding
|
|
||||||
import com.moez.QKSMS.common.util.extensions.within
|
import com.moez.QKSMS.common.util.extensions.within
|
||||||
import com.moez.QKSMS.databinding.HsvPickerViewBinding
|
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.hsv_picker_view.view.*
|
||||||
|
|
||||||
class HSVPickerView @JvmOverloads constructor(
|
class HSVPickerView @JvmOverloads constructor(
|
||||||
context: Context, attrs: AttributeSet? = null
|
context: Context, attrs: AttributeSet? = null
|
||||||
@@ -38,8 +39,6 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
|
|
||||||
val selectedColor: Subject<Int> = BehaviorSubject.create()
|
val selectedColor: Subject<Int> = BehaviorSubject.create()
|
||||||
|
|
||||||
private val binding = viewBinding(HsvPickerViewBinding::inflate)
|
|
||||||
|
|
||||||
private val hues = arrayOf(0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF00FF, 0xFFFF0000)
|
private val hues = arrayOf(0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF00FF, 0xFFFF0000)
|
||||||
.map { it.toInt() }.toIntArray()
|
.map { it.toInt() }.toIntArray()
|
||||||
|
|
||||||
@@ -53,10 +52,12 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
View.inflate(context, R.layout.hsv_picker_view, this)
|
||||||
|
|
||||||
var swatchX = 0f
|
var swatchX = 0f
|
||||||
var swatchY = 0f
|
var swatchY = 0f
|
||||||
|
|
||||||
binding.saturation.setOnTouchListener { _, event ->
|
saturation.setOnTouchListener { _, event ->
|
||||||
setupBounds()
|
setupBounds()
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
@@ -67,8 +68,8 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
// Calculate the new x/y position
|
// Calculate the new x/y position
|
||||||
binding.swatch.x = (event.rawX + swatchX + min).within(min, max)
|
swatch.x = (event.rawX + swatchX + min).within(min, max)
|
||||||
binding.swatch.y = (event.rawY + swatchY + min).within(min, max)
|
swatch.y = (event.rawY + swatchY + min).within(min, max)
|
||||||
|
|
||||||
updateSelectedColor()
|
updateSelectedColor()
|
||||||
}
|
}
|
||||||
@@ -84,7 +85,7 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
|
|
||||||
var hueThumbX = 0f
|
var hueThumbX = 0f
|
||||||
|
|
||||||
binding.hueGroup.setOnTouchListener { _, event ->
|
hueGroup.setOnTouchListener { _, event ->
|
||||||
setupBounds()
|
setupBounds()
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
@@ -95,8 +96,8 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
val x = (event.rawX + hueThumbX + min).within(min, max)
|
val x = (event.rawX + hueThumbX + min).within(min, max)
|
||||||
|
|
||||||
binding.hueThumb.x = x
|
hueThumb.x = x
|
||||||
hue = (binding.hueThumb.x - min) / (max - min) * 360
|
hue = (hueThumb.x - min) / (max - min) * 360
|
||||||
|
|
||||||
updateSelectedColor()
|
updateSelectedColor()
|
||||||
}
|
}
|
||||||
@@ -110,14 +111,14 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.hueTrack.clipToOutline = true
|
hueTrack.clipToOutline = true
|
||||||
binding.hueTrack.setImageDrawable(GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, hues))
|
hueTrack.setImageDrawable(GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, hues))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupBounds() {
|
private fun setupBounds() {
|
||||||
if (min == 0f || max == 0f) {
|
if (min == 0f || max == 0f) {
|
||||||
min = binding.saturation.x - binding.swatch.width / 2
|
min = saturation.x - swatch.width / 2
|
||||||
max = min + binding.saturation.width
|
max = min + saturation.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,10 +126,10 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
setupBounds()
|
setupBounds()
|
||||||
|
|
||||||
val range = max - min
|
val range = max - min
|
||||||
val hsv = floatArrayOf(hue, (binding.swatch.x - min) / range, 1 - (binding.swatch.y - min) / range)
|
val hsv = floatArrayOf(hue, (swatch.x - min) / range, 1 - (swatch.y - min) / range)
|
||||||
val color = Color.HSVToColor(hsv)
|
val color = Color.HSVToColor(hsv)
|
||||||
|
|
||||||
binding.swatch.setTint(color)
|
swatch.setTint(color)
|
||||||
selectedColor.onNext(color)
|
selectedColor.onNext(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,9 +145,9 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
setupBounds()
|
setupBounds()
|
||||||
val range = max - min
|
val range = max - min
|
||||||
|
|
||||||
binding.hueThumb.x = range * hsv[0] / 360 + min
|
hueThumb.x = range * hsv[0] / 360 + min
|
||||||
binding.swatch.x = range * hsv[1] + min
|
swatch.x = range * hsv[1] + min
|
||||||
binding.swatch.y = range * (1 - hsv[2]) + min
|
swatch.y = range * (1 - hsv[2]) + min
|
||||||
|
|
||||||
updateSelectedColor()
|
updateSelectedColor()
|
||||||
}
|
}
|
||||||
@@ -155,7 +156,7 @@ class HSVPickerView @JvmOverloads constructor(
|
|||||||
private fun updateHue() {
|
private fun updateHue() {
|
||||||
val hsv = floatArrayOf(hue, 1f, 1f)
|
val hsv = floatArrayOf(hue, 1f, 1f)
|
||||||
val tint = Color.HSVToColor(hsv)
|
val tint = Color.HSVToColor(hsv)
|
||||||
binding.saturation.setBackgroundTint(tint)
|
saturation.setBackgroundTint(tint)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ import android.view.ViewGroup
|
|||||||
import com.google.android.flexbox.FlexDirection
|
import com.google.android.flexbox.FlexDirection
|
||||||
import com.google.android.flexbox.FlexWrap
|
import com.google.android.flexbox.FlexWrap
|
||||||
import com.google.android.flexbox.FlexboxLayout
|
import com.google.android.flexbox.FlexboxLayout
|
||||||
|
import com.moez.QKSMS.R
|
||||||
import com.moez.QKSMS.common.base.QkAdapter
|
import com.moez.QKSMS.common.base.QkAdapter
|
||||||
import com.moez.QKSMS.common.base.QkViewHolder
|
import com.moez.QKSMS.common.base.QkViewHolder
|
||||||
import com.moez.QKSMS.common.util.Colors
|
import com.moez.QKSMS.common.util.Colors
|
||||||
@@ -32,16 +33,17 @@ import com.moez.QKSMS.common.util.extensions.dpToPx
|
|||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setTint
|
import com.moez.QKSMS.common.util.extensions.setTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.databinding.ThemeListItemBinding
|
|
||||||
import com.moez.QKSMS.databinding.ThemePaletteListItemBinding
|
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.theme_list_item.view.*
|
||||||
|
import kotlinx.android.synthetic.main.theme_palette_list_item.*
|
||||||
|
import kotlinx.android.synthetic.main.theme_palette_list_item.view.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ThemeAdapter @Inject constructor(
|
class ThemeAdapter @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val colors: Colors
|
private val colors: Colors
|
||||||
) : QkAdapter<List<Int>, ThemePaletteListItemBinding>() {
|
) : QkAdapter<List<Int>>() {
|
||||||
|
|
||||||
val colorSelected: Subject<Int> = PublishSubject.create()
|
val colorSelected: Subject<Int> = PublishSubject.create()
|
||||||
|
|
||||||
@@ -59,14 +61,15 @@ class ThemeAdapter @Inject constructor(
|
|||||||
|
|
||||||
private var iconTint = 0
|
private var iconTint = 0
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder<ThemePaletteListItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
|
||||||
return QkViewHolder(parent, ThemePaletteListItemBinding::inflate).apply {
|
val view = LayoutInflater.from(parent.context).inflate(R.layout.theme_palette_list_item, parent, false)
|
||||||
binding.palette.flexWrap = FlexWrap.WRAP
|
view.palette.flexWrap = FlexWrap.WRAP
|
||||||
binding.palette.flexDirection = FlexDirection.ROW
|
view.palette.flexDirection = FlexDirection.ROW
|
||||||
}
|
|
||||||
|
return QkViewHolder(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: QkViewHolder<ThemePaletteListItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: QkViewHolder, position: Int) {
|
||||||
val palette = getItem(position)
|
val palette = getItem(position)
|
||||||
|
|
||||||
val screenWidth = Resources.getSystem().displayMetrics.widthPixels
|
val screenWidth = Resources.getSystem().displayMetrics.widthPixels
|
||||||
@@ -78,15 +81,15 @@ class ThemeAdapter @Inject constructor(
|
|||||||
}
|
}
|
||||||
val swatchPadding = (screenWidth - size * 5) / 12
|
val swatchPadding = (screenWidth - size * 5) / 12
|
||||||
|
|
||||||
holder.binding.palette.removeAllViews()
|
holder.palette.removeAllViews()
|
||||||
holder.binding.palette.setPadding(swatchPadding, swatchPadding, swatchPadding, swatchPadding)
|
holder.palette.setPadding(swatchPadding, swatchPadding, swatchPadding, swatchPadding)
|
||||||
|
|
||||||
(palette.subList(0, 5) + palette.subList(5, 10).reversed())
|
(palette.subList(0, 5) + palette.subList(5, 10).reversed())
|
||||||
.mapIndexed { index, color ->
|
.mapIndexed { index, color ->
|
||||||
ThemeListItemBinding.inflate(LayoutInflater.from(context), holder.binding.palette, false).apply {
|
LayoutInflater.from(context).inflate(R.layout.theme_list_item, holder.palette, false).apply {
|
||||||
|
|
||||||
// Send clicks to the selected subject
|
// Send clicks to the selected subject
|
||||||
root.setOnClickListener { colorSelected.onNext(color) }
|
setOnClickListener { colorSelected.onNext(color) }
|
||||||
|
|
||||||
// Apply the color to the view
|
// Apply the color to the view
|
||||||
theme.setBackgroundTint(color)
|
theme.setBackgroundTint(color)
|
||||||
@@ -96,15 +99,15 @@ class ThemeAdapter @Inject constructor(
|
|||||||
check.setTint(iconTint)
|
check.setTint(iconTint)
|
||||||
|
|
||||||
// Update the size so that the spacing is perfectly even
|
// Update the size so that the spacing is perfectly even
|
||||||
root.layoutParams = (root.layoutParams as FlexboxLayout.LayoutParams).apply {
|
layoutParams = (layoutParams as FlexboxLayout.LayoutParams).apply {
|
||||||
height = size
|
height = size
|
||||||
width = size
|
width = size
|
||||||
isWrapBefore = index % 5 == 0
|
isWrapBefore = index % 5 == 0
|
||||||
setMargins(swatchPadding, swatchPadding, swatchPadding, swatchPadding)
|
setMargins(swatchPadding, swatchPadding, swatchPadding, swatchPadding)
|
||||||
}
|
}
|
||||||
}.root
|
}
|
||||||
}
|
}
|
||||||
.forEach { theme -> holder.binding.palette.addView(theme) }
|
.forEach { theme -> holder.palette.addView(theme) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+21
-21
@@ -29,19 +29,18 @@ import com.moez.QKSMS.common.util.Colors
|
|||||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||||
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
import com.moez.QKSMS.common.util.extensions.setBackgroundTint
|
||||||
import com.moez.QKSMS.common.util.extensions.setVisible
|
import com.moez.QKSMS.common.util.extensions.setVisible
|
||||||
import com.moez.QKSMS.databinding.ThemePickerControllerBinding
|
|
||||||
import com.moez.QKSMS.feature.themepicker.injection.ThemePickerModule
|
import com.moez.QKSMS.feature.themepicker.injection.ThemePickerModule
|
||||||
import com.moez.QKSMS.injection.appComponent
|
import com.moez.QKSMS.injection.appComponent
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.PublishSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import kotlinx.android.synthetic.main.theme_picker_controller.*
|
||||||
|
import kotlinx.android.synthetic.main.theme_picker_hsv.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ThemePickerController(
|
class ThemePickerController(
|
||||||
val recipientId: Long = 0L
|
val recipientId: Long = 0L
|
||||||
) : QkController<ThemePickerView, ThemePickerState, ThemePickerPresenter, ThemePickerControllerBinding>(
|
) : QkController<ThemePickerView, ThemePickerState, ThemePickerPresenter>(), ThemePickerView {
|
||||||
ThemePickerControllerBinding::inflate
|
|
||||||
), ThemePickerView {
|
|
||||||
|
|
||||||
@Inject override lateinit var presenter: ThemePickerPresenter
|
@Inject override lateinit var presenter: ThemePickerPresenter
|
||||||
|
|
||||||
@@ -57,17 +56,19 @@ class ThemePickerController(
|
|||||||
.themePickerModule(ThemePickerModule(this))
|
.themePickerModule(ThemePickerModule(this))
|
||||||
.build()
|
.build()
|
||||||
.inject(this)
|
.inject(this)
|
||||||
|
|
||||||
|
layoutRes = R.layout.theme_picker_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated() {
|
override fun onViewCreated() {
|
||||||
binding.pager.offscreenPageLimit = 1
|
pager.offscreenPageLimit = 1
|
||||||
binding.pager.adapter = themePagerAdapter
|
pager.adapter = themePagerAdapter
|
||||||
binding.tabs.pager = binding.pager
|
tabs.pager = pager
|
||||||
|
|
||||||
themeAdapter.data = colors.materialColors
|
themeAdapter.data = colors.materialColors
|
||||||
|
|
||||||
binding.materialColors.layoutManager = LinearLayoutManager(activity)
|
materialColors.layoutManager = LinearLayoutManager(activity)
|
||||||
binding.materialColors.adapter = themeAdapter
|
materialColors.adapter = themeAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
@@ -85,13 +86,12 @@ class ThemePickerController(
|
|||||||
super.onDetach(view)
|
super.onDetach(view)
|
||||||
|
|
||||||
themedActivity?.supportActionBar?.let { toolbar ->
|
themedActivity?.supportActionBar?.let { toolbar ->
|
||||||
ObjectAnimator.ofFloat(toolbar, "elevation", toolbar.elevation, 8.dpToPx(toolbar.themedContext).toFloat())
|
ObjectAnimator.ofFloat(toolbar, "elevation", toolbar.elevation, 8.dpToPx(toolbar.themedContext).toFloat()).start()
|
||||||
.start()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showQksmsPlusSnackbar() {
|
override fun showQksmsPlusSnackbar() {
|
||||||
Snackbar.make(binding.contentView, 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) }
|
setAction(R.string.button_more) { viewQksmsPlusSubject.onNext(Unit) }
|
||||||
setActionTextColor(colors.theme().theme)
|
setActionTextColor(colors.theme().theme)
|
||||||
show()
|
show()
|
||||||
@@ -100,26 +100,26 @@ class ThemePickerController(
|
|||||||
|
|
||||||
override fun themeSelected(): Observable<Int> = themeAdapter.colorSelected
|
override fun themeSelected(): Observable<Int> = themeAdapter.colorSelected
|
||||||
|
|
||||||
override fun hsvThemeSelected(): Observable<Int> = binding.hsvPicker.picker.selectedColor
|
override fun hsvThemeSelected(): Observable<Int> = picker.selectedColor
|
||||||
|
|
||||||
override fun clearHsvThemeClicks(): Observable<*> = binding.hsvPicker.clear.clicks()
|
override fun clearHsvThemeClicks(): Observable<*> = clear.clicks()
|
||||||
|
|
||||||
override fun applyHsvThemeClicks(): Observable<*> = binding.hsvPicker.apply.clicks()
|
override fun applyHsvThemeClicks(): Observable<*> = apply.clicks()
|
||||||
|
|
||||||
override fun viewQksmsPlusClicks(): Observable<*> = viewQksmsPlusSubject
|
override fun viewQksmsPlusClicks(): Observable<*> = viewQksmsPlusSubject
|
||||||
|
|
||||||
override fun render(state: ThemePickerState) {
|
override fun render(state: ThemePickerState) {
|
||||||
binding.tabs.setRecipientId(state.recipientId)
|
tabs.setRecipientId(state.recipientId)
|
||||||
|
|
||||||
binding.hsvPicker.hex.setText(Integer.toHexString(state.newColor).takeLast(6))
|
hex.setText(Integer.toHexString(state.newColor).takeLast(6))
|
||||||
|
|
||||||
binding.hsvPicker.applyGroup.setVisible(state.applyThemeVisible)
|
applyGroup.setVisible(state.applyThemeVisible)
|
||||||
binding.hsvPicker.apply.setBackgroundTint(state.newColor)
|
apply.setBackgroundTint(state.newColor)
|
||||||
binding.hsvPicker.apply.setTextColor(state.newTextColor)
|
apply.setTextColor(state.newTextColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setCurrentTheme(color: Int) {
|
override fun setCurrentTheme(color: Int) {
|
||||||
binding.hsvPicker.picker.setColor(color)
|
picker.setColor(color)
|
||||||
themeAdapter.selectedColor = color
|
themeAdapter.selectedColor = color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/appBarLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="108dp"
|
android:layout_height="108dp"
|
||||||
android:fitsSystemWindows="true">
|
android:fitsSystemWindows="true">
|
||||||
|
|||||||
@@ -17,21 +17,25 @@
|
|||||||
~ You should have received a copy of the GNU General Public License
|
~ You should have received a copy of the GNU General Public License
|
||||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/card"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:backgroundTint="@color/tools_theme"
|
android:layout_margin="8dp"
|
||||||
tools:parentTag="com.moez.QKSMS.feature.compose.editing.DetailedChipView">
|
android:background="@drawable/rounded_rectangle_2dp"
|
||||||
|
android:elevation="8dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
|
tools:backgroundTint="@color/tools_theme">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.AvatarView
|
<com.moez.QKSMS.common.widget.AvatarView
|
||||||
android:id="@+id/avatar"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
@@ -80,4 +84,4 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
tools:tint="@color/white" />
|
tools:tint="@color/white" />
|
||||||
|
|
||||||
</merge>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -121,20 +121,20 @@
|
|||||||
android:background="?android:attr/divider"
|
android:background="?android:attr/divider"
|
||||||
app:layout_constraintBottom_toTopOf="@id/snackbar" />
|
app:layout_constraintBottom_toTopOf="@id/snackbar" />
|
||||||
|
|
||||||
<include
|
<ViewStub
|
||||||
android:id="@+id/snackbar"
|
android:id="@+id/snackbar"
|
||||||
layout="@layout/main_permission_hint"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:inflatedId="@id/snackbar"
|
||||||
|
android:layout="@layout/main_permission_hint"
|
||||||
app:layout_constraintBottom_toTopOf="@id/syncing" />
|
app:layout_constraintBottom_toTopOf="@id/syncing" />
|
||||||
|
|
||||||
<include
|
<ViewStub
|
||||||
android:id="@+id/syncing"
|
android:id="@+id/syncing"
|
||||||
layout="@layout/main_syncing"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:inflatedId="@id/syncing"
|
||||||
|
android:layout="@layout/main_syncing"
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
app:layout_constraintBottom_toBottomOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -146,4 +146,4 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start" />
|
android:layout_gravity="start" />
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
@@ -24,22 +24,22 @@
|
|||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.QkTextView
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/snackbarTitle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintBottom_toTopOf="@id/message"
|
app:layout_constraintBottom_toTopOf="@id/snackbarMessage"
|
||||||
app:layout_constraintEnd_toStartOf="@id/button"
|
app:layout_constraintEnd_toStartOf="@id/snackbarButton"
|
||||||
app:layout_constraintHorizontal_bias="0"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:textSize="primary"
|
app:textSize="primary"
|
||||||
tools:text="Love texting again" />
|
tools:text="Love texting again" />
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.QkTextView
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
android:id="@+id/message"
|
android:id="@+id/snackbarMessage"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
@@ -47,14 +47,14 @@
|
|||||||
android:paddingBottom="16dp"
|
android:paddingBottom="16dp"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/button"
|
app:layout_constraintEnd_toStartOf="@id/snackbarButton"
|
||||||
app:layout_constraintHorizontal_bias="0"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:textSize="secondary"
|
app:textSize="secondary"
|
||||||
tools:text="Make QKSMS your default SMS app" />
|
tools:text="Make QKSMS your default SMS app" />
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.QkTextView
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
android:id="@+id/button"
|
android:id="@+id/snackbarButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
@@ -63,11 +63,11 @@
|
|||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:textColor="@color/tools_theme"
|
android:textColor="@color/tools_theme"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/message"
|
app:layout_constraintBottom_toBottomOf="@id/snackbarMessage"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/title"
|
app:layout_constraintTop_toTopOf="@id/snackbarTitle"
|
||||||
app:textColor="theme"
|
app:textColor="theme"
|
||||||
app:textSize="secondary"
|
app:textSize="secondary"
|
||||||
tools:text="Change" />
|
tools:text="Change" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.QkTextView
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
android:id="@+id/label"
|
android:id="@+id/syncingLabel"
|
||||||
style="@style/TextPrimary"
|
style="@style/TextPrimary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress"
|
android:id="@+id/syncingProgress"
|
||||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -107,12 +107,6 @@
|
|||||||
tools:backgroundTint="@color/tools_theme"
|
tools:backgroundTint="@color/tools_theme"
|
||||||
tools:text="@tools:sample/lorem/random" />
|
tools:text="@tools:sample/lorem/random" />
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/cancel"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
tools:ignore="MissingConstraints" />
|
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.QkTextView
|
<com.moez.QKSMS.common.widget.QkTextView
|
||||||
android:id="@+id/status"
|
android:id="@+id/status"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -79,11 +79,6 @@
|
|||||||
tools:itemCount="1"
|
tools:itemCount="1"
|
||||||
tools:listitem="@layout/mms_preview_list_item" />
|
tools:listitem="@layout/mms_preview_list_item" />
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.AvatarView
|
|
||||||
android:id="@+id/avatar"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp" />
|
|
||||||
|
|
||||||
<com.moez.QKSMS.common.widget.TightTextView
|
<com.moez.QKSMS.common.widget.TightTextView
|
||||||
android:id="@+id/body"
|
android:id="@+id/body"
|
||||||
style="@style/TextPrimary"
|
style="@style/TextPrimary"
|
||||||
|
|||||||
@@ -23,9 +23,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<include
|
<include layout="@layout/collapsing_toolbar" />
|
||||||
android:id="@+id/appBarLayout"
|
|
||||||
layout="@layout/collapsing_toolbar" />
|
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -151,9 +151,7 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<include
|
<include layout="@layout/collapsing_toolbar" />
|
||||||
android:id="@+id/appBarLayout"
|
|
||||||
layout="@layout/collapsing_toolbar" />
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -17,13 +17,19 @@
|
|||||||
~ You should have received a copy of the GNU General Public License
|
~ You should have received a copy of the GNU General Public License
|
||||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<View xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/themePreview"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="24dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="24dp"
|
android:paddingStart="8dp"
|
||||||
android:layout_gravity="center"
|
android:paddingEnd="8dp">
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
<View
|
||||||
android:background="@drawable/circle"
|
android:id="@+id/themePreview"
|
||||||
tools:backgroundTint="@color/tools_theme" />
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@drawable/circle"
|
||||||
|
tools:backgroundTint="@color/tools_theme" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
Reference in New Issue
Block a user