From 89fa4dab7dd2034a6a2cb4aee523c12a56df29f3 Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Fri, 19 Jun 2026 00:00:05 +0300 Subject: [PATCH 1/2] fix: recalculate grid span count after rotation Signed-off-by: Himanshu Gupta --- .../files/filelist/MainFileListFragment.kt | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt index cbcc73f3cad..2614384bdca 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt @@ -335,6 +335,9 @@ class MainFileListFragment : Fragment(), override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) updateConfigDependentSizes() + if (::viewType.isInitialized && viewType == ViewType.VIEW_TYPE_GRID) { + updateRecyclerViewLayoutForCurrentViewType() + } } private fun updateConfigDependentSizes() { @@ -998,17 +1001,30 @@ class MainFileListFragment : Fragment(), } override fun onViewTypeListener(viewType: ViewType) { + this.viewType = viewType binding.optionsLayout.viewTypeSelected = viewType if (viewType == ViewType.VIEW_TYPE_LIST) { mainFileListViewModel.setListModeAsPreferred() - layoutManager.spanCount = 1 } else { mainFileListViewModel.setGridModeAsPreferred() - layoutManager.spanCount = ColumnQuantity(requireContext(), R.layout.grid_item).calculateNoOfColumns() } + updateRecyclerViewLayoutForCurrentViewType() + } + + private fun updateRecyclerViewLayoutForCurrentViewType() { + if (!::layoutManager.isInitialized || !::fileListAdapter.isInitialized) { + return + } + + layoutManager.spanCount = when (viewType) { + ViewType.VIEW_TYPE_LIST -> 1 + ViewType.VIEW_TYPE_GRID -> ColumnQuantity(requireContext(), R.layout.grid_item).calculateNoOfColumns() + } + layoutManager.invalidateSpanAssignments() + binding.recyclerViewMainFileList.requestLayout() fileListAdapter.notifyItemRangeChanged(0, fileListAdapter.itemCount) } @@ -1675,4 +1691,3 @@ class MainFileListFragment : Fragment(), } } } - From c889d0b1219ae40fa81721b1fd2adbf53dcf8588 Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Fri, 19 Jun 2026 00:00:08 +0300 Subject: [PATCH 2/2] chore: add calens file Signed-off-by: Himanshu Gupta --- changelog/unreleased/4884 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog/unreleased/4884 diff --git a/changelog/unreleased/4884 b/changelog/unreleased/4884 new file mode 100644 index 00000000000..717efb05d44 --- /dev/null +++ b/changelog/unreleased/4884 @@ -0,0 +1,6 @@ +Bugfix: Grid mode after rotation + +Grid mode now recalculates its column count after device rotation, keeping +file tiles in the correct layout for the new orientation. + +https://github.com/owncloud/android/issues/4884