updating the Color Customization activity
This commit is contained in:
parent
1028c93a53
commit
c77a30ed53
5 changed files with 98 additions and 48 deletions
|
@ -8,7 +8,6 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.BuildConfig
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.dialogs.*
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
|
@ -16,8 +15,8 @@ import com.simplemobiletools.commons.helpers.*
|
|||
import com.simplemobiletools.commons.models.MyTheme
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.commons.models.SharedTheme
|
||||
import com.simplemobiletools.commons.views.MyTextView
|
||||
import kotlinx.android.synthetic.main.activity_customization.*
|
||||
import java.util.*
|
||||
|
||||
class CustomizationActivity : BaseSimpleActivity() {
|
||||
private val THEME_LIGHT = 0
|
||||
|
@ -88,7 +87,13 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
baseConfig.isUsingSharedTheme = false
|
||||
}
|
||||
|
||||
updateTextColors(customization_holder)
|
||||
val textColor = if (baseConfig.isUsingSystemTheme) {
|
||||
getProperTextColor()
|
||||
} else {
|
||||
baseConfig.textColor
|
||||
}
|
||||
|
||||
updateLabelColors(textColor)
|
||||
originalAppIconColor = baseConfig.appIconColor
|
||||
|
||||
if (resources.getBoolean(R.bool.hide_google_relations)) {
|
||||
|
@ -98,10 +103,13 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateBackgroundColor(curBackgroundColor)
|
||||
updateActionbarColor(curPrimaryColor)
|
||||
updateNavigationBarColor(curNavigationBarColor)
|
||||
setTheme(getThemeId(curPrimaryColor))
|
||||
setTheme(getThemeId(getCurrentPrimaryColor()))
|
||||
|
||||
if (!baseConfig.isUsingSystemTheme) {
|
||||
updateBackgroundColor(getCurrentBackgroundColor())
|
||||
updateActionbarColor(getCurrentPrimaryColor())
|
||||
updateNavigationBarColor(curNavigationBarColor)
|
||||
}
|
||||
|
||||
curPrimaryLineColorPicker?.getSpecificColor()?.apply {
|
||||
updateActionbarColor(this)
|
||||
|
@ -112,7 +120,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_customization, menu)
|
||||
menu.findItem(R.id.save).isVisible = hasUnsavedChanges
|
||||
updateMenuItemColors(menu, true, curPrimaryColor)
|
||||
updateMenuItemColors(menu, true, getCurrentPrimaryColor())
|
||||
this.menu = menu
|
||||
return true
|
||||
}
|
||||
|
@ -177,8 +185,8 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
|
||||
private fun setupThemePicker() {
|
||||
curSelectedThemeId = getCurrentThemeId()
|
||||
updateAutoThemeFields()
|
||||
customization_theme.text = getThemeText()
|
||||
updateAutoThemeFields()
|
||||
handleAccentColorLayout()
|
||||
customization_theme_holder.setOnClickListener {
|
||||
if (baseConfig.wasAppIconCustomizationWarningShown) {
|
||||
|
@ -265,20 +273,20 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
curNavigationBarColor = getThemeNavigationColor(curSelectedThemeId)
|
||||
setTheme(getThemeId(curPrimaryColor))
|
||||
setTheme(getThemeId(getCurrentPrimaryColor()))
|
||||
colorChanged()
|
||||
updateMenuItemColors(menu, true, curPrimaryColor)
|
||||
updateMenuItemColors(menu, true, getCurrentPrimaryColor())
|
||||
}
|
||||
}
|
||||
|
||||
hasUnsavedChanges = true
|
||||
invalidateOptionsMenu()
|
||||
updateTextColors(customization_holder, curTextColor)
|
||||
updateBackgroundColor(curBackgroundColor)
|
||||
updateActionbarColor(curPrimaryColor)
|
||||
updateLabelColors(getCurrentTextColor())
|
||||
updateBackgroundColor(getCurrentBackgroundColor())
|
||||
updateActionbarColor(getCurrentPrimaryColor())
|
||||
updateNavigationBarColor(curNavigationBarColor)
|
||||
updateAutoThemeFields()
|
||||
updateApplyToAllColors(curPrimaryColor)
|
||||
updateApplyToAllColors(getCurrentPrimaryColor())
|
||||
handleAccentColorLayout()
|
||||
}
|
||||
|
||||
|
@ -303,7 +311,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
private fun getCurrentThemeId(): Int {
|
||||
if (baseConfig.isUsingSharedTheme) {
|
||||
return THEME_SHARED
|
||||
} else if (baseConfig.isUsingSystemTheme) {
|
||||
} else if (baseConfig.isUsingSystemTheme && !hasUnsavedChanges) {
|
||||
return THEME_SYSTEM
|
||||
} else if (baseConfig.isUsingAutoTheme || curSelectedThemeId == THEME_AUTO) {
|
||||
return THEME_AUTO
|
||||
|
@ -417,7 +425,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
updateActionbarColor()
|
||||
updateNavigationBarColor()
|
||||
invalidateOptionsMenu()
|
||||
updateTextColors(customization_holder)
|
||||
updateLabelColors(getCurrentTextColor())
|
||||
}
|
||||
|
||||
private fun initColorVariables() {
|
||||
|
@ -430,13 +438,16 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupColorsPickers() {
|
||||
customization_text_color.setFillWithStroke(curTextColor, curBackgroundColor)
|
||||
customization_primary_color.setFillWithStroke(curPrimaryColor, curBackgroundColor)
|
||||
customization_accent_color.setFillWithStroke(curAccentColor, curBackgroundColor)
|
||||
customization_background_color.setFillWithStroke(curBackgroundColor, curBackgroundColor)
|
||||
customization_app_icon_color.setFillWithStroke(curAppIconColor, curBackgroundColor)
|
||||
customization_navigation_bar_color.setFillWithStroke(curNavigationBarColor, curBackgroundColor)
|
||||
apply_to_all.setTextColor(curPrimaryColor.getContrastColor())
|
||||
val textColor = getCurrentTextColor()
|
||||
val backgroundColor = getCurrentBackgroundColor()
|
||||
val primaryColor = getCurrentPrimaryColor()
|
||||
customization_text_color.setFillWithStroke(textColor, backgroundColor)
|
||||
customization_primary_color.setFillWithStroke(primaryColor, backgroundColor)
|
||||
customization_accent_color.setFillWithStroke(curAccentColor, backgroundColor)
|
||||
customization_background_color.setFillWithStroke(backgroundColor, backgroundColor)
|
||||
customization_app_icon_color.setFillWithStroke(curAppIconColor, backgroundColor)
|
||||
customization_navigation_bar_color.setFillWithStroke(curNavigationBarColor, backgroundColor)
|
||||
apply_to_all.setTextColor(primaryColor.getContrastColor())
|
||||
|
||||
customization_text_color_holder.setOnClickListener { pickTextColor() }
|
||||
customization_background_color_holder.setOnClickListener { pickBackgroundColor() }
|
||||
|
@ -471,7 +482,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
|
||||
private fun setCurrentTextColor(color: Int) {
|
||||
curTextColor = color
|
||||
updateTextColors(customization_holder, color)
|
||||
updateLabelColors(color)
|
||||
}
|
||||
|
||||
private fun setCurrentBackgroundColor(color: Int) {
|
||||
|
@ -486,7 +497,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updateApplyToAllColors(newColor: Int) {
|
||||
if (newColor == baseConfig.primaryColor) {
|
||||
if (newColor == baseConfig.primaryColor && !baseConfig.isUsingSystemTheme) {
|
||||
apply_to_all.setBackgroundResource(R.drawable.button_background_rounded)
|
||||
} else {
|
||||
val applyBackground = resources.getDrawable(R.drawable.button_background_rounded, theme) as RippleDrawable
|
||||
|
@ -622,4 +633,41 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
PurchaseThankYouDialog(this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateLabelColors(textColor: Int) {
|
||||
arrayListOf<MyTextView>(
|
||||
customization_theme_label,
|
||||
customization_theme,
|
||||
customization_text_color_label,
|
||||
customization_background_color_label,
|
||||
customization_primary_color_label,
|
||||
customization_accent_color_label,
|
||||
customization_app_icon_color_label,
|
||||
customization_navigation_bar_color_label
|
||||
).forEach {
|
||||
it.setTextColor(textColor)
|
||||
}
|
||||
|
||||
val primaryColor = getCurrentPrimaryColor()
|
||||
apply_to_all.setTextColor(primaryColor.getContrastColor())
|
||||
updateApplyToAllColors(primaryColor)
|
||||
}
|
||||
|
||||
private fun getCurrentTextColor() = if (customization_theme.value == getString(R.string.system_default)) {
|
||||
resources.getColor(R.color.you_neutral_text_color)
|
||||
} else {
|
||||
curTextColor
|
||||
}
|
||||
|
||||
private fun getCurrentBackgroundColor() = if (customization_theme.value == getString(R.string.system_default)) {
|
||||
resources.getColor(R.color.you_background_color)
|
||||
} else {
|
||||
curBackgroundColor
|
||||
}
|
||||
|
||||
private fun getCurrentPrimaryColor() = if (customization_theme.value == getString(R.string.system_default)) {
|
||||
resources.getColor(R.color.you_primary_color)
|
||||
} else {
|
||||
curPrimaryColor
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,10 @@ import android.provider.MediaStore
|
|||
import android.telecom.PhoneAccountHandle
|
||||
import android.telecom.TelecomManager
|
||||
import android.text.Html
|
||||
import android.view.*
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
|
@ -43,7 +46,6 @@ import java.io.FileNotFoundException
|
|||
import java.io.FileOutputStream
|
||||
import java.io.OutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
fun AppCompatActivity.updateActionBarTitle(text: String, color: Int = baseConfig.primaryColor) {
|
||||
if (baseConfig.isUsingSystemTheme) {
|
||||
|
@ -1349,11 +1351,13 @@ fun Activity.setupDialogStuff(
|
|||
return
|
||||
}
|
||||
|
||||
val textColor = getProperTextColor()
|
||||
val backgroundColor = getProperBackgroundColor()
|
||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||
if (view is ViewGroup)
|
||||
if (view is ViewGroup) {
|
||||
updateTextColors(view)
|
||||
else if (view is MyTextView) {
|
||||
view.setColors(getProperTextColor(), adjustedPrimaryColor, getProperBackgroundColor())
|
||||
} else if (view is MyTextView) {
|
||||
view.setColors(textColor, adjustedPrimaryColor, backgroundColor)
|
||||
}
|
||||
|
||||
var title: TextView? = null
|
||||
|
@ -1365,13 +1369,13 @@ fun Activity.setupDialogStuff(
|
|||
} else {
|
||||
setText(titleId)
|
||||
}
|
||||
setTextColor(baseConfig.textColor)
|
||||
setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
|
||||
// if we use the same primary and background color, use the text color for dialog confirmation buttons
|
||||
val dialogButtonColor = if (adjustedPrimaryColor == baseConfig.backgroundColor) {
|
||||
baseConfig.textColor
|
||||
textColor
|
||||
} else {
|
||||
adjustedPrimaryColor
|
||||
}
|
||||
|
|
|
@ -11,13 +11,6 @@ import com.simplemobiletools.commons.R
|
|||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.SharedTheme
|
||||
import com.simplemobiletools.commons.views.*
|
||||
import java.util.*
|
||||
|
||||
fun Context.getProperBackgroundColor() = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_background_color)
|
||||
} else {
|
||||
baseConfig.backgroundColor
|
||||
}
|
||||
|
||||
fun Context.getProperTextColor() = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_neutral_text_color)
|
||||
|
@ -25,6 +18,12 @@ fun Context.getProperTextColor() = if (baseConfig.isUsingSystemTheme) {
|
|||
baseConfig.textColor
|
||||
}
|
||||
|
||||
fun Context.getProperBackgroundColor() = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_background_color)
|
||||
} else {
|
||||
baseConfig.backgroundColor
|
||||
}
|
||||
|
||||
fun Context.getProperPrimaryColor() = if (baseConfig.isUsingSystemTheme) {
|
||||
resources.getColor(R.color.you_primary_color)
|
||||
} else {
|
||||
|
@ -33,8 +32,8 @@ fun Context.getProperPrimaryColor() = if (baseConfig.isUsingSystemTheme) {
|
|||
|
||||
fun Context.updateTextColors(viewGroup: ViewGroup, tmpTextColor: Int = 0, tmpAccentColor: Int = 0) {
|
||||
val textColor = when {
|
||||
tmpTextColor == 0 -> baseConfig.textColor
|
||||
baseConfig.isUsingSystemTheme -> getProperTextColor()
|
||||
tmpTextColor == 0 -> baseConfig.textColor
|
||||
else -> tmpTextColor
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/line_color_picker_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -13,20 +12,20 @@
|
|||
android:layout_height="@dimen/line_color_picker_app_icon_size"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.simplemobiletools.commons.views.LineColorPicker
|
||||
android:id="@+id/primary_line_color_picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/line_color_picker_height"
|
||||
android:layout_below="@+id/line_color_picker_icon"/>
|
||||
android:layout_below="@+id/line_color_picker_icon" />
|
||||
|
||||
<com.simplemobiletools.commons.views.LineColorPicker
|
||||
android:id="@+id/secondary_line_color_picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/line_color_picker_height"
|
||||
android:layout_below="@+id/primary_line_color_picker"
|
||||
android:layout_marginTop="@dimen/big_margin"/>
|
||||
android:layout_marginTop="@dimen/big_margin" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/hex_code"
|
||||
|
@ -36,6 +35,6 @@
|
|||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="@dimen/big_margin"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
tools:text="#FF0000"/>
|
||||
tools:text="#FF0000" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="you_background_color">@android:color/system_accent1_300</color>
|
||||
<color name="you_background_color">@android:color/system_accent1_10</color>
|
||||
<color name="you_neutral_text_color">@android:color/system_accent1_800</color>
|
||||
<color name="you_primary_color">@android:color/system_accent1_400</color>
|
||||
<color name="you_primary_dark_color">@android:color/system_accent1_600</color>
|
||||
|
|
Loading…
Reference in a new issue