fixing some coloring issues

This commit is contained in:
tibbi 2022-07-07 23:25:41 +02:00
parent 721a9246ad
commit b544a8b692
8 changed files with 41 additions and 16 deletions

View file

@ -35,7 +35,6 @@ class AboutActivity : BaseSimpleActivity() {
val textColor = getProperTextColor()
val backgroundColor = getProperBackgroundColor()
primaryColor = getProperPrimaryColor()
setupToolbar(about_toolbar, TOOLBAR_NAVIGATION_ARROW)
arrayOf(
about_faq_icon,
@ -65,6 +64,7 @@ class AboutActivity : BaseSimpleActivity() {
override fun onResume() {
super.onResume()
updateTextColors(about_nested_scrollview)
setupToolbar(about_toolbar, TOOLBAR_NAVIGATION_ARROW)
setupFAQ()
setupEmail()

View file

@ -84,6 +84,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
}
}
@SuppressLint("NewApi")
override fun onResume() {
super.onResume()
if (useDynamicTheme) {
@ -228,17 +229,17 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
}
}
fun setupToolbar(toolbar: MaterialToolbar, toolbarNavigationIcon: Int = TOOLBAR_NAVIGATION_NONE) {
toolbar.setBackgroundColor(getProperStatusBarColor())
toolbar.setTitleTextColor(getProperStatusBarColor().getContrastColor())
toolbar.overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, getProperStatusBarColor().getContrastColor())
fun setupToolbar(toolbar: MaterialToolbar, toolbarNavigationIcon: Int = TOOLBAR_NAVIGATION_NONE, statusBarColor: Int = getProperStatusBarColor()) {
toolbar.setBackgroundColor(statusBarColor)
toolbar.setTitleTextColor(statusBarColor.getContrastColor())
toolbar.overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, statusBarColor.getContrastColor())
if (toolbarNavigationIcon != TOOLBAR_NAVIGATION_NONE) {
val drawableId = if (toolbarNavigationIcon == TOOLBAR_NAVIGATION_CROSS) R.drawable.ic_cross_vector else R.drawable.ic_arrow_left_vector
toolbar.navigationIcon = resources.getColoredDrawableWithColor(drawableId, getProperStatusBarColor().getContrastColor())
toolbar.navigationIcon = resources.getColoredDrawableWithColor(drawableId, statusBarColor.getContrastColor())
}
updateMenuItemColors(toolbar.menu)
updateMenuItemColors(toolbar.menu, toolbarNavigationIcon == TOOLBAR_NAVIGATION_CROSS, statusBarColor)
toolbar.setNavigationOnClickListener {
hideKeyboard()
finish()

View file

@ -18,7 +18,6 @@ class ContributorsActivity : BaseSimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_contributors)
setupToolbar(contributors_toolbar, TOOLBAR_NAVIGATION_ARROW)
val textColor = getProperTextColor()
val backgroundColor = getProperBackgroundColor()
@ -48,4 +47,9 @@ class ContributorsActivity : BaseSimpleActivity() {
contributors_label.beGone()
}
}
override fun onResume() {
super.onResume()
setupToolbar(contributors_toolbar, TOOLBAR_NAVIGATION_ARROW)
}
}

View file

@ -230,6 +230,7 @@ class CustomizationActivity : BaseSimpleActivity() {
curSelectedThemeId != THEME_AUTO && curSelectedThemeId != THEME_SYSTEM && curSelectedThemeId != THEME_SHARED && !hideGoogleRelations
)
updateMenuItemColors(customization_toolbar.menu, true, getCurrentStatusBarColor())
setupToolbar(customization_toolbar, TOOLBAR_NAVIGATION_CROSS, getCurrentStatusBarColor())
}
}
@ -248,6 +249,7 @@ class CustomizationActivity : BaseSimpleActivity() {
curAppIconColor = baseConfig.customAppIconColor
setTheme(getThemeId(curPrimaryColor))
updateMenuItemColors(customization_toolbar.menu, true, curPrimaryColor)
setupToolbar(customization_toolbar, TOOLBAR_NAVIGATION_CROSS, curPrimaryColor)
setupColorsPickers()
} else {
baseConfig.customPrimaryColor = curPrimaryColor
@ -270,6 +272,7 @@ class CustomizationActivity : BaseSimpleActivity() {
setTheme(getThemeId(curPrimaryColor))
setupColorsPickers()
updateMenuItemColors(customization_toolbar.menu, true, curPrimaryColor)
setupToolbar(customization_toolbar, TOOLBAR_NAVIGATION_CROSS, curPrimaryColor)
}
} else {
val theme = predefinedThemes[curSelectedThemeId]!!
@ -286,6 +289,7 @@ class CustomizationActivity : BaseSimpleActivity() {
setTheme(getThemeId(getCurrentPrimaryColor()))
colorChanged()
updateMenuItemColors(customization_toolbar.menu, true, getCurrentStatusBarColor())
setupToolbar(customization_toolbar, TOOLBAR_NAVIGATION_CROSS, getCurrentStatusBarColor())
}
}
@ -575,12 +579,12 @@ class CustomizationActivity : BaseSimpleActivity() {
setTheme(getThemeId(color))
}
updateMenuItemColors(customization_toolbar.menu, true, color)
customization_toolbar.setBackgroundColor(color)
setupToolbar(customization_toolbar, TOOLBAR_NAVIGATION_CROSS, color)
} else {
updateActionbarColor(curPrimaryColor)
setTheme(getThemeId(curPrimaryColor))
updateMenuItemColors(customization_toolbar.menu, true, curPrimaryColor)
customization_toolbar.setBackgroundColor(curPrimaryColor)
setupToolbar(customization_toolbar, TOOLBAR_NAVIGATION_CROSS, curPrimaryColor)
}
}
}

View file

@ -23,7 +23,6 @@ class FAQActivity : BaseSimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_faq)
setupToolbar(faq_toolbar, TOOLBAR_NAVIGATION_ARROW)
val dividerMargin = resources.getDimension(R.dimen.medium_margin).toInt()
val titleColor = getProperPrimaryColor()
@ -54,4 +53,9 @@ class FAQActivity : BaseSimpleActivity() {
}
}
}
override fun onResume() {
super.onResume()
setupToolbar(faq_toolbar, TOOLBAR_NAVIGATION_ARROW)
}
}

View file

@ -18,7 +18,6 @@ class LicenseActivity : BaseSimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_license)
setupToolbar(license_toolbar, TOOLBAR_NAVIGATION_ARROW)
val dividerMargin = resources.getDimension(R.dimen.medium_margin).toInt()
val textColor = getProperTextColor()
@ -53,6 +52,11 @@ class LicenseActivity : BaseSimpleActivity() {
}
}
override fun onResume() {
super.onResume()
setupToolbar(license_toolbar, TOOLBAR_NAVIGATION_ARROW)
}
private fun initLicenses() = arrayOf(
License(LICENSE_KOTLIN, R.string.kotlin_title, R.string.kotlin_text, R.string.kotlin_url),
License(LICENSE_SUBSAMPLING, R.string.subsampling_title, R.string.subsampling_text, R.string.subsampling_url),

View file

@ -7,6 +7,7 @@ import com.google.android.material.appbar.MaterialToolbar
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.TOOLBAR_NAVIGATION_CROSS
import com.simplemobiletools.commons.interfaces.LineColorPickerListener
import kotlinx.android.synthetic.main.dialog_line_color_picker.view.*
@ -78,9 +79,11 @@ class LineColorPickerDialog(
if (isPrimaryColorPicker) {
activity.updateActionbarColor(color)
activity.setTheme(activity.getThemeId(color))
activity.updateMenuItemColors(toolbar?.menu, true, color)
toolbar?.setBackgroundColor(color)
toolbar?.setTitleTextColor(color.getContrastColor())
if (toolbar != null) {
activity.updateMenuItemColors(toolbar.menu, true, color)
activity.setupToolbar(toolbar, TOOLBAR_NAVIGATION_CROSS, color)
}
if (!wasDimmedBackgroundRemoved) {
dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)

View file

@ -3,6 +3,7 @@ package com.simplemobiletools.commons.samples.activities
import android.os.Bundle
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.appLaunched
import com.simplemobiletools.commons.models.FAQItem
import com.simplemobiletools.commons.samples.BuildConfig
import com.simplemobiletools.commons.samples.R
import kotlinx.android.synthetic.main.activity_main.*
@ -21,7 +22,6 @@ class MainActivity : BaseSimpleActivity() {
setContentView(R.layout.activity_main)
appLaunched(BuildConfig.APPLICATION_ID)
setupToolbar(main_toolbar)
main_color_customization.setOnClickListener {
startCustomizationActivity()
}
@ -41,4 +41,9 @@ class MainActivity : BaseSimpleActivity() {
}, 1000L)
}*/
}
override fun onResume() {
super.onResume()
setupToolbar(main_toolbar)
}
}