diff --git a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt index aed75dff9599df375707a375794e37d9fe9dc305..e907f32c2daa88c999e11e3d7b781481fc959580 100644 --- a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt +++ b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt @@ -24,6 +24,7 @@ import android.os.Build import android.provider.Settings import android.util.TypedValue import android.view.ContextThemeWrapper +import androidx.core.content.res.ResourcesCompat import com.f2prateek.rx.preferences2.Preference import com.f2prateek.rx.preferences2.RxSharedPreferences import com.moez.QKSMS.common.util.extensions.versionCode @@ -76,6 +77,7 @@ class Preferences @Inject constructor(private val context: Context, private val val canUseSubId = rxPrefs.getBoolean("canUseSubId", true) val version = rxPrefs.getInteger("version", context.versionCode) val changelogVersion = rxPrefs.getInteger("changelogVersion", context.versionCode) + @Deprecated("This should only be accessed when migrating to @blockingManager") val sia = rxPrefs.getBoolean("sia", false) @@ -121,26 +123,6 @@ class Preferences @Inject constructor(private val context: Context, private val } } - fun systemColor(): Int { - val typedValue = TypedValue() - val contextThemeWrapper = ContextThemeWrapper(context, - R.style.Theme_DeviceDefault) - contextThemeWrapper.theme.resolveAttribute(android.R.attr.colorAccent, - typedValue, true) - - return typedValue.data - } - - fun theme( - recipientId: Long = 0, - default: Int = rxPrefs.getInteger("theme", 0xFF7bb6ff.toInt()).get() - ): Preference { - return when (recipientId) { - 0L -> rxPrefs.getInteger("theme", systemColor()) -// 0L -> rxPrefs.getInteger("theme", 0xFF0097A7.toInt()) - else -> rxPrefs.getInteger("theme_$recipientId", default) - } - } fun notifications(threadId: Long = 0): Preference { val default = rxPrefs.getBoolean("notifications", true) diff --git a/e-ui-sdk.jar b/e-ui-sdk.jar new file mode 100644 index 0000000000000000000000000000000000000000..222953d20421211ecc08ca2e2f16e735263d2f58 Binary files /dev/null and b/e-ui-sdk.jar differ diff --git a/presentation/build.gradle b/presentation/build.gradle index ccd4f721c65dc94c6fbed3e6956e58a1160fcaee..de7cb762b133cc3e5b94bc1ad9dc67b4a08005dd 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -36,9 +36,15 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - /* signingConfigs { - release - }*/ + + aaptOptions { + additionalParameters '-I', 'e-ui-sdk.jar' + } + + + /* signingConfigs { + release + }*/ buildTypes { release { @@ -47,6 +53,11 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' //signingConfig signingConfigs.release } + + debug{ + applicationIdSuffix ".debug" + } + } compileOptions { @@ -95,7 +106,11 @@ configurations { withAnalyticsRelease } + + dependencies { + // e-ui sdk + compileOnly files("../e-ui-sdk.jar") // lifecycle implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" diff --git a/presentation/src/main/java/com/moez/QKSMS/common/MenuItemAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/common/MenuItemAdapter.kt index bc506cd802c61744a6de2f3363ee4218b426c037..61a1b2fa88b8ce38a8ad10825c60ce2ac44bcef3 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/MenuItemAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/MenuItemAdapter.kt @@ -71,7 +71,7 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private intArrayOf(-android.R.attr.state_activated)) val text = parent.context.resolveThemeColor(android.R.attr.textColorTertiary) - view.check.imageTintList = ColorStateList(states, intArrayOf(colors.theme().theme, text)) + view.check.imageTintList = ColorStateList(states, intArrayOf(context.getColor(R.color.tools_theme), text)) return QkViewHolder(view).apply { view.setOnClickListener { diff --git a/presentation/src/main/java/com/moez/QKSMS/common/QKApplication.kt b/presentation/src/main/java/com/moez/QKSMS/common/QKApplication.kt index bd5eec858de77d3938b767ebf31c5e00a17224cb..4ecd2caaf95e9b15625a33263555679d3f9467e6 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/QKApplication.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/QKApplication.kt @@ -29,6 +29,7 @@ import com.moez.QKSMS.R import com.moez.QKSMS.common.util.CrashlyticsTree import com.moez.QKSMS.common.util.FileLoggingTree import com.moez.QKSMS.injection.AppComponentManager +import com.moez.QKSMS.injection.AppModule_ProvideRxPreferencesFactory import com.moez.QKSMS.injection.appComponent import com.moez.QKSMS.manager.AnalyticsManager import com.moez.QKSMS.migration.QkMigration @@ -52,16 +53,24 @@ class QKApplication : Application(), HasActivityInjector, HasBroadcastReceiverIn * Inject these so that they are forced to initialize */ @Suppress("unused") - @Inject lateinit var analyticsManager: AnalyticsManager + @Inject + lateinit var analyticsManager: AnalyticsManager + @Suppress("unused") - @Inject lateinit var qkMigration: QkMigration + @Inject + lateinit var qkMigration: QkMigration + + @Inject + lateinit var dispatchingActivityInjector: DispatchingAndroidInjector + @Inject + lateinit var dispatchingBroadcastReceiverInjector: DispatchingAndroidInjector + @Inject + lateinit var dispatchingServiceInjector: DispatchingAndroidInjector - @Inject lateinit var dispatchingActivityInjector: DispatchingAndroidInjector - @Inject lateinit var dispatchingBroadcastReceiverInjector: DispatchingAndroidInjector - @Inject lateinit var dispatchingServiceInjector: DispatchingAndroidInjector @Inject lateinit var fileLoggingTree: FileLoggingTree - @Inject lateinit var nightModeManager: NightModeManager + @Inject + lateinit var nightModeManager: NightModeManager override fun onCreate() { super.onCreate() diff --git a/presentation/src/main/java/com/moez/QKSMS/common/base/QkThemedActivity.kt b/presentation/src/main/java/com/moez/QKSMS/common/base/QkThemedActivity.kt index 5e69ea374dc804ce1e31a08dff13cd38651e4cc7..d2843e820b998c79d6062d2d5502a70c845763b8 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/base/QkThemedActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/base/QkThemedActivity.kt @@ -50,8 +50,10 @@ import javax.inject.Inject */ abstract class QkThemedActivity : QkActivity() { - @Inject lateinit var colors: Colors - @Inject lateinit var prefs: Preferences + @Inject + lateinit var colors: Colors + @Inject + lateinit var prefs: Preferences /** * In case the activity should be themed for a specific conversation, the selected conversation @@ -59,13 +61,6 @@ abstract class QkThemedActivity : QkActivity() { */ val threadId: Subject = BehaviorSubject.createDefault(0) - /** - * Switch the theme if the threadId changes - */ - val theme = threadId - .distinctUntilChanged() - .switchMap { threadId -> colors.themeObservable(threadId) } - @SuppressLint("InlinedApi") override fun onCreate(savedInstanceState: Bundle?) { setTheme(getActivityThemeRes(prefs.black.get())) @@ -104,18 +99,6 @@ abstract class QkThemedActivity : QkActivity() { // Set the color for the overflow and navigation icon val textSecondary = resolveThemeColor(android.R.attr.textColorSecondary) toolbar?.overflowIcon = toolbar?.overflowIcon?.apply { setTint(textSecondary) } - - // Update the colours of the menu items - Observables.combineLatest(menu, theme) { menu, theme -> - menu.iterator().forEach { menuItem -> - val tint = when (menuItem.itemId) { - in getColoredMenuItems() -> prefs.systemColor() - else -> textSecondary - } - - menuItem.icon = menuItem.icon?.apply { setTint(tint) } - } - }.autoDisposable(scope(Lifecycle.Event.ON_DESTROY)).subscribe() } open fun getColoredMenuItems(): List { diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/Colors.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/Colors.kt index fd0d9f1b4818db78072a8e17bb5f0d38ee9a9db7..eda797829acd8cee75a6b071ca304e2a91fe043a 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/Colors.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/util/Colors.kt @@ -30,11 +30,15 @@ import javax.inject.Singleton @Singleton class Colors @Inject constructor(private val context: Context, private val prefs: Preferences) { + /* init { + prefs.setSystemColor(R.color.tools_theme) + }*/ + data class Theme(val theme: Int, private val colors: Colors) { - val highlight by lazy { colors.highlightColorForTheme(theme) } - val textPrimary by lazy { colors.textPrimaryOnThemeForColor(theme) } - val textSecondary by lazy { colors.textSecondaryOnThemeForColor(theme) } - val textTertiary by lazy { colors.textTertiaryOnThemeForColor(theme) } + val highlight by lazy { colors.highlightColorForTheme(R.color.tools_theme) } + val textPrimary by lazy { colors.textPrimaryOnThemeForColor(R.color.textPrimary) } + val textSecondary by lazy { colors.textSecondaryOnThemeForColor(R.color.textSecondary) } + val textTertiary by lazy { colors.textTertiaryOnThemeForColor(R.color.textTertiary) } } val materialColors = listOf( @@ -66,13 +70,6 @@ class Colors @Inject constructor(private val context: Context, private val prefs private val secondaryTextLuminance = measureLuminance(context.getColorCompat(R.color.textSecondaryDark)) private val tertiaryTextLuminance = measureLuminance(context.getColorCompat(R.color.textTertiaryDark)) - fun theme(threadId: Long = 0): Theme = Theme(prefs.theme(threadId).get(), this) - - fun themeObservable(threadId: Long = 0): Observable { - return prefs.theme(threadId).asObservable() - .map { color -> Theme(color, this) } - } - fun highlightColorForTheme(theme: Int): Int = FloatArray(3) .apply { Color.colorToHSV(theme, this) } .let { hsv -> hsv.apply { set(2, 0.75f) } } // 75% value diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt index 487b358afdcb6d7a92311c1011ec5b2b1fe6a6a4..3055d8d715284bbf3a91efe76ede2b6be564e4e2 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/util/NotificationManagerImpl.kt @@ -126,7 +126,7 @@ class NotificationManagerImpl @Inject constructor( val notification = NotificationCompat.Builder(context, getChannelIdForNotification(threadId)) .setCategory(NotificationCompat.CATEGORY_MESSAGE) - .setColor(colors.theme(threadId).theme) + .setColor(context.getColor(R.color.tools_theme)) .setPriority(NotificationCompat.PRIORITY_MAX) .setSmallIcon(R.drawable.ic_notification) .setNumber(messages.size) @@ -295,7 +295,7 @@ class NotificationManagerImpl @Inject constructor( val notification = NotificationCompat.Builder(context, getChannelIdForNotification(threadId)) .setContentTitle(context.getString(R.string.notification_message_failed_title)) .setContentText(context.getString(R.string.notification_message_failed_text, conversation.getTitle())) - .setColor(colors.theme(threadId).theme) + .setColor(context.getColor(R.color.tools_theme)) .setPriority(NotificationManagerCompat.IMPORTANCE_MAX) .setSmallIcon(R.drawable.ic_notification_failed) .setAutoCancel(true) @@ -408,7 +408,7 @@ class NotificationManagerImpl @Inject constructor( .setShowWhen(false) .setWhen(System.currentTimeMillis()) // Set this anyway in case it's shown .setSmallIcon(R.drawable.ic_file_download_black_24dp) - .setColor(colors.theme().theme) + .setColor(context.getColor(R.color.tools_theme)) .setCategory(NotificationCompat.CATEGORY_PROGRESS) .setPriority(NotificationCompat.PRIORITY_MIN) .setProgress(0, 0, true) diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/TextViewStyler.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/TextViewStyler.kt index ccfd1f99da0f07fa256abbfe81d20edcf6d05958..fdc09f4a9dd84c2e49123a426e92263125bbddae 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/TextViewStyler.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/util/TextViewStyler.kt @@ -23,6 +23,7 @@ import android.os.Build import android.util.AttributeSet import android.widget.EditText import android.widget.TextView +import androidx.core.content.ContextCompat.getColor import com.moez.QKSMS.R import com.moez.QKSMS.common.util.TextViewStyler.Companion.SIZE_PRIMARY import com.moez.QKSMS.common.util.TextViewStyler.Companion.SIZE_SECONDARY @@ -35,11 +36,10 @@ import com.moez.QKSMS.util.Preferences import javax.inject.Inject - class TextViewStyler @Inject constructor( - private val prefs: Preferences, - private val colors: Colors, - private val fontProvider: FontProvider + private val prefs: Preferences, + private val colors: Colors, + private val fontProvider: FontProvider ) { companion object { @@ -123,16 +123,16 @@ class TextViewStyler @Inject constructor( } when (colorAttr) { - COLOR_THEME -> textView.setTextColor(colors.theme().theme) - COLOR_PRIMARY_ON_THEME -> textView.setTextColor(colors.theme().textPrimary) - COLOR_SECONDARY_ON_THEME -> textView.setTextColor(colors.theme().textSecondary) - COLOR_TERTIARY_ON_THEME -> textView.setTextColor(colors.theme().textTertiary) + COLOR_THEME -> textView.setTextColor(getColor(textView.context, R.color.tools_theme)) + COLOR_PRIMARY_ON_THEME -> textView.setTextColor(getColor(textView.context, R.color.textPrimary)) + COLOR_SECONDARY_ON_THEME -> textView.setTextColor(getColor(textView.context, R.color.textSecondary)) + COLOR_TERTIARY_ON_THEME -> textView.setTextColor(getColor(textView.context, R.color.textTertiary)) } setTextSize(textView, textSizeAttr) if (textView is EditText) { - val drawable = textView.resources.getDrawable(R.drawable.cursor).apply { setTint(colors.theme().theme) } + val drawable = textView.resources.getDrawable(R.drawable.cursor).apply { setTint(R.color.tools_theme) } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { textView.textCursorDrawable = drawable } diff --git a/presentation/src/main/java/com/moez/QKSMS/common/widget/AvatarView.kt b/presentation/src/main/java/com/moez/QKSMS/common/widget/AvatarView.kt index 1d6b4d899b2212269bbaa32843e054366f463f41..800ff43b85e9222a951e45d6477979e8c4e48dc7 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/widget/AvatarView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/widget/AvatarView.kt @@ -44,7 +44,6 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet @Inject lateinit var navigator: Navigator @Inject lateinit var prefs: Preferences - /** * This value can be changes if we should use the theme from a particular conversation */ @@ -112,15 +111,14 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet } fun applyTheme(threadId: Long) { - colors.theme(threadId).run { - setBackgroundTint(theme) - initial.setTextColor(textPrimary) - icon.setTint(textPrimary) - } + setBackgroundTint(context.getColor(R.color.tools_theme)) + initial.setTextColor(context.getColor(R.color.white)) + icon.setTint(context.getColor(R.color.white)) + } private fun updateView() { - setBackgroundTint(prefs.systemColor()) + setBackgroundTint(context.getColor(R.color.tools_theme)) if (name?.isNotEmpty() == true) { initial.text = name?.substring(0, 1) icon.visibility = GONE diff --git a/presentation/src/main/java/com/moez/QKSMS/common/widget/PagerTitleView.kt b/presentation/src/main/java/com/moez/QKSMS/common/widget/PagerTitleView.kt index 3f2ff65feb7e3b7860c5625a04832e49da410646..133cc7e00e58868264a47c0beb066e3794f93fc3 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/widget/PagerTitleView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/widget/PagerTitleView.kt @@ -90,19 +90,10 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut intArrayOf(android.R.attr.state_activated), intArrayOf(-android.R.attr.state_activated)) - threadId - .distinctUntilChanged() - .switchMap { threadId -> colors.themeObservable(threadId) } - .map { theme -> - val textSecondary = context.resolveThemeColor(android.R.attr.textColorSecondary) - ColorStateList(states, intArrayOf(theme.theme, textSecondary)) - } - .autoDisposable(ViewScopeProvider.from(this)) - .subscribe { colorStateList -> - childCount.forEach { index -> - (getChildAt(index) as? TextView)?.setTextColor(colorStateList) - } - } + val textSecondary = context.resolveThemeColor(android.R.attr.textColorSecondary) + childCount.forEach { index -> + (getChildAt(index) as? TextView)?.setTextColor(ColorStateList(states, intArrayOf(R.color.tools_theme, textSecondary))) + } } } diff --git a/presentation/src/main/java/com/moez/QKSMS/common/widget/PreferenceView.kt b/presentation/src/main/java/com/moez/QKSMS/common/widget/PreferenceView.kt index d661dd363109fda8e1c285e3ff10800dd8e0b6c6..c52e87412a59d9fa73b04101c63d8b276b0baf42 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/widget/PreferenceView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/widget/PreferenceView.kt @@ -29,6 +29,7 @@ import androidx.appcompat.widget.LinearLayoutCompat import com.moez.QKSMS.R import com.moez.QKSMS.common.util.extensions.resolveThemeAttribute import com.moez.QKSMS.common.util.extensions.resolveThemeColorStateList +import com.moez.QKSMS.common.util.extensions.setTint import com.moez.QKSMS.common.util.extensions.setVisible import com.moez.QKSMS.injection.appComponent import com.moez.QKSMS.util.Preferences @@ -36,7 +37,7 @@ import kotlinx.android.synthetic.main.preference_view.view.* import javax.inject.Inject class PreferenceView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, attrs: AttributeSet? = null ) : LinearLayoutCompat(context, attrs) { @Inject lateinit var prefs: Preferences @@ -79,7 +80,7 @@ class PreferenceView @JvmOverloads constructor( orientation = HORIZONTAL gravity = Gravity.CENTER_VERTICAL - icon.setColorFilter(prefs.systemColor()) + icon.setColorFilter(context.getColor(R.color.tools_theme)) context.obtainStyledAttributes(attrs, R.styleable.PreferenceView).run { title = getString(R.styleable.PreferenceView_title) @@ -94,6 +95,7 @@ class PreferenceView @JvmOverloads constructor( getResourceId(R.styleable.PreferenceView_icon, -1).takeIf { it != -1 }?.let { id -> icon.setVisible(true) icon.setImageResource(id) + icon.setTint(context.getColor(R.color.tools_theme)) } recycle() diff --git a/presentation/src/main/java/com/moez/QKSMS/common/widget/QkSwitch.kt b/presentation/src/main/java/com/moez/QKSMS/common/widget/QkSwitch.kt index 500377d84177e754815dfca68108a197d266a419..721319c120e4808f0b4a8073a5199d26673b82b8 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/widget/QkSwitch.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/widget/QkSwitch.kt @@ -32,8 +32,11 @@ import javax.inject.Inject class QkSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : SwitchCompat(context, attrs) { - @Inject lateinit var colors: Colors - @Inject lateinit var prefs: Preferences + @Inject + lateinit var colors: Colors + + @Inject + lateinit var prefs: Preferences init { if (!isInEditMode) { @@ -52,12 +55,12 @@ class QkSwitch @JvmOverloads constructor(context: Context, attrs: AttributeSet? thumbTintList = ColorStateList(states, intArrayOf( context.resolveThemeColor(R.attr.switchThumbDisabled), - colors.theme().theme, + context.getColor(R.color.tools_theme), context.resolveThemeColor(R.attr.switchThumbEnabled))) trackTintList = ColorStateList(states, intArrayOf( context.resolveThemeColor(R.attr.switchTrackDisabled), - colors.theme().theme.withAlpha(0x4D), + context.getColor(R.color.tools_theme).withAlpha(0x4D), context.resolveThemeColor(R.attr.switchTrackEnabled))) } } diff --git a/presentation/src/main/java/com/moez/QKSMS/common/widget/RadioPreferenceView.kt b/presentation/src/main/java/com/moez/QKSMS/common/widget/RadioPreferenceView.kt index 9f129c1af7cfb81e91f419b6fe7a634ffccb8fd0..b98ad0904ca8eef10398c5f0fbe815042fc4ecf0 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/widget/RadioPreferenceView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/widget/RadioPreferenceView.kt @@ -81,7 +81,7 @@ class RadioPreferenceView @JvmOverloads constructor( val themeColor = when (isInEditMode) { true -> context.resources.getColor(R.color.tools_theme) - false -> colors.theme().theme + false -> R.color.tools_theme } val textSecondary = context.resolveThemeColor(android.R.attr.textColorTertiary) radioButton.buttonTintList = ColorStateList(states, intArrayOf(themeColor, textSecondary)) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupController.kt index b773c387576d010f538b72ffbd1c789ec4f42217..4aa285b61f7fb09b3f3a170843bc78d3d35772f4 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupController.kt @@ -49,9 +49,14 @@ import javax.inject.Inject class BackupController : QkController(), BackupView { - @Inject lateinit var adapter: BackupAdapter - @Inject lateinit var dateFormatter: DateFormatter - @Inject override lateinit var presenter: BackupPresenter + @Inject + lateinit var adapter: BackupAdapter + + @Inject + lateinit var dateFormatter: DateFormatter + + @Inject + override lateinit var presenter: BackupPresenter private val activityVisibleSubject: Subject = PublishSubject.create() private val confirmRestoreSubject: Subject = PublishSubject.create() @@ -100,13 +105,12 @@ class BackupController : QkController( override fun onViewCreated() { super.onViewCreated() - themedActivity?.colors?.theme()?.let { theme -> - progressBar.indeterminateTintList = ColorStateList.valueOf(theme.theme) - progressBar.progressTintList = ColorStateList.valueOf(theme.theme) - fab.setBackgroundTint(theme.theme) - fabIcon.setTint(theme.textPrimary) - fabLabel.setTextColor(theme.textPrimary) - } + progressBar.indeterminateTintList = ColorStateList.valueOf(progressBar.context.getColor(R.color.tools_theme)) + progressBar.progressTintList = ColorStateList.valueOf(progressBar.context.getColor(R.color.tools_theme)) + fab.setBackgroundTint(fab.context.getColor(R.color.tools_theme)) + fabIcon.setTint(fabIcon.context.getColor(R.color.white)) + fabLabel.setTextColor(fabIcon.context.getColor(R.color.textPrimary)) + // Make the list titles bold linearLayout.children diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt index 8b0927ecac3b11669ae2415dd3f5584b797dafc3..90c18fcaf2fdf4a3dc83135d7ba675776d9875cc 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/blocking/numbers/BlockedNumbersController.kt @@ -61,8 +61,8 @@ class BlockedNumbersController : QkController = PublishSubject.create() override val queryChangedIntent: Observable by lazy { chipsAdapter.textChanges } @@ -111,7 +118,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView { override val inputContentIntent by lazy { message.inputContentSelected } override val scheduleSelectedIntent: Subject = PublishSubject.create() override val changeSimIntent by lazy { sim.clicks() } - override val selectPreferredSIM by lazy { viewSelectPreferredSim.clicks()} + override val selectPreferredSIM by lazy { viewSelectPreferredSim.clicks() } override val scheduleCancelIntent by lazy { scheduledCancel.clicks() } override val sendIntent by lazy { send.clicks() } override val viewQksmsPlusIntent: Subject = PublishSubject.create() @@ -148,12 +155,9 @@ class ComposeActivity : QkThemedActivity(), ComposeView { message.supportsInputContent = true - theme - .doOnNext { loading.setTint(prefs.systemColor()) } - .doOnNext { attach.setBackgroundTint(prefs.systemColor()) } - .doOnNext { send.setTint(prefs.systemColor()) } - .autoDisposable(scope()) - .subscribe { messageList.scrapViews() } + loading.setTint(getColor(R.color.tools_theme)) + attach.setBackgroundTint(getColor(R.color.tools_theme)) + send.setTint(getColor(R.color.tools_theme)) window.callback = ComposeWindowCallback(window.callback, this) @@ -163,6 +167,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView { composeBackground.setBackgroundTint(resolveThemeColor(R.attr.composeBackground)) } } + override fun onResume() { super.onResume() @@ -341,7 +346,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView { override fun showQksmsPlusSnackbar(message: Int) { Snackbar.make(contentView, message, Snackbar.LENGTH_LONG).run { setAction(R.string.button_more) { viewQksmsPlusIntent.onNext(Unit) } - setActionTextColor(colors.theme().theme) + setActionTextColor(getColor(R.color.tools_theme)) show() } } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/DetailedChipView.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/DetailedChipView.kt index 5bcca0daee61936ff32a7126efa628de96122894..13ccdb9d58c4cee9d67498c2cd2d33dc70523a2e 100755 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/DetailedChipView.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/DetailedChipView.kt @@ -34,7 +34,8 @@ import javax.inject.Inject class DetailedChipView(context: Context) : RelativeLayout(context) { - @Inject lateinit var colors: Colors + @Inject + lateinit var colors: Colors init { View.inflate(context, R.layout.contact_chip_detailed, this) @@ -47,12 +48,11 @@ class DetailedChipView(context: Context) : RelativeLayout(context) { isFocusable = true isFocusableInTouchMode = true - colors.theme().let { theme -> - card.setBackgroundTint(theme.theme) - name.setTextColor(theme.textPrimary) - info.setTextColor(theme.textTertiary) - delete.setTint(theme.textPrimary) - } + card.setBackgroundTint(context.getColor(R.color.tools_theme)) + name.setTextColor(context.getColor(R.color.textPrimary)) + info.setTextColor(context.getColor(R.color.textTertiary)) + delete.setTint(context.getColor(R.color.textPrimary)) + } fun setContact(contact: Contact) { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt index 8e0beb6b823878c3d7815cae9a1cc65b0deafdd8..db5779e072725ca7f7acd8d63635f4309dec6a95 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt @@ -69,14 +69,14 @@ import javax.inject.Inject import javax.inject.Provider class MessagesAdapter @Inject constructor( - subscriptionManager: SubscriptionManagerCompat, - private val context: Context, - private val colors: Colors, - private val dateFormatter: DateFormatter, - private val partsAdapterProvider: Provider, - private val phoneNumberUtils: PhoneNumberUtils, - private val prefs: Preferences, - private val textViewStyler: TextViewStyler + subscriptionManager: SubscriptionManagerCompat, + private val context: Context, + private val colors: Colors, + private val dateFormatter: DateFormatter, + private val partsAdapterProvider: Provider, + private val phoneNumberUtils: PhoneNumberUtils, + private val prefs: Preferences, + private val textViewStyler: TextViewStyler ) : QkRealmAdapter() { companion object { @@ -101,9 +101,6 @@ class MessagesAdapter @Inject constructor( field = value contactCache.clear() - // Update the theme - theme = colors.theme(value?.first?.id ?: 0) - updateData(value?.second) } @@ -129,8 +126,6 @@ class MessagesAdapter @Inject constructor( private val partsViewPool = RecyclerView.RecycledViewPool() private val subs = subscriptionManager.activeSubscriptionInfoList - var theme: Colors.Theme = colors.theme() - /** * If the viewType is negative, then the viewHolder has an attachment. We'll consider * this a unique viewType even though it uses the same view, so that regular messages @@ -144,13 +139,13 @@ class MessagesAdapter @Inject constructor( if (viewType == VIEW_TYPE_MESSAGE_OUT) { view = layoutInflater.inflate(R.layout.message_list_item_out, parent, false) - view.findViewById(R.id.cancelIcon).setTint(theme.theme) - view.findViewById(R.id.cancel).setTint(theme.theme) + view.findViewById(R.id.cancelIcon).setTint(context.getColor(R.color.tools_theme)) + view.findViewById(R.id.cancel).setTint(context.getColor(R.color.tools_theme)) } else { view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false) view.avatar.threadId = conversation?.id ?: 0 - view.body.setTextColor(theme.textPrimary) - view.body.setBackgroundTint(theme.theme) + view.body.setTextColor(context.getColor(R.color.white)) + view.body.setBackgroundTint(context.getColor(R.color.tools_theme)) } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -219,8 +214,10 @@ class MessagesAdapter @Inject constructor( bindStatus(viewHolder, message, next) // Bind the timestamp - val timeSincePrevious = TimeUnit.MILLISECONDS.toMinutes(message.date - (previous?.date ?: 0)) - val simIndex = subs.takeIf { it.size > 1 }?.indexOfFirst { it.subscriptionId == message.subId } ?: -1 + val timeSincePrevious = TimeUnit.MILLISECONDS.toMinutes(message.date - (previous?.date + ?: 0)) + val simIndex = subs.takeIf { it.size > 1 }?.indexOfFirst { it.subscriptionId == message.subId } + ?: -1 view.timestamp.text = dateFormatter.getMessageTimestamp(message.date) view.simIndex.text = "${simIndex + 1}" @@ -239,9 +236,9 @@ class MessagesAdapter @Inject constructor( view.avatar.threadId = conversation?.id ?: 0 view.avatar.setContact(contactCache[message.address]) view.avatar.setVisible(!canGroup(message, next), View.INVISIBLE) - view.avatar.setBackgroundTint(prefs.systemColor()) - view.body.setTextColor(theme.textPrimary) - view.body.setBackgroundTint(prefs.systemColor()) + view.avatar.setBackgroundTint(context.getColor(R.color.tools_theme)) + view.body.setTextColor(context.getColor(R.color.white)) + view.body.setBackgroundTint(context.getColor(R.color.tools_theme)) } // Bind the body text @@ -282,7 +279,6 @@ class MessagesAdapter @Inject constructor( // Bind the attachments val partsAdapter = view.attachments.adapter as PartsAdapter - partsAdapter.theme = theme partsAdapter.setData(message, previous, next, view) } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/FileBinder.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/FileBinder.kt index 73d9ab8362909423e4718839fc24d29a482a1916..20c9d65f7ae577831ede34eda9070a82cf443a7f 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/FileBinder.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/FileBinder.kt @@ -40,18 +40,17 @@ import javax.inject.Inject class FileBinder @Inject constructor(colors: Colors, private val context: Context) : PartBinder() { override val partLayout = R.layout.mms_file_list_item - override var theme = colors.theme() // This is the last binder we check. If we're here, we can bind the part override fun canBindPart(part: MmsPart) = true @SuppressLint("CheckResult") override fun bindPart( - view: View, - part: MmsPart, - message: Message, - canGroupWithPrevious: Boolean, - canGroupWithNext: Boolean + view: View, + part: MmsPart, + message: Message, + canGroupWithPrevious: Boolean, + canGroupWithNext: Boolean ) { BubbleUtils.getBubble(false, canGroupWithPrevious, canGroupWithNext, message.isMe()) .let(view.fileBackground::setBackgroundResource) @@ -78,10 +77,10 @@ class FileBinder @Inject constructor(colors: Colors, private val context: Contex val params = view.fileBackground.layoutParams as FrameLayout.LayoutParams if (!message.isMe()) { view.fileBackground.layoutParams = params.apply { gravity = Gravity.START } - view.fileBackground.setBackgroundTint(theme.theme) - view.icon.setTint(theme.textPrimary) - view.filename.setTextColor(theme.textPrimary) - view.size.setTextColor(theme.textTertiary) + view.fileBackground.setBackgroundTint(context.getColor(R.color.tools_theme)) + view.icon.setTint(context.getColor(R.color.white)) + view.filename.setTextColor(context.getColor(R.color.textPrimary)) + view.size.setTextColor(context.getColor(R.color.textPrimary)) } else { view.fileBackground.layoutParams = params.apply { gravity = Gravity.END } view.fileBackground.setBackgroundTint(view.context.resolveThemeColor(R.attr.bubbleColor)) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/MediaBinder.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/MediaBinder.kt index dafece1c6225f4d8e2c33694a54e80d4fdf5bc68..99d3dbbff818b5e7a5a21846f9ee4432e8869ab6 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/MediaBinder.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/MediaBinder.kt @@ -35,7 +35,6 @@ import javax.inject.Inject class MediaBinder @Inject constructor(colors: Colors, private val context: Context) : PartBinder() { override val partLayout = R.layout.mms_preview_list_item - override var theme = colors.theme() override fun canBindPart(part: MmsPart) = part.isImage() || part.isVideo() diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartBinder.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartBinder.kt index fc3fb7fc4733fbefd73f9b6b19cacb5e05d6fd43..eaa9d11c098377c3752cf44018cdac9d52b5b7f5 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartBinder.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartBinder.kt @@ -31,7 +31,6 @@ abstract class PartBinder { abstract val partLayout: Int - abstract var theme: Colors.Theme abstract fun canBindPart(part: MmsPart): Boolean diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartsAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartsAdapter.kt index 31c67aee5bdd8e760c84a0b26a24d442ab84f1b3..17918d74941b7258205a7b8b001c3dd382378a51 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartsAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/PartsAdapter.kt @@ -43,12 +43,6 @@ class PartsAdapter @Inject constructor( private val partBinders = listOf(mediaBinder, vCardBinder, fileBinder) - var theme: Colors.Theme = colors.theme() - set(value) { - field = value - partBinders.forEach { binder -> binder.theme = value } - } - val clicks: Observable = Observable.merge(partBinders.map { it.clicks }) private lateinit var message: Message diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/VCardBinder.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/VCardBinder.kt index 294f23c79dd16d2447ac4546810a0c34e84a4e57..32aa099b86af02b27f477b23f40b27bcf4fd5644 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/VCardBinder.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/part/VCardBinder.kt @@ -43,16 +43,15 @@ import javax.inject.Inject class VCardBinder @Inject constructor(colors: Colors, private val context: Context) : PartBinder() { override val partLayout = R.layout.mms_vcard_list_item - override var theme = colors.theme() override fun canBindPart(part: MmsPart) = part.isVCard() override fun bindPart( - view: View, - part: MmsPart, - message: Message, - canGroupWithPrevious: Boolean, - canGroupWithNext: Boolean + view: View, + part: MmsPart, + message: Message, + canGroupWithPrevious: Boolean, + canGroupWithNext: Boolean ) { BubbleUtils.getBubble(false, canGroupWithPrevious, canGroupWithNext, message.isMe()) .let(view.vCardBackground::setBackgroundResource) @@ -64,15 +63,15 @@ class VCardBinder @Inject constructor(colors: Colors, private val context: Conte .mapNotNull { inputStream -> inputStream.use { Ezvcard.parse(it).first() } } .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe( { vcard -> view.name?.text = vcard.formattedName.value }, { throwable -> Log.i("VCardBinder.kt", "Name field is null") } ) + .subscribe({ vcard -> view.name?.text = vcard.formattedName.value }, { throwable -> Log.i("VCardBinder.kt", "Name field is null") }) val params = view.vCardBackground.layoutParams as FrameLayout.LayoutParams if (!message.isMe()) { view.vCardBackground.layoutParams = params.apply { gravity = Gravity.START } - view.vCardBackground.setBackgroundTint(theme.theme) - view.vCardAvatar.setTint(theme.textPrimary) - view.name.setTextColor(theme.textPrimary) - view.label.setTextColor(theme.textTertiary) + view.vCardBackground.setBackgroundTint(context.getColor(R.color.tools_theme)) + view.vCardAvatar.setTint(context.getColor(R.color.textPrimary)) + view.name.setTextColor(context.getColor(R.color.textPrimary)) + view.label.setTextColor(context.getColor(R.color.textPrimary)) } else { view.vCardBackground.layoutParams = params.apply { gravity = Gravity.END } view.vCardBackground.setBackgroundTint(view.context.resolveThemeColor(R.attr.bubbleColor)) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationInfoController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationInfoController.kt index 2967ab6ea6ef98bc5968f7dfaf26ba185b80d42f..acb18950e00ae906b71f215f6fb2099daedc2a31 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationInfoController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/conversationinfo/ConversationInfoController.kt @@ -42,15 +42,21 @@ import kotlinx.android.synthetic.main.conversation_info_controller.* import javax.inject.Inject class ConversationInfoController( - val threadId: Long = 0 + val threadId: Long = 0 ) : QkController(), ConversationInfoView { - @Inject override lateinit var presenter: ConversationInfoPresenter - @Inject lateinit var blockingDialog: BlockingDialog - @Inject lateinit var navigator: Navigator - @Inject lateinit var recipientAdapter: ConversationRecipientAdapter - @Inject lateinit var mediaAdapter: ConversationMediaAdapter - @Inject lateinit var itemDecoration: GridSpacingItemDecoration + @Inject + override lateinit var presenter: ConversationInfoPresenter + @Inject + lateinit var blockingDialog: BlockingDialog + @Inject + lateinit var navigator: Navigator + @Inject + lateinit var recipientAdapter: ConversationRecipientAdapter + @Inject + lateinit var mediaAdapter: ConversationMediaAdapter + @Inject + lateinit var itemDecoration: GridSpacingItemDecoration private val nameDialog: FieldDialog by lazy { FieldDialog(activity!!, activity!!.getString(R.string.info_name), nameChangeSubject::onNext) @@ -76,11 +82,7 @@ class ConversationInfoController( media.adapter = mediaAdapter media.addItemDecoration(itemDecoration) - - themedActivity - ?.theme - ?.autoDisposable(scope()) - ?.subscribe { recipients?.scrapViews() } + recipients?.scrapViews() } override fun onAttach(view: View) { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationItemTouchCallback.kt b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationItemTouchCallback.kt index 7b834c3c8643cbcab1f800ddfd9341e0008abca4..9cc133f742fa3bb681b4d97d373d092bddc556f1 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationItemTouchCallback.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationItemTouchCallback.kt @@ -63,18 +63,14 @@ class ConversationItemTouchCallback @Inject constructor( private val iconLength = 24.dpToPx(context) init { - disposables += colors.themeObservable() - .doOnNext { theme -> backgroundPaint.color = theme.theme } - .subscribeOn(Schedulers.io()) - .subscribe() disposables += Observables - .combineLatest(prefs.swipeRight.asObservable(), prefs.swipeLeft.asObservable(), colors.themeObservable() - ) { right, left, theme -> + .combineLatest(prefs.swipeRight.asObservable(), prefs.swipeLeft.asObservable() + ) { right, left -> rightAction = right - swipeRightIcon = iconForAction(right, theme.textPrimary) + swipeRightIcon = iconForAction(right, context.getColor(R.color.textPrimary)) leftAction = left - swipeLeftIcon = iconForAction(left, theme.textPrimary) + swipeLeftIcon = iconForAction(left, context.getColor(R.color.textPrimary)) setDefaultSwipeDirs((if (right == Preferences.SWIPE_ACTION_NONE) 0 else ItemTouchHelper.RIGHT) or (if (left == Preferences.SWIPE_ACTION_NONE) 0 else ItemTouchHelper.LEFT)) } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt index f35caac4bda89878bfa7b3a90190c8255a8ec09d..21c03d8b365ee59fe37901d51f404f0cdf09fc43 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt @@ -60,7 +60,7 @@ class ConversationsAdapter @Inject constructor( view.snippet.maxLines = 5 view.unread.isVisible = true - view.unread.setTint(colors.theme().theme) + view.unread.setTint(context.getColor(R.color.tools_theme)) view.date.setTypeface(view.date.typeface, Typeface.BOLD) view.date.setTextColor(textColorPrimary) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt index 4f26995cfe1b6ea992058ca2df878d5149916d06..b008a74ee740832184c3c78161738e9f472bf3fc 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainActivity.kt @@ -72,14 +72,29 @@ import javax.inject.Inject class MainActivity : QkThemedActivity(), MainView { - @Inject lateinit var blockingDialog: BlockingDialog - @Inject lateinit var disposables: CompositeDisposable - @Inject lateinit var navigator: Navigator - @Inject lateinit var conversationsAdapter: ConversationsAdapter - @Inject lateinit var drawerBadgesExperiment: DrawerBadgesExperiment - @Inject lateinit var searchAdapter: SearchAdapter - @Inject lateinit var itemTouchCallback: ConversationItemTouchCallback - @Inject lateinit var viewModelFactory: ViewModelProvider.Factory + @Inject + lateinit var blockingDialog: BlockingDialog + + @Inject + lateinit var disposables: CompositeDisposable + + @Inject + lateinit var navigator: Navigator + + @Inject + lateinit var conversationsAdapter: ConversationsAdapter + + @Inject + lateinit var drawerBadgesExperiment: DrawerBadgesExperiment + + @Inject + lateinit var searchAdapter: SearchAdapter + + @Inject + lateinit var itemTouchCallback: ConversationItemTouchCallback + + @Inject + lateinit var viewModelFactory: ViewModelProvider.Factory override val onNewIntentIntent: Subject = PublishSubject.create() override val activityResumedIntent: Subject = PublishSubject.create() @@ -132,8 +147,8 @@ class MainActivity : QkThemedActivity(), MainView { } (syncing as? ViewStub)?.setOnInflateListener { _, _ -> - syncingProgress?.progressTintList = ColorStateList.valueOf(theme.blockingFirst().theme) - syncingProgress?.indeterminateTintList = ColorStateList.valueOf(theme.blockingFirst().theme) + syncingProgress?.progressTintList = ColorStateList.valueOf(getColor(R.color.tools_theme)) + syncingProgress?.indeterminateTintList = ColorStateList.valueOf(getColor(R.color.tools_theme)) } toggle.syncState() @@ -149,29 +164,25 @@ class MainActivity : QkThemedActivity(), MainView { drawer.clicks().autoDisposable(scope()).subscribe() // Set the theme color tint to the recyclerView, progressbar, and FAB - theme - .doOnNext { recyclerView.scrapViews() } - .autoDisposable(scope()) - .subscribe { theme -> - // Set the color for the drawer icons - val states = arrayOf(intArrayOf(android.R.attr.state_activated), - intArrayOf(-android.R.attr.state_activated)) - resolveThemeColor(android.R.attr.textColorSecondary) - .let { textSecondary -> ColorStateList(states, intArrayOf(theme.theme, textSecondary)) } - .let { tintList -> - inboxIcon.imageTintList = tintList - archivedIcon.imageTintList = tintList - } - - // Miscellaneous views - syncingProgress?.progressTintList = ColorStateList.valueOf(theme.theme) - syncingProgress?.indeterminateTintList = ColorStateList.valueOf(theme.theme) - compose.setBackgroundTint(theme.theme) - - // Set the FAB compose icon color - compose.setTint(theme.textPrimary) + + // Set the color for the drawer icons + val states = arrayOf(intArrayOf(android.R.attr.state_activated), + intArrayOf(-android.R.attr.state_activated)) + resolveThemeColor(android.R.attr.textColorSecondary) + .let { textSecondary -> ColorStateList(states, intArrayOf(getColor(R.color.tools_theme), textSecondary)) } + .let { tintList -> + inboxIcon.imageTintList = tintList + inboxLabel.setTextColor(tintList) + archivedIcon.imageTintList = tintList + archivedLabel.setTextColor(tintList) } + // Miscellaneous views + syncingProgress?.progressTintList = ColorStateList.valueOf(resources.getColor(R.color.tools_theme)) + syncingProgress?.indeterminateTintList = ColorStateList.valueOf(getColor(R.color.tools_theme)) + // Set the FAB compose icon color + compose.setTint(getColor(R.color.tools_theme)) + itemTouchCallback.adapter = conversationsAdapter conversationsAdapter.autoScrollToStart(recyclerView) } @@ -361,7 +372,7 @@ class MainActivity : QkThemedActivity(), MainView { override fun showArchivedSnackbar() { Snackbar.make(drawerLayout, R.string.toast_archived, Snackbar.LENGTH_LONG).apply { setAction(R.string.button_undo) { undoArchiveIntent.onNext(Unit) } - setActionTextColor(colors.theme().theme) + setActionTextColor(getColor(R.color.tools_theme)) show() } } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/SearchAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/SearchAdapter.kt index 6e429aa595b85d2f5dd1aef79df9e841ab6eef85..dacaac38f07d7f6ade173ae3e2c8071936575644 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/SearchAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/SearchAdapter.kt @@ -24,6 +24,7 @@ import android.text.Spanned import android.text.style.BackgroundColorSpan import android.view.LayoutInflater import android.view.ViewGroup +import com.google.android.material.color.MaterialColors.getColor import com.moez.QKSMS.R import com.moez.QKSMS.common.Navigator import com.moez.QKSMS.common.base.QkAdapter @@ -37,13 +38,12 @@ import kotlinx.android.synthetic.main.search_list_item.view.* import javax.inject.Inject class SearchAdapter @Inject constructor( - colors: Colors, - private val context: Context, - private val dateFormatter: DateFormatter, - private val navigator: Navigator + colors: Colors, + private val context: Context, + private val dateFormatter: DateFormatter, + private val navigator: Navigator ) : QkAdapter() { - private val highlightColor: Int by lazy { colors.theme().highlight } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder { val layoutInflater = LayoutInflater.from(parent.context) @@ -68,7 +68,7 @@ class SearchAdapter @Inject constructor( var index = title.removeAccents().indexOf(query, ignoreCase = true) while (index >= 0) { - title.setSpan(BackgroundColorSpan(highlightColor), index, index + query.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + title.setSpan(BackgroundColorSpan(context.getColor(R.color.tools_theme)), index, index + query.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) index = title.indexOf(query, index + query.length, true) } view.title.text = title diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivity.kt index 1df78e0456445de9141c2fdf546500e4e0f904e4..806856ac2f85d5cb893a19119dec4261d4c37921 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusActivity.kt @@ -88,10 +88,9 @@ class PlusActivity : QkThemedActivity(), PlusView { collapsingToolbar.setCollapsedTitleTextColor(textPrimary) collapsingToolbar.setExpandedTitleColor(textPrimary) - val theme = colors.theme().theme - donate.setBackgroundTint(theme) - upgrade.setBackgroundTint(theme) - thanksIcon.setTint(theme) + donate.setBackgroundTint(getColor(R.color.tools_theme)) + upgrade.setBackgroundTint(getColor(R.color.tools_theme)) + thanksIcon.setTint(getColor(R.color.tools_theme)) } override fun render(state: PlusState) { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledActivity.kt b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledActivity.kt index 341c987e38ddd001c026e1b3b5a9a821afbb52d5..419a5468b9075e83aed7f3761cfe0333fed45261 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledActivity.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/scheduled/ScheduledActivity.kt @@ -38,10 +38,14 @@ import javax.inject.Inject class ScheduledActivity : QkThemedActivity(), ScheduledView { - @Inject lateinit var dialog: QkDialog - @Inject lateinit var fontProvider: FontProvider - @Inject lateinit var messageAdapter: ScheduledMessageAdapter - @Inject lateinit var viewModelFactory: ViewModelProvider.Factory + @Inject + lateinit var dialog: QkDialog + @Inject + lateinit var fontProvider: FontProvider + @Inject + lateinit var messageAdapter: ScheduledMessageAdapter + @Inject + lateinit var viewModelFactory: ViewModelProvider.Factory override val messageClickIntent by lazy { messageAdapter.clicks } override val messageMenuIntent by lazy { dialog.adapter.menuItemClicks } @@ -71,12 +75,11 @@ class ScheduledActivity : QkThemedActivity(), ScheduledView { messageAdapter.emptyView = empty messages.adapter = messageAdapter - colors.theme().let { theme -> - sampleMessage.setBackgroundTint(theme.theme) - sampleMessage.setTextColor(theme.textPrimary) - compose.setTint(theme.textPrimary) - compose.setBackgroundTint(theme.theme) - } + sampleMessage.setBackgroundTint(getColor(R.color.tools_theme)) + sampleMessage.setTextColor(getColor(R.color.textPrimary)) + compose.setTint(getColor(R.color.textPrimary)) + compose.setBackgroundTint(getColor(R.color.tools_theme)) + } override fun render(state: ScheduledState) { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt index 7f0c378a9f878ddc7bfa905d6816266a58328e6f..7d5eeab18baee1159935144efe8932724c0b60e5 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt @@ -83,9 +83,6 @@ class SettingsController : QkController newState { copy(theme = theme.theme) } } - - disposables += prefs.theme().asObservable() - .subscribe { color -> newState { copy(theme = color) } } val nightModeLabels = context.resources.getStringArray(R.array.night_modes) disposables += prefs.nightMode.asObservable() diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/swipe/SwipeActionsController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/swipe/SwipeActionsController.kt index 8121ad443de30d1e99ff4e16d4e0c5395af8858d..a6187d839761ea6eddb21fda0afe38d5f1a4a65e 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/swipe/SwipeActionsController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/swipe/SwipeActionsController.kt @@ -20,6 +20,7 @@ package com.moez.QKSMS.feature.settings.swipe import android.view.View import androidx.core.view.isVisible +import com.google.android.material.color.MaterialColors.getColor import com.jakewharton.rxbinding2.view.clicks import com.moez.QKSMS.R import com.moez.QKSMS.common.QkDialog @@ -39,9 +40,12 @@ import javax.inject.Inject class SwipeActionsController : QkController(), SwipeActionsView { - @Inject override lateinit var presenter: SwipeActionsPresenter - @Inject lateinit var actionsDialog: QkDialog - @Inject lateinit var colors: Colors + @Inject + override lateinit var presenter: SwipeActionsPresenter + @Inject + lateinit var actionsDialog: QkDialog + @Inject + lateinit var colors: Colors /** * Allows us to subscribe to [actionClicks] more than once @@ -56,12 +60,11 @@ class SwipeActionsController : QkController - rightIcon.setBackgroundTint(theme.theme) - rightIcon.setTint(theme.textPrimary) - leftIcon.setBackgroundTint(theme.theme) - leftIcon.setTint(theme.textPrimary) - } + + rightIcon.setBackgroundTint(rightIcon.context.getColor(R.color.tools_theme)) + rightIcon.setTint(rightIcon.context.getColor(R.color.white)) + leftIcon.setBackgroundTint(leftIcon.context.getColor(R.color.tools_theme)) + leftIcon.setTint(leftIcon.context.getColor(R.color.white)) right.postDelayed({ right?.animateLayoutChanges = true }, 100) left.postDelayed({ left?.animateLayoutChanges = true }, 100) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetAdapter.kt index 4b5a3d1d4dbf78cb112654dbae664ec14c9bb904..d51e6350e0de621904ceb6a234263e7b652081b6 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetAdapter.kt @@ -62,7 +62,7 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory { private val night get() = prefs.night.get() private val black get() = prefs.black.get() - private val theme get() = colors.theme() + private val background get() = context.getColorCompat(when { night && black -> R.color.black @@ -111,9 +111,9 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory { // Avatar remoteViews.setViewVisibility(R.id.avatar, if (smallWidget) View.GONE else View.VISIBLE) - remoteViews.setInt(R.id.avatar, "setBackgroundColor", theme.theme) - remoteViews.setTextColor(R.id.initial, theme.textPrimary) - remoteViews.setInt(R.id.icon, "setColorFilter", theme.textPrimary) + remoteViews.setInt(R.id.avatar, "setBackgroundColor", context.getColor(R.color.tools_theme)) + remoteViews.setTextColor(R.id.initial, context.getColor(R.color.tools_theme)) + remoteViews.setInt(R.id.icon, "setColorFilter", context.getColor(R.color.textPrimary)) remoteViews.setInt(R.id.avatarMask, "setColorFilter", background) val contact = conversation.recipients.map { recipient -> diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetProvider.kt b/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetProvider.kt index 3c3960d8616ded9069cacb48d41359d89903582d..74b9321da1c38def315eae5b9010ced9df3c13b1 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetProvider.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetProvider.kt @@ -121,7 +121,7 @@ class WidgetProvider : AppWidgetProvider() { remoteViews.setInt(R.id.toolbar, "setColorFilter", context.getColorCompat(when { night && black -> R.color.black night && !black -> R.color.toolbarDark - else -> R.color.toolbarLight + else -> R.color.colorPrimary })) remoteViews.setTextColor(R.id.title, context.getColorCompat(when (night) { @@ -129,7 +129,7 @@ class WidgetProvider : AppWidgetProvider() { false -> R.color.textPrimary })) - remoteViews.setInt(R.id.compose, "setColorFilter", colors.theme().theme) + remoteViews.setInt(R.id.compose, "setColorFilter", context.getColor(R.color.tools_theme)) // Set adapter for conversations val intent = Intent(context, WidgetService::class.java) diff --git a/presentation/src/main/java/com/moez/QKSMS/interactor/MigratePreferences.kt b/presentation/src/main/java/com/moez/QKSMS/interactor/MigratePreferences.kt index a13d8e755221decb3d4048df8fdba95598aad4a4..99020dd02fc7634ea837da2646dabe36d56ba70e 100644 --- a/presentation/src/main/java/com/moez/QKSMS/interactor/MigratePreferences.kt +++ b/presentation/src/main/java/com/moez/QKSMS/interactor/MigratePreferences.kt @@ -40,10 +40,6 @@ class MigratePreferences @Inject constructor( .filter { seen -> seen.get() } // Only proceed if this value is true. It will be set false at the end .doOnNext { // Theme - val defaultTheme = prefs.theme().get().toString() - val oldTheme = rxPrefs.getString("pref_key_theme", defaultTheme).get() - prefs.theme().set(Integer.parseInt(oldTheme)) - // Night mode val background = rxPrefs.getString("pref_key_background", "light").get() val autoNight = rxPrefs.getBoolean("pref_key_night_auto", false).get() diff --git a/presentation/src/main/res/layout/container_activity.xml b/presentation/src/main/res/layout/container_activity.xml index 1f4c959c33a178076d329f2dcdffd051dafa9c47..16ca0bb1557f367273062e9ffe17ce3e08c048bc 100644 --- a/presentation/src/main/res/layout/container_activity.xml +++ b/presentation/src/main/res/layout/container_activity.xml @@ -1,5 +1,4 @@ - - - #00838F + @lineageos.platform:color/color_default_accent + @lineageos.platform:color/color_default_primary + @lineageos.platform:color/color_default_primary_dark diff --git a/presentation/src/main/res/values/themes.xml b/presentation/src/main/res/values/themes.xml index 6537493077f63255871aef9881e84c4b1006b0bb..f7566207ac00e81c46577dd2982168838c8d9025 100644 --- a/presentation/src/main/res/values/themes.xml +++ b/presentation/src/main/res/values/themes.xml @@ -1,5 +1,4 @@ - -