Skip to content

Commit 0fcbc2a

Browse files
committed
empty state ui for album detailed view and minor code refactoring.
1 parent f9de060 commit 0fcbc2a

22 files changed

+1433
-286
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,15 @@
586586
<activity
587587
android:name=".ui.activity.FolderPickerActivity"
588588
android:exported="false" />
589-
<activity
590-
android:name=".ui.fragment.albums.AlbumsPickerActivity"
591-
android:exported="false" />
592589
<activity
593590
android:name=".ui.activity.FilePickerActivity"
594591
android:exported="false"
595592
android:launchMode="singleTop"
596593
android:theme="@style/Theme.ownCloud.Dialog.NoTitle"
597594
android:windowSoftInputMode="adjustResize" />
595+
<activity
596+
android:name=".ui.activity.AlbumsPickerActivity"
597+
android:exported="false" />
598598
<activity
599599
android:name=".ui.activity.ShareActivity"
600600
android:exported="false"

app/src/main/java/com/nextcloud/client/di/ComponentsModule.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
import com.owncloud.android.ui.fragment.UnifiedSearchFragment;
119119
import com.owncloud.android.ui.fragment.albums.AlbumItemsFragment;
120120
import com.owncloud.android.ui.fragment.albums.AlbumsFragment;
121-
import com.owncloud.android.ui.fragment.albums.AlbumsPickerActivity;
121+
import com.owncloud.android.ui.activity.AlbumsPickerActivity;
122122
import com.owncloud.android.ui.fragment.contactsbackup.BackupFragment;
123123
import com.owncloud.android.ui.fragment.contactsbackup.BackupListFragment;
124124
import com.owncloud.android.ui.preview.FileDownloadFragment;
@@ -320,15 +320,6 @@ abstract class ComponentsModule {
320320
@ContributesAndroidInjector
321321
abstract GalleryFragment photoFragment();
322322

323-
@ContributesAndroidInjector
324-
abstract AlbumsFragment albumsFragment();
325-
326-
@ContributesAndroidInjector
327-
abstract AlbumItemsFragment albumItemsFragment();
328-
329-
@ContributesAndroidInjector
330-
abstract AlbumItemActionsBottomSheet albumItemActionsBottomSheet();
331-
332323
@ContributesAndroidInjector
333324
abstract MultipleAccountsDialog multipleAccountsDialog();
334325

@@ -398,18 +389,12 @@ abstract class ComponentsModule {
398389
@ContributesAndroidInjector
399390
abstract CreateFolderDialogFragment createFolderDialogFragment();
400391

401-
@ContributesAndroidInjector
402-
abstract CreateAlbumDialogFragment createAlbumDialogFragment();
403-
404392
@ContributesAndroidInjector
405393
abstract ExpirationDatePickerDialogFragment expirationDatePickerDialogFragment();
406394

407395
@ContributesAndroidInjector
408396
abstract FileActivity fileActivity();
409397

410-
@ContributesAndroidInjector
411-
abstract AlbumsPickerActivity albumsPickerActivity();
412-
413398
@ContributesAndroidInjector
414399
abstract FileDownloadFragment fileDownloadFragment();
415400

@@ -525,4 +510,19 @@ abstract class ComponentsModule {
525510

526511
@ContributesAndroidInjector
527512
abstract TermsOfServiceDialog termsOfServiceDialog();
513+
514+
@ContributesAndroidInjector
515+
abstract AlbumsPickerActivity albumsPickerActivity();
516+
517+
@ContributesAndroidInjector
518+
abstract CreateAlbumDialogFragment createAlbumDialogFragment();
519+
520+
@ContributesAndroidInjector
521+
abstract AlbumsFragment albumsFragment();
522+
523+
@ContributesAndroidInjector
524+
abstract AlbumItemsFragment albumItemsFragment();
525+
526+
@ContributesAndroidInjector
527+
abstract AlbumItemActionsBottomSheet albumItemActionsBottomSheet();
528528
}

app/src/main/java/com/nextcloud/ui/albumItemActions/AlbumItemActionsBottomSheet.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-FileCopyrightText: 2024 TSI-mc <[email protected]>
55
* SPDX-License-Identifier: AGPL-3.0-or-later
66
*/
7+
78
package com.nextcloud.ui.albumItemActions
89

910
import android.os.Bundle
@@ -56,7 +57,7 @@ class AlbumItemActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
5657
super.onViewCreated(view, savedInstanceState)
5758
binding.bottomSheetHeader.visibility = View.GONE
5859
binding.bottomSheetLoading.visibility = View.GONE
59-
displayActions(AlbumItemAction.SORTED_VALUES)
60+
displayActions()
6061
}
6162

6263
override fun onDestroyView() {
@@ -78,9 +79,9 @@ class AlbumItemActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
7879
return this
7980
}
8081

81-
private fun displayActions(actions: List<AlbumItemAction>) {
82+
private fun displayActions() {
8283
if (binding.fileActionsList.isEmpty()) {
83-
actions.forEach { action ->
84+
AlbumItemAction.SORTED_VALUES.forEach { action ->
8485
val view = inflateActionView(action)
8586
binding.fileActionsList.addView(view)
8687
}

app/src/main/java/com/owncloud/android/services/OperationsService.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -681,12 +681,6 @@ private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) {
681681
operation = new RenameFileOperation(remotePath, newName, fileDataStorageManager);
682682
break;
683683

684-
case ACTION_RENAME_ALBUM:
685-
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
686-
String newAlbumName = operationIntent.getStringExtra(EXTRA_NEWNAME);
687-
operation = new RenameAlbumOperation(remotePath, newAlbumName, fileDataStorageManager);
688-
break;
689-
690684
case ACTION_REMOVE:
691685
// Remove file or folder
692686
OCFile file = IntentExtensionsKt.getParcelableArgument(operationIntent, EXTRA_FILE, OCFile.class);
@@ -700,12 +694,6 @@ private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) {
700694
fileDataStorageManager);
701695
break;
702696

703-
case ACTION_REMOVE_ALBUM:
704-
String albumNameToRemove = operationIntent.getStringExtra(EXTRA_ALBUM_NAME);
705-
operation = new RemoveAlbumOperation(albumNameToRemove,
706-
fileDataStorageManager);
707-
break;
708-
709697
case ACTION_CREATE_FOLDER:
710698
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
711699
operation = new CreateFolderOperation(remotePath,
@@ -714,11 +702,6 @@ private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) {
714702
fileDataStorageManager);
715703
break;
716704

717-
case ACTION_CREATE_ALBUM:
718-
String albumName = operationIntent.getStringExtra(EXTRA_ALBUM_NAME);
719-
operation = new CreateNewAlbumOperation(albumName);
720-
break;
721-
722705
case ACTION_SYNC_FILE:
723706
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
724707
boolean syncFileContents = operationIntent.getBooleanExtra(EXTRA_SYNC_FILE_CONTENTS, true);
@@ -753,12 +736,6 @@ private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) {
753736
operation = new CopyFileOperation(remotePath, newParentPath, fileDataStorageManager);
754737
break;
755738

756-
case ACTION_ALBUM_COPY_FILE:
757-
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
758-
newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
759-
operation = new CopyFileToAlbumOperation(remotePath, newParentPath, fileDataStorageManager);
760-
break;
761-
762739
case ACTION_CHECK_CURRENT_CREDENTIALS:
763740
operation = new CheckCurrentCredentialsOperation(user, fileDataStorageManager);
764741
break;
@@ -778,6 +755,29 @@ private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) {
778755
}
779756
break;
780757

758+
case ACTION_CREATE_ALBUM:
759+
String albumName = operationIntent.getStringExtra(EXTRA_ALBUM_NAME);
760+
operation = new CreateNewAlbumOperation(albumName);
761+
break;
762+
763+
case ACTION_ALBUM_COPY_FILE:
764+
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
765+
newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
766+
operation = new CopyFileToAlbumOperation(remotePath, newParentPath, fileDataStorageManager);
767+
break;
768+
769+
case ACTION_RENAME_ALBUM:
770+
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
771+
String newAlbumName = operationIntent.getStringExtra(EXTRA_NEWNAME);
772+
operation = new RenameAlbumOperation(remotePath, newAlbumName, fileDataStorageManager);
773+
break;
774+
775+
case ACTION_REMOVE_ALBUM:
776+
String albumNameToRemove = operationIntent.getStringExtra(EXTRA_ALBUM_NAME);
777+
operation = new RemoveAlbumOperation(albumNameToRemove,
778+
fileDataStorageManager);
779+
break;
780+
781781
default:
782782
// do nothing
783783
break;
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/*
22
* Nextcloud - Android Client
33
*
4-
* SPDX-FileCopyrightText: 2023 TSI-mc
5-
* SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
6-
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
4+
* SPDX-FileCopyrightText: 2025 Your Name <[email protected]>
5+
* SPDX-License-Identifier: AGPL-3.0-or-later
76
*/
8-
package com.owncloud.android.ui.fragment.albums
7+
package com.owncloud.android.ui.activity
98

109
import android.content.Intent
1110
import android.content.res.Resources
@@ -22,13 +21,12 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult
2221
import com.owncloud.android.lib.common.utils.Log_OC
2322
import com.owncloud.android.lib.resources.files.SearchRemoteOperation
2423
import com.owncloud.android.operations.albums.CreateNewAlbumOperation
25-
import com.owncloud.android.ui.activity.FileActivity
2624
import com.owncloud.android.ui.activity.FolderPickerActivity.Companion.TAG_LIST_OF_FOLDERS
27-
import com.owncloud.android.ui.activity.OnEnforceableRefreshListener
2825
import com.owncloud.android.ui.events.SearchEvent
2926
import com.owncloud.android.ui.fragment.FileFragment
3027
import com.owncloud.android.ui.fragment.GalleryFragment
3128
import com.owncloud.android.ui.fragment.OCFileListFragment
29+
import com.owncloud.android.ui.fragment.albums.AlbumsFragment
3230
import com.owncloud.android.utils.DisplayUtils
3331
import com.owncloud.android.utils.ErrorMessageAdapter
3432

app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,24 +1922,6 @@ private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOp
19221922
}
19231923
}
19241924

1925-
private void onRemoveAlbumOperationFinish(RemoveAlbumOperation operation, RemoteOperationResult result) {
1926-
1927-
if (result.isSuccess()) {
1928-
1929-
Fragment fragment = getSupportFragmentManager().findFragmentByTag(AlbumItemsFragment.Companion.getTAG());
1930-
if (fragment instanceof AlbumItemsFragment albumItemsFragment) {
1931-
albumItemsFragment.onAlbumDeleted();
1932-
}
1933-
} else {
1934-
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
1935-
1936-
if (result.isSslRecoverableException()) {
1937-
mLastSslUntrustedServerResult = result;
1938-
showUntrustedCertDialog(mLastSslUntrustedServerResult);
1939-
}
1940-
}
1941-
}
1942-
19431925
private void onRestoreFileVersionOperationFinish(RemoteOperationResult result) {
19441926
if (result.isSuccess()) {
19451927
OCFile file = getFile();
@@ -2014,26 +1996,6 @@ private void onCopyFileOperationFinish(CopyFileOperation operation, RemoteOperat
20141996
}
20151997
}
20161998

2017-
private void onCopyAlbumFileOperationFinish(CopyFileToAlbumOperation operation, RemoteOperationResult result) {
2018-
if (result.isSuccess()) {
2019-
// when item added from inside of Album
2020-
Fragment fragment = getSupportFragmentManager().findFragmentByTag(AlbumItemsFragment.Companion.getTAG());
2021-
if (fragment instanceof AlbumItemsFragment albumItemsFragment) {
2022-
albumItemsFragment.refreshData();
2023-
} else {
2024-
// files added directly from Media tab
2025-
DisplayUtils.showSnackMessage(this, "File added successfully");
2026-
}
2027-
Log_OC.e(TAG, "Files copied successfully");
2028-
} else {
2029-
try {
2030-
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
2031-
} catch (NotFoundException e) {
2032-
Log_OC.e(TAG, "Error while trying to show fail message ", e);
2033-
}
2034-
}
2035-
}
2036-
20371999
/**
20382000
* Updates the view associated to the activity after the finish of an operation trying to rename a file.
20392001
*
@@ -2086,24 +2048,6 @@ private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOp
20862048
}
20872049

20882050

2089-
private void onRenameAlbumOperationFinish(RenameAlbumOperation operation, RemoteOperationResult result) {
2090-
if (result.isSuccess()) {
2091-
2092-
Fragment fragment = getSupportFragmentManager().findFragmentByTag(AlbumItemsFragment.Companion.getTAG());
2093-
if (fragment instanceof AlbumItemsFragment albumItemsFragment) {
2094-
albumItemsFragment.onAlbumRenamed(operation.getNewAlbumName());
2095-
}
2096-
2097-
} else {
2098-
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
2099-
2100-
if (result.isSslRecoverableException()) {
2101-
mLastSslUntrustedServerResult = result;
2102-
showUntrustedCertDialog(mLastSslUntrustedServerResult);
2103-
}
2104-
}
2105-
}
2106-
21072051
private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) {
21082052
if (result.isSuccess() && operation.transferWasRequested()) {
21092053
OCFile syncedFile = operation.getLocalFile();
@@ -2138,6 +2082,62 @@ private void onCreateFolderOperationFinish(CreateFolderOperation operation, Remo
21382082
}
21392083
}
21402084

2085+
private void onRemoveAlbumOperationFinish(RemoveAlbumOperation operation, RemoteOperationResult result) {
2086+
2087+
if (result.isSuccess()) {
2088+
2089+
Fragment fragment = getSupportFragmentManager().findFragmentByTag(AlbumItemsFragment.Companion.getTAG());
2090+
if (fragment instanceof AlbumItemsFragment albumItemsFragment) {
2091+
albumItemsFragment.onAlbumDeleted();
2092+
}
2093+
} else {
2094+
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
2095+
2096+
if (result.isSslRecoverableException()) {
2097+
mLastSslUntrustedServerResult = result;
2098+
showUntrustedCertDialog(mLastSslUntrustedServerResult);
2099+
}
2100+
}
2101+
}
2102+
2103+
private void onCopyAlbumFileOperationFinish(CopyFileToAlbumOperation operation, RemoteOperationResult result) {
2104+
if (result.isSuccess()) {
2105+
// when item added from inside of Album
2106+
Fragment fragment = getSupportFragmentManager().findFragmentByTag(AlbumItemsFragment.Companion.getTAG());
2107+
if (fragment instanceof AlbumItemsFragment albumItemsFragment) {
2108+
albumItemsFragment.refreshData();
2109+
} else {
2110+
// files added directly from Media tab
2111+
DisplayUtils.showSnackMessage(this, getResources().getString(R.string.album_file_added_message));
2112+
}
2113+
Log_OC.e(TAG, "Files copied successfully");
2114+
} else {
2115+
try {
2116+
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
2117+
} catch (NotFoundException e) {
2118+
Log_OC.e(TAG, "Error while trying to show fail message ", e);
2119+
}
2120+
}
2121+
}
2122+
2123+
private void onRenameAlbumOperationFinish(RenameAlbumOperation operation, RemoteOperationResult result) {
2124+
if (result.isSuccess()) {
2125+
2126+
Fragment fragment = getSupportFragmentManager().findFragmentByTag(AlbumItemsFragment.Companion.getTAG());
2127+
if (fragment instanceof AlbumItemsFragment albumItemsFragment) {
2128+
albumItemsFragment.onAlbumRenamed(operation.getNewAlbumName());
2129+
}
2130+
2131+
} else {
2132+
DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()));
2133+
2134+
if (result.isSslRecoverableException()) {
2135+
mLastSslUntrustedServerResult = result;
2136+
showUntrustedCertDialog(mLastSslUntrustedServerResult);
2137+
}
2138+
}
2139+
}
2140+
21412141
private void onCreateAlbumOperationFinish(CreateNewAlbumOperation operation, RemoteOperationResult result) {
21422142
if (result.isSuccess()) {
21432143
Fragment fragment = getSupportFragmentManager().findFragmentByTag(AlbumsFragment.Companion.getTAG());

app/src/main/java/com/owncloud/android/ui/adapter/OCFileListDelegate.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import com.owncloud.android.ui.activity.ComponentsGetter
3434
import com.owncloud.android.ui.fragment.GalleryFragment
3535
import com.owncloud.android.ui.fragment.SearchType
3636
import com.owncloud.android.ui.fragment.albums.AlbumItemsFragment
37-
import com.owncloud.android.ui.fragment.albums.AlbumsPickerActivity
37+
import com.owncloud.android.ui.activity.AlbumsPickerActivity
3838
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface
3939
import com.owncloud.android.utils.BitmapUtils
4040
import com.owncloud.android.utils.DisplayUtils

app/src/main/java/com/owncloud/android/ui/fragment/albums/AlbumGridItemViewHolder.kt renamed to app/src/main/java/com/owncloud/android/ui/adapter/albums/AlbumGridItemViewHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: AGPL-3.0-or-later
66
*/
77

8-
package com.owncloud.android.ui.fragment.albums
8+
package com.owncloud.android.ui.adapter.albums
99

1010
import android.widget.ImageView
1111
import android.widget.TextView

app/src/main/java/com/owncloud/android/ui/fragment/albums/AlbumItemViewHolder.kt renamed to app/src/main/java/com/owncloud/android/ui/adapter/albums/AlbumItemViewHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: AGPL-3.0-or-later
66
*/
77

8-
package com.owncloud.android.ui.fragment.albums
8+
package com.owncloud.android.ui.adapter.albums
99

1010
import android.widget.ImageView
1111
import android.widget.TextView

app/src/main/java/com/owncloud/android/ui/fragment/albums/AlbumListItemViewHolder.kt renamed to app/src/main/java/com/owncloud/android/ui/adapter/albums/AlbumListItemViewHolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-License-Identifier: AGPL-3.0-or-later
66
*/
77

8-
package com.owncloud.android.ui.fragment.albums
8+
package com.owncloud.android.ui.adapter.albums
99

1010
import android.widget.ImageView
1111
import android.widget.TextView

0 commit comments

Comments
 (0)