Эх сурвалжийг харах

Merge pull request #2810 from nextcloud/bugfix/noid/showUploadFailedNotificationForNormalUpload

Show upload failed notification when failed normal upload
Andy Scherzinger 2 жил өмнө
parent
commit
968593ccf7

+ 7 - 2
app/src/main/java/com/nextcloud/talk/jobs/UploadAndShareFilesWorker.kt

@@ -121,10 +121,12 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
             val remotePath = getRemotePath(currentUser)
             val uploadSuccess: Boolean
 
+            initNotificationSetup()
+
             if (file != null && file.length() > CHUNK_UPLOAD_THRESHOLD_SIZE) {
                 Log.d(TAG, "starting chunked upload because size is " + file.length())
 
-                initNotification()
+                initNotificationWithPercentage()
                 val mimeType = context.contentResolver.getType(sourceFileUri)?.toMediaTypeOrNull()
 
                 uploadSuccess = ChunkedFileUploader(
@@ -190,14 +192,16 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
         mNotifyManager!!.notify(notificationId, notification)
     }
 
-    private fun initNotification() {
+    private fun initNotificationSetup() {
         mNotifyManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
         mBuilder = NotificationCompat.Builder(
             context,
             NotificationUtils.NotificationChannels
                 .NOTIFICATION_CHANNEL_UPLOADS.name
         )
+    }
 
+    private fun initNotificationWithPercentage() {
         notification = mBuilder!!
             .setContentTitle(context.resources.getString(R.string.nc_upload_in_progess))
             .setContentText(getNotificationContentText(ZERO_PERCENT))
@@ -258,6 +262,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
         notification = mBuilder!!
             .setContentTitle(failureTitle)
             .setContentText(failureText)
+            .setSmallIcon(R.drawable.baseline_error_24)
             .setOngoing(false)
             .build()
 

+ 22 - 0
app/src/main/res/drawable/baseline_error_24.xml

@@ -0,0 +1,22 @@
+<!--
+    @author Google LLC
+    Copyright (C) 2018 Google LLC
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<vector android:height="24dp" android:fillColor="#ffffff"
+    android:viewportHeight="24" android:viewportWidth="24"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z"/>
+</vector>