adding initial search menu on the main screen
This commit is contained in:
parent
a15ff47313
commit
f6b563d0bc
3 changed files with 20 additions and 31 deletions
|
@ -87,6 +87,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
private var mStoredStyleString = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
appLaunched(BuildConfig.APPLICATION_ID)
|
||||
|
@ -113,6 +114,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
updateMaterialActivityViews(directories_coordinator, directories_grid, useTransparentNavigation = true, useTopSearchMenu = true)
|
||||
|
||||
directories_refresh_layout.setOnRefreshListener { getDirectories() }
|
||||
storeStateVariables()
|
||||
checkWhatsNewDialog()
|
||||
|
@ -183,11 +186,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateMenuColors()
|
||||
config.isThirdPartyIntent = false
|
||||
mDateFormat = config.dateFormat
|
||||
mTimeFormat = getTimeFormat()
|
||||
|
||||
setupToolbar(directories_toolbar, searchMenuItem = mSearchMenuItem)
|
||||
refreshMenuItems()
|
||||
|
||||
if (mStoredAnimateGifs != config.animateGifs) {
|
||||
|
@ -289,8 +292,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (mIsSearchOpen && mSearchMenuItem != null) {
|
||||
mSearchMenuItem!!.collapseActionView()
|
||||
if (main_menu.isSearchOpen) {
|
||||
main_menu.closeSearch()
|
||||
} else if (config.groupDirectSubfolders) {
|
||||
if (mCurrentPathPrefix.isEmpty()) {
|
||||
super.onBackPressed()
|
||||
|
@ -306,16 +309,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
|
||||
private fun refreshMenuItems() {
|
||||
if (!mIsThirdPartyIntent) {
|
||||
directories_toolbar.menu.apply {
|
||||
main_menu.getToolbar().menu.apply {
|
||||
findItem(R.id.increase_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt < MAX_COLUMN_COUNT
|
||||
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID && config.dirColumnCnt > 1
|
||||
findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
|
||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
||||
setupSearch(this)
|
||||
}
|
||||
}
|
||||
|
||||
directories_toolbar.menu.apply {
|
||||
main_menu.getToolbar().menu.apply {
|
||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden
|
||||
findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden
|
||||
|
||||
|
@ -331,13 +333,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
R.menu.menu_main
|
||||
}
|
||||
|
||||
directories_toolbar.inflateMenu(menuId)
|
||||
main_menu.getToolbar().inflateMenu(menuId)
|
||||
main_menu.toggleHideOnScroll(true)
|
||||
main_menu.setupMenu()
|
||||
|
||||
if (!mIsThirdPartyIntent) {
|
||||
setupSearch(directories_toolbar.menu)
|
||||
}
|
||||
|
||||
directories_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.sort -> showSortingDialog()
|
||||
R.id.filter -> showFilterMediaDialog()
|
||||
|
@ -371,6 +371,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
mWasProtectionHandled = savedInstanceState.getBoolean(WAS_PROTECTION_HANDLED, false)
|
||||
}
|
||||
|
||||
private fun updateMenuColors() {
|
||||
updateStatusbarColor(getProperBackgroundColor())
|
||||
main_menu.updateColors()
|
||||
}
|
||||
|
||||
private fun getRecyclerAdapter() = directories_grid.adapter as? DirectoryAdapter
|
||||
|
||||
private fun storeStateVariables() {
|
||||
|
|
|
@ -5,20 +5,10 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/directories_app_bar_layout"
|
||||
<com.simplemobiletools.commons.views.MySearchMenu
|
||||
android:id="@+id/main_menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/directories_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/color_primary"
|
||||
app:title="@string/app_launcher_name"
|
||||
app:titleTextAppearance="@style/AppTheme.ActionBar.TitleTextStyle" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/directories_holder"
|
||||
|
|
|
@ -3,12 +3,6 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="AppCompatResource">
|
||||
<item
|
||||
android:id="@+id/search"
|
||||
android:icon="@drawable/ic_search_vector"
|
||||
android:title="@string/search"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="collapseActionView|always" />
|
||||
<item
|
||||
android:id="@+id/open_camera"
|
||||
android:icon="@drawable/ic_camera_vector"
|
||||
|
|
Loading…
Reference in a new issue