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

Unverified Commit 430d55b7 authored by solokot's avatar solokot Committed by GitHub
Browse files

Merge pull request #27 from SimpleMobileTools/master

upd
parents b5b673cd c2cc72ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.20.5'
        propVersionName = '4.0.0'
        kotlin_version = '1.2.41'
        support_libs = '27.1.1'
    }
+0 −8
Original line number Diff line number Diff line
@@ -374,12 +374,4 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
            }
        }
    }

    fun checkAppIconColorChange(storedAppIconColor: Int, appId: String) {
        if (storedAppIconColor != baseConfig.appIconColor) {
            getAppIconColors().forEachIndexed { index, color ->
                toggleAppIconColor(appId, index, baseConfig.appIconColor == color)
            }
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ abstract class BaseSplashActivity : AppCompatActivity() {
                        textColor = it.textColor
                        backgroundColor = it.backgroundColor
                        primaryColor = it.primaryColor
                        appIconColor = it.appIconColor
                    }
                }
                initActivity()
+58 −41
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ class CustomizationActivity : BaseSimpleActivity() {
    private var curPrimaryColor = 0
    private var curAppIconColor = 0
    private var curSelectedThemeId = 0
    private var originalAppIconColor = 0
    private var hasUnsavedChanges = false
    private var predefinedThemes = LinkedHashMap<Int, MyTheme>()
    private var curPrimaryLineColorPicker: LineColorPickerDialog? = null
@@ -43,49 +44,37 @@ class CustomizationActivity : BaseSimpleActivity() {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_customization)

        try {
            storedSharedTheme = getSharedThemeSync(getMyContentProviderCursorLoader())
        } catch (e: Exception) {
            toast(R.string.update_thank_you)
            finish()
            return
        }
        initColorVariables()
        setupColorsPickers()

        if (isThankYouInstalled()) {
            val cursorLoader = getMyContentProviderCursorLoader()
            Thread {
                try {
                    storedSharedTheme = getSharedThemeSync(cursorLoader)
                    if (storedSharedTheme == null) {
                        baseConfig.isUsingSharedTheme = false
                    } else {
                        baseConfig.wasSharedThemeEverActivated = true
                    }

        predefinedThemes.apply {
            put(THEME_LIGHT, MyTheme(R.string.light_theme, R.color.theme_light_text_color, R.color.theme_light_background_color, R.color.color_primary, R.color.color_primary))
            put(THEME_DARK, MyTheme(R.string.dark_theme, R.color.theme_dark_text_color, R.color.theme_dark_background_color, R.color.color_primary, R.color.color_primary))
            //put(THEME_SOLARIZED, MyTheme(R.string.solarized, R.color.theme_solarized_text_color, R.color.theme_solarized_background_color, R.color.theme_solarized_primary_color))
            put(THEME_DARK_RED, MyTheme(R.string.dark_red, R.color.theme_dark_text_color, R.color.theme_dark_background_color, R.color.theme_dark_red_primary_color, R.color.md_red_700))
            put(THEME_BLACK_WHITE, MyTheme(R.string.black_white, android.R.color.white, android.R.color.black, android.R.color.black, R.color.md_grey_black))
            put(THEME_CUSTOM, MyTheme(R.string.custom, 0, 0, 0, 0))

            if (storedSharedTheme != null) {
                put(THEME_SHARED, MyTheme(R.string.shared, 0, 0, 0, 0))
                    runOnUiThread {
                        setupThemes()
                        apply_to_all_holder.beVisibleIf(storedSharedTheme == null)
                    }
                } catch (e: Exception) {
                    toast(R.string.update_thank_you)
                    finish()
                }

        if (!isThankYouInstalled()) {
            }.start()
        } else {
            setupThemes()
            baseConfig.isUsingSharedTheme = false
        }

        supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross)
        updateTextColors(customization_holder)
        initColorVariables()
        setupColorsPickers()

        customization_text_color_holder.setOnClickListener { pickTextColor() }
        customization_background_color_holder.setOnClickListener { pickBackgroundColor() }
        customization_primary_color_holder.setOnClickListener { pickPrimaryColor() }
        customization_app_icon_color_holder.setOnClickListener { pickAppIconColor() }
        apply_to_all_holder.setOnClickListener { applyToAll() }
        apply_to_all_holder.beGoneIf(baseConfig.wasSharedThemeEverActivated)
        setupThemePicker()
        originalAppIconColor = baseConfig.appIconColor
    }

    override fun onResume() {
@@ -122,6 +111,22 @@ class CustomizationActivity : BaseSimpleActivity() {
        }
    }

    private fun setupThemes() {
        predefinedThemes.apply {
            put(THEME_LIGHT, MyTheme(R.string.light_theme, R.color.theme_light_text_color, R.color.theme_light_background_color, R.color.color_primary, R.color.color_primary))
            put(THEME_DARK, MyTheme(R.string.dark_theme, R.color.theme_dark_text_color, R.color.theme_dark_background_color, R.color.color_primary, R.color.color_primary))
            //put(THEME_SOLARIZED, MyTheme(R.string.solarized, R.color.theme_solarized_text_color, R.color.theme_solarized_background_color, R.color.theme_solarized_primary_color))
            put(THEME_DARK_RED, MyTheme(R.string.dark_red, R.color.theme_dark_text_color, R.color.theme_dark_background_color, R.color.theme_dark_red_primary_color, R.color.md_red_700))
            put(THEME_BLACK_WHITE, MyTheme(R.string.black_white, android.R.color.white, android.R.color.black, android.R.color.black, R.color.md_grey_black))
            put(THEME_CUSTOM, MyTheme(R.string.custom, 0, 0, 0, 0))

            if (storedSharedTheme != null) {
                put(THEME_SHARED, MyTheme(R.string.shared, 0, 0, 0, 0))
            }
        }
        setupThemePicker()
    }

    private fun setupThemePicker() {
        curSelectedThemeId = getCurrentThemeId()
        customization_theme.text = getThemeText()
@@ -171,7 +176,7 @@ class CustomizationActivity : BaseSimpleActivity() {
                        curTextColor = textColor
                        curBackgroundColor = backgroundColor
                        curPrimaryColor = primaryColor
                        curAppIconColor = curAppIconColor
                        curAppIconColor = appIconColor
                    }
                    setTheme(getThemeId(curPrimaryColor))
                    setupColorsPickers()
@@ -236,6 +241,7 @@ class CustomizationActivity : BaseSimpleActivity() {
    }

    private fun saveChanges(finishAfterSave: Boolean) {
        val didAppIconColorChange = curAppIconColor != originalAppIconColor
        baseConfig.apply {
            textColor = curTextColor
            backgroundColor = curBackgroundColor
@@ -243,6 +249,10 @@ class CustomizationActivity : BaseSimpleActivity() {
            appIconColor = curAppIconColor
        }

        if (didAppIconColorChange) {
            checkAppIconColor()
        }

        if (curSelectedThemeId == THEME_SHARED) {
            val newSharedTheme = SharedTheme(curTextColor, curBackgroundColor, curPrimaryColor, curAppIconColor)
            updateSharedTheme(newSharedTheme)
@@ -251,6 +261,7 @@ class CustomizationActivity : BaseSimpleActivity() {
                sendBroadcast(this)
            }
        }

        baseConfig.isUsingSharedTheme = curSelectedThemeId == THEME_SHARED
        hasUnsavedChanges = false
        if (finishAfterSave) {
@@ -279,10 +290,16 @@ class CustomizationActivity : BaseSimpleActivity() {
    }

    private fun setupColorsPickers() {
        customization_text_color.setBackgroundWithStroke(curTextColor, curBackgroundColor)
        customization_primary_color.setBackgroundWithStroke(curPrimaryColor, curBackgroundColor)
        customization_background_color.setBackgroundWithStroke(curBackgroundColor, curBackgroundColor)
        customization_app_icon_color.setBackgroundWithStroke(curAppIconColor, curBackgroundColor)
        customization_text_color.setFillWithStroke(curTextColor, curBackgroundColor)
        customization_primary_color.setFillWithStroke(curPrimaryColor, curBackgroundColor)
        customization_background_color.setFillWithStroke(curBackgroundColor, curBackgroundColor)
        customization_app_icon_color.setFillWithStroke(curAppIconColor, curBackgroundColor)

        customization_text_color_holder.setOnClickListener { pickTextColor() }
        customization_background_color_holder.setOnClickListener { pickBackgroundColor() }
        customization_primary_color_holder.setOnClickListener { pickPrimaryColor() }
        customization_app_icon_color_holder.setOnClickListener { pickAppIconColor() }
        apply_to_all_holder.setOnClickListener { applyToAll() }
    }

    private fun hasColorChanged(old: Int, new: Int) = Math.abs(old - new) > 1
+4 −4
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ class ColorPickerDialog(val activity: Activity, color: Int, val removeDimmedBack
            newHexField = color_picker_new_hex

            viewSatVal.setHue(getHue())
            viewNewColor.setBackgroundWithStroke(getColor(), backgroundColor)
            color_picker_old_color.setBackgroundWithStroke(color, backgroundColor)
            viewNewColor.setFillWithStroke(getColor(), backgroundColor)
            color_picker_old_color.setFillWithStroke(color, backgroundColor)

            val hexCode = getHexCode(color)
            color_picker_old_hex.text = "#$hexCode"
@@ -102,7 +102,7 @@ class ColorPickerDialog(val activity: Activity, color: Int, val removeDimmedBack
                currentColorHsv[2] = 1f - 1f / viewSatVal.measuredHeight * y

                moveColorPicker()
                viewNewColor.setBackgroundWithStroke(getColor(), backgroundColor)
                viewNewColor.setFillWithStroke(getColor(), backgroundColor)
                newHexField.setText(getHexCode(getColor()))
                return@OnTouchListener true
            }
@@ -163,7 +163,7 @@ class ColorPickerDialog(val activity: Activity, color: Int, val removeDimmedBack
    private fun updateHue() {
        viewSatVal.setHue(getHue())
        moveHuePicker()
        viewNewColor.setBackgroundWithStroke(getColor(), backgroundColor)
        viewNewColor.setFillWithStroke(getColor(), backgroundColor)
        if (removeDimmedBackground && !wasDimmedBackgroundRemoved) {
            dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
            wasDimmedBackgroundRemoved = true
Loading