adding some top search menu related code
This commit is contained in:
parent
cf120f1fa8
commit
61f60f11eb
9 changed files with 50 additions and 30 deletions
|
@ -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) ?: ""
|
||||
|
|
|
@ -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<ImageView>(androidx.appcompat.R.id.search_close_btn)?.apply {
|
||||
applyColorFilter(contrastColor)
|
||||
}
|
||||
updateTopBarColors(toolbar, statusBarColor)
|
||||
|
||||
searchMenuItem?.actionView?.findViewById<EditText>(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<ImageView>(androidx.appcompat.R.id.search_close_btn)?.apply {
|
||||
applyColorFilter(contrastColor)
|
||||
}
|
||||
|
||||
if (isQPlus()) {
|
||||
textCursorDrawable = null
|
||||
searchMenuItem?.actionView?.findViewById<EditText>(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<View>(androidx.appcompat.R.id.search_plate)?.apply {
|
||||
background.setColorFilter(contrastColor, PorterDuff.Mode.MULTIPLY)
|
||||
}
|
||||
}
|
||||
|
||||
// search underline
|
||||
searchMenuItem?.actionView?.findViewById<View>(androidx.appcompat.R.id.search_plate)?.apply {
|
||||
background.setColorFilter(contrastColor, PorterDuff.Mode.MULTIPLY)
|
||||
}
|
||||
|
||||
updateTopBarColors(toolbar, statusBarColor)
|
||||
}
|
||||
|
||||
fun updateRecentsAppIcon() {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
9
commons/src/main/res/drawable/search_menu_background.xml
Normal file
9
commons/src/main/res/drawable/search_menu_background.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="@dimen/material_dialog_corner_radius" />
|
||||
<solid android:color="?attr/colorPrimary" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue