@@ -8,6 +8,7 @@ object UploadProgress {
88 private data class Progress (
99 var bytesUploaded : Long ,
1010 val size : Long ,
11+ val wifiOnly : Boolean ,
1112 var complete : Boolean = false
1213 ) {
1314 fun complete () {
@@ -19,8 +20,8 @@ object UploadProgress {
1920 private val map = mutableMapOf<String , Progress >()
2021
2122 @Synchronized
22- fun add (id : String , size : Long ) {
23- map[id] = Progress (bytesUploaded = 0L , size = size)
23+ fun add (id : String , size : Long , wifiOnly : Boolean ) {
24+ map[id] = Progress (bytesUploaded = 0L , size = size, wifiOnly = wifiOnly )
2425 }
2526
2627 @Synchronized
@@ -55,4 +56,16 @@ object UploadProgress {
5556 private fun clearIfCompleted () {
5657 if (map.values.all { it.complete }) map.clear()
5758 }
59+
60+ /* *
61+ * Returns true if any incomplete upload can proceed without WiFi (wifiOnly=false).
62+ * Used to determine notification text when no upload is actively running:
63+ * - If true: at least one upload only needs mobile data, so show "Waiting for internet"
64+ * - If false: all uploads need WiFi, so show "Waiting for WiFi"
65+ * This ensures the notification reflects the minimum connectivity needed to make progress.
66+ */
67+ @Synchronized
68+ fun hasNonWifiOnlyUploads (): Boolean {
69+ return map.values.any { ! it.complete && ! it.wifiOnly }
70+ }
5871}
0 commit comments