forked from upstream-mirrors/quik
Merge branch 'dev' of https://github.com/moezbhatti/qksms into dev
This commit is contained in:
@@ -20,13 +20,12 @@ package common.util.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.support.v4.view.ViewPager
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import io.reactivex.Observable
|
||||
|
||||
fun EditText.showKeyboard() {
|
||||
requestFocus()
|
||||
@@ -39,21 +38,15 @@ fun ImageView.setTint(color: Int) {
|
||||
}
|
||||
|
||||
fun View.setBackgroundTint(color: Int) {
|
||||
|
||||
// API 21 doesn't support this
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)
|
||||
}
|
||||
|
||||
backgroundTintList = ColorStateList.valueOf(color)
|
||||
}
|
||||
|
||||
fun View.setMargins(left: Int? = null, top: Int? = null, right: Int? = null, bottom: Int? = null) {
|
||||
val lp = layoutParams as? ViewGroup.MarginLayoutParams ?: return
|
||||
|
||||
lp.setMargins(
|
||||
left ?: lp.leftMargin,
|
||||
top ?: lp.topMargin,
|
||||
right ?: lp.rightMargin,
|
||||
bottom ?: lp.rightMargin)
|
||||
|
||||
layoutParams = lp
|
||||
}
|
||||
|
||||
fun View.setPadding(left: Int? = null, top: Int? = null, right: Int? = null, bottom: Int? = null) {
|
||||
setPadding(left ?: paddingLeft, top ?: paddingTop, right ?: paddingRight, bottom ?: paddingBottom)
|
||||
}
|
||||
@@ -62,15 +55,3 @@ fun View.setVisible(visible: Boolean, invisible: Int = View.GONE) {
|
||||
visibility = if (visible) View.VISIBLE else invisible
|
||||
}
|
||||
|
||||
data class PageScroll(val position: Int, val offset: Float)
|
||||
|
||||
fun ViewPager.pageScrolled(): Observable<PageScroll> {
|
||||
return Observable.create<PageScroll> { emitter ->
|
||||
addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
|
||||
emitter.onNext(PageScroll(position, positionOffset))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.Navigator
|
||||
import common.util.Colors
|
||||
import common.util.GlideApp
|
||||
import common.util.extensions.setBackgroundTint
|
||||
import common.util.extensions.setTint
|
||||
import injection.appComponent
|
||||
import kotlinx.android.synthetic.main.avatar_view.view.*
|
||||
@@ -90,15 +91,12 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
if (!isInEditMode) {
|
||||
colors.themeForConversation(threadId)
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> background.setTint(color) }
|
||||
.subscribe { color -> setBackgroundTint(color) }
|
||||
|
||||
colors.textPrimaryOnThemeForConversation(threadId).let { observable ->
|
||||
initial.textColorObservable = observable
|
||||
|
||||
observable
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> icon.setTint(color) }
|
||||
}
|
||||
colors.textPrimaryOnThemeForConversation(threadId)
|
||||
.apply { initial.textColorObservable = this }
|
||||
.autoDisposable(scope())
|
||||
.subscribe { color -> icon.setTint(color) }
|
||||
|
||||
clicks()
|
||||
.autoDisposable(scope())
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package feature.compose
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import android.view.LayoutInflater
|
||||
@@ -224,6 +225,14 @@ class MessagesAdapter @Inject constructor(
|
||||
// setClipToOutline doesn't work unless all of the corners have the same radius, so we have
|
||||
// to use the message_only bubble
|
||||
if (hasImages) view.messageBackground.setBackgroundResource(R.drawable.message_only)
|
||||
|
||||
// If we're on API 21, we need to re-tint the background
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
view.messageBackground.setBackgroundTint(when (message.isMe()) {
|
||||
true -> colors.bubble
|
||||
false -> theme
|
||||
}.blockingFirst())
|
||||
}
|
||||
}
|
||||
|
||||
private fun canGroup(message: Message, other: Message?): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user