From d96c0d1d9ecc75e9c78dfbf1f86966e9b66b997c Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Thu, 1 Feb 2024 15:46:22 +0100 Subject: [PATCH 01/14] Implement global pause functionality Signed-off-by: Jonas Mayer --- .../client/jobs/BackgroundJobFactory.kt | 1 + .../client/jobs/upload/FileUploadHelper.kt | 2 +- .../client/jobs/upload/FileUploadWorker.kt | 10 ++++ .../client/jobs/upload/FileUploaderIntents.kt | 6 +-- .../jobs/upload/UploadNotificationManager.kt | 21 ++++++++ .../client/preferences/AppPreferences.java | 4 ++ .../preferences/AppPreferencesImpl.java | 12 +++++ .../ui/activity/UploadListActivity.java | 46 +++++++++++------ .../android/ui/adapter/UploadListAdapter.java | 51 ++++++++++++++----- .../main/res/menu/activity_upload_list.xml | 9 ++-- .../res/menu/upload_list_failed_options.xml | 32 ++++++++++++ app/src/main/res/values/strings.xml | 4 ++ 12 files changed, 164 insertions(+), 34 deletions(-) create mode 100644 app/src/main/res/menu/upload_list_failed_options.xml diff --git a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobFactory.kt b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobFactory.kt index e445bf2231e4..03ece0215871 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobFactory.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobFactory.kt @@ -251,6 +251,7 @@ class BackgroundJobFactory @Inject constructor( viewThemeUtils.get(), localBroadcastManager.get(), backgroundJobManager.get(), + preferences, context, params ) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt index 8c71a8b6677e..99c86cbe36b3 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadHelper.kt @@ -160,7 +160,7 @@ class FileUploadHelper { } } - private fun cancelAndRestartUploadJob(user: User) { + fun cancelAndRestartUploadJob(user: User) { backgroundJobManager.run { cancelFilesUploadJob(user) startFilesUploadJob(user) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt index b00d3a37354f..2decfa240cce 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt @@ -32,6 +32,7 @@ import com.nextcloud.client.device.PowerManagementService import com.nextcloud.client.jobs.BackgroundJobManager import com.nextcloud.client.jobs.BackgroundJobManagerImpl import com.nextcloud.client.network.ConnectivityService +import com.nextcloud.client.preferences.AppPreferences import com.nextcloud.model.WorkerState import com.nextcloud.model.WorkerStateLiveData import com.owncloud.android.datamodel.FileDataStorageManager @@ -58,6 +59,7 @@ class FileUploadWorker( val viewThemeUtils: ViewThemeUtils, val localBroadcastManager: LocalBroadcastManager, private val backgroundJobManager: BackgroundJobManager, + val preferences: AppPreferences, val context: Context, params: WorkerParameters ) : Worker(context, params), OnDatatransferProgressListener { @@ -141,6 +143,14 @@ class FileUploadWorker( var currentPage = uploadsStorageManager.getCurrentAndPendingUploadsForAccountPageAscById(-1, accountName) while (currentPage.isNotEmpty() && !isStopped) { + if (preferences.globalUploadPaused){ + Log_OC.d(TAG, "Upload is paused, skip uploading files!") + notificationManager.notifyPaused( + intents.notificationStartIntent(null) + ) + return Result.success() + } + Log_OC.d(TAG, "Handling ${currentPage.size} uploads for account $accountName") val lastId = currentPage.last().uploadId uploadFiles(currentPage, accountName) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploaderIntents.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploaderIntents.kt index c068d7aa25cc..cb9e620a4084 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploaderIntents.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploaderIntents.kt @@ -97,10 +97,10 @@ class FileUploaderIntents(private val context: Context) { ) } - fun notificationStartIntent(operation: UploadFileOperation): PendingIntent { + fun notificationStartIntent(operation: UploadFileOperation?): PendingIntent { val intent = UploadListActivity.createIntent( - operation.file, - operation.user, + operation?.file, + operation?.user, Intent.FLAG_ACTIVITY_CLEAR_TOP, context ) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt index 2c3a01f7f90b..df86017280da 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt @@ -37,6 +37,7 @@ import com.owncloud.android.utils.theme.ViewThemeUtils class UploadNotificationManager(private val context: Context, private val viewThemeUtils: ViewThemeUtils) { companion object { + private const val ID = 411 } @@ -192,4 +193,24 @@ class UploadNotificationManager(private val context: Context, private val viewTh fun dismissWorkerNotifications() { notificationManager.cancel(ID) } + + fun notifyPaused(startIntent: PendingIntent) { + notificationBuilder = NotificationUtils.newNotificationBuilder(context, viewThemeUtils).apply { + setSmallIcon(R.drawable.notification_icon) + setOngoing(true) + setTicker(context.getString(R.string.upload_global_pause)) + setContentTitle(context.getString(R.string.upload_global_pause_title)) + setContentText(context.getString(R.string.upload_global_pause)) + clearActions() + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD) + } + + setContentIntent(startIntent) + } + + + showNotification() + } } diff --git a/app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java b/app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java index bb93d3fa5ec8..e11c5bf09b29 100644 --- a/app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java +++ b/app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java @@ -387,6 +387,10 @@ default void onDarkThemeModeChanged(DarkMode mode) { void setCalendarLastBackup(long timestamp); + boolean getGlobalUploadPaused(); + + void setGlobalUploadPaused(boolean globalPausedState); + void setPdfZoomTipShownCount(int count); int getPdfZoomTipShownCount(); diff --git a/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java b/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java index 4643f18dbc82..79489a321aae 100644 --- a/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java +++ b/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java @@ -107,6 +107,8 @@ public final class AppPreferencesImpl implements AppPreferences { private static final String PREF__CALENDAR_AUTOMATIC_BACKUP = "calendar_automatic_backup"; private static final String PREF__CALENDAR_LAST_BACKUP = "calendar_last_backup"; + private static final String PREF__GLOBAL_PAUSE_STATE = "global_pause_state"; + private static final String PREF__PDF_ZOOM_TIP_SHOWN = "pdf_zoom_tip_shown"; private static final String PREF__MEDIA_FOLDER_LAST_PATH = "media_folder_last_path"; @@ -741,6 +743,16 @@ public void setCalendarLastBackup(long timestamp) { preferences.edit().putLong(PREF__CALENDAR_LAST_BACKUP, timestamp).apply(); } + @Override + public boolean getGlobalUploadPaused() { + return preferences.getBoolean(PREF__GLOBAL_PAUSE_STATE,false); + } + + @Override + public void setGlobalUploadPaused(boolean globalPausedState) { + preferences.edit().putBoolean(PREF__GLOBAL_PAUSE_STATE, globalPausedState).apply(); + } + @Override public void setPdfZoomTipShownCount(int count) { preferences.edit().putInt(PREF__PDF_ZOOM_TIP_SHOWN, count).apply(); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index 6bf94c222d89..67c9b211c533 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -211,12 +211,16 @@ private void refresh() { backgroundJobManager.startImmediateFilesSyncJob(false, true); if(uploadsStorageManager.getFailedUploads().length > 0){ - new Thread(() -> FileUploadHelper.Companion.instance().retryFailedUploads( - uploadsStorageManager, - connectivityService, - userAccountManager, - powerManagementService)) - .start(); + new Thread(() -> { + FileUploadHelper.Companion.instance().retryFailedUploads( + uploadsStorageManager, + connectivityService, + accountManager, + powerManagementService); + this.runOnUiThread(() -> { + uploadListAdapter.loadUploadItemsFromDb(); + }); + }).start(); DisplayUtils.showSnackMessage(this, R.string.uploader_local_files_uploaded); } @@ -266,12 +270,21 @@ public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_upload_list, menu); + if (menu.getItem(0).getItemId() == R.id.action_toogle_global_pause){ + if (preferences.getGlobalUploadPaused()){ + menu.getItem(0).setIcon(android.R.drawable.ic_media_play); + }else{ + menu.getItem(0).setIcon(android.R.drawable.ic_media_pause); + } + + } + return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { - boolean retval = true; + int itemId = item.getItemId(); if (itemId == android.R.id.home) { @@ -280,17 +293,20 @@ public boolean onOptionsItemSelected(MenuItem item) { } else { openDrawer(); } - } else if (itemId == R.id.action_clear_failed_uploads) { - for (OCUpload upload : uploadsStorageManager.getFailedButNotDelayedUploadsForCurrentAccount()){ - uploadListAdapter.cancelOldErrorNotification(upload); + } else if (itemId == R.id.action_toogle_global_pause) { + preferences.setGlobalUploadPaused(!preferences.getGlobalUploadPaused()); + if (preferences.getGlobalUploadPaused()){ + item.setIcon(android.R.drawable.ic_media_play); + }else{ + item.setIcon(android.R.drawable.ic_media_pause); + } + + for (User user: accountManager.getAllUsers()){ + if (user != null) FileUploadHelper.Companion.instance().cancelAndRestartUploadJob(user); } - uploadsStorageManager.clearFailedButNotDelayedUploads(); - uploadListAdapter.loadUploadItemsFromDb(); - } else { - retval = super.onOptionsItemSelected(item); } - return retval; + return true; } @Override diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index 3a5e26fc9732..c34629afe87d 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -122,29 +122,56 @@ public void onBindHeaderViewHolder(SectionedViewHolder holder, int section, bool headerViewHolder.binding.uploadListTitle.setOnClickListener(v -> toggleSectionExpanded(section)); switch (group.type) { - case CURRENT, FINISHED -> headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_close); - case FAILED -> headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_sync); + case CURRENT: case FINISHED: + headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_close); + break; + case FAILED: + headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_dots_vertical); + break; + } headerViewHolder.binding.uploadListAction.setOnClickListener(v -> { + PopupMenu popup; + final Optional optionalUser = parentActivity.getUser(); switch (group.type) { case CURRENT -> { for (OCUpload upload : group.getItems()) { uploadHelper.cancelFileUpload(upload.getRemotePath(), upload.getAccountName()); } + loadUploadItemsFromDb(); } - case FINISHED -> uploadsStorageManager.clearSuccessfulUploads(); - case FAILED -> new Thread(() -> FileUploadHelper.Companion.instance().retryFailedUploads( - uploadsStorageManager, - connectivityService, - accountManager, - powerManagementService)).start(); - default -> { + case FINISHED -> { + uploadsStorageManager.clearSuccessfulUploads(); + loadUploadItemsFromDb(); } - // do nothing - } + case FAILED -> { + popup = new PopupMenu(MainApp.getAppContext(), headerViewHolder.binding.uploadListAction); + popup.inflate(R.menu.upload_list_failed_options); + popup.setOnMenuItemClickListener(i -> { + int itemId = i.getItemId(); + + if (itemId == R.id.action_upload_list_failed_clear) { + uploadsStorageManager.clearFailedButNotDelayedUploads(); + loadUploadItemsFromDb(); + } else { + + new Thread(() -> { + FileUploadHelper.Companion.instance().retryFailedUploads( + uploadsStorageManager, + connectivityService, + accountManager, + powerManagementService); + parentActivity.runOnUiThread(this::loadUploadItemsFromDb); + }).start(); + - loadUploadItemsFromDb(); + } + return true; + }); + popup.show(); + } + } }); } diff --git a/app/src/main/res/menu/activity_upload_list.xml b/app/src/main/res/menu/activity_upload_list.xml index 0f9c66208263..cf30fea8a19c 100644 --- a/app/src/main/res/menu/activity_upload_list.xml +++ b/app/src/main/res/menu/activity_upload_list.xml @@ -16,13 +16,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . --> - + + android:id="@+id/action_toogle_global_pause" + android:icon="@android:drawable/ic_media_pause" + android:title="@string/action_clear_failed_uploads" + app:showAsAction="always" /> diff --git a/app/src/main/res/menu/upload_list_failed_options.xml b/app/src/main/res/menu/upload_list_failed_options.xml new file mode 100644 index 000000000000..59e6c6f65cae --- /dev/null +++ b/app/src/main/res/menu/upload_list_failed_options.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 275d65f20701..8f53720ea48b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -845,9 +845,13 @@ Sync conflict, please resolve manually Cannot create local file File could not be copied to local storage + Upload for all files is paused + Upload paused Storage quota exceeded Server not available Delete entries + Retry failed uploads + Clear failed uploads Dismiss notification Clear all notifications Loading is taking longer than expected From bba93328ed15b8721ff874cbda0713fe49b78202 Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Mon, 5 Feb 2024 12:24:52 +0100 Subject: [PATCH 02/14] Add info text to upload list activity Signed-off-by: Jonas Mayer --- .../owncloud/android/ui/activity/DrawerActivity.java | 4 ++++ .../android/ui/activity/UploadListActivity.java | 11 ++++++++--- .../android/ui/adapter/UploadListAdapter.java | 2 ++ app/src/main/res/menu/activity_upload_list.xml | 4 ++-- app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 359ea619d24b..61ad9629e005 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -1155,6 +1155,10 @@ public boolean isDrawerIndicatorAvailable() { return true; } + public AppPreferences getAppPreferences(){ + return preferences; + } + @Override protected void onStart() { super.onStart(); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index 67c9b211c533..6234c5c07bf9 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -49,7 +49,6 @@ import com.owncloud.android.databinding.UploadListLayoutBinding; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.UploadsStorageManager; -import com.owncloud.android.db.OCUpload; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.utils.Log_OC; @@ -270,11 +269,17 @@ public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_upload_list, menu); - if (menu.getItem(0).getItemId() == R.id.action_toogle_global_pause){ + if (menu.getItem(0).getItemId() == R.id.action_toggle_global_pause){ if (preferences.getGlobalUploadPaused()){ menu.getItem(0).setIcon(android.R.drawable.ic_media_play); + menu.getItem(0).setTitle(getApplicationContext().getString( + R.string.upload_action_global_upload_resume + )); }else{ menu.getItem(0).setIcon(android.R.drawable.ic_media_pause); + menu.getItem(0).setTitle(getApplicationContext().getString( + R.string.upload_action_global_upload_pause + )); } } @@ -293,7 +298,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } else { openDrawer(); } - } else if (itemId == R.id.action_toogle_global_pause) { + } else if (itemId == R.id.action_toggle_global_pause) { preferences.setGlobalUploadPaused(!preferences.getGlobalUploadPaused()); if (preferences.getGlobalUploadPaused()){ item.setIcon(android.R.drawable.ic_media_play); diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index c34629afe87d..f61646084817 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -646,6 +646,8 @@ private String getStatusText(OCUpload upload) { if (uploadHelper.isUploadingNow(upload)) { // really uploading, bind the progress bar to listen for progress updates status = parentActivity.getString(R.string.uploader_upload_in_progress_ticker); + } else if (parentActivity.getAppPreferences().getGlobalUploadPaused()) { + status = parentActivity.getString(R.string.upload_global_pause); } break; diff --git a/app/src/main/res/menu/activity_upload_list.xml b/app/src/main/res/menu/activity_upload_list.xml index cf30fea8a19c..ee99cf634ff9 100644 --- a/app/src/main/res/menu/activity_upload_list.xml +++ b/app/src/main/res/menu/activity_upload_list.xml @@ -23,9 +23,9 @@ android:checkableBehavior="none"> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8f53720ea48b..988550125c07 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -852,6 +852,8 @@ Delete entries Retry failed uploads Clear failed uploads + Pause all uploads + Resume all uploads Dismiss notification Clear all notifications Loading is taking longer than expected From 3fa3f03bf8f3dbabb8efdd9902d7c1f4609acc91 Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Mon, 5 Feb 2024 22:06:07 +0100 Subject: [PATCH 03/14] rebase Signed-off-by: Jonas Mayer --- .../client/jobs/upload/FileUploadWorker.kt | 3 ++- .../jobs/upload/UploadNotificationManager.kt | 1 - .../ui/activity/UploadListActivity.java | 3 +++ .../android/ui/adapter/UploadListAdapter.java | 27 +++++++------------ 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt index 2decfa240cce..329884886c2a 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt @@ -138,12 +138,13 @@ class FileUploadWorker( WorkerStateLiveData.instance().setWorkState(WorkerState.Idle) } + @Suppress("ReturnCount") private fun retrievePagesBySortingUploadsByID(): Result { val accountName = inputData.getString(ACCOUNT) ?: return Result.failure() var currentPage = uploadsStorageManager.getCurrentAndPendingUploadsForAccountPageAscById(-1, accountName) while (currentPage.isNotEmpty() && !isStopped) { - if (preferences.globalUploadPaused){ + if (preferences.globalUploadPaused) { Log_OC.d(TAG, "Upload is paused, skip uploading files!") notificationManager.notifyPaused( intents.notificationStartIntent(null) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt index df86017280da..5fec34362609 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt @@ -210,7 +210,6 @@ class UploadNotificationManager(private val context: Context, private val viewTh setContentIntent(startIntent) } - showNotification() } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index 6234c5c07bf9..0d3f4e9843eb 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -24,6 +24,7 @@ package com.owncloud.android.ui.activity; import android.accounts.Account; +import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -287,6 +288,7 @@ public boolean onCreateOptionsMenu(Menu menu) { return true; } + @SuppressLint("NotifyDataSetChanged") @Override public boolean onOptionsItemSelected(MenuItem item) { @@ -309,6 +311,7 @@ public boolean onOptionsItemSelected(MenuItem item) { for (User user: accountManager.getAllUsers()){ if (user != null) FileUploadHelper.Companion.instance().cancelAndRestartUploadJob(user); } + uploadListAdapter.notifyDataSetChanged(); } return true; diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index f61646084817..ed85f21288c0 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -287,7 +287,6 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati itemViewHolder.binding.uploadRemotePath.setVisibility(View.VISIBLE); itemViewHolder.binding.uploadFileSize.setVisibility(View.VISIBLE); itemViewHolder.binding.uploadStatus.setVisibility(View.VISIBLE); - itemViewHolder.binding.uploadStatus.setTypeface(null, Typeface.NORMAL); itemViewHolder.binding.uploadProgressBar.setVisibility(View.GONE); // Update information depending of upload details @@ -333,7 +332,6 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati // show status if same file conflict or local file deleted if (item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED && item.getLastResult() != UploadResult.UPLOADED){ itemViewHolder.binding.uploadStatus.setVisibility(View.VISIBLE); - itemViewHolder.binding.uploadStatus.setTypeface(null, Typeface.BOLD); itemViewHolder.binding.uploadDate.setVisibility(View.GONE); itemViewHolder.binding.uploadFileSize.setVisibility(View.GONE); } @@ -641,32 +639,27 @@ private void openConflictActivity(OCFile file, OCUpload upload) { private String getStatusText(OCUpload upload) { String status; switch (upload.getUploadStatus()) { - case UPLOAD_IN_PROGRESS: + case UPLOAD_IN_PROGRESS -> { status = parentActivity.getString(R.string.uploads_view_later_waiting_to_upload); if (uploadHelper.isUploadingNow(upload)) { // really uploading, bind the progress bar to listen for progress updates status = parentActivity.getString(R.string.uploader_upload_in_progress_ticker); - } else if (parentActivity.getAppPreferences().getGlobalUploadPaused()) { + } + if (parentActivity.getAppPreferences().getGlobalUploadPaused()) { status = parentActivity.getString(R.string.upload_global_pause); } - break; - - case UPLOAD_SUCCEEDED: - if (upload.getLastResult() == UploadResult.SAME_FILE_CONFLICT){ + } + case UPLOAD_SUCCEEDED -> { + if (upload.getLastResult() == UploadResult.SAME_FILE_CONFLICT) { status = parentActivity.getString(R.string.uploads_view_upload_status_succeeded_same_file); - }else if (upload.getLastResult() == UploadResult.FILE_NOT_FOUND) { + } else if (upload.getLastResult() == UploadResult.FILE_NOT_FOUND) { status = getUploadFailedStatusText(upload.getLastResult()); } else { status = parentActivity.getString(R.string.uploads_view_upload_status_succeeded); } - break; - - case UPLOAD_FAILED: - status = getUploadFailedStatusText(upload.getLastResult()); - break; - - default: - status = "Uncontrolled status: " + upload.getUploadStatus(); + } + case UPLOAD_FAILED -> status = getUploadFailedStatusText(upload.getLastResult()); + default -> status = "Uncontrolled status: " + upload.getUploadStatus(); } return status; } From d6dfaa9a0da76651411e161480dc4e479909b317 Mon Sep 17 00:00:00 2001 From: Jonas Mayer <43114340+JonasMayerDev@users.noreply.github.com> Date: Fri, 9 Feb 2024 22:02:32 +0100 Subject: [PATCH 04/14] Update upload_list_failed_options.xml with right copyright year Signed-off-by: Jonas Mayer <43114340+JonasMayerDev@users.noreply.github.com> --- app/src/main/res/menu/upload_list_failed_options.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/menu/upload_list_failed_options.xml b/app/src/main/res/menu/upload_list_failed_options.xml index 59e6c6f65cae..9d263e8bd41a 100644 --- a/app/src/main/res/menu/upload_list_failed_options.xml +++ b/app/src/main/res/menu/upload_list_failed_options.xml @@ -3,8 +3,8 @@ Nextcloud Android client application @author Jonas Mayer - Copyright (C) 2019 Jonas Mayer - Copyright (C) 2019 Nextcloud GmbH + Copyright (C) 2024 Jonas Mayer + Copyright (C) 2024 Nextcloud GmbH This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by From 42054debe210d9af868f10a7f5f47dbab092fc5e Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Fri, 9 Feb 2024 22:34:33 +0100 Subject: [PATCH 05/14] suppress not true warning Signed-off-by: Jonas Mayer --- .../com/owncloud/android/ui/activity/UploadListActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index 0d3f4e9843eb..3ecf85730f83 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -65,6 +65,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.recyclerview.widget.GridLayoutManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** * Activity listing pending, active, and completed uploads. User can delete @@ -266,6 +267,7 @@ protected void onPause() { } @Override + @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_upload_list, menu); From 70d3b5c7a4da7f98d8347e6f5e84690865b73c52 Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Mon, 12 Feb 2024 11:24:15 +0100 Subject: [PATCH 06/14] suppress right warning Signed-off-by: Jonas Mayer --- .../com/owncloud/android/ui/activity/UploadListActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index 3ecf85730f83..fd499bdcde52 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -267,7 +267,7 @@ protected void onPause() { } @Override - @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") + @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_upload_list, menu); From 935faeb6936e881f4b4fb78a6897d98945bfa4a6 Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Mon, 12 Feb 2024 14:29:36 +0100 Subject: [PATCH 07/14] suppress false warning Signed-off-by: Jonas Mayer --- .../com/owncloud/android/ui/activity/UploadListActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index fd499bdcde52..3a75e5ce3936 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -290,8 +290,9 @@ public boolean onCreateOptionsMenu(Menu menu) { return true; } - @SuppressLint("NotifyDataSetChanged") @Override + @SuppressLint("NotifyDataSetChanged") + @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); From 955de94ea16687ea901d34c1a1217cece4e1a77c Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Mon, 12 Feb 2024 15:40:22 +0100 Subject: [PATCH 08/14] fix lint and incorporate changes by alper Signed-off-by: Jonas Mayer --- .../jobs/upload/UploadNotificationManager.kt | 16 +-- .../ui/activity/UploadListActivity.java | 59 ++++---- .../android/ui/adapter/UploadListAdapter.java | 136 +++++++++--------- app/src/main/res/values/strings.xml | 2 - 4 files changed, 107 insertions(+), 106 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt index 5fec34362609..8ec4394d0a84 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt @@ -37,16 +37,12 @@ import com.owncloud.android.utils.theme.ViewThemeUtils class UploadNotificationManager(private val context: Context, private val viewThemeUtils: ViewThemeUtils) { companion object { - private const val ID = 411 } private var notification: Notification? = null - private var notificationBuilder: NotificationCompat.Builder - private val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - - init { - notificationBuilder = NotificationUtils.newNotificationBuilder(context, viewThemeUtils).apply { + private var notificationBuilder: NotificationCompat.Builder = + NotificationUtils.newNotificationBuilder(context, viewThemeUtils).apply { setContentTitle(context.getString(R.string.foreground_service_upload)) setSmallIcon(R.drawable.notification_icon) setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon)) @@ -55,13 +51,15 @@ class UploadNotificationManager(private val context: Context, private val viewTh setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD) } } + private val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + init { notification = notificationBuilder.build() } @Suppress("MagicNumber") fun prepareForStart(upload: UploadFileOperation, pendingIntent: PendingIntent, startIntent: PendingIntent) { - notificationBuilder = NotificationUtils.newNotificationBuilder(context, viewThemeUtils).apply { + notificationBuilder.run { setSmallIcon(R.drawable.notification_icon) setOngoing(true) setTicker(context.getString(R.string.foreground_service_upload)) @@ -195,12 +193,14 @@ class UploadNotificationManager(private val context: Context, private val viewTh } fun notifyPaused(startIntent: PendingIntent) { - notificationBuilder = NotificationUtils.newNotificationBuilder(context, viewThemeUtils).apply { + notificationBuilder.apply { setSmallIcon(R.drawable.notification_icon) setOngoing(true) + setAutoCancel(false) setTicker(context.getString(R.string.upload_global_pause)) setContentTitle(context.getString(R.string.upload_global_pause_title)) setContentText(context.getString(R.string.upload_global_pause)) + setProgress(0, 0, false) clearActions() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index 3a75e5ce3936..eeb2c1c6de3b 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -68,9 +68,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** - * Activity listing pending, active, and completed uploads. User can delete - * completed uploads from view. Content of this list of coming from - * {@link UploadsStorageManager}. + * Activity listing pending, active, and completed uploads. User can delete completed uploads from view. Content of this + * list of coming from {@link UploadsStorageManager}. */ public class UploadListActivity extends FileActivity { @@ -211,7 +210,7 @@ private void loadItems() { private void refresh() { backgroundJobManager.startImmediateFilesSyncJob(false, true); - if(uploadsStorageManager.getFailedUploads().length > 0){ + if (uploadsStorageManager.getFailedUploads().length > 0) { new Thread(() -> { FileUploadHelper.Companion.instance().retryFailedUploads( uploadsStorageManager, @@ -267,32 +266,46 @@ protected void onPause() { } @Override - @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_upload_list, menu); + updateGlobalPauseIcon(menu.getItem(0)); + return true; + } - if (menu.getItem(0).getItemId() == R.id.action_toggle_global_pause){ - if (preferences.getGlobalUploadPaused()){ - menu.getItem(0).setIcon(android.R.drawable.ic_media_play); - menu.getItem(0).setTitle(getApplicationContext().getString( + @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") + private void updateGlobalPauseIcon(MenuItem pauseMenuItem) { + if (pauseMenuItem.getItemId() == R.id.action_toggle_global_pause) { + if (preferences.getGlobalUploadPaused()) { + pauseMenuItem.setIcon(android.R.drawable.ic_media_play); + pauseMenuItem.setTitle(getApplicationContext().getString( R.string.upload_action_global_upload_resume - )); - }else{ - menu.getItem(0).setIcon(android.R.drawable.ic_media_pause); - menu.getItem(0).setTitle(getApplicationContext().getString( + )); + } else { + pauseMenuItem.setIcon(android.R.drawable.ic_media_pause); + pauseMenuItem.setTitle(getApplicationContext().getString( R.string.upload_action_global_upload_pause - )); + )); } } + } - return true; + @SuppressLint("NotifyDataSetChanged") + private void toggleGlobalPause(MenuItem pauseMenuItem) { + preferences.setGlobalUploadPaused(!preferences.getGlobalUploadPaused()); + updateGlobalPauseIcon(pauseMenuItem); + + for (User user : accountManager.getAllUsers()) { + if (user != null) { + FileUploadHelper.Companion.instance().cancelAndRestartUploadJob(user); + } + } + + uploadListAdapter.notifyDataSetChanged(); } @Override - @SuppressLint("NotifyDataSetChanged") - @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); @@ -304,17 +317,7 @@ public boolean onOptionsItemSelected(MenuItem item) { openDrawer(); } } else if (itemId == R.id.action_toggle_global_pause) { - preferences.setGlobalUploadPaused(!preferences.getGlobalUploadPaused()); - if (preferences.getGlobalUploadPaused()){ - item.setIcon(android.R.drawable.ic_media_play); - }else{ - item.setIcon(android.R.drawable.ic_media_pause); - } - - for (User user: accountManager.getAllUsers()){ - if (user != null) FileUploadHelper.Companion.instance().cancelAndRestartUploadJob(user); - } - uploadListAdapter.notifyDataSetChanged(); + toggleGlobalPause(item); } return true; diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index ed85f21288c0..20512215c754 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -122,57 +122,56 @@ public void onBindHeaderViewHolder(SectionedViewHolder holder, int section, bool headerViewHolder.binding.uploadListTitle.setOnClickListener(v -> toggleSectionExpanded(section)); switch (group.type) { - case CURRENT: case FINISHED: - headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_close); - break; - case FAILED: - headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_dots_vertical); - break; - + case CURRENT, FINISHED -> headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_close); + case FAILED -> headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_dots_vertical); } headerViewHolder.binding.uploadListAction.setOnClickListener(v -> { - PopupMenu popup; - final Optional optionalUser = parentActivity.getUser(); switch (group.type) { case CURRENT -> { + // cancel all current uploads for (OCUpload upload : group.getItems()) { uploadHelper.cancelFileUpload(upload.getRemotePath(), upload.getAccountName()); } loadUploadItemsFromDb(); } case FINISHED -> { + // clear successfully uploaded section uploadsStorageManager.clearSuccessfulUploads(); loadUploadItemsFromDb(); } case FAILED -> { - popup = new PopupMenu(MainApp.getAppContext(), headerViewHolder.binding.uploadListAction); - popup.inflate(R.menu.upload_list_failed_options); - popup.setOnMenuItemClickListener(i -> { - int itemId = i.getItemId(); - - if (itemId == R.id.action_upload_list_failed_clear) { - uploadsStorageManager.clearFailedButNotDelayedUploads(); - loadUploadItemsFromDb(); - } else { + // show popup with option clear or retry filed uploads + createFailedPopupMenu(headerViewHolder); + } + } + }); + } - new Thread(() -> { - FileUploadHelper.Companion.instance().retryFailedUploads( - uploadsStorageManager, - connectivityService, - accountManager, - powerManagementService); - parentActivity.runOnUiThread(this::loadUploadItemsFromDb); - }).start(); + private void createFailedPopupMenu(HeaderViewHolder headerViewHolder) { + PopupMenu failedPopup = new PopupMenu(MainApp.getAppContext(), headerViewHolder.binding.uploadListAction); + failedPopup.inflate(R.menu.upload_list_failed_options); + failedPopup.setOnMenuItemClickListener(i -> { + int itemId = i.getItemId(); + + if (itemId == R.id.action_upload_list_failed_clear) { + uploadsStorageManager.clearFailedButNotDelayedUploads(); + loadUploadItemsFromDb(); + } else { + new Thread(() -> { + FileUploadHelper.Companion.instance().retryFailedUploads( + uploadsStorageManager, + connectivityService, + accountManager, + powerManagementService); + parentActivity.runOnUiThread(this::loadUploadItemsFromDb); + }).start(); - } - return true; - }); - popup.show(); - } } + return true; }); + failedPopup.show(); } @Override @@ -255,7 +254,7 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati // file size if (item.getFileSize() != 0) { itemViewHolder.binding.uploadFileSize.setText(String.format("%s, ", - DisplayUtils.bytesToHumanReadable(item.getFileSize()))); + DisplayUtils.bytesToHumanReadable(item.getFileSize()))); } else { itemViewHolder.binding.uploadFileSize.setText(""); } @@ -330,7 +329,7 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati } // show status if same file conflict or local file deleted - if (item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED && item.getLastResult() != UploadResult.UPLOADED){ + if (item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED && item.getLastResult() != UploadResult.UPLOADED) { itemViewHolder.binding.uploadStatus.setVisibility(View.VISIBLE); itemViewHolder.binding.uploadDate.setVisibility(View.GONE); itemViewHolder.binding.uploadFileSize.setVisibility(View.GONE); @@ -398,16 +397,16 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati DisplayUtils.showSnackMessage( v.getRootView().findViewById(android.R.id.content), R.string.local_file_not_found_message - ); + ); } }); - } else if (item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED){ + } else if (item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) { itemViewHolder.binding.uploadListItemLayout.setOnClickListener(v -> onUploadedItemClick(item)); } // click on thumbnail to open locally - if (item.getUploadStatus() != UploadStatus.UPLOAD_SUCCEEDED){ + if (item.getUploadStatus() != UploadStatus.UPLOAD_SUCCEEDED) { itemViewHolder.binding.thumbnail.setOnClickListener(v -> onUploadingItemClick(item)); } @@ -420,17 +419,17 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati fakeFileToCheatThumbnailsCacheManagerInterface.setMimeType(item.getMimeType()); boolean allowedToCreateNewThumbnail = ThumbnailsCacheManager.cancelPotentialThumbnailWork( - fakeFileToCheatThumbnailsCacheManagerInterface, itemViewHolder.binding.thumbnail - ); + fakeFileToCheatThumbnailsCacheManagerInterface, itemViewHolder.binding.thumbnail + ); // TODO this code is duplicated; refactor to a common place if (MimeTypeUtil.isImage(fakeFileToCheatThumbnailsCacheManagerInterface) - && fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId() != null && - item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) { + && fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId() != null && + item.getUploadStatus() == UploadStatus.UPLOAD_SUCCEEDED) { // Thumbnail in Cache? Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache( - String.valueOf(fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId()) - ); + String.valueOf(fakeFileToCheatThumbnailsCacheManagerInterface.getRemoteId()) + ); if (thumbnail != null && !fakeFileToCheatThumbnailsCacheManagerInterface.isUpdateThumbnailNeeded()) { itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail); } else { @@ -438,11 +437,11 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati Optional user = parentActivity.getUser(); if (allowedToCreateNewThumbnail && user.isPresent()) { final ThumbnailsCacheManager.ThumbnailGenerationTask task = - new ThumbnailsCacheManager.ThumbnailGenerationTask( - itemViewHolder.binding.thumbnail, - parentActivity.getStorageManager(), - user.get() - ); + new ThumbnailsCacheManager.ThumbnailGenerationTask( + itemViewHolder.binding.thumbnail, + parentActivity.getStorageManager(), + user.get() + ); if (thumbnail == null) { if (MimeTypeUtil.isVideo(fakeFileToCheatThumbnailsCacheManagerInterface)) { thumbnail = ThumbnailsCacheManager.mDefaultVideo; @@ -451,20 +450,20 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati } } final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable = - new ThumbnailsCacheManager.AsyncThumbnailDrawable( - parentActivity.getResources(), - thumbnail, - task - ); + new ThumbnailsCacheManager.AsyncThumbnailDrawable( + parentActivity.getResources(), + thumbnail, + task + ); itemViewHolder.binding.thumbnail.setImageDrawable(asyncDrawable); task.execute(new ThumbnailsCacheManager.ThumbnailGenerationTaskObject( - fakeFileToCheatThumbnailsCacheManagerInterface, null)); + fakeFileToCheatThumbnailsCacheManagerInterface, null)); } } if ("image/png".equals(item.getMimeType())) { itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources() - .getColor(R.color.bg_default)); + .getColor(R.color.bg_default)); } @@ -472,14 +471,14 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati File file = new File(item.getLocalPath()); // Thumbnail in Cache? Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache( - String.valueOf(file.hashCode())); + String.valueOf(file.hashCode())); if (thumbnail != null) { itemViewHolder.binding.thumbnail.setImageBitmap(thumbnail); } else { // generate new Thumbnail if (allowedToCreateNewThumbnail) { final ThumbnailsCacheManager.ThumbnailGenerationTask task = - new ThumbnailsCacheManager.ThumbnailGenerationTask(itemViewHolder.binding.thumbnail); + new ThumbnailsCacheManager.ThumbnailGenerationTask(itemViewHolder.binding.thumbnail); if (MimeTypeUtil.isVideo(file)) { thumbnail = ThumbnailsCacheManager.mDefaultVideo; @@ -499,7 +498,7 @@ public void onBindViewHolder(SectionedViewHolder holder, int section, int relati if ("image/png".equalsIgnoreCase(item.getMimeType())) { itemViewHolder.binding.thumbnail.setBackgroundColor(parentActivity.getResources() - .getColor(R.color.bg_default)); + .getColor(R.color.bg_default)); } } else { if (optionalUser.isPresent()) { @@ -630,8 +629,7 @@ private void openConflictActivity(OCFile file, OCUpload upload) { } /** - * Gets the status text to show to the user according to the status and last result of the - * the given upload. + * Gets the status text to show to the user according to the status and last result of the the given upload. * * @param upload Upload to describe. * @return Text describing the status of the given upload. @@ -712,8 +710,8 @@ private String getUploadFailedStatusText(UploadResult result) { case SSL_RECOVERABLE_PEER_UNVERIFIED: status = parentActivity.getString( - R.string.uploads_view_upload_status_failed_ssl_certificate_not_trusted - ); + R.string.uploads_view_upload_status_failed_ssl_certificate_not_trusted + ); break; case UNKNOWN: status = parentActivity.getString(R.string.uploads_view_upload_status_unknown_fail); @@ -723,7 +721,7 @@ private String getUploadFailedStatusText(UploadResult result) { break; case DELAYED_IN_POWER_SAVE_MODE: status = parentActivity.getString( - R.string.uploads_view_upload_status_waiting_exit_power_save_mode); + R.string.uploads_view_upload_status_waiting_exit_power_save_mode); break; case VIRUS_DETECTED: status = parentActivity.getString(R.string.uploads_view_upload_status_virus_detected); @@ -798,17 +796,17 @@ private void onUploadingItemClick(OCUpload file) { */ private void onUploadedItemClick(OCUpload upload) { final OCFile file = parentActivity.getStorageManager().getFileByEncryptedRemotePath(upload.getRemotePath()); - if (file == null){ + if (file == null) { DisplayUtils.showSnackMessage(parentActivity, R.string.error_retrieving_file); Log_OC.i(TAG, "Could not find uploaded file on remote."); return; } - if (PreviewImageFragment.canBePreviewed(file)){ + if (PreviewImageFragment.canBePreviewed(file)) { //show image preview and stay in uploads tab Intent intent = FileDisplayActivity.openFileIntent(parentActivity, parentActivity.getUser().get(), file); parentActivity.startActivity(intent); - }else{ + } else { Intent intent = new Intent(parentActivity, FileDisplayActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.putExtra(FileDisplayActivity.KEY_FILE_PATH, upload.getRemotePath()); @@ -904,14 +902,16 @@ private int getGroupItemCount() { } } - public void cancelOldErrorNotification(OCUpload upload){ + public void cancelOldErrorNotification(OCUpload upload) { if (mNotificationManager == null) { mNotificationManager = (NotificationManager) parentActivity.getSystemService(parentActivity.NOTIFICATION_SERVICE); } - if (upload == null) return; - mNotificationManager.cancel(NotificationUtils.createUploadNotificationTag(upload.getRemotePath(),upload.getLocalPath()), + if (upload == null) { + return; + } + mNotificationManager.cancel(NotificationUtils.createUploadNotificationTag(upload.getRemotePath(), upload.getLocalPath()), FileUploadWorker.NOTIFICATION_ERROR_ID); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 988550125c07..63e3c9e4b147 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -522,8 +522,6 @@ %1$s (conversation) on %1$s - Clear failed uploads - Grid view List view From 9a5bf130fdfff75f21f7e49375a53411e181e61b Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Mon, 12 Feb 2024 16:23:46 +0100 Subject: [PATCH 09/14] push so alper can help me Signed-off-by: Jonas Mayer --- .../ui/activity/UploadListActivity.java | 40 +++++++++++++------ app/src/main/res/drawable/ic_pause.xml | 9 +++++ 2 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/drawable/ic_pause.xml diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index eeb2c1c6de3b..50c38e36c217 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -29,6 +29,9 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.graphics.Canvas; +import android.graphics.ColorFilter; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; @@ -57,11 +60,16 @@ import com.owncloud.android.ui.adapter.UploadListAdapter; import com.owncloud.android.ui.decoration.MediaGridItemDecoration; import com.owncloud.android.utils.DisplayUtils; +import com.owncloud.android.utils.DrawableUtil; import com.owncloud.android.utils.FilesSyncHelper; import com.owncloud.android.utils.theme.ViewThemeUtils; import javax.inject.Inject; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.content.res.AppCompatResources; +import androidx.core.content.res.ResourcesCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.recyclerview.widget.GridLayoutManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -275,20 +283,28 @@ public boolean onCreateOptionsMenu(Menu menu) { @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") private void updateGlobalPauseIcon(MenuItem pauseMenuItem) { - if (pauseMenuItem.getItemId() == R.id.action_toggle_global_pause) { - if (preferences.getGlobalUploadPaused()) { - pauseMenuItem.setIcon(android.R.drawable.ic_media_play); - pauseMenuItem.setTitle(getApplicationContext().getString( - R.string.upload_action_global_upload_resume - )); - } else { - pauseMenuItem.setIcon(android.R.drawable.ic_media_pause); - pauseMenuItem.setTitle(getApplicationContext().getString( - R.string.upload_action_global_upload_pause - )); - } + if (pauseMenuItem.getItemId() != R.id.action_toggle_global_pause) { + return; + } + int iconId; + String title; + if (preferences.getGlobalUploadPaused()) { + iconId = R.drawable.ic_play_arrow; + title = getString(R.string.upload_action_global_upload_resume); + } else { + iconId = R.drawable.ic_pause; + title = getString(R.string.upload_action_global_upload_pause); } + /* + DrawableUtil drawableUtil = new DrawableUtil(); + Drawable iconDrawable = AppCompatResources.getDrawable(this, iconId); + assert iconDrawable != null; + iconDrawable = drawableUtil.changeColor(iconDrawable, R.color.dark_background_text_color); + */ + + pauseMenuItem.setIcon(iconId); + pauseMenuItem.setTitle(title); } @SuppressLint("NotifyDataSetChanged") diff --git a/app/src/main/res/drawable/ic_pause.xml b/app/src/main/res/drawable/ic_pause.xml new file mode 100644 index 000000000000..2f8d6bb2e540 --- /dev/null +++ b/app/src/main/res/drawable/ic_pause.xml @@ -0,0 +1,9 @@ + + + From d5b111ae7e012fa79cbab54e3f13ebb6f6f71a94 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 12 Feb 2024 16:43:29 +0100 Subject: [PATCH 10/14] Add play icon and set better color for both theme Signed-off-by: alperozturk --- .../ui/activity/UploadListActivity.java | 8 +---- app/src/main/res/drawable/ic_pause.xml | 2 +- app/src/main/res/drawable/ic_play.xml | 30 +++++++++++++++++++ app/src/main/res/values-night/colors.xml | 1 + app/src/main/res/values/colors.xml | 1 + 5 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/drawable/ic_play.xml diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index 50c38e36c217..b5977d7188f9 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -290,18 +290,12 @@ private void updateGlobalPauseIcon(MenuItem pauseMenuItem) { int iconId; String title; if (preferences.getGlobalUploadPaused()) { - iconId = R.drawable.ic_play_arrow; + iconId = R.drawable.ic_play; title = getString(R.string.upload_action_global_upload_resume); } else { iconId = R.drawable.ic_pause; title = getString(R.string.upload_action_global_upload_pause); } - /* - DrawableUtil drawableUtil = new DrawableUtil(); - Drawable iconDrawable = AppCompatResources.getDrawable(this, iconId); - assert iconDrawable != null; - iconDrawable = drawableUtil.changeColor(iconDrawable, R.color.dark_background_text_color); - */ pauseMenuItem.setIcon(iconId); pauseMenuItem.setTitle(title); diff --git a/app/src/main/res/drawable/ic_pause.xml b/app/src/main/res/drawable/ic_pause.xml index 2f8d6bb2e540..3ee93a2b3321 100644 --- a/app/src/main/res/drawable/ic_pause.xml +++ b/app/src/main/res/drawable/ic_pause.xml @@ -4,6 +4,6 @@ android:viewportWidth="960" android:viewportHeight="960"> diff --git a/app/src/main/res/drawable/ic_play.xml b/app/src/main/res/drawable/ic_play.xml new file mode 100644 index 000000000000..5557cd3b7fae --- /dev/null +++ b/app/src/main/res/drawable/ic_play.xml @@ -0,0 +1,30 @@ + + + + + diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 08bf64d552ad..0c23e15f1550 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -33,6 +33,7 @@ #818181 #222222 #ffffff + #EAE0E5 @color/appbar diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 58fcdecf1fc2..b18023e7d3df 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -59,6 +59,7 @@ #000000 #ededed #000000 + #1D1B1E #ffffff #ffffff From a5bc2684c50f979aa69d952fe4e4a570d4a1d2ef Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 12 Feb 2024 16:52:04 +0100 Subject: [PATCH 11/14] Remove repeated notification builder code Signed-off-by: alperozturk --- .../jobs/upload/UploadNotificationManager.kt | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt index 8ec4394d0a84..a02919f01f37 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt @@ -35,7 +35,7 @@ import com.owncloud.android.operations.UploadFileOperation import com.owncloud.android.ui.notifications.NotificationUtils import com.owncloud.android.utils.theme.ViewThemeUtils -class UploadNotificationManager(private val context: Context, private val viewThemeUtils: ViewThemeUtils) { +class UploadNotificationManager(private val context: Context, viewThemeUtils: ViewThemeUtils) { companion object { private const val ID = 411 } @@ -60,11 +60,7 @@ class UploadNotificationManager(private val context: Context, private val viewTh @Suppress("MagicNumber") fun prepareForStart(upload: UploadFileOperation, pendingIntent: PendingIntent, startIntent: PendingIntent) { notificationBuilder.run { - setSmallIcon(R.drawable.notification_icon) - setOngoing(true) - setTicker(context.getString(R.string.foreground_service_upload)) setContentTitle(context.getString(R.string.uploader_upload_in_progress_ticker)) - setProgress(100, 0, false) setContentText( String.format( context.getString(R.string.uploader_upload_in_progress), @@ -72,6 +68,9 @@ class UploadNotificationManager(private val context: Context, private val viewTh upload.fileName ) ) + setTicker(context.getString(R.string.foreground_service_upload)) + setProgress(100, 0, false) + setOngoing(true) clearActions() addAction( @@ -80,10 +79,6 @@ class UploadNotificationManager(private val context: Context, private val viewTh pendingIntent ) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD) - } - setContentIntent(startIntent) } @@ -192,22 +187,16 @@ class UploadNotificationManager(private val context: Context, private val viewTh notificationManager.cancel(ID) } - fun notifyPaused(startIntent: PendingIntent) { + fun notifyPaused(intent: PendingIntent) { notificationBuilder.apply { - setSmallIcon(R.drawable.notification_icon) - setOngoing(true) - setAutoCancel(false) - setTicker(context.getString(R.string.upload_global_pause)) setContentTitle(context.getString(R.string.upload_global_pause_title)) setContentText(context.getString(R.string.upload_global_pause)) + setTicker(context.getString(R.string.upload_global_pause)) + setOngoing(true) + setAutoCancel(false) setProgress(0, 0, false) clearActions() - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD) - } - - setContentIntent(startIntent) + setContentIntent(intent) } showNotification() From aee4a6cb9d5e10e89f918684323cf07143d86e21 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 12 Feb 2024 17:02:19 +0100 Subject: [PATCH 12/14] Change Title, remove description for uploads. Signed-off-by: alperozturk --- .../nextcloud/client/jobs/upload/UploadNotificationManager.kt | 3 +-- .../com/owncloud/android/ui/adapter/UploadListAdapter.java | 2 +- app/src/main/res/values/strings.xml | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt index a02919f01f37..76bbce3594bd 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt @@ -190,8 +190,7 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi fun notifyPaused(intent: PendingIntent) { notificationBuilder.apply { setContentTitle(context.getString(R.string.upload_global_pause_title)) - setContentText(context.getString(R.string.upload_global_pause)) - setTicker(context.getString(R.string.upload_global_pause)) + setTicker(context.getString(R.string.upload_global_pause_title)) setOngoing(true) setAutoCancel(false) setProgress(0, 0, false) diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index 20512215c754..f7d5f8132cff 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -644,7 +644,7 @@ private String getStatusText(OCUpload upload) { status = parentActivity.getString(R.string.uploader_upload_in_progress_ticker); } if (parentActivity.getAppPreferences().getGlobalUploadPaused()) { - status = parentActivity.getString(R.string.upload_global_pause); + status = parentActivity.getString(R.string.upload_global_pause_title); } } case UPLOAD_SUCCEEDED -> { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 63e3c9e4b147..6fd30bc9360f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -843,8 +843,7 @@ Sync conflict, please resolve manually Cannot create local file File could not be copied to local storage - Upload for all files is paused - Upload paused + All uploads are paused Storage quota exceeded Server not available Delete entries From d75227aa0fae6952132d6552b7249c618f62992f Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Mon, 12 Feb 2024 23:35:41 +0100 Subject: [PATCH 13/14] Fix codacy issue Signed-off-by: Jonas Mayer --- .../nextcloud/client/jobs/upload/FileUploadWorker.kt | 2 +- .../nextcloud/client/preferences/AppPreferences.java | 2 +- .../client/preferences/AppPreferencesImpl.java | 2 +- .../android/ui/activity/UploadListActivity.java | 12 ++---------- .../android/ui/adapter/UploadListAdapter.java | 3 +-- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt index 329884886c2a..91b2586ef82b 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt @@ -144,7 +144,7 @@ class FileUploadWorker( var currentPage = uploadsStorageManager.getCurrentAndPendingUploadsForAccountPageAscById(-1, accountName) while (currentPage.isNotEmpty() && !isStopped) { - if (preferences.globalUploadPaused) { + if (preferences.isGlobalUploadPaused) { Log_OC.d(TAG, "Upload is paused, skip uploading files!") notificationManager.notifyPaused( intents.notificationStartIntent(null) diff --git a/app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java b/app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java index e11c5bf09b29..febd96c6215d 100644 --- a/app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java +++ b/app/src/main/java/com/nextcloud/client/preferences/AppPreferences.java @@ -387,7 +387,7 @@ default void onDarkThemeModeChanged(DarkMode mode) { void setCalendarLastBackup(long timestamp); - boolean getGlobalUploadPaused(); + boolean isGlobalUploadPaused(); void setGlobalUploadPaused(boolean globalPausedState); diff --git a/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java b/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java index 79489a321aae..ac69794aafcb 100644 --- a/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java +++ b/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java @@ -744,7 +744,7 @@ public void setCalendarLastBackup(long timestamp) { } @Override - public boolean getGlobalUploadPaused() { + public boolean isGlobalUploadPaused() { return preferences.getBoolean(PREF__GLOBAL_PAUSE_STATE,false); } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index b5977d7188f9..aff97bc173f5 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -29,9 +29,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.graphics.Canvas; -import android.graphics.ColorFilter; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; @@ -60,16 +57,11 @@ import com.owncloud.android.ui.adapter.UploadListAdapter; import com.owncloud.android.ui.decoration.MediaGridItemDecoration; import com.owncloud.android.utils.DisplayUtils; -import com.owncloud.android.utils.DrawableUtil; import com.owncloud.android.utils.FilesSyncHelper; import com.owncloud.android.utils.theme.ViewThemeUtils; import javax.inject.Inject; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.content.res.AppCompatResources; -import androidx.core.content.res.ResourcesCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.recyclerview.widget.GridLayoutManager; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; @@ -289,7 +281,7 @@ private void updateGlobalPauseIcon(MenuItem pauseMenuItem) { int iconId; String title; - if (preferences.getGlobalUploadPaused()) { + if (preferences.isGlobalUploadPaused()) { iconId = R.drawable.ic_play; title = getString(R.string.upload_action_global_upload_resume); } else { @@ -303,7 +295,7 @@ private void updateGlobalPauseIcon(MenuItem pauseMenuItem) { @SuppressLint("NotifyDataSetChanged") private void toggleGlobalPause(MenuItem pauseMenuItem) { - preferences.setGlobalUploadPaused(!preferences.getGlobalUploadPaused()); + preferences.setGlobalUploadPaused(!preferences.isGlobalUploadPaused()); updateGlobalPauseIcon(pauseMenuItem); for (User user : accountManager.getAllUsers()) { diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index f7d5f8132cff..50168c5b0dc0 100755 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -29,7 +29,6 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; -import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; import android.text.format.DateUtils; @@ -643,7 +642,7 @@ private String getStatusText(OCUpload upload) { // really uploading, bind the progress bar to listen for progress updates status = parentActivity.getString(R.string.uploader_upload_in_progress_ticker); } - if (parentActivity.getAppPreferences().getGlobalUploadPaused()) { + if (parentActivity.getAppPreferences().isGlobalUploadPaused()) { status = parentActivity.getString(R.string.upload_global_pause_title); } } From 4e184d1830afaef5680b8c682775abd5491bdc56 Mon Sep 17 00:00:00 2001 From: Jonas Mayer Date: Tue, 13 Feb 2024 13:56:39 +0100 Subject: [PATCH 14/14] Make onOptionsItemSelected not always return true Signed-off-by: Jonas Mayer --- .../com/owncloud/android/ui/activity/UploadListActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index aff97bc173f5..543dee7bb4bf 100755 --- a/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -320,6 +320,8 @@ public boolean onOptionsItemSelected(MenuItem item) { } } else if (itemId == R.id.action_toggle_global_pause) { toggleGlobalPause(item); + } else { + return super.onOptionsItemSelected(item); } return true;