瀏覽代碼

Rename PeerConnectionEvent to ProximitySensorEvent

Proximity sensor events should not have been part of
PeerConnectionEvent. However, now that all the peer connection related
properties were removed the remaining event can be renamed to something
more accurate.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Daniel Calviño Sánchez 2 年之前
父節點
當前提交
5d7b5160b7

+ 8 - 8
app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

@@ -64,7 +64,7 @@ import com.nextcloud.talk.data.user.model.User;
 import com.nextcloud.talk.databinding.CallActivityBinding;
 import com.nextcloud.talk.events.ConfigurationChangeEvent;
 import com.nextcloud.talk.events.NetworkEvent;
-import com.nextcloud.talk.events.PeerConnectionEvent;
+import com.nextcloud.talk.events.ProximitySensorEvent;
 import com.nextcloud.talk.events.WebSocketCommunicationEvent;
 import com.nextcloud.talk.models.ExternalSignalingServer;
 import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
@@ -2124,15 +2124,15 @@ public class CallActivity extends CallBaseActivity {
     }
 
     @Subscribe(threadMode = ThreadMode.MAIN)
-    public void onMessageEvent(PeerConnectionEvent peerConnectionEvent) {
-         if (peerConnectionEvent.getPeerConnectionEventType() ==
-            PeerConnectionEvent.PeerConnectionEventType.SENSOR_FAR ||
-            peerConnectionEvent.getPeerConnectionEventType() ==
-                PeerConnectionEvent.PeerConnectionEventType.SENSOR_NEAR) {
+    public void onMessageEvent(ProximitySensorEvent proximitySensorEvent) {
+         if (proximitySensorEvent.getProximitySensorEventType() ==
+            ProximitySensorEvent.ProximitySensorEventType.SENSOR_FAR ||
+            proximitySensorEvent.getProximitySensorEventType() ==
+                ProximitySensorEvent.ProximitySensorEventType.SENSOR_NEAR) {
 
             if (!isVoiceOnlyCall) {
-                boolean enableVideo = peerConnectionEvent.getPeerConnectionEventType() ==
-                    PeerConnectionEvent.PeerConnectionEventType.SENSOR_FAR && videoOn;
+                boolean enableVideo = proximitySensorEvent.getProximitySensorEventType() ==
+                    ProximitySensorEvent.ProximitySensorEventType.SENSOR_FAR && videoOn;
                 if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_CAMERA) &&
                     (currentCallStatus == CallStatus.CONNECTING || isConnectionEstablished()) && videoOn
                     && enableVideo != localVideoTrack.enabled()) {

+ 16 - 16
app/src/main/java/com/nextcloud/talk/events/PeerConnectionEvent.java → app/src/main/java/com/nextcloud/talk/events/ProximitySensorEvent.java

@@ -20,31 +20,31 @@
 
 package com.nextcloud.talk.events;
 
-public class PeerConnectionEvent {
-    private final PeerConnectionEventType peerConnectionEventType;
+public class ProximitySensorEvent {
+    private final ProximitySensorEventType proximitySensorEventType;
 
-    public PeerConnectionEvent(PeerConnectionEventType peerConnectionEventType) {
-        this.peerConnectionEventType = peerConnectionEventType;
+    public ProximitySensorEvent(ProximitySensorEventType proximitySensorEventType) {
+        this.proximitySensorEventType = proximitySensorEventType;
     }
 
-    public PeerConnectionEventType getPeerConnectionEventType() {
-        return this.peerConnectionEventType;
+    public ProximitySensorEventType getProximitySensorEventType() {
+        return this.proximitySensorEventType;
     }
 
     public boolean equals(final Object o) {
         if (o == this) {
             return true;
         }
-        if (!(o instanceof PeerConnectionEvent)) {
+        if (!(o instanceof ProximitySensorEvent)) {
             return false;
         }
-        final PeerConnectionEvent other = (PeerConnectionEvent) o;
+        final ProximitySensorEvent other = (ProximitySensorEvent) o;
         if (!other.canEqual((Object) this)) {
             return false;
         }
-        final Object this$peerConnectionEventType = this.getPeerConnectionEventType();
-        final Object other$peerConnectionEventType = other.getPeerConnectionEventType();
-        if (this$peerConnectionEventType == null ? other$peerConnectionEventType != null : !this$peerConnectionEventType.equals(other$peerConnectionEventType)) {
+        final Object this$proximitySensorEventType = this.getProximitySensorEventType();
+        final Object other$proximitySensorEventType = other.getProximitySensorEventType();
+        if (this$proximitySensorEventType == null ? other$proximitySensorEventType != null : !this$proximitySensorEventType.equals(other$proximitySensorEventType)) {
             return false;
         }
 
@@ -52,22 +52,22 @@ public class PeerConnectionEvent {
     }
 
     protected boolean canEqual(final Object other) {
-        return other instanceof PeerConnectionEvent;
+        return other instanceof ProximitySensorEvent;
     }
 
     public int hashCode() {
         final int PRIME = 59;
         int result = 1;
-        final Object $peerConnectionEventType = this.getPeerConnectionEventType();
-        result = result * PRIME + ($peerConnectionEventType == null ? 43 : $peerConnectionEventType.hashCode());
+        final Object $proximitySensorEventType = this.getProximitySensorEventType();
+        result = result * PRIME + ($proximitySensorEventType == null ? 43 : $proximitySensorEventType.hashCode());
         return result;
     }
 
     public String toString() {
-        return "PeerConnectionEvent(peerConnectionEventType=" + this.getPeerConnectionEventType() + ")";
+        return "ProximitySensorEvent(proximitySensorEventType=" + this.getProximitySensorEventType() + ")";
     }
 
-    public enum PeerConnectionEventType {
+    public enum ProximitySensorEventType {
         SENSOR_FAR, SENSOR_NEAR
     }
 }

+ 3 - 3
app/src/main/java/com/nextcloud/talk/webrtc/WebRtcAudioManager.java

@@ -43,7 +43,7 @@ import android.media.AudioDeviceInfo;
 import android.media.AudioManager;
 import android.util.Log;
 
-import com.nextcloud.talk.events.PeerConnectionEvent;
+import com.nextcloud.talk.events.ProximitySensorEvent;
 import com.nextcloud.talk.utils.power.PowerManagerUtils;
 
 import org.greenrobot.eventbus.EventBus;
@@ -136,13 +136,13 @@ public class WebRtcAudioManager {
                 setAudioDeviceInternal(AudioDevice.EARPIECE);
                 Log.d(TAG, "switched to EARPIECE because userSelectedAudioDevice was SPEAKER_PHONE and proximity=near");
 
-                EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.SENSOR_NEAR));
+                EventBus.getDefault().post(new ProximitySensorEvent(ProximitySensorEvent.ProximitySensorEventType.SENSOR_NEAR));
 
             } else {
                 setAudioDeviceInternal(WebRtcAudioManager.AudioDevice.SPEAKER_PHONE);
                 Log.d(TAG, "switched to SPEAKER_PHONE because userSelectedAudioDevice was SPEAKER_PHONE and proximity=far");
 
-                EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.SENSOR_FAR));
+                EventBus.getDefault().post(new ProximitySensorEvent(ProximitySensorEvent.ProximitySensorEventType.SENSOR_FAR));
             }
         }
     }