Squashed commit of the following:

commit 1f890b96beb893c866ed9b47d8e3a9ac6e20662f
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Wed Jan 31 17:41:22 2018 -0500

    Clean up bindView in PlusViewModel

commit c71f4853d385df66a79f9372ecf29507cb64152b
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Wed Jan 31 02:14:37 2018 -0500

    Move QKSMS+ to sliding menu

commit a23d1dd6d314935cd96c530e3419a3a2ca4cab27
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Wed Jan 31 00:28:42 2018 -0500

    Make selected plan more visible

commit 540cda206ede1d3b81d7d42438257f76f9f07cd4
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Wed Jan 31 00:27:03 2018 -0500

    Allow changing dynamic textcolor programatically

commit 859325dd5ffa7aa5958ae2eb5c9eac62bcb8f7bd
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 22:26:41 2018 -0500

    Dark mode support for ripple selected state

commit 6a1d5c387fe0a08ef05573f3f07a1cd82b1a37ec
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 22:18:27 2018 -0500

    Remove explicit upgrade button, click plan to buy

commit 4a6e85b0c513c8604f8993f78add2b3910c0b49d
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 20:43:09 2018 -0500

    Show thank you UI if user has upgraded

commit 080fccf40b4461b6a833ba77fce1267bd8251281
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 17:52:02 2018 -0500

    Allow changing plans

commit ac122f138b1840de39f7a7bd1fb36727056233e1
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Tue Jan 30 16:33:59 2018 -0500

    Allow purchase of subscription

commit 3e689443ec197a929308d9add270ae6777cdeae1
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 23:21:31 2018 -0500

    Allow selection of different plans

commit d51a90160898b39de5ba4e69fdc8351e2fe7093c
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 19:42:56 2018 -0500

    Collapsing toolbar for QKSMS+ activity

commit 06c0d5a834884f144ad7e149b7dea3b0ba38b643
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 18:02:05 2018 -0500

    Display pricing information in QKSMS+ activity

commit c0be51eec5e1b091dbe8ba69f28c48e5379011f3
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 17:26:16 2018 -0500

    Add ability to view QKSMS+ activity from settings

commit 51e7782a274503401d53a22ccbe55eab2523f200
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 15:41:40 2018 -0500

    Indicate currently selected theme

commit 0b3bb3e24b3c40ac517cf05404638061f9b520b8
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 15:19:28 2018 -0500

    Move ThemeAdapter package

commit 828b6fe10afd6493884ee8d1c472dcd39f5371d4
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 15:10:14 2018 -0500

    Evenly space theme swatches with other items and borders

commit 220499c0676f03c282b201dfd67faa10f20a546d
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Mon Jan 29 14:45:47 2018 -0500

    Evenly distribute theme swatches

commit 4d0995da773f720411b22091fc58d03497d38438
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 22:53:49 2018 -0500

    Use separate activity for Theme picker

commit 3886c1890a6320667f9999071213f181e4e2de79
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 20:00:17 2018 -0500

    Update more text

commit 3e3995fdf58ee849f6fedabd895aff42f521e473
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 19:56:04 2018 -0500

    Update text for blocking

commit b8ffbf30761105abe1150279994c8d0ebd7a68b7
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 19:49:11 2018 -0500

    Build layout for QKSMS+ activity

commit 90518ad8291d5028ceb765ca60fe1d36a5edb33a
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 19:48:59 2018 -0500

    Improve layout preview support for some custom views

commit 3b301b641e1b747d0ac7192bb50e51d494fe6ef8
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 02:22:54 2018 -0500

    Use up-to-date material design colors

commit e8c9cec67767c8702f1b6ccf7ee89c22e585132c
Author: Moez Bhatti <moez.bhatti@gmail.com>
Date:   Sun Jan 28 01:21:24 2018 -0500

    Add strings and icons for QKSMS+ features
This commit is contained in:
Moez Bhatti
2018-01-31 21:20:29 -05:00
parent 218b611ae3
commit 317940d4f7
40 changed files with 1443 additions and 172 deletions
@@ -22,46 +22,101 @@ import android.content.Context
import android.support.v7.widget.AppCompatTextView
import android.util.AttributeSet
import com.moez.QKSMS.R
import com.uber.autodispose.android.scope
import com.uber.autodispose.kotlin.autoDisposable
import common.di.appComponent
import common.util.Colors
import common.util.extensions.getColorCompat
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import javax.inject.Inject
open class QkTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null)
: AppCompatTextView(context, attrs) {
companion object {
const val COLOR_PRIMARY = 0
const val COLOR_SECONDARY = 1
const val COLOR_TERTIARY = 2
const val COLOR_PRIMARY_ON_THEME = 3
const val COLOR_SECONDARY_ON_THEME = 4
const val COLOR_TERTIARY_ON_THEME = 5
}
@Inject lateinit var colors: Colors
private var textColorDisposable: Disposable? = null
private var textColorObservable: Observable<Int>? = null
set(value) {
if (field !== value) {
field = value
if (isAttachedToWindow) {
textColorDisposable?.let { disposable ->
if (!disposable.isDisposed) {
disposable.dispose()
}
}
subscribeColorChanges()
}
}
}
init {
appComponent.inject(this)
if (!isInEditMode) {
appComponent.inject(this)
}
context.obtainStyledAttributes(attrs, R.styleable.QkTextView)?.run {
textColorObservable = when (getInt(R.styleable.QkTextView_textColor, -1)) {
0 -> colors.textPrimary
1 -> colors.textSecondary
2 -> colors.textTertiary
3 -> colors.textPrimaryOnTheme
4 -> colors.textSecondaryOnTheme
5 -> colors.textTertiaryOnTheme
else -> null
val colorAttr = getInt(R.styleable.QkTextView_textColor, -1)
if (isInEditMode) {
setTextColor(context.getColorCompat(when (colorAttr) {
COLOR_PRIMARY -> R.color.textPrimary
COLOR_SECONDARY -> R.color.textSecondary
COLOR_TERTIARY -> R.color.textTertiary
COLOR_PRIMARY_ON_THEME -> R.color.textPrimaryDark
COLOR_SECONDARY_ON_THEME -> R.color.textSecondaryDark
COLOR_TERTIARY_ON_THEME -> R.color.textTertiaryDark
else -> R.color.textPrimary
}))
} else {
setColor(colorAttr)
}
recycle()
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
textColorObservable
?.autoDisposable(scope())
fun setColor(colorAttr: Int) {
textColorObservable = when (colorAttr) {
COLOR_PRIMARY -> colors.textPrimary
COLOR_SECONDARY -> colors.textSecondary
COLOR_TERTIARY -> colors.textTertiary
COLOR_PRIMARY_ON_THEME -> colors.textPrimaryOnTheme
COLOR_SECONDARY_ON_THEME -> colors.textSecondaryOnTheme
COLOR_TERTIARY_ON_THEME -> colors.textTertiaryOnTheme
else -> null
}
}
private fun subscribeColorChanges() {
textColorDisposable = textColorObservable
?.subscribe { color ->
setTextColor(color)
setLinkTextColor(color)
}
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
if (textColorDisposable?.isDisposed != false) {
subscribeColorChanges()
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
textColorDisposable?.dispose()
}
}