Adds space settings

This commit is contained in:
ericdecanini 2022-05-21 09:55:18 +02:00
parent f54da187ca
commit 2d32d0da54
3 changed files with 55 additions and 1 deletions

View File

@ -57,6 +57,10 @@ import im.vector.app.features.popup.VerificationVectorAlert
import im.vector.app.features.settings.VectorLocale
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.settings.VectorSettingsActivity.Companion.EXTRA_DIRECT_ACCESS_SECURITY_PRIVACY_MANAGE_SESSIONS
import im.vector.app.features.spaces.SpaceExploreActivity
import im.vector.app.features.spaces.manage.ManageType
import im.vector.app.features.spaces.manage.SpaceManageActivity
import im.vector.app.features.spaces.share.ShareSpaceBottomSheet
import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.workers.signout.BannerState
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
@ -87,6 +91,8 @@ class HomeDetailFragment @Inject constructor(
private lateinit var sharedActionViewModel: HomeSharedActionViewModel
private lateinit var sharedCallActionViewModel: SharedKnownCallsViewModel
private var isInSpace = false
private var hasUnreadRooms = false
set(value) {
if (value != field) {
@ -103,6 +109,20 @@ class HomeDetailFragment @Inject constructor(
viewModel.handle(HomeDetailAction.MarkAllRoomsRead)
return true
}
R.id.menu_explore_rooms -> {
sharedActionViewModel.space.value?.let { startActivity(SpaceExploreActivity.newIntent(requireContext(), it.roomId)) }
return true
}
R.id.menu_invite_people -> {
activity?.let { activity ->
sharedActionViewModel.space.value?.let { ShareSpaceBottomSheet.show(activity.supportFragmentManager, it.roomId) }
}
return true
}
R.id.menu_add_rooms -> {
sharedActionViewModel.space.value?.let { startActivity(SpaceManageActivity.newIntent(requireActivity(), it.roomId, ManageType.AddRooms)) }
return true
}
}
return super.onOptionsItemSelected(item)
@ -117,6 +137,11 @@ class HomeDetailFragment @Inject constructor(
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_explore_rooms)?.isVisible = isInSpace
menu.findItem(R.id.menu_invite_people)?.isVisible = isInSpace
menu.findItem(R.id.menu_add_rooms)?.isVisible = isInSpace
super.onPrepareOptionsMenu(menu)
}
@ -390,12 +415,16 @@ class HomeDetailFragment @Inject constructor(
views.backButtonText.text = getString(R.string.all_chats)
views.toolbarChevron.rotation = 0F
if (spaceSummary == null) {
isInSpace = false
invalidateOptionsMenu()
views.backButtonLayout.isVisible = false
views.groupToolbarSpaceTitleView.isVisible = false
views.groupToolbarSpaceTitleView.text = getString(R.string.all_chats)
views.groupToolbarTitleView.text = getString(R.string.all_chats)
views.spaceAvatar.isVisible = false
} else {
isInSpace = true
invalidateOptionsMenu()
views.backButtonLayout.isVisible = true
views.groupToolbarSpaceTitleView.isVisible = true
views.groupToolbarSpaceTitleView.text = spaceSummary.displayName

View File

@ -7,26 +7,31 @@
android:id="@+id/menu_home_setting"
android:icon="@drawable/ic_settings_x"
android:title="@string/settings"
android:orderInCategory="100"
app:showAsAction="never" />
<item
android:id="@+id/menu_home_suggestion"
android:icon="@drawable/ic_material_bug_report"
android:orderInCategory="110"
android:title="@string/send_suggestion" />
<item
android:id="@+id/menu_home_report_bug"
android:icon="@drawable/ic_material_bug_report"
android:orderInCategory="120"
android:title="@string/send_bug_report" />
<item
android:id="@+id/menu_home_init_sync_legacy"
android:title="Do a legacy init sync"
android:orderInCategory="130"
tools:ignore="HardcodedText" />
<item
android:id="@+id/menu_home_init_sync_optimized"
android:title="Do an optimized init sync"
android:orderInCategory="140"
tools:ignore="HardcodedText" />
<item

View File

@ -1,9 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_home_mark_all_as_read"
android:icon="@drawable/ic_material_done"
android:orderInCategory="50"
android:title="@string/action_mark_all_as_read" />
<item
android:id="@+id/menu_explore_rooms"
android:title="@string/space_explore_activity_title"
android:orderInCategory="10"
app:showAsAction="never" />
<item
android:id="@+id/menu_invite_people"
android:title="@string/invite_people_menu"
android:orderInCategory="20"
app:showAsAction="never" />
<item
android:id="@+id/menu_add_rooms"
android:title="@string/space_add_child_title"
android:orderInCategory="30"
app:showAsAction="never" />
</menu>