Переглянути джерело

VoIP: Revise status texts (#787)

Danilo Bargen 6 роки тому
батько
коміт
9e65dc6a9a
4 змінених файлів з 78 додано та 28 видалено
  1. 4 0
      public/i18n/de.json
  2. 4 0
      public/i18n/en.json
  3. 69 28
      src/directives/message_voip_status.ts
  4. 1 0
      src/threema.d.ts

+ 4 - 0
public/i18n/de.json

@@ -296,9 +296,13 @@
     },
     "voip": {
         "CALL_MISSED": "Verpasster Anruf",
+        "CALL_MISSED_BUSY": "Verpasster Anruf (Besetzt)",
         "CALL_FINISHED_IN": "Eingehender Anruf",
         "CALL_FINISHED_OUT": "Ausgehender Anruf",
         "CALL_REJECTED": "Anruf abgelehnt",
+        "CALL_REJECTED_BUSY": "Anrufempfänger ist besetzt",
+        "CALL_REJECTED_UNAVAILABLE": "Anrufempfänger nicht verfügbar",
+        "CALL_REJECTED_DISABLED": "Threema-Anrufe sind auf dem Zielgerät deaktiviert",
         "CALL_ABORTED": "Anruf abgebrochen"
     },
     "battery": {

+ 4 - 0
public/i18n/en.json

@@ -296,9 +296,13 @@
     },
     "voip": {
         "CALL_MISSED": "Missed call",
+        "CALL_MISSED_BUSY": "Missed call (Busy)",
         "CALL_FINISHED_IN": "Incoming call",
         "CALL_FINISHED_OUT": "Outgoing call",
         "CALL_REJECTED": "Call rejected",
+        "CALL_REJECTED_BUSY": "Call recipient is busy",
+        "CALL_REJECTED_UNAVAILABLE": "Call recipient is unavailable",
+        "CALL_REJECTED_DISABLED": "Threema calls disabled by recipient",
         "CALL_ABORTED": "Call aborted"
     },
     "battery": {

+ 69 - 28
src/directives/message_voip_status.ts

@@ -28,37 +28,78 @@ export default [
             controllerAs: 'ctrl',
             controller: [function() {
                 this.$onInit = function() {
-                    this.status = this.message.voip.status;
-                    this.duration = this.message.voip.duration;
-                    this.reason = this.message.voip.reason;
-                    this.incoming = !this.message.isOutbox;
-                    this.outgoing = this.message.isOutbox;
+                    const voip: threema.VoipStatusInfo = this.message.voip;
+                    const incoming = !this.message.isOutbox;
+
+                    switch (voip.status) {
+                        case threema.VoipStatus.Missed:
+                            this.colorClass = 'color-status-error';
+                            this.icon = 'call_missed';
+                            this.msgString = 'voip.CALL_MISSED';
+                            break;
+                        case threema.VoipStatus.Finished:
+                            this.colorClass = 'color-status-ok';
+                            if (incoming) {
+                                this.icon = 'call_received';
+                                this.msgString = 'voip.CALL_FINISHED_IN';
+                            } else {
+                                this.icon = 'call_made';
+                                this.msgString = 'voip.CALL_FINISHED_OUT';
+                            }
+                            break;
+                        case threema.VoipStatus.Rejected:
+                            if (incoming) {
+                                this.icon = 'call_missed';
+                                switch (voip.reason) {
+                                    case threema.VoipRejectReason.Busy:
+                                        this.colorClass = 'color-status-error';
+                                        this.msgString = 'voip.CALL_MISSED_BUSY';
+                                        break;
+                                    case threema.VoipRejectReason.Rejected:
+                                        this.colorClass = 'color-status-warning';
+                                        this.msgString = 'voip.CALL_REJECTED';
+                                        break;
+                                    case threema.VoipRejectReason.Unknown:
+                                    case threema.VoipRejectReason.Timeout:
+                                    case threema.VoipRejectReason.Disabled:
+                                    default:
+                                        this.colorClass = 'color-status-error';
+                                        this.msgString = 'voip.CALL_MISSED';
+                                        break;
+                                }
+                            } else {
+                                this.icon = 'call_missed_outgoing';
+                                this.colorClass = 'color-status-error';
+                                switch (voip.reason) {
+                                    case threema.VoipRejectReason.Busy:
+                                        this.msgString = 'voip.CALL_REJECTED_BUSY';
+                                        break;
+                                    case threema.VoipRejectReason.Timeout:
+                                        this.msgString = 'voip.CALL_REJECTED_UNAVAILABLE';
+                                        break;
+                                    case threema.VoipRejectReason.Disabled:
+                                        this.msgString = 'voip.CALL_REJECTED_DISABLED';
+                                        break;
+                                    case threema.VoipRejectReason.Rejected:
+                                    case threema.VoipRejectReason.Unknown:
+                                    default:
+                                        this.msgString = 'voip.CALL_REJECTED';
+                                        break;
+                                }
+                            }
+                            break;
+                        case threema.VoipStatus.Aborted:
+                            this.colorClass = 'color-status-warning';
+                            this.icon = 'call_missed_outgoing';
+                            this.msgString = 'voip.CALL_ABORTED';
+                            break;
+                    }
                 };
             }],
             template: `
-                <p ng-if="ctrl.status === 1">
-                    <md-icon class="material-icons color-status-warning">call_missed</md-icon>
-                    <span translate>voip.CALL_MISSED</span>
-                </p>
-                <p ng-if="ctrl.status === 2 && ctrl.incoming">
-                    <md-icon class="material-icons color-status-ok">call_received</md-icon>
-                    <span translate>voip.CALL_FINISHED_IN</span>
-                </p>
-                <p ng-if="ctrl.status === 2 && ctrl.outgoing">
-                    <md-icon class="material-icons color-status-ok">call_made</md-icon>
-                    <span translate>voip.CALL_FINISHED_OUT</span>
-                </p>
-                <p ng-if="ctrl.status === 3 && ctrl.incoming">
-                    <md-icon class="material-icons color-status-error">call_missed</md-icon>
-                    <span translate>voip.CALL_REJECTED</span>
-                </p>
-                <p ng-if="ctrl.status === 3 && ctrl.outgoing">
-                    <md-icon class="material-icons color-status-error">call_missed_outgoing</md-icon>
-                    <span translate>voip.CALL_REJECTED</span>
-                </p>
-                <p ng-if="ctrl.status === 4">
-                    <md-icon class="material-icons color-status-warning">call_missed_outgoing</md-icon>
-                    <span translate>voip.CALL_ABORTED</span>
+                 <p>
+                    <md-icon class="material-icons {{ ctrl.colorClass }}">{{ ctrl.icon }}</md-icon>
+                    <span translate>{{ ctrl.msgString }}</span>
                 </p>
             `,
         };

+ 1 - 0
src/threema.d.ts

@@ -146,6 +146,7 @@ declare namespace threema {
         Busy = 1,
         Timeout = 2,
         Rejected = 3,
+        Disabled = 4,
     }
 
     interface VoipStatusInfo {