Skip to content

Commit f908e6f

Browse files
committed
fix: remove folder size label for Kiteworks servers
1 parent f799d50 commit f908e6f

5 files changed

Lines changed: 40 additions & 8 deletions

File tree

owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/FileListAdapter.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ class FileListAdapter(
281281
view.binding.let {
282282
it.fileListConstraintLayout.filterTouchesWhenObscured = PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(context)
283283
it.Filename.text = file.fileName
284-
it.fileListSize.text = DisplayUtils.bytesToHumanReadable(file.length, context, true)
284+
val isFolderInKw = isMultiPersonal && file.isFolder
285+
it.fileListSize.text = if (isFolderInKw) "" else DisplayUtils.bytesToHumanReadable(file.length, context, true)
286+
it.fileListSeparator.visibility = if (isFolderInKw) View.GONE else View.VISIBLE
287+
it.fileListLastMod.layoutParams = (it.fileListLastMod.layoutParams as ViewGroup.MarginLayoutParams).also {
288+
params -> params.marginStart = if (isFolderInKw) 0 else
289+
context.resources.getDimensionPixelSize(R.dimen.standard_quarter_margin) }
285290
it.fileListLastMod.text = DisplayUtils.getRelativeTimestamp(context, file.modificationTimestamp)
286291
it.threeDotMenu.isVisible = getCheckedItems().isEmpty()
287292
it.threeDotMenu.contentDescription = context.getString(R.string.content_description_file_operations, file.fileName)

owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,17 @@ class MainFileListFragment : Fragment(),
634634
fileNameBottomSheet.text = file.fileName
635635

636636
val fileSizeBottomSheet = fileOptionsBottomSheetSingleFile.findViewById<TextView>(R.id.file_size_bottom_sheet)
637-
fileSizeBottomSheet.text = DisplayUtils.bytesToHumanReadable(file.length, requireContext(), true)
637+
val isFolderInKw = isMultiPersonal && file.isFolder
638+
fileSizeBottomSheet.text = if (isFolderInKw) "" else DisplayUtils.bytesToHumanReadable(file.length, requireContext(), true)
639+
640+
val fileSeparatorBottomSheet = fileOptionsBottomSheetSingleFile.findViewById<TextView>(R.id.file_separator_bottom_sheet)
641+
fileSeparatorBottomSheet.visibility = if (isFolderInKw) View.GONE else View.VISIBLE
638642

639643
val fileLastModBottomSheet = fileOptionsBottomSheetSingleFile.findViewById<TextView>(R.id.file_last_mod_bottom_sheet)
640644
fileLastModBottomSheet.text = DisplayUtils.getRelativeTimestamp(requireContext(), file.modificationTimestamp)
645+
fileLastModBottomSheet.layoutParams = (fileLastModBottomSheet.layoutParams as ViewGroup.MarginLayoutParams).also {
646+
params -> params.marginStart = if (isFolderInKw) 0 else
647+
requireContext().resources.getDimensionPixelSize(R.dimen.standard_quarter_margin) }
641648

642649
fileOptionsBottomSheetSingleFileLayout = fileOptionsBottomSheetSingleFile.findViewById(R.id.file_options_bottom_sheet_layout)
643650
menuOptions.forEach { menuOption ->

owncloudApp/src/main/java/com/owncloud/android/ui/ReceiveExternalFilesViewModel.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* ownCloud Android client application
33
*
4-
* Copyright (C) 2024 ownCloud GmbH.
4+
* Copyright (C) 2025 ownCloud GmbH.
55
* <p>
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License version 2,
@@ -44,11 +44,16 @@ class ReceiveExternalFilesViewModel(
4444
private val _spacesAreAllowed = MutableLiveData<Boolean>()
4545
val spacesAreAllowed: LiveData<Boolean> = _spacesAreAllowed
4646

47+
private val _isMultiPersonal = MutableLiveData<Boolean>()
48+
val isMultiPersonal: LiveData<Boolean> = _isMultiPersonal
49+
4750
init {
4851
viewModelScope.launch(coroutinesDispatcherProvider.io) {
4952
val capabilities = getStoredCapabilitiesUseCase(GetStoredCapabilitiesUseCase.Params(accountName))
5053
val spacesAvailableForAccount = capabilities?.isSpacesAllowed() == true
5154
_spacesAreAllowed.postValue(spacesAvailableForAccount)
55+
val isMultiPersonalCapability = capabilities?.spaces?.hasMultiplePersonalSpaces == true
56+
_isMultiPersonal.postValue(isMultiPersonalCapability)
5257
}
5358
}
5459

owncloudApp/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
181181
private boolean showHiddenFiles;
182182
private OCSharedPreferencesProvider sharedPreferencesProvider;
183183
private boolean areSpacesAllowed;
184+
private boolean isMultiPersonal;
184185

185186

186187
Pattern pattern = Pattern.compile("[/\\\\]");
@@ -227,6 +228,8 @@ protected void onCreate(Bundle savedInstanceState) {
227228

228229
}
229230
private void subscribeToViewModels() {
231+
mReceiveExternalFilesViewModel.isMultiPersonal().observe(this, isMultiPersonalCapability ->
232+
isMultiPersonal = isMultiPersonalCapability);
230233
mReceiveExternalFilesViewModel.getSpacesAreAllowed().observe(this, spaces -> {
231234
areSpacesAllowed = spaces;
232235

@@ -549,7 +552,7 @@ private void updateDirectoryList() {
549552
if (mFile != null) {
550553
if (mAdapter == null) {
551554
mAdapter = new ReceiveExternalFilesAdapter(
552-
this, getStorageManager(), getAccount(), showHiddenFiles);
555+
this, getStorageManager(), getAccount(), showHiddenFiles, isMultiPersonal);
553556
mListView.setAdapter(mAdapter);
554557
}
555558
Vector<OCFile> files = new Vector<>(sortFileList(getStorageManager().getFolderContent(mFile)));

owncloudApp/src/main/java/com/owncloud/android/ui/adapter/ReceiveExternalFilesAdapter.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* @author Shashvat Kedia
77
* @author David González Verdugo
88
* @author John Kalimeris
9-
* Copyright (C) 2021 ownCloud GmbH.
9+
* @author Jorge Aguado Recio
10+
*
11+
* Copyright (C) 2025 ownCloud GmbH.
1012
* <p>
1113
* This program is free software: you can redistribute it and/or modify
1214
* it under the terms of the GNU General Public License version 2,
@@ -58,13 +60,15 @@ public class ReceiveExternalFilesAdapter extends BaseAdapter implements ListAdap
5860
private FileDataStorageManager mStorageManager;
5961
private LayoutInflater mInflater;
6062
private OnSearchQueryUpdateListener mOnSearchQueryUpdateListener;
63+
private boolean mIsMultiPersonal;
6164

6265
private Boolean mShowHiddenFiles;
6366

6467
public ReceiveExternalFilesAdapter(Context context,
6568
FileDataStorageManager storageManager,
6669
Account account,
67-
boolean showHiddenFiles) {
70+
boolean showHiddenFiles,
71+
boolean isMultiPersonal) {
6872
mStorageManager = storageManager;
6973
mContext = context;
7074
mInflater = (LayoutInflater) mContext
@@ -74,6 +78,7 @@ public ReceiveExternalFilesAdapter(Context context,
7478
if (mContext instanceof OnSearchQueryUpdateListener) {
7579
mOnSearchQueryUpdateListener = (OnSearchQueryUpdateListener) mContext;
7680
}
81+
mIsMultiPersonal = isMultiPersonal;
7782
}
7883

7984
@Override
@@ -142,8 +147,15 @@ public View getView(int position, View convertView, ViewGroup parent) {
142147
TextView fileSizeSeparatorV = vi.findViewById(R.id.file_separator);
143148

144149
fileSizeV.setVisibility(View.VISIBLE);
145-
fileSizeSeparatorV.setVisibility(View.VISIBLE);
146-
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getLength(), mContext, true));
150+
151+
boolean isFolderInKw = mIsMultiPersonal && file.isFolder();
152+
if (isFolderInKw) {
153+
fileSizeSeparatorV.setVisibility(View.GONE);
154+
fileSizeV.setText("");
155+
} else {
156+
fileSizeSeparatorV.setVisibility(View.VISIBLE);
157+
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getLength(), mContext, true));
158+
}
147159

148160
// get Thumbnail if file is image
149161
if (file.isImage() && file.getRemoteId() != null) {

0 commit comments

Comments
 (0)