close search on pressing back + removing some supportactionbar references

This commit is contained in:
tibbi 2022-07-26 18:35:30 +02:00
parent 28acd10747
commit dd68534109
2 changed files with 11 additions and 12 deletions

View File

@ -70,7 +70,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:8f22bc5532' implementation 'com.github.SimpleMobileTools:Simple-Commons:92fd18b221'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

View File

@ -255,7 +255,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
R.id.export_events -> tryExportEvents() R.id.export_events -> tryExportEvents()
R.id.settings -> launchSettings() R.id.settings -> launchSettings()
R.id.about -> launchAbout() R.id.about -> launchAbout()
android.R.id.home -> onBackPressed()
else -> return@setOnMenuItemClickListener false else -> return@setOnMenuItemClickListener false
} }
return@setOnMenuItemClickListener true return@setOnMenuItemClickListener true
@ -263,12 +262,16 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
} }
override fun onBackPressed() { override fun onBackPressed() {
swipe_refresh_layout.isRefreshing = false if (mIsSearchOpen) {
checkSwipeRefreshAvailability() closeSearch()
when { } else {
fab_extended_overlay.isVisible() -> hideExtendedFab() swipe_refresh_layout.isRefreshing = false
currentFragments.size > 1 -> removeTopFragment() checkSwipeRefreshAvailability()
else -> super.onBackPressed() when {
fab_extended_overlay.isVisible() -> hideExtendedFab()
currentFragments.size > 1 -> removeTopFragment()
else -> super.onBackPressed()
}
} }
} }
@ -929,7 +932,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
fragment.arguments = bundle fragment.arguments = bundle
supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow() supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow()
supportActionBar?.setDisplayHomeAsUpEnabled(false)
} }
private fun fixDayCode(dayCode: String? = null): String? = when { private fun fixDayCode(dayCode: String? = null): String? = when {
@ -989,7 +991,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow() supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow()
resetActionBarTitle() resetActionBarTitle()
calendar_fab.beVisible() calendar_fab.beVisible()
supportActionBar?.setDisplayHomeAsUpEnabled(true)
} }
fun openDayFromMonthly(dateTime: DateTime) { fun openDayFromMonthly(dateTime: DateTime) {
@ -1004,7 +1005,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
fragment.arguments = bundle fragment.arguments = bundle
try { try {
supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow() supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow()
supportActionBar?.setDisplayHomeAsUpEnabled(true)
} catch (e: Exception) { } catch (e: Exception) {
} }
} }
@ -1027,7 +1027,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
updateActionBarTitle() updateActionBarTitle()
} }
calendar_fab.beGoneIf(currentFragments.size == 1 && config.storedView == YEARLY_VIEW) calendar_fab.beGoneIf(currentFragments.size == 1 && config.storedView == YEARLY_VIEW)
supportActionBar?.setDisplayHomeAsUpEnabled(currentFragments.size > 1)
} }
private fun refreshViewPager() { private fun refreshViewPager() {