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 932a812b6..51d5d8d44 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/AboutActivity.kt @@ -45,7 +45,7 @@ class AboutActivity : BaseSimpleActivity() { backgroundColor = getProperBackgroundColor() inflater = LayoutInflater.from(this) - updateMaterialActivityViews(about_coordinator, about_holder, true) + updateMaterialActivityViews(about_coordinator, about_holder, useTransparentNavigation = true, useTopSearchMenu = false) setupMaterialScrollListener(about_nested_scrollview, about_toolbar) appName = intent.getStringExtra(APP_NAME) ?: "" 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 7f32b6f2c..412124a25 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt @@ -68,6 +68,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { private var scrollingView: ScrollingView? = null private var toolbar: Toolbar? = null private var useTransparentNavigation = false + private var useTopSearchMenu = false private val GENERIC_PERM_HANDLER = 100 private val DELETE_FILE_SDK_30_HANDLER = 300 private val RECOVERABLE_SECURITY_HANDLER = 301 @@ -204,10 +205,16 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } // use translucent navigation bar, set the background color to action and status bars - fun updateMaterialActivityViews(mainCoordinatorLayout: CoordinatorLayout?, nestedView: View?, useTransparentNavigation: Boolean) { + fun updateMaterialActivityViews( + mainCoordinatorLayout: CoordinatorLayout?, + nestedView: View?, + useTransparentNavigation: Boolean, + useTopSearchMenu: Boolean + ) { this.mainCoordinatorLayout = mainCoordinatorLayout this.nestedView = nestedView this.useTransparentNavigation = useTransparentNavigation + this.useTopSearchMenu = useTopSearchMenu handleNavigationAndScrolling() val backgroundColor = getProperBackgroundColor() @@ -284,14 +291,16 @@ abstract class BaseSimpleActivity : AppCompatActivity() { } fun updateTopBarColors(toolbar: Toolbar, color: Int) { - updateStatusbarColor(color) - toolbar.setBackgroundColor(color) - val contrastColor = color.getContrastColor() - toolbar.setTitleTextColor(contrastColor) - toolbar.navigationIcon?.applyColorFilter(contrastColor) + if (!useTopSearchMenu) { + updateStatusbarColor(color) + toolbar.setBackgroundColor(color) + toolbar.setTitleTextColor(contrastColor) + toolbar.navigationIcon?.applyColorFilter(contrastColor) + toolbar.collapseIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, contrastColor) + } + toolbar.overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, contrastColor) - toolbar.collapseIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, contrastColor) val menu = toolbar.menu for (i in 0 until menu.size()) { @@ -333,26 +342,28 @@ abstract class BaseSimpleActivity : AppCompatActivity() { finish() } - searchMenuItem?.actionView?.findViewById(androidx.appcompat.R.id.search_close_btn)?.apply { - applyColorFilter(contrastColor) - } + updateTopBarColors(toolbar, statusBarColor) - searchMenuItem?.actionView?.findViewById(androidx.appcompat.R.id.search_src_text)?.apply { - setTextColor(contrastColor) - setHintTextColor(contrastColor.adjustAlpha(MEDIUM_ALPHA)) - hint = "${getString(R.string.search)}…" + if (!useTopSearchMenu) { + searchMenuItem?.actionView?.findViewById(androidx.appcompat.R.id.search_close_btn)?.apply { + applyColorFilter(contrastColor) + } - if (isQPlus()) { - textCursorDrawable = null + searchMenuItem?.actionView?.findViewById(androidx.appcompat.R.id.search_src_text)?.apply { + setTextColor(contrastColor) + setHintTextColor(contrastColor.adjustAlpha(MEDIUM_ALPHA)) + hint = "${getString(R.string.search)}…" + + if (isQPlus()) { + textCursorDrawable = null + } + } + + // search underline + searchMenuItem?.actionView?.findViewById(androidx.appcompat.R.id.search_plate)?.apply { + background.setColorFilter(contrastColor, PorterDuff.Mode.MULTIPLY) } } - - // search underline - searchMenuItem?.actionView?.findViewById(androidx.appcompat.R.id.search_plate)?.apply { - background.setColorFilter(contrastColor, PorterDuff.Mode.MULTIPLY) - } - - updateTopBarColors(toolbar, statusBarColor) } fun updateRecentsAppIcon() { 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 347bcf764..4b3df1952 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ContributorsActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ContributorsActivity.kt @@ -24,7 +24,7 @@ class ContributorsActivity : BaseSimpleActivity() { setContentView(R.layout.activity_contributors) updateTextColors(contributors_holder) - updateMaterialActivityViews(contributors_coordinator, contributors_holder, true) + updateMaterialActivityViews(contributors_coordinator, contributors_holder, useTransparentNavigation = true, useTopSearchMenu = false) setupMaterialScrollListener(contributors_nested_scrollview, contributors_toolbar) val primaryColor = getProperPrimaryColor() 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 fcd806227..9f9e1699c 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/CustomizationActivity.kt @@ -53,7 +53,7 @@ class CustomizationActivity : BaseSimpleActivity() { setupOptionsMenu() refreshMenuItems() - updateMaterialActivityViews(customization_coordinator, customization_holder, true) + updateMaterialActivityViews(customization_coordinator, customization_holder, useTransparentNavigation = true, useTopSearchMenu = false) isThankYou = packageName.removeSuffix(".debug") == "com.simplemobiletools.thankyou" initColorVariables() 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 4cb7711c3..9c47f6dea 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/FAQActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/FAQActivity.kt @@ -27,7 +27,7 @@ class FAQActivity : BaseSimpleActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_faq) - updateMaterialActivityViews(faq_coordinator, faq_holder, true) + updateMaterialActivityViews(faq_coordinator, faq_holder, useTransparentNavigation = true, useTopSearchMenu = false) setupMaterialScrollListener(faq_nested_scrollview, faq_toolbar) val textColor = getProperTextColor() 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 75f9f8abf..3346e69b2 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt @@ -20,7 +20,7 @@ class LicenseActivity : BaseSimpleActivity() { setContentView(R.layout.activity_license) updateTextColors(licenses_holder) - updateMaterialActivityViews(licenses_coordinator, licenses_holder, true) + updateMaterialActivityViews(licenses_coordinator, licenses_holder, useTransparentNavigation = true, useTopSearchMenu = false) setupMaterialScrollListener(licenses_nested_scrollview, licenses_toolbar) val textColor = getProperTextColor() diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt index b266bd5f9..e582ea0d3 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt @@ -35,7 +35,7 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity(), RefreshRecyclerViewLi updateBlockedNumbers() setupOptionsMenu() - updateMaterialActivityViews(block_numbers_coordinator, manage_blocked_numbers_list, true) + updateMaterialActivityViews(block_numbers_coordinator, manage_blocked_numbers_list, useTransparentNavigation = true, useTopSearchMenu = false) setupMaterialScrollListener(manage_blocked_numbers_list, block_numbers_toolbar) updateTextColors(manage_blocked_numbers_wrapper) updatePlaceholderTexts() diff --git a/commons/src/main/res/drawable/search_menu_background.xml b/commons/src/main/res/drawable/search_menu_background.xml new file mode 100644 index 000000000..f803f7089 --- /dev/null +++ b/commons/src/main/res/drawable/search_menu_background.xml @@ -0,0 +1,9 @@ + + + + + + + + + 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 612514197..ff71ea6c8 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 @@ -24,7 +24,7 @@ class MainActivity : BaseSimpleActivity() { setContentView(R.layout.activity_main) appLaunched(BuildConfig.APPLICATION_ID) - updateMaterialActivityViews(main_coordinator, main_holder, true) + updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = true, useTopSearchMenu = false) setupMaterialScrollListener(main_nested_scrollview, main_toolbar) main_color_customization.setOnClickListener {