diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT_showDetailsActivitiesNone_light_white.png b/screenshots/gplay/debug/com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT_showDetailsActivitiesNone_light_white.png index 93e06caf80..9d05bfab8f 100644 Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT_showDetailsActivitiesNone_light_white.png and b/screenshots/gplay/debug/com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT_showDetailsActivitiesNone_light_white.png differ diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT_showDetailsActivities_light_white.png b/screenshots/gplay/debug/com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT_showDetailsActivities_light_white.png index 0dde55a729..e70545147d 100644 Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT_showDetailsActivities_light_white.png and b/screenshots/gplay/debug/com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT_showDetailsActivities_light_white.png differ diff --git a/src/androidTest/java/com/owncloud/android/ui/activity/NotificationsActivityIT.kt b/src/androidTest/java/com/owncloud/android/ui/activity/NotificationsActivityIT.kt index 9913ca46b7..a2b3c122fb 100644 --- a/src/androidTest/java/com/owncloud/android/ui/activity/NotificationsActivityIT.kt +++ b/src/androidTest/java/com/owncloud/android/ui/activity/NotificationsActivityIT.kt @@ -48,6 +48,8 @@ class NotificationsActivityIT : AbstractIT() { fun empty() { val sut: NotificationsActivity = activityRule.launchActivity(null) + waitForIdleSync() + sut.runOnUiThread { sut.populateList(ArrayList()) } shortSleep() diff --git a/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailFragmentStaticServerIT.kt b/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailFragmentStaticServerIT.kt index 0d5757d3de..a88e02061d 100644 --- a/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailFragmentStaticServerIT.kt +++ b/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailFragmentStaticServerIT.kt @@ -49,6 +49,8 @@ class FileDetailFragmentStaticServerIT : AbstractIT() { sut.addFragment(FileDetailActivitiesFragment.newInstance(file, user)) waitForIdleSync() + shortSleep() + shortSleep() screenshot(sut) } @@ -59,6 +61,8 @@ class FileDetailFragmentStaticServerIT : AbstractIT() { sut.addFragment(FileDetailSharingFragment.newInstance(file, user)) waitForIdleSync() + shortSleep() + shortSleep() screenshot(sut) } @@ -128,6 +132,8 @@ class FileDetailFragmentStaticServerIT : AbstractIT() { sut.fileDetailActivitiesFragment.populateList(activities as List?, true) } + shortSleep() + shortSleep() screenshot(activity) } @@ -145,7 +151,7 @@ class FileDetailFragmentStaticServerIT : AbstractIT() { } shortSleep() - + shortSleep() screenshot(activity) } @@ -166,7 +172,6 @@ class FileDetailFragmentStaticServerIT : AbstractIT() { shortSleep() shortSleep() - screenshot(activity) } @@ -177,6 +182,9 @@ class FileDetailFragmentStaticServerIT : AbstractIT() { sut.addFragment(FileDetailFragment.newInstance(file, user, 1)) waitForIdleSync() + + shortSleep() + shortSleep() screenshot(sut) } } diff --git a/src/main/java/com/owncloud/android/files/services/FileDownloader.java b/src/main/java/com/owncloud/android/files/services/FileDownloader.java index 1132a2591d..91a6155dfc 100644 --- a/src/main/java/com/owncloud/android/files/services/FileDownloader.java +++ b/src/main/java/com/owncloud/android/files/services/FileDownloader.java @@ -69,6 +69,7 @@ import com.owncloud.android.utils.MimeTypeUtil; import com.owncloud.android.utils.theme.ThemeColorUtils; import java.io.File; +import java.security.SecureRandom; import java.util.AbstractList; import java.util.HashMap; import java.util.Iterator; @@ -80,6 +81,7 @@ import javax.inject.Inject; import androidx.core.app.NotificationCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import dagger.android.AndroidInjection; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; public class FileDownloader extends Service implements OnDatatransferProgressListener, OnAccountsUpdateListener { @@ -419,6 +421,7 @@ public class FileDownloader extends Service } } Log_OC.d(TAG, "Stopping after command with id " + msg.arg1); + mService.mNotificationManager.cancel(FOREGROUND_SERVICE_ID); mService.stopForeground(true); mService.stopSelf(msg.arg1); } @@ -612,17 +615,18 @@ public class FileDownloader extends Service * @param downloadResult Result of the download operation. * @param download Finished download operation */ + @SuppressFBWarnings("DMI") private void notifyDownloadResult(DownloadFileOperation download, RemoteOperationResult downloadResult) { if (mNotificationManager == null) { mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); } - if (mNotificationManager != null) { - mNotificationManager.cancel(R.string.downloader_download_in_progress_ticker); - } - if (!downloadResult.isCancelled()) { + if (downloadResult.isSuccess()) { + // Dont show notification except an error has occured. + return; + } int tickerId = downloadResult.isSuccess() ? R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker; @@ -651,7 +655,7 @@ public class FileDownloader extends Service download, getResources())); if (mNotificationManager != null) { - mNotificationManager.notify(tickerId, mNotificationBuilder.build()); + mNotificationManager.notify((new SecureRandom()).nextInt(), mNotificationBuilder.build()); // Remove success notification if (downloadResult.isSuccess()) { diff --git a/src/main/java/com/owncloud/android/files/services/FileUploader.java b/src/main/java/com/owncloud/android/files/services/FileUploader.java index ef3c9dc330..4bee47fe8f 100644 --- a/src/main/java/com/owncloud/android/files/services/FileUploader.java +++ b/src/main/java/com/owncloud/android/files/services/FileUploader.java @@ -80,6 +80,7 @@ import com.owncloud.android.utils.ErrorMessageAdapter; import com.owncloud.android.utils.theme.ThemeColorUtils; import java.io.File; +import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -92,6 +93,7 @@ import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import dagger.android.AndroidInjection; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** * Service for uploading files. Invoke using context.startService(...). @@ -744,6 +746,7 @@ public class FileUploader extends Service * @param uploadResult Result of the upload operation. * @param upload Finished upload operation */ + @SuppressFBWarnings("DMI") private void notifyUploadResult(UploadFileOperation upload, RemoteOperationResult uploadResult) { Log_OC.d(TAG, "NotifyUploadResult with resultCode: " + uploadResult.getCode()); // cancelled operation or success -> silent removal of progress notification @@ -751,8 +754,6 @@ public class FileUploader extends Service mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); } - mNotificationManager.cancel(FOREGROUND_SERVICE_ID); - // Only notify if the upload fails if (!uploadResult.isCancelled() && !uploadResult.isSuccess() && @@ -826,7 +827,10 @@ public class FileUploader extends Service } mNotificationBuilder.setContentText(content); - mNotificationManager.notify(tickerId, mNotificationBuilder.build()); + if (!uploadResult.isSuccess()) { + mNotificationManager.notify((new SecureRandom()).nextInt(), mNotificationBuilder.build()); + } + } } @@ -1405,6 +1409,7 @@ public class FileUploader extends Service } } Log_OC.d(TAG, "Stopping command after id " + msg.arg1); + mService.mNotificationManager.cancel(FOREGROUND_SERVICE_ID); mService.stopForeground(true); mService.stopSelf(msg.arg1); }