Browse code

Display in the UI when the transfer is over

Natasha Kerensikova authored on29/04/2016 23:28:50
Showing1 changed files
... ...
@@ -47,6 +47,7 @@ static bool cfg_auto_close = false;
47 47
 static bool auto_close = false;
48 48
 static bool configuring = false;
49 49
 static int cfg_wakeup_time = -1;
50
+static int32_t last_key = 0;
50 51
 
51 52
 static struct widget {
52 53
 	char		label[64];
... ...
@@ -83,8 +84,8 @@ update_half_progress(struct widget *widget) {
83 84
 
84 85
 	time_t t, now = time(0);
85 86
 	struct tm *tm;
86
-	int32_t last_key = (now + 59) / 60;
87
-	int32_t key_span = last_key - widget->first_key;
87
+	int32_t key_span = (last_key ? last_key : (now + 59) / 60)
88
+	    - widget->first_key;
88 89
 	int32_t keys_done = widget->current_key - widget->first_key + 1;
89 90
 	int32_t running_time = widget->start_time
90 91
 	    ? now - widget->start_time : 0;
... ...
@@ -96,7 +97,9 @@ update_half_progress(struct widget *widget) {
96 97
 	tm = localtime(&t);
97 98
 	strftime(widget->label, sizeof widget->label, "%F %H:%M", tm);
98 99
 
99
-	if (running_time > 0) {
100
+	if (last_key > 0 && widget->current_key == (uint32_t)last_key) {
101
+		snprintf(widget->rate, sizeof widget->rate, "DONE");
102
+	} else if (running_time > 0) {
100 103
 		int32_t i = ((widget->current_key - widget->first_key) * 60
101 104
 		    + running_time / 2) / running_time;
102 105
 		snprintf(widget->rate, sizeof widget->rate,
... ...
@@ -389,6 +392,8 @@ send_next_line(void) {
389 392
 	if (minute_index >= minute_data_size
390 393
 	    && !load_minute_data_page(minute_last)) {
391 394
 		sending_data = false;
395
+		last_key = phone.current_key;
396
+		display_dirty = true;
392 397
 		if (auto_close && web.current_key >= phone.current_key)
393 398
 			close_app();
394 399
 		return;
... ...
@@ -427,6 +432,7 @@ handle_last_sent(Tuple *tuple) {
427 432
 
428 433
 	if (!sending_data) {
429 434
 		sending_data = true;
435
+		last_key = 0;
430 436
 		send_next_line();
431 437
 	}
432 438
 }