diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt index fe0c29891..db4d52509 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt @@ -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() diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt index c23e3cb28..5a90cb74c 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt @@ -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() diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ContributorsActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ContributorsActivity.kt index 630ea818e..8cfb9743a 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ContributorsActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ContributorsActivity.kt @@ -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) + } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt index 1539f32d8..741833016 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt @@ -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) } } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/FAQActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/FAQActivity.kt index 0997cc715..afefde29a 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/FAQActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/FAQActivity.kt @@ -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) + } } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt index be001a0d1..a3420751f 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt @@ -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), diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt index c07802c0b..2d4042eb4 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/LineColorPickerDialog.kt @@ -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) diff --git a/samples/src/main/kotlin/com/simplemobiletools/commons/samples/activities/MainActivity.kt b/samples/src/main/kotlin/com/simplemobiletools/commons/samples/activities/MainActivity.kt index d3d4862f2..aa7e8871e 100644 --- a/samples/src/main/kotlin/com/simplemobiletools/commons/samples/activities/MainActivity.kt +++ b/samples/src/main/kotlin/com/simplemobiletools/commons/samples/activities/MainActivity.kt @@ -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) + } }