Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 863a79e5 authored by Mohit Mali's avatar Mohit Mali
Browse files

-Removed 'system accent color in Message'

parent 140173d4
Loading
Loading
Loading
Loading
Loading
+2 −20
Original line number Diff line number Diff line
@@ -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<Int> {
        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<Boolean> {
        val default = rxPrefs.getBoolean("notifications", true)
+1 −1
Original line number Diff line number Diff line
@@ -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 {
+15 −6
Original line number Diff line number Diff line
@@ -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<Activity>
    @Inject
    lateinit var dispatchingBroadcastReceiverInjector: DispatchingAndroidInjector<BroadcastReceiver>
    @Inject
    lateinit var dispatchingServiceInjector: DispatchingAndroidInjector<Service>

    @Inject lateinit var dispatchingActivityInjector: DispatchingAndroidInjector<Activity>
    @Inject lateinit var dispatchingBroadcastReceiverInjector: DispatchingAndroidInjector<BroadcastReceiver>
    @Inject lateinit var dispatchingServiceInjector: DispatchingAndroidInjector<Service>
    @Inject
    lateinit var fileLoggingTree: FileLoggingTree
    @Inject lateinit var nightModeManager: NightModeManager
    @Inject
    lateinit var nightModeManager: NightModeManager

    override fun onCreate() {
        super.onCreate()
+4 −21
Original line number Diff line number Diff line
@@ -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<Long> = 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<Int> {
+8 −11
Original line number Diff line number Diff line
@@ -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<Theme> {
        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
Loading