From d3a1746475e374bc45f14980c130b96e5a0e66c3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 7 Dec 2021 16:56:09 +0100 Subject: [PATCH] Use id from existing views instead of "hard-coded" values And improve our extension --- changelog.d/4650.misc | 1 + .../root/src/app_package/Activity.kt.ftl | 4 +- .../settings/DebugPrivateSettingsActivity.kt | 3 +- .../im/vector/app/core/extensions/Activity.kt | 46 ++++++++++--------- .../preview/AttachmentsPreviewActivity.kt | 3 +- .../app/features/auth/ReAuthActivity.kt | 2 +- .../createdirect/CreateDirectRoomActivity.kt | 10 ++-- .../restore/KeysBackupRestoreActivity.kt | 8 ++-- .../settings/KeysBackupManageActivity.kt | 2 +- .../setup/KeysBackupSetupActivity.kt | 6 +-- .../quads/SharedSecureStorageActivity.kt | 19 ++++---- .../features/devtools/RoomDevToolActivity.kt | 6 +-- .../vector/app/features/home/HomeActivity.kt | 6 +-- .../home/room/detail/RoomDetailActivity.kt | 7 ++- .../home/room/detail/search/SearchActivity.kt | 3 +- .../room/filtered/FilteredRoomsActivity.kt | 3 +- .../invite/InviteUsersToRoomActivity.kt | 6 +-- .../app/features/login/LoginActivity.kt | 38 +++++++-------- .../app/features/login2/LoginActivity2.kt | 46 +++++++++---------- .../im/vector/app/features/pin/PinActivity.kt | 3 +- .../poll/create/CreatePollActivity.kt | 3 +- .../features/qrcode/QrCodeScannerActivity.kt | 3 +- .../roomdirectory/RoomDirectoryActivity.kt | 7 ++- .../createroom/CreateRoomActivity.kt | 3 +- .../roompreview/RoomPreviewActivity.kt | 5 +- .../RoomMemberProfileActivity.kt | 3 +- .../roomprofile/RoomProfileActivity.kt | 23 +++++----- .../settings/joinrule/RoomJoinRuleActivity.kt | 4 +- .../settings/VectorSettingsActivity.kt | 18 ++++---- .../features/share/IncomingShareActivity.kt | 3 +- .../signout/soft/SoftLogoutActivity.kt | 2 +- .../signout/soft/SoftLogoutActivity2.kt | 2 +- .../features/spaces/SpaceCreationActivity.kt | 2 +- .../features/spaces/SpaceExploreActivity.kt | 17 +++---- .../features/spaces/SpacePreviewActivity.kt | 24 ++++------ .../leave/SpaceLeaveAdvancedActivity.kt | 18 +++----- .../spaces/manage/SpaceManageActivity.kt | 46 +++++++++---------- .../spaces/people/SpacePeopleActivity.kt | 18 +++----- .../app/features/terms/ReviewTermsActivity.kt | 2 +- .../app/features/usercode/UserCodeActivity.kt | 2 +- .../app/features/widgets/WidgetActivity.kt | 2 +- 41 files changed, 196 insertions(+), 233 deletions(-) create mode 100644 changelog.d/4650.misc diff --git a/changelog.d/4650.misc b/changelog.d/4650.misc new file mode 100644 index 0000000000..3537441d51 --- /dev/null +++ b/changelog.d/4650.misc @@ -0,0 +1 @@ +Cleanup id ref. Use type views instead \ No newline at end of file diff --git a/tools/templates/ElementFeature/root/src/app_package/Activity.kt.ftl b/tools/templates/ElementFeature/root/src/app_package/Activity.kt.ftl index a4622d1d21..a5c097065e 100644 --- a/tools/templates/ElementFeature/root/src/app_package/Activity.kt.ftl +++ b/tools/templates/ElementFeature/root/src/app_package/Activity.kt.ftl @@ -35,9 +35,9 @@ class ${activityClass} : VectorBaseActivity(), ToolbarConfigurable { <#if createFragmentArgs> val fragmentArgs: ${fragmentArgsClass} = intent?.extras?.getParcelable(EXTRA_FRAGMENT_ARGS) ?: return - addFragment(R.id.simpleFragmentContainer, ${fragmentClass}::class.java, fragmentArgs) + addFragment(views.simpleFragmentContainer.id, ${fragmentClass}::class.java, fragmentArgs) <#else> - addFragment(R.id.simpleFragmentContainer, ${fragmentClass}::class.java) + addFragment(views.simpleFragmentContainer.id, ${fragmentClass}::class.java) } } diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt index 25a068e794..a28394e57d 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt @@ -17,7 +17,6 @@ package im.vector.app.features.debug.settings import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySimpleBinding @@ -30,7 +29,7 @@ class DebugPrivateSettingsActivity : VectorBaseActivity() override fun initUiAndData() { if (isFirstCreation()) { addFragment( - R.id.simpleFragmentContainer, + views.simpleFragmentContainer, DebugPrivateSettingsFragment::class.java ) } diff --git a/vector/src/main/java/im/vector/app/core/extensions/Activity.kt b/vector/src/main/java/im/vector/app/core/extensions/Activity.kt index da58498238..38e6ed017b 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/Activity.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/Activity.kt @@ -19,6 +19,9 @@ package im.vector.app.core.extensions import android.app.Activity import android.content.Intent import android.os.Parcelable +import android.view.View +import android.view.ViewGroup +import android.view.ViewParent import android.view.WindowManager import androidx.activity.ComponentActivity import androidx.activity.result.ActivityResult @@ -33,57 +36,56 @@ fun ComponentActivity.registerStartForActivityResult(onResult: (ActivityResult) } fun AppCompatActivity.addFragment( - frameId: Int, + container: ViewGroup, fragment: Fragment, - allowStateLoss: Boolean = false -) { - supportFragmentManager.commitTransaction(allowStateLoss) { add(frameId, fragment) } + allowStateLoss: Boolean = false) { + supportFragmentManager.commitTransaction(allowStateLoss) { add(container.id, fragment) } } fun AppCompatActivity.addFragment( - frameId: Int, + container: ViewGroup, fragmentClass: Class, params: Parcelable? = null, tag: String? = null, - allowStateLoss: Boolean = false -) { + allowStateLoss: Boolean = false) { supportFragmentManager.commitTransaction(allowStateLoss) { - add(frameId, fragmentClass, params.toMvRxBundle(), tag) + add(container.id, fragmentClass, params.toMvRxBundle(), tag) } } fun AppCompatActivity.replaceFragment( - frameId: Int, + container: ViewGroup, fragment: Fragment, tag: String? = null, - allowStateLoss: Boolean = false -) { - supportFragmentManager.commitTransaction(allowStateLoss) { replace(frameId, fragment, tag) } + allowStateLoss: Boolean = false) { + supportFragmentManager.commitTransaction(allowStateLoss) { + replace(container.id, fragment, tag) + } } fun AppCompatActivity.replaceFragment( - frameId: Int, + container: ViewGroup, fragmentClass: Class, params: Parcelable? = null, tag: String? = null, - allowStateLoss: Boolean = false -) { + allowStateLoss: Boolean = false) { supportFragmentManager.commitTransaction(allowStateLoss) { - replace(frameId, fragmentClass, params.toMvRxBundle(), tag) + replace(container.id, fragmentClass, params.toMvRxBundle(), tag) } } fun AppCompatActivity.addFragmentToBackstack( - frameId: Int, + container: ViewGroup, fragment: Fragment, tag: String? = null, - allowStateLoss: Boolean = false -) { - supportFragmentManager.commitTransaction(allowStateLoss) { replace(frameId, fragment).addToBackStack(tag) } + allowStateLoss: Boolean = false) { + supportFragmentManager.commitTransaction(allowStateLoss) { + replace(container.id, fragment).addToBackStack(tag) + } } fun AppCompatActivity.addFragmentToBackstack( - frameId: Int, + container: ViewGroup, fragmentClass: Class, params: Parcelable? = null, tag: String? = null, @@ -91,7 +93,7 @@ fun AppCompatActivity.addFragmentToBackstack( option: ((FragmentTransaction) -> Unit)? = null) { supportFragmentManager.commitTransaction(allowStateLoss) { option?.invoke(this) - replace(frameId, fragmentClass, params.toMvRxBundle(), tag).addToBackStack(tag) + replace(container.id, fragmentClass, params.toMvRxBundle(), tag).addToBackStack(tag) } } diff --git a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewActivity.kt b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewActivity.kt index 939dd9f11d..a52036011f 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewActivity.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewActivity.kt @@ -21,7 +21,6 @@ import android.content.Context import android.content.Intent import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity @@ -61,7 +60,7 @@ class AttachmentsPreviewActivity : VectorBaseActivity(), override fun initUiAndData() { if (isFirstCreation()) { val fragmentArgs: AttachmentsPreviewArgs = intent?.extras?.getParcelable(EXTRA_FRAGMENT_ARGS) ?: return - addFragment(R.id.simpleFragmentContainer, AttachmentsPreviewFragment::class.java, fragmentArgs) + addFragment(views.simpleFragmentContainer, AttachmentsPreviewFragment::class.java, fragmentArgs) } } diff --git a/vector/src/main/java/im/vector/app/features/auth/ReAuthActivity.kt b/vector/src/main/java/im/vector/app/features/auth/ReAuthActivity.kt index e3c9795b13..78c6cbb021 100644 --- a/vector/src/main/java/im/vector/app/features/auth/ReAuthActivity.kt +++ b/vector/src/main/java/im/vector/app/features/auth/ReAuthActivity.kt @@ -79,7 +79,7 @@ class ReAuthActivity : SimpleFragmentActivity() { // so we assume that after the user close the tab we return success and let caller retry the UIA flow :/ if (isFirstCreation()) { addFragment( - R.id.container, + views.container, PromptFragment::class.java ) } diff --git a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt index 3ff989da5a..3221a5bf66 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt @@ -80,7 +80,7 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { .launchIn(lifecycleScope) if (isFirstCreation()) { addFragment( - R.id.container, + views.container, UserListFragment::class.java, UserListFragmentArgs( title = getString(R.string.fab_menu_create_chat), @@ -95,20 +95,20 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { private fun openAddByQrCode() { if (checkPermissions(PERMISSIONS_FOR_TAKING_PHOTO, this, permissionCameraLauncher)) { - addFragment(R.id.container, CreateDirectRoomByQrCodeFragment::class.java) + addFragment(views.container, CreateDirectRoomByQrCodeFragment::class.java) } } private fun openPhoneBook() { // Check permission first if (checkPermissions(PERMISSIONS_FOR_MEMBERS_SEARCH, this, permissionReadContactLauncher)) { - addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) + addFragmentToBackstack(views.container, ContactsBookFragment::class.java) } } private val permissionReadContactLauncher = registerForPermissionsResult { allGranted, deniedPermanently -> if (allGranted) { - doOnPostResume { addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) } + doOnPostResume { addFragmentToBackstack(views.container, ContactsBookFragment::class.java) } } else if (deniedPermanently) { onPermissionDeniedSnackbar(R.string.permissions_denied_add_contact) } @@ -116,7 +116,7 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { private val permissionCameraLauncher = registerForPermissionsResult { allGranted, deniedPermanently -> if (allGranted) { - addFragment(R.id.container, CreateDirectRoomByQrCodeFragment::class.java) + addFragment(views.container, CreateDirectRoomByQrCodeFragment::class.java) } else if (deniedPermanently) { onPermissionDeniedSnackbar(R.string.permissions_denied_qr_code) } diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreActivity.kt index bdae975846..6e5d7f5fab 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreActivity.kt @@ -64,9 +64,9 @@ class KeysBackupRestoreActivity : SimpleFragmentActivity() { val isBackupCreatedFromPassphrase = viewModel.keyVersionResult.value?.getAuthDataAsMegolmBackupAuthData()?.privateKeySalt != null if (isBackupCreatedFromPassphrase) { - replaceFragment(R.id.container, KeysBackupRestoreFromPassphraseFragment::class.java) + replaceFragment(views.container, KeysBackupRestoreFromPassphraseFragment::class.java) } else { - replaceFragment(R.id.container, KeysBackupRestoreFromKeyFragment::class.java) + replaceFragment(views.container, KeysBackupRestoreFromKeyFragment::class.java) } } } @@ -91,13 +91,13 @@ class KeysBackupRestoreActivity : SimpleFragmentActivity() { viewModel.navigateEvent.observeEvent(this) { uxStateEvent -> when (uxStateEvent) { KeysBackupRestoreSharedViewModel.NAVIGATE_TO_RECOVER_WITH_KEY -> { - addFragmentToBackstack(R.id.container, KeysBackupRestoreFromKeyFragment::class.java, allowStateLoss = true) + addFragmentToBackstack(views.container, KeysBackupRestoreFromKeyFragment::class.java, allowStateLoss = true) } KeysBackupRestoreSharedViewModel.NAVIGATE_TO_SUCCESS -> { viewModel.keyVersionResult.value?.version?.let { KeysBackupBanner.onRecoverDoneForVersion(this, it) } - replaceFragment(R.id.container, KeysBackupRestoreSuccessFragment::class.java, allowStateLoss = true) + replaceFragment(views.container, KeysBackupRestoreSuccessFragment::class.java, allowStateLoss = true) } KeysBackupRestoreSharedViewModel.NAVIGATE_TO_4S -> { launch4SActivity() diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupManageActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupManageActivity.kt index 2b666e9cf8..13df109dd5 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupManageActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupManageActivity.kt @@ -44,7 +44,7 @@ class KeysBackupManageActivity : SimpleFragmentActivity() { override fun initUiAndData() { super.initUiAndData() if (supportFragmentManager.fragments.isEmpty()) { - replaceFragment(R.id.container, KeysBackupSettingsFragment::class.java) + replaceFragment(views.container, KeysBackupSettingsFragment::class.java) viewModel.handle(KeyBackupSettingsAction.Init) } diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupActivity.kt index 0f7c09ca16..3d2ef648ff 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupActivity.kt @@ -54,7 +54,7 @@ class KeysBackupSetupActivity : SimpleFragmentActivity() { override fun initUiAndData() { super.initUiAndData() if (isFirstCreation()) { - replaceFragment(R.id.container, KeysBackupSetupStep1Fragment::class.java) + replaceFragment(views.container, KeysBackupSetupStep1Fragment::class.java) } viewModel = viewModelProvider.get(KeysBackupSetupSharedViewModel::class.java) @@ -80,11 +80,11 @@ class KeysBackupSetupActivity : SimpleFragmentActivity() { when (uxStateEvent) { KeysBackupSetupSharedViewModel.NAVIGATE_TO_STEP_2 -> { supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE) - replaceFragment(R.id.container, KeysBackupSetupStep2Fragment::class.java) + replaceFragment(views.container, KeysBackupSetupStep2Fragment::class.java) } KeysBackupSetupSharedViewModel.NAVIGATE_TO_STEP_3 -> { supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE) - replaceFragment(R.id.container, KeysBackupSetupStep3Fragment::class.java) + replaceFragment(views.container, KeysBackupSetupStep3Fragment::class.java) } KeysBackupSetupSharedViewModel.NAVIGATE_FINISH -> { val resultIntent = Intent() diff --git a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt index bb854aca26..b317ac95ad 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt @@ -31,7 +31,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R import im.vector.app.core.error.ErrorFormatter -import im.vector.app.core.extensions.commitTransaction +import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.features.crypto.recover.SetupMode @@ -84,7 +84,7 @@ class SharedSecureStorageActivity : SharedSecureStorageViewState.Step.ResetAll -> SharedSecuredStorageResetAllFragment::class } - showFragment(fragment, Bundle()) + showFragment(fragment) } private fun observeViewEvents(it: SharedSecureStorageViewEvent?) { @@ -131,15 +131,14 @@ class SharedSecureStorageActivity : } } - private fun showFragment(fragmentClass: KClass, bundle: Bundle) { + private fun showFragment(fragmentClass: KClass) { if (supportFragmentManager.findFragmentByTag(fragmentClass.simpleName) == null) { - supportFragmentManager.commitTransaction { - replace(R.id.container, - fragmentClass.java, - bundle, - fragmentClass.simpleName - ) - } + replaceFragment( + views.container, + fragmentClass.java, + null, + fragmentClass.simpleName + ) } } diff --git a/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolActivity.kt b/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolActivity.kt index 099fa2bdb9..57d3ccc16b 100644 --- a/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolActivity.kt +++ b/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolActivity.kt @@ -91,7 +91,7 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac val classJava = RoomDevToolFragment::class.java val tag = classJava.name if (supportFragmentManager.findFragmentByTag(tag) == null) { - replaceFragment(R.id.container, RoomDevToolFragment::class.java) + replaceFragment(views.container, RoomDevToolFragment::class.java) } else { supportFragmentManager.popBackStack() } @@ -155,14 +155,14 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac if (supportFragmentManager.findFragmentByTag(tag) == null) { supportFragmentManager.beginTransaction() .setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out) - .replace(R.id.container, fragment, tag) + .replace(views.container.id, fragment, tag) .addToBackStack(tag) .commit() } else { if (!supportFragmentManager.popBackStackImmediate(tag, 0)) { supportFragmentManager.beginTransaction() .setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out) - .replace(R.id.container, fragment, tag) + .replace(views.container.id, fragment, tag) .addToBackStack(tag) .commit() } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index 16c0655d85..04f3f7cc9c 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -175,8 +175,8 @@ class HomeActivity : sharedActionViewModel = viewModelProvider.get(HomeSharedActionViewModel::class.java) views.drawerLayout.addDrawerListener(drawerListener) if (isFirstCreation()) { - replaceFragment(R.id.homeDetailFragmentContainer, HomeDetailFragment::class.java) - replaceFragment(R.id.homeDrawerFragmentContainer, HomeDrawerFragment::class.java) + replaceFragment(views.homeDetailFragmentContainer, HomeDetailFragment::class.java) + replaceFragment(views.homeDrawerFragmentContainer, HomeDrawerFragment::class.java) } sharedActionViewModel @@ -192,7 +192,7 @@ class HomeActivity : // When switching from space to group or group to space, we need to reload the fragment // To be removed when dropping legacy groups if (sharedAction.clearFragment) { - replaceFragment(R.id.homeDetailFragmentContainer, HomeDetailFragment::class.java, allowStateLoss = true) + replaceFragment(views.homeDetailFragmentContainer, HomeDetailFragment::class.java, allowStateLoss = true) } else { // nop } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt index 684c0010a5..05dbd724d1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt @@ -29,7 +29,6 @@ import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.viewModel import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.endKeepScreenOn import im.vector.app.core.extensions.hideKeyboard import im.vector.app.core.extensions.keepScreenOn @@ -108,8 +107,8 @@ class RoomDetailActivity : currentRoomId = roomDetailArgs.roomId if (isFirstCreation()) { - replaceFragment(R.id.roomDetailContainer, RoomDetailFragment::class.java, roomDetailArgs) - replaceFragment(R.id.roomDetailDrawerContainer, BreadcrumbsFragment::class.java) + replaceFragment(views.roomDetailContainer, RoomDetailFragment::class.java, roomDetailArgs) + replaceFragment(views.roomDetailDrawerContainer, BreadcrumbsFragment::class.java) } sharedActionViewModel = viewModelProvider.get(RoomDetailSharedActionViewModel::class.java) @@ -146,7 +145,7 @@ class RoomDetailActivity : if (currentRoomId != switchToRoom.roomId) { currentRoomId = switchToRoom.roomId requireActiveMembershipViewModel.handle(RequireActiveMembershipAction.ChangeRoom(switchToRoom.roomId)) - replaceFragment(R.id.roomDetailContainer, RoomDetailFragment::class.java, RoomDetailArgs(switchToRoom.roomId)) + replaceFragment(views.roomDetailContainer, RoomDetailFragment::class.java, RoomDetailArgs(switchToRoom.roomId)) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchActivity.kt index eea62b0907..bc1dc088df 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchActivity.kt @@ -22,7 +22,6 @@ import android.os.Bundle import androidx.appcompat.widget.SearchView import com.airbnb.mvrx.Mavericks import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySearchBinding @@ -47,7 +46,7 @@ class SearchActivity : VectorBaseActivity() { override fun initUiAndData() { if (isFirstCreation()) { val fragmentArgs: SearchArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return - addFragment(R.id.searchFragmentContainer, SearchFragment::class.java, fragmentArgs, FRAGMENT_TAG) + addFragment(views.searchFragmentContainer, SearchFragment::class.java, fragmentArgs, FRAGMENT_TAG) } views.searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(query: String): Boolean { diff --git a/vector/src/main/java/im/vector/app/features/home/room/filtered/FilteredRoomsActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/filtered/FilteredRoomsActivity.kt index 18618099bd..5f8ccc794a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/filtered/FilteredRoomsActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/filtered/FilteredRoomsActivity.kt @@ -21,7 +21,6 @@ import android.content.Intent import android.os.Bundle import androidx.appcompat.widget.SearchView import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityFilteredRoomsBinding @@ -46,7 +45,7 @@ class FilteredRoomsActivity : VectorBaseActivity() configureToolbar(views.filteredRoomsToolbar) if (isFirstCreation()) { val params = RoomListParams(RoomListDisplayMode.FILTERED) - replaceFragment(R.id.filteredRoomsFragmentContainer, RoomListFragment::class.java, params, FRAGMENT_TAG) + replaceFragment(views.filteredRoomsFragmentContainer, RoomListFragment::class.java, params, FRAGMENT_TAG) } views.filteredRoomsSearchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(query: String): Boolean { diff --git a/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt b/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt index 1bf1c12a48..48a70fb164 100644 --- a/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt +++ b/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt @@ -81,7 +81,7 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() { .launchIn(lifecycleScope) if (isFirstCreation()) { addFragment( - R.id.container, + views.container, UserListFragment::class.java, UserListFragmentArgs( title = getString(R.string.invite_users_to_room_title), @@ -104,13 +104,13 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() { private fun openPhoneBook() { // Check permission first if (checkPermissions(PERMISSIONS_FOR_MEMBERS_SEARCH, this, permissionContactLauncher)) { - addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) + addFragmentToBackstack(views.container, ContactsBookFragment::class.java) } } private val permissionContactLauncher = registerForPermissionsResult { allGranted, deniedPermanently -> if (allGranted) { - doOnPostResume { addFragmentToBackstack(R.id.container, ContactsBookFragment::class.java) } + doOnPostResume { addFragmentToBackstack(views.container, ContactsBookFragment::class.java) } } else if (deniedPermanently) { onPermissionDeniedSnackbar(R.string.permissions_denied_add_contact) } diff --git a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt index bbad40ce78..c46dca27b3 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt @@ -64,7 +64,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo private val popExitAnim = R.anim.exit_fade_out private val topFragment: Fragment? - get() = supportFragmentManager.findFragmentById(R.id.loginFragmentContainer) + get() = supportFragmentManager.findFragmentById(views.loginFragmentContainer.id) private val commonOption: (FragmentTransaction) -> Unit = { ft -> // Find the loginLogo on the current Fragment, this should not return null @@ -100,7 +100,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo } protected open fun addFirstFragment() { - addFragment(R.id.loginFragmentContainer, LoginSplashFragment::class.java) + addFragment(views.loginFragmentContainer, LoginSplashFragment::class.java) } private fun handleLoginViewEvents(loginViewEvents: LoginViewEvents) { @@ -118,7 +118,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo // First ask for login and password // I add a tag to indicate that this fragment is a registration stage. // This way it will be automatically popped in when starting the next registration stage - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginFragment::class.java, tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption @@ -135,7 +135,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo Unit } is LoginViewEvents.OpenServerSelection -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginServerSelectionFragment::class.java, option = { ft -> findViewById(R.id.loginSplashLogo)?.let { ft.addSharedElement(it, ViewCompat.getTransitionName(it) ?: "") } @@ -149,23 +149,23 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo is LoginViewEvents.OnServerSelectionDone -> onServerSelectionDone(loginViewEvents) is LoginViewEvents.OnSignModeSelected -> onSignModeSelected(loginViewEvents) is LoginViewEvents.OnLoginFlowRetrieved -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginSignUpSignInSelectionFragment::class.java, option = commonOption) is LoginViewEvents.OnWebLoginError -> onWebLoginError(loginViewEvents) is LoginViewEvents.OnForgetPasswordClicked -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginResetPasswordFragment::class.java, option = commonOption) is LoginViewEvents.OnResetPasswordSendThreePidDone -> { supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginResetPasswordMailConfirmationFragment::class.java, option = commonOption) } is LoginViewEvents.OnResetPasswordMailConfirmationSuccess -> { supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginResetPasswordSuccessFragment::class.java, option = commonOption) } @@ -176,7 +176,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo is LoginViewEvents.OnSendEmailSuccess -> { // Pop the enter email Fragment supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginWaitForEmailFragment::class.java, LoginWaitForEmailFragmentArgument(loginViewEvents.email), tag = FRAGMENT_REGISTRATION_STAGE_TAG, @@ -185,7 +185,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo is LoginViewEvents.OnSendMsisdnSuccess -> { // Pop the enter Msisdn Fragment supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginGenericTextInputFormFragment::class.java, LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.ConfirmMsisdn, true, loginViewEvents.msisdn), tag = FRAGMENT_REGISTRATION_STAGE_TAG, @@ -229,7 +229,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo when (loginViewEvents.serverType) { ServerType.MatrixOrg -> Unit // In this case, we wait for the login flow ServerType.EMS, - ServerType.Other -> addFragmentToBackstack(R.id.loginFragmentContainer, + ServerType.Other -> addFragmentToBackstack(views.loginFragmentContainer, LoginServerUrlFormFragment::class.java, option = commonOption) ServerType.Unknown -> Unit /* Should not happen */ @@ -249,14 +249,14 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo LoginMode.Unknown, is LoginMode.Sso -> error("Developer error") is LoginMode.SsoAndPassword, - LoginMode.Password -> addFragmentToBackstack(R.id.loginFragmentContainer, + LoginMode.Password -> addFragmentToBackstack(views.loginFragmentContainer, LoginFragment::class.java, tag = FRAGMENT_LOGIN_TAG, option = commonOption) LoginMode.Unsupported -> onLoginModeNotSupported(state.loginModeSupportedTypes) }.exhaustive } - SignMode.SignInWithMatrixId -> addFragmentToBackstack(R.id.loginFragmentContainer, + SignMode.SignInWithMatrixId -> addFragmentToBackstack(views.loginFragmentContainer, LoginFragment::class.java, tag = FRAGMENT_LOGIN_TAG, option = commonOption) @@ -279,7 +279,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo .setTitle(R.string.app_name) .setMessage(getString(R.string.login_registration_not_supported)) .setPositiveButton(R.string.yes) { _, _ -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginWebFragment::class.java, option = commonOption) } @@ -292,7 +292,7 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo .setTitle(R.string.app_name) .setMessage(getString(R.string.login_mode_not_supported, supportedTypes.joinToString { "'$it'" })) .setPositiveButton(R.string.yes) { _, _ -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginWebFragment::class.java, option = commonOption) } @@ -322,22 +322,22 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) when (stage) { - is Stage.ReCaptcha -> addFragmentToBackstack(R.id.loginFragmentContainer, + is Stage.ReCaptcha -> addFragmentToBackstack(views.loginFragmentContainer, LoginCaptchaFragment::class.java, LoginCaptchaFragmentArgument(stage.publicKey), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) - is Stage.Email -> addFragmentToBackstack(R.id.loginFragmentContainer, + is Stage.Email -> addFragmentToBackstack(views.loginFragmentContainer, LoginGenericTextInputFormFragment::class.java, LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetEmail, stage.mandatory), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) - is Stage.Msisdn -> addFragmentToBackstack(R.id.loginFragmentContainer, + is Stage.Msisdn -> addFragmentToBackstack(views.loginFragmentContainer, LoginGenericTextInputFormFragment::class.java, LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetMsisdn, stage.mandatory), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) - is Stage.Terms -> addFragmentToBackstack(R.id.loginFragmentContainer, + is Stage.Terms -> addFragmentToBackstack(views.loginFragmentContainer, LoginTermsFragment::class.java, LoginTermsFragmentArgument(stage.policies.toLocalizedLoginTerms(getString(R.string.resources_language))), tag = FRAGMENT_REGISTRATION_STAGE_TAG, diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt index eea480864a..ce9d9f762e 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt @@ -71,7 +71,7 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC private val popExitAnim = R.anim.exit_fade_out private val topFragment: Fragment? - get() = supportFragmentManager.findFragmentById(R.id.loginFragmentContainer) + get() = supportFragmentManager.findFragmentById(views.loginFragmentContainer.id) private val commonOption: (FragmentTransaction) -> Unit = { ft -> // Find the loginLogo on the current Fragment, this should not return null @@ -108,7 +108,7 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC } protected open fun addFirstFragment() { - addFragment(R.id.loginFragmentContainer, LoginSplashSignUpSignInSelectionFragment2::class.java) + addFragment(views.loginFragmentContainer, LoginSplashSignUpSignInSelectionFragment2::class.java) } private fun handleLoginViewEvents(event: LoginViewEvents2) { @@ -127,7 +127,7 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC // First ask for login and password // I add a tag to indicate that this fragment is a registration stage. // This way it will be automatically popped in when starting the next registration stage - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginFragment2::class.java, tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption @@ -146,7 +146,7 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC Unit } is LoginViewEvents2.OpenServerSelection -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginServerSelectionFragment2::class.java, option = { ft -> findViewById(R.id.loginSplashLogo)?.let { ft.addSharedElement(it, ViewCompat.getTransitionName(it) ?: "") } @@ -158,12 +158,12 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC // ft.setCustomAnimations(enterAnim, exitAnim, popEnterAnim, popExitAnim) }) is LoginViewEvents2.OpenHomeServerUrlFormScreen -> { - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginServerUrlFormFragment2::class.java, option = commonOption) } is LoginViewEvents2.OpenSignInEnterIdentifierScreen -> { - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginFragmentSigninUsername2::class.java, option = { ft -> findViewById(R.id.loginSplashLogo)?.let { ft.addSharedElement(it, ViewCompat.getTransitionName(it) ?: "") } @@ -176,24 +176,24 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC }) } is LoginViewEvents2.OpenSsoOnlyScreen -> { - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginSsoOnlyFragment2::class.java, option = commonOption) } is LoginViewEvents2.OnWebLoginError -> onWebLoginError(event) is LoginViewEvents2.OpenResetPasswordScreen -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginResetPasswordFragment2::class.java, option = commonOption) is LoginViewEvents2.OnResetPasswordSendThreePidDone -> { supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginResetPasswordMailConfirmationFragment2::class.java, option = commonOption) } is LoginViewEvents2.OnResetPasswordMailConfirmationSuccess -> { supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginResetPasswordSuccessFragment2::class.java, option = commonOption) } @@ -202,37 +202,37 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) } is LoginViewEvents2.OnSendEmailSuccess -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginWaitForEmailFragment2::class.java, LoginWaitForEmailFragmentArgument(event.email), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) is LoginViewEvents2.OpenSigninPasswordScreen -> { - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginFragmentSigninPassword2::class.java, tag = FRAGMENT_LOGIN_TAG, option = commonOption) } is LoginViewEvents2.OpenSignupPasswordScreen -> { - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginFragmentSignupPassword2::class.java, tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) } is LoginViewEvents2.OpenSignUpChooseUsernameScreen -> { - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginFragmentSignupUsername2::class.java, tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) } is LoginViewEvents2.OpenSignInWithAnythingScreen -> { - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginFragmentToAny2::class.java, tag = FRAGMENT_LOGIN_TAG, option = commonOption) } is LoginViewEvents2.OnSendMsisdnSuccess -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginGenericTextInputFormFragment2::class.java, LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.ConfirmMsisdn, true, event.msisdn), tag = FRAGMENT_REGISTRATION_STAGE_TAG, @@ -257,7 +257,7 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC if (event.newAccount) { // Propose to set avatar and display name // Back on this Fragment will finish the Activity - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, AccountCreatedFragment::class.java, option = commonOption) } else { @@ -312,7 +312,7 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC .setTitle(R.string.app_name) .setMessage(getString(R.string.login_registration_not_supported)) .setPositiveButton(R.string.yes) { _, _ -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginWebFragment2::class.java, option = commonOption) } @@ -325,7 +325,7 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC .setTitle(R.string.app_name) .setMessage(getString(R.string.login_mode_not_supported, supportedTypes.joinToString { "'$it'" })) .setPositiveButton(R.string.yes) { _, _ -> - addFragmentToBackstack(R.id.loginFragmentContainer, + addFragmentToBackstack(views.loginFragmentContainer, LoginWebFragment2::class.java, option = commonOption) } @@ -355,22 +355,22 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) when (stage) { - is Stage.ReCaptcha -> addFragmentToBackstack(R.id.loginFragmentContainer, + is Stage.ReCaptcha -> addFragmentToBackstack(views.loginFragmentContainer, LoginCaptchaFragment2::class.java, LoginCaptchaFragmentArgument(stage.publicKey), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) - is Stage.Email -> addFragmentToBackstack(R.id.loginFragmentContainer, + is Stage.Email -> addFragmentToBackstack(views.loginFragmentContainer, LoginGenericTextInputFormFragment2::class.java, LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetEmail, stage.mandatory), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) - is Stage.Msisdn -> addFragmentToBackstack(R.id.loginFragmentContainer, + is Stage.Msisdn -> addFragmentToBackstack(views.loginFragmentContainer, LoginGenericTextInputFormFragment2::class.java, LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetMsisdn, stage.mandatory), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption) - is Stage.Terms -> addFragmentToBackstack(R.id.loginFragmentContainer, + is Stage.Terms -> addFragmentToBackstack(views.loginFragmentContainer, LoginTermsFragment2::class.java, LoginTermsFragmentArgument(stage.policies.toLocalizedLoginTerms(getString(R.string.resources_language))), tag = FRAGMENT_REGISTRATION_STAGE_TAG, diff --git a/vector/src/main/java/im/vector/app/features/pin/PinActivity.kt b/vector/src/main/java/im/vector/app/features/pin/PinActivity.kt index 0978f0d5b5..ef79799074 100644 --- a/vector/src/main/java/im/vector/app/features/pin/PinActivity.kt +++ b/vector/src/main/java/im/vector/app/features/pin/PinActivity.kt @@ -21,7 +21,6 @@ import android.content.Intent import com.airbnb.mvrx.Mavericks import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity @@ -45,7 +44,7 @@ class PinActivity : VectorBaseActivity(), ToolbarConfigur override fun initUiAndData() { if (isFirstCreation()) { val fragmentArgs: PinArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return - addFragment(R.id.simpleFragmentContainer, PinFragment::class.java, fragmentArgs) + addFragment(views.simpleFragmentContainer, PinFragment::class.java, fragmentArgs) } } diff --git a/vector/src/main/java/im/vector/app/features/poll/create/CreatePollActivity.kt b/vector/src/main/java/im/vector/app/features/poll/create/CreatePollActivity.kt index fc830ddae9..5a93e19b1a 100644 --- a/vector/src/main/java/im/vector/app/features/poll/create/CreatePollActivity.kt +++ b/vector/src/main/java/im/vector/app/features/poll/create/CreatePollActivity.kt @@ -21,7 +21,6 @@ import android.content.Intent import android.os.Bundle import android.view.View import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.SimpleFragmentActivity @@ -36,7 +35,7 @@ class CreatePollActivity : SimpleFragmentActivity() { if (isFirstCreation()) { addFragment( - R.id.container, + views.container, CreatePollFragment::class.java, createPollArgs ) diff --git a/vector/src/main/java/im/vector/app/features/qrcode/QrCodeScannerActivity.kt b/vector/src/main/java/im/vector/app/features/qrcode/QrCodeScannerActivity.kt index 7fb2f1f254..d347bc0250 100644 --- a/vector/src/main/java/im/vector/app/features/qrcode/QrCodeScannerActivity.kt +++ b/vector/src/main/java/im/vector/app/features/qrcode/QrCodeScannerActivity.kt @@ -24,7 +24,6 @@ import com.google.zxing.BarcodeFormat import com.google.zxing.Result import com.google.zxing.ResultMetadataType import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySimpleBinding @@ -39,7 +38,7 @@ class QrCodeScannerActivity : VectorBaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (isFirstCreation()) { - replaceFragment(R.id.simpleFragmentContainer, QrCodeScannerFragment::class.java) + replaceFragment(views.simpleFragmentContainer, QrCodeScannerFragment::class.java) } } diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/RoomDirectoryActivity.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/RoomDirectoryActivity.kt index 82dc31c4d6..a52732d790 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/RoomDirectoryActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/RoomDirectoryActivity.kt @@ -23,7 +23,6 @@ import androidx.lifecycle.lifecycleScope import com.airbnb.mvrx.viewModel import com.airbnb.mvrx.withState import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragmentToBackstack import im.vector.app.core.extensions.popBackstack @@ -66,14 +65,14 @@ class RoomDirectoryActivity : VectorBaseActivity(), Matri // Transmit the filter to the CreateRoomFragment withState(roomDirectoryViewModel) { addFragmentToBackstack( - R.id.simpleFragmentContainer, + views.simpleFragmentContainer, CreateRoomFragment::class.java, CreateRoomArgs(it.currentFilter) ) } } is RoomDirectorySharedAction.ChangeProtocol -> - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomDirectoryPickerFragment::class.java) + addFragmentToBackstack(views.simpleFragmentContainer, RoomDirectoryPickerFragment::class.java) is RoomDirectorySharedAction.Close -> finish() } } @@ -82,7 +81,7 @@ class RoomDirectoryActivity : VectorBaseActivity(), Matri override fun initUiAndData() { if (isFirstCreation()) { - addFragment(R.id.simpleFragmentContainer, PublicRoomsFragment::class.java) + addFragment(views.simpleFragmentContainer, PublicRoomsFragment::class.java) } } diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomActivity.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomActivity.kt index b3a21dadb9..e9762d09d3 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/createroom/CreateRoomActivity.kt @@ -22,7 +22,6 @@ import android.os.Bundle import androidx.lifecycle.lifecycleScope import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity @@ -51,7 +50,7 @@ class CreateRoomActivity : VectorBaseActivity(), ToolbarC override fun initUiAndData() { if (isFirstCreation()) { addFragment( - R.id.simpleFragmentContainer, + views.simpleFragmentContainer, CreateRoomFragment::class.java, CreateRoomArgs( intent?.getStringExtra(INITIAL_NAME) ?: "", diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt index 86bfdb79cd..394d738b26 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewActivity.kt @@ -21,7 +21,6 @@ import android.content.Intent import android.os.Parcelable import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity @@ -94,9 +93,9 @@ class RoomPreviewActivity : VectorBaseActivity(), Toolbar // TODO Room preview: Note: M does not recommend to use /events anymore, so for now we just display the room preview // TODO the same way if it was not world readable Timber.d("just display the room preview the same way if it was not world readable") - addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args) + addFragment(views.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args) } else { - addFragment(R.id.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args) + addFragment(views.simpleFragmentContainer, RoomPreviewNoPreviewFragment::class.java, args) } } } diff --git a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileActivity.kt b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileActivity.kt index c563f6b855..2d925270b3 100644 --- a/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roommemberprofile/RoomMemberProfileActivity.kt @@ -24,7 +24,6 @@ import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.viewModel import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity @@ -54,7 +53,7 @@ class RoomMemberProfileActivity : override fun initUiAndData() { if (isFirstCreation()) { val fragmentArgs: RoomMemberProfileArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return - addFragment(R.id.simpleFragmentContainer, RoomMemberProfileFragment::class.java, fragmentArgs) + addFragment(views.simpleFragmentContainer, RoomMemberProfileFragment::class.java, fragmentArgs) } requireActiveMembershipViewModel.observeViewEvents { diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt index c06a2927c5..7b92007692 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileActivity.kt @@ -25,7 +25,6 @@ import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.viewModel import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragmentToBackstack import im.vector.app.core.extensions.exhaustive @@ -86,13 +85,13 @@ class RoomProfileActivity : if (isFirstCreation()) { when (intent?.extras?.getInt(EXTRA_DIRECT_ACCESS, EXTRA_DIRECT_ACCESS_ROOM_ROOT)) { EXTRA_DIRECT_ACCESS_ROOM_SETTINGS -> { - addFragment(R.id.simpleFragmentContainer, RoomProfileFragment::class.java, roomProfileArgs) - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomSettingsFragment::class.java, roomProfileArgs) + addFragment(views.simpleFragmentContainer, RoomProfileFragment::class.java, roomProfileArgs) + addFragmentToBackstack(views.simpleFragmentContainer, RoomSettingsFragment::class.java, roomProfileArgs) } EXTRA_DIRECT_ACCESS_ROOM_MEMBERS -> { - addFragment(R.id.simpleFragmentContainer, RoomMemberListFragment::class.java, roomProfileArgs) + addFragment(views.simpleFragmentContainer, RoomMemberListFragment::class.java, roomProfileArgs) } - else -> addFragment(R.id.simpleFragmentContainer, RoomProfileFragment::class.java, roomProfileArgs) + else -> addFragment(views.simpleFragmentContainer, RoomProfileFragment::class.java, roomProfileArgs) } } sharedActionViewModel @@ -132,31 +131,31 @@ class RoomProfileActivity : } private fun openRoomUploads() { - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomUploadsFragment::class.java, roomProfileArgs) + addFragmentToBackstack(views.simpleFragmentContainer, RoomUploadsFragment::class.java, roomProfileArgs) } private fun openRoomSettings() { - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomSettingsFragment::class.java, roomProfileArgs) + addFragmentToBackstack(views.simpleFragmentContainer, RoomSettingsFragment::class.java, roomProfileArgs) } private fun openRoomAlias() { - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomAliasFragment::class.java, roomProfileArgs) + addFragmentToBackstack(views.simpleFragmentContainer, RoomAliasFragment::class.java, roomProfileArgs) } private fun openRoomPermissions() { - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomPermissionsFragment::class.java, roomProfileArgs) + addFragmentToBackstack(views.simpleFragmentContainer, RoomPermissionsFragment::class.java, roomProfileArgs) } private fun openRoomMembers() { - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomMemberListFragment::class.java, roomProfileArgs) + addFragmentToBackstack(views.simpleFragmentContainer, RoomMemberListFragment::class.java, roomProfileArgs) } private fun openBannedRoomMembers() { - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomBannedMemberListFragment::class.java, roomProfileArgs) + addFragmentToBackstack(views.simpleFragmentContainer, RoomBannedMemberListFragment::class.java, roomProfileArgs) } private fun openRoomNotificationSettings() { - addFragmentToBackstack(R.id.simpleFragmentContainer, RoomNotificationSettingsFragment::class.java, roomProfileArgs) + addFragmentToBackstack(views.simpleFragmentContainer, RoomNotificationSettingsFragment::class.java, roomProfileArgs) } override fun configure(toolbar: MaterialToolbar) { diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/joinrule/RoomJoinRuleActivity.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/joinrule/RoomJoinRuleActivity.kt index c826fe5e64..7099d30862 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/joinrule/RoomJoinRuleActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/joinrule/RoomJoinRuleActivity.kt @@ -61,7 +61,7 @@ class RoomJoinRuleActivity : VectorBaseActivity() { roomProfileArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return if (isFirstCreation()) { addFragment( - R.id.simpleFragmentContainer, + views.simpleFragmentContainer, RoomJoinRuleFragment::class.java, roomProfileArgs ) @@ -121,7 +121,7 @@ class RoomJoinRuleActivity : VectorBaseActivity() { supportFragmentManager.commitTransaction { setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out) val tag = RoomJoinRuleChooseRestrictedFragment::class.simpleName - replace(R.id.simpleFragmentContainer, + replace(views.simpleFragmentContainer.id, RoomJoinRuleChooseRestrictedFragment::class.java, this@RoomJoinRuleActivity.roomProfileArgs.toMvRxBundle(), tag diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsActivity.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsActivity.kt index 399379ed97..f502da24ff 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsActivity.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsActivity.kt @@ -70,25 +70,25 @@ class VectorSettingsActivity : VectorBaseActivity when (val payload = readPayload(SettingsActivityPayload.Root)) { SettingsActivityPayload.General -> - replaceFragment(R.id.vector_settings_page, VectorSettingsGeneralFragment::class.java, null, FRAGMENT_TAG) + replaceFragment(views.vectorSettingsPage, VectorSettingsGeneralFragment::class.java, null, FRAGMENT_TAG) SettingsActivityPayload.AdvancedSettings -> - replaceFragment(R.id.vector_settings_page, VectorSettingsAdvancedSettingsFragment::class.java, null, FRAGMENT_TAG) + replaceFragment(views.vectorSettingsPage, VectorSettingsAdvancedSettingsFragment::class.java, null, FRAGMENT_TAG) SettingsActivityPayload.SecurityPrivacy -> - replaceFragment(R.id.vector_settings_page, VectorSettingsSecurityPrivacyFragment::class.java, null, FRAGMENT_TAG) + replaceFragment(views.vectorSettingsPage, VectorSettingsSecurityPrivacyFragment::class.java, null, FRAGMENT_TAG) SettingsActivityPayload.SecurityPrivacyManageSessions -> - replaceFragment(R.id.vector_settings_page, + replaceFragment(views.vectorSettingsPage, VectorSettingsDevicesFragment::class.java, null, FRAGMENT_TAG) SettingsActivityPayload.Notifications -> { requestHighlightPreferenceKeyOnResume(VectorPreferences.SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY) - replaceFragment(R.id.vector_settings_page, VectorSettingsNotificationPreferenceFragment::class.java, null, FRAGMENT_TAG) + replaceFragment(views.vectorSettingsPage, VectorSettingsNotificationPreferenceFragment::class.java, null, FRAGMENT_TAG) } is SettingsActivityPayload.DiscoverySettings -> { - replaceFragment(R.id.vector_settings_page, DiscoverySettingsFragment::class.java, payload, FRAGMENT_TAG) + replaceFragment(views.vectorSettingsPage, DiscoverySettingsFragment::class.java, payload, FRAGMENT_TAG) } else -> - replaceFragment(R.id.vector_settings_page, VectorSettingsRootFragment::class.java, null, FRAGMENT_TAG) + replaceFragment(views.vectorSettingsPage, VectorSettingsRootFragment::class.java, null, FRAGMENT_TAG) } } @@ -123,7 +123,7 @@ class VectorSettingsActivity : VectorBaseActivity // Replace the existing Fragment with the new Fragment supportFragmentManager.beginTransaction() .setCustomAnimations(R.anim.right_in, R.anim.fade_out, R.anim.fade_in, R.anim.right_out) - .replace(R.id.vector_settings_page, oFragment, pref.title.toString()) + .replace(views.vectorSettingsPage.id, oFragment, pref.title.toString()) .addToBackStack(null) .commit() return true @@ -154,7 +154,7 @@ class VectorSettingsActivity : VectorBaseActivity fun navigateTo(fragmentClass: Class, arguments: Bundle? = null) { supportFragmentManager.beginTransaction() .setCustomAnimations(R.anim.right_in, R.anim.fade_out, R.anim.fade_in, R.anim.right_out) - .replace(R.id.vector_settings_page, fragmentClass, arguments) + .replace(views.vectorSettingsPage.id, fragmentClass, arguments) .addToBackStack(null) .commit() } diff --git a/vector/src/main/java/im/vector/app/features/share/IncomingShareActivity.kt b/vector/src/main/java/im/vector/app/features/share/IncomingShareActivity.kt index 09321ad27e..294f1d4d91 100644 --- a/vector/src/main/java/im/vector/app/features/share/IncomingShareActivity.kt +++ b/vector/src/main/java/im/vector/app/features/share/IncomingShareActivity.kt @@ -18,7 +18,6 @@ package im.vector.app.features.share import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity @@ -33,7 +32,7 @@ class IncomingShareActivity : VectorBaseActivity(), Toolb override fun initUiAndData() { if (isFirstCreation()) { - addFragment(R.id.simpleFragmentContainer, IncomingShareFragment::class.java) + addFragment(views.simpleFragmentContainer, IncomingShareFragment::class.java) } } diff --git a/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity.kt b/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity.kt index 4fba8fc3de..9acc81d0c2 100644 --- a/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity.kt +++ b/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity.kt @@ -87,7 +87,7 @@ class SoftLogoutActivity : LoginActivity() { } override fun addFirstFragment() { - replaceFragment(R.id.loginFragmentContainer, SoftLogoutFragment::class.java) + replaceFragment(views.loginFragmentContainer, SoftLogoutFragment::class.java) } private fun updateWithState(softLogoutViewState: SoftLogoutViewState) { diff --git a/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity2.kt b/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity2.kt index 26500b60f0..8489b2baef 100644 --- a/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity2.kt +++ b/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity2.kt @@ -89,7 +89,7 @@ class SoftLogoutActivity2 : LoginActivity2() { } override fun addFirstFragment() { - replaceFragment(R.id.loginFragmentContainer, SoftLogoutFragment::class.java) + replaceFragment(views.loginFragmentContainer, SoftLogoutFragment::class.java) } private fun updateWithState(softLogoutViewState: SoftLogoutViewState) { diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceCreationActivity.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceCreationActivity.kt index 82a3205681..e8f3702efc 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceCreationActivity.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceCreationActivity.kt @@ -123,7 +123,7 @@ class SpaceCreationActivity : SimpleFragmentActivity() { val frag = supportFragmentManager.findFragmentByTag(fragmentClass.name) ?: createFragment(fragmentClass) supportFragmentManager.beginTransaction() .setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out) - .replace(R.id.container, + .replace(views.container.id, frag, fragmentClass.name ) diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceExploreActivity.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceExploreActivity.kt index 780183d866..3361305c83 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceExploreActivity.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceExploreActivity.kt @@ -25,7 +25,7 @@ import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.viewModel import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.extensions.commitTransaction +import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySimpleBinding import im.vector.app.features.matrixto.MatrixToBottomSheet @@ -65,17 +65,12 @@ class SpaceExploreActivity : VectorBaseActivity(), Matrix supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false) if (isFirstCreation()) { - val simpleName = SpaceDirectoryFragment::class.java.simpleName val args = intent?.getParcelableExtra(Mavericks.KEY_ARG) - if (supportFragmentManager.findFragmentByTag(simpleName) == null) { - supportFragmentManager.commitTransaction { - replace(R.id.simpleFragmentContainer, - SpaceDirectoryFragment::class.java, - Bundle().apply { this.putParcelable(Mavericks.KEY_ARG, args) }, - simpleName - ) - } - } + replaceFragment( + views.simpleFragmentContainer, + SpaceDirectoryFragment::class.java, + args + ) } sharedViewModel.observeViewEvents { diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpacePreviewActivity.kt b/vector/src/main/java/im/vector/app/features/spaces/SpacePreviewActivity.kt index b616cdcce7..03ddc6e677 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpacePreviewActivity.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpacePreviewActivity.kt @@ -22,8 +22,7 @@ import android.os.Bundle import androidx.lifecycle.lifecycleScope import com.airbnb.mvrx.Mavericks import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R -import im.vector.app.core.extensions.commitTransaction +import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySimpleBinding import im.vector.app.features.spaces.preview.SpacePreviewArgs @@ -45,26 +44,21 @@ class SpacePreviewActivity : VectorBaseActivity() { .stream() .onEach { action -> when (action) { - SpacePreviewSharedAction.DismissAction -> finish() - SpacePreviewSharedAction.ShowModalLoading -> showWaitingView() - SpacePreviewSharedAction.HideModalLoading -> hideWaitingView() + SpacePreviewSharedAction.DismissAction -> finish() + SpacePreviewSharedAction.ShowModalLoading -> showWaitingView() + SpacePreviewSharedAction.HideModalLoading -> hideWaitingView() is SpacePreviewSharedAction.ShowErrorMessage -> action.error?.let { showSnackbar(it) } } } .launchIn(lifecycleScope) if (isFirstCreation()) { - val simpleName = SpacePreviewFragment::class.java.simpleName val args = intent?.getParcelableExtra(Mavericks.KEY_ARG) - if (supportFragmentManager.findFragmentByTag(simpleName) == null) { - supportFragmentManager.commitTransaction { - replace(R.id.simpleFragmentContainer, - SpacePreviewFragment::class.java, - Bundle().apply { this.putParcelable(Mavericks.KEY_ARG, args) }, - simpleName - ) - } - } + replaceFragment( + views.simpleFragmentContainer, + SpacePreviewFragment::class.java, + args + ) } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt b/vector/src/main/java/im/vector/app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt index 69de39e436..6076388289 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt @@ -31,8 +31,8 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R import im.vector.app.core.error.ErrorFormatter -import im.vector.app.core.extensions.commitTransaction import im.vector.app.core.extensions.hideKeyboard +import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity @@ -69,17 +69,11 @@ class SpaceLeaveAdvancedActivity : VectorBaseActivity(Mavericks.KEY_ARG) if (isFirstCreation()) { - val simpleName = SpaceLeaveAdvancedFragment::class.java.simpleName - if (supportFragmentManager.findFragmentByTag(simpleName) == null) { - supportFragmentManager.commitTransaction { - replace( - R.id.simpleFragmentContainer, - SpaceLeaveAdvancedFragment::class.java, - Bundle().apply { this.putParcelable(Mavericks.KEY_ARG, args) }, - simpleName - ) - } - } + replaceFragment( + views.simpleFragmentContainer, + SpaceLeaveAdvancedFragment::class.java, + args + ) } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceManageActivity.kt b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceManageActivity.kt index 932110d0e3..bf1b88c6bf 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceManageActivity.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/manage/SpaceManageActivity.kt @@ -30,8 +30,8 @@ import com.google.android.material.appbar.MaterialToolbar import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R import im.vector.app.core.extensions.addFragmentToBackstack -import im.vector.app.core.extensions.commitTransaction import im.vector.app.core.extensions.hideKeyboard +import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySimpleLoadingBinding @@ -100,28 +100,26 @@ class SpaceManageActivity : VectorBaseActivity(), ManageType.AddRoomsOnlySpaces -> { val simpleName = SpaceAddRoomFragment::class.java.simpleName if (supportFragmentManager.findFragmentByTag(simpleName) == null) { - supportFragmentManager.commitTransaction { - replace(R.id.simpleFragmentContainer, - SpaceAddRoomFragment::class.java, - Bundle().apply { this.putParcelable(Mavericks.KEY_ARG, args) }, - simpleName - ) - } + replaceFragment( + views.simpleFragmentContainer, + SpaceAddRoomFragment::class.java, + args, + simpleName + ) } } - ManageType.Settings -> { + ManageType.Settings -> { val simpleName = SpaceSettingsFragment::class.java.simpleName if (supportFragmentManager.findFragmentByTag(simpleName) == null && args?.spaceId != null) { - supportFragmentManager.commitTransaction { - replace(R.id.simpleFragmentContainer, - SpaceSettingsFragment::class.java, - Bundle().apply { this.putParcelable(Mavericks.KEY_ARG, RoomProfileArgs(args.spaceId)) }, - simpleName - ) - } + replaceFragment( + views.simpleFragmentContainer, + SpaceSettingsFragment::class.java, + RoomProfileArgs(args.spaceId), + simpleName + ) } } - ManageType.ManageRooms -> { + ManageType.ManageRooms -> { // no direct access for now } } @@ -141,22 +139,22 @@ class SpaceManageActivity : VectorBaseActivity(), } SpaceManagedSharedViewEvents.NavigateToCreateRoom -> { addFragmentToBackstack( - R.id.simpleFragmentContainer, + views.simpleFragmentContainer, CreateRoomFragment::class.java, CreateRoomArgs("", parentSpaceId = args?.spaceId) ) } - SpaceManagedSharedViewEvents.NavigateToCreateSpace -> { + SpaceManagedSharedViewEvents.NavigateToCreateSpace -> { addFragmentToBackstack( - R.id.simpleFragmentContainer, + views.simpleFragmentContainer, CreateRoomFragment::class.java, CreateRoomArgs("", parentSpaceId = args?.spaceId, isSpace = true) ) } - SpaceManagedSharedViewEvents.NavigateToManageRooms -> { + SpaceManagedSharedViewEvents.NavigateToManageRooms -> { args?.spaceId?.let { spaceId -> addFragmentToBackstack( - R.id.simpleFragmentContainer, + views.simpleFragmentContainer, SpaceManageRoomsFragment::class.java, SpaceManageArgs(spaceId, ManageType.ManageRooms) ) @@ -165,7 +163,7 @@ class SpaceManageActivity : VectorBaseActivity(), SpaceManagedSharedViewEvents.NavigateToAliasSettings -> { args?.spaceId?.let { spaceId -> addFragmentToBackstack( - R.id.simpleFragmentContainer, + views.simpleFragmentContainer, RoomAliasFragment::class.java, RoomProfileArgs(spaceId) ) @@ -174,7 +172,7 @@ class SpaceManageActivity : VectorBaseActivity(), SpaceManagedSharedViewEvents.NavigateToPermissionSettings -> { args?.spaceId?.let { spaceId -> addFragmentToBackstack( - R.id.simpleFragmentContainer, RoomPermissionsFragment::class.java, + views.simpleFragmentContainer, RoomPermissionsFragment::class.java, RoomProfileArgs(spaceId) ) } diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleActivity.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleActivity.kt index a269273cd5..f5832a8547 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleActivity.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleActivity.kt @@ -24,9 +24,8 @@ import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import com.airbnb.mvrx.Mavericks import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.R -import im.vector.app.core.extensions.commitTransaction import im.vector.app.core.extensions.hideKeyboard +import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.GenericIdArgs import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySimpleLoadingBinding @@ -64,16 +63,11 @@ class SpacePeopleActivity : VectorBaseActivity() { super.onCreate(savedInstanceState) val args = intent?.getParcelableExtra(Mavericks.KEY_ARG) if (isFirstCreation()) { - val simpleName = SpacePeopleFragment::class.java.simpleName - if (supportFragmentManager.findFragmentByTag(simpleName) == null) { - supportFragmentManager.commitTransaction { - replace(R.id.simpleFragmentContainer, - SpacePeopleFragment::class.java, - Bundle().apply { this.putParcelable(Mavericks.KEY_ARG, args) }, - simpleName - ) - } - } + replaceFragment( + views.simpleFragmentContainer, + SpacePeopleFragment::class.java, + args + ) } sharedActionViewModel = viewModelProvider.get(SpacePeopleSharedActionViewModel::class.java) diff --git a/vector/src/main/java/im/vector/app/features/terms/ReviewTermsActivity.kt b/vector/src/main/java/im/vector/app/features/terms/ReviewTermsActivity.kt index 0efb6119af..e6071fdd2a 100644 --- a/vector/src/main/java/im/vector/app/features/terms/ReviewTermsActivity.kt +++ b/vector/src/main/java/im/vector/app/features/terms/ReviewTermsActivity.kt @@ -40,7 +40,7 @@ class ReviewTermsActivity : SimpleFragmentActivity() { super.initUiAndData() if (isFirstCreation()) { - replaceFragment(R.id.container, ReviewTermsFragment::class.java) + replaceFragment(views.container, ReviewTermsFragment::class.java) } reviewTermsViewModel.termsArgs = intent.getParcelableExtra(EXTRA_INFO) ?: error("Missing parameter") diff --git a/vector/src/main/java/im/vector/app/features/usercode/UserCodeActivity.kt b/vector/src/main/java/im/vector/app/features/usercode/UserCodeActivity.kt index 7fa7a45131..7011f8c280 100644 --- a/vector/src/main/java/im/vector/app/features/usercode/UserCodeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/usercode/UserCodeActivity.kt @@ -117,7 +117,7 @@ class UserCodeActivity : VectorBaseActivity(), if (supportFragmentManager.findFragmentByTag(fragmentClass.simpleName) == null) { supportFragmentManager.commitTransaction { setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out) - replace(R.id.simpleFragmentContainer, + replace(views.simpleFragmentContainer.id, fragmentClass.java, bundle, fragmentClass.simpleName diff --git a/vector/src/main/java/im/vector/app/features/widgets/WidgetActivity.kt b/vector/src/main/java/im/vector/app/features/widgets/WidgetActivity.kt index f8d817acd5..1e6d130c67 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/WidgetActivity.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/WidgetActivity.kt @@ -107,7 +107,7 @@ class WidgetActivity : VectorBaseActivity(), } WidgetStatus.WIDGET_ALLOWED -> { if (supportFragmentManager.findFragmentByTag(WIDGET_FRAGMENT_TAG) == null) { - addFragment(R.id.fragmentContainer, WidgetFragment::class.java, widgetArgs, WIDGET_FRAGMENT_TAG) + addFragment(views.fragmentContainer, WidgetFragment::class.java, widgetArgs, WIDGET_FRAGMENT_TAG) } } }