Makes options menu disappear on modal showing
This commit is contained in:
parent
df0415748f
commit
a961ed7de7
25
vector/src/main/java/im/vector/app/SessionVariables.kt
Normal file
25
vector/src/main/java/im/vector/app/SessionVariables.kt
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app
|
||||
|
||||
class SessionVariables {
|
||||
|
||||
companion object {
|
||||
|
||||
var optionsMenuShouldShow = true
|
||||
}
|
||||
}
|
@ -25,7 +25,6 @@ import android.os.Parcelable
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
@ -38,6 +37,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.AppStateHandler
|
||||
import im.vector.app.R
|
||||
import im.vector.app.SessionVariables
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.hideKeyboard
|
||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||
@ -521,11 +521,15 @@ class HomeActivity :
|
||||
override fun getMenuRes() = R.menu.home
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
menu.findItem(R.id.menu_home_init_sync_legacy).isVisible = vectorPreferences.developerMode()
|
||||
menu.findItem(R.id.menu_home_init_sync_optimized).isVisible = vectorPreferences.developerMode()
|
||||
menu.findItem(R.id.menu_home_init_sync_legacy)?.isVisible = vectorPreferences.developerMode()
|
||||
menu.findItem(R.id.menu_home_init_sync_optimized)?.isVisible = vectorPreferences.developerMode()
|
||||
return super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
return if (SessionVariables.optionsMenuShouldShow) super.onCreateOptionsMenu(menu) else false
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.menu_home_suggestion -> {
|
||||
|
@ -19,6 +19,7 @@ package im.vector.app.features.home
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -33,6 +34,7 @@ import com.google.android.material.badge.BadgeDrawable
|
||||
import im.vector.app.AppStateHandler
|
||||
import im.vector.app.R
|
||||
import im.vector.app.RoomGroupingMethod
|
||||
import im.vector.app.SessionVariables
|
||||
import im.vector.app.core.extensions.commitTransaction
|
||||
import im.vector.app.core.extensions.toMvRxBundle
|
||||
import im.vector.app.core.platform.OnBackPressed
|
||||
@ -106,10 +108,14 @@ class HomeDetailFragment @Inject constructor(
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
if (SessionVariables.optionsMenuShouldShow) super.onCreateOptionsMenu(menu, inflater) else Unit
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
withState(viewModel) { state ->
|
||||
val isRoomList = state.currentTab is HomeTab.RoomList
|
||||
menu.findItem(R.id.menu_home_mark_all_as_read).isVisible = isRoomList && hasUnreadRooms
|
||||
menu.findItem(R.id.menu_home_mark_all_as_read)?.isVisible = isRoomList && hasUnreadRooms
|
||||
}
|
||||
super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
@ -253,6 +259,8 @@ class HomeDetailFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun showModal() {
|
||||
SessionVariables.optionsMenuShouldShow = false
|
||||
invalidateOptionsMenu()
|
||||
views.spaceModalFragment.isVisible = true
|
||||
views.dimView.isVisible = true
|
||||
views.dimViewBottom.isVisible = true
|
||||
@ -264,6 +272,8 @@ class HomeDetailFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun hideModal() {
|
||||
SessionVariables.optionsMenuShouldShow = true
|
||||
invalidateOptionsMenu()
|
||||
views.spaceModalFragment.isVisible = false
|
||||
views.dimView.isVisible = false
|
||||
views.dimViewBottom.isVisible = false
|
||||
|
Loading…
Reference in New Issue
Block a user