mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-25 14:40:41 +01:00
Magical sensor stuff
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
00cb0869de
commit
fdaa69f489
@ -777,7 +777,26 @@ public class CallActivity extends AppCompatActivity {
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||
public void onMessageEvent(PeerConnectionEvent peerConnectionEvent) {
|
||||
endPeerConnection(peerConnectionEvent.getSessionId());
|
||||
if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent.PeerConnectionEventType
|
||||
.CLOSE_PEER)) {
|
||||
endPeerConnection(peerConnectionEvent.getSessionId());
|
||||
} else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||
.PeerConnectionEventType.SENSOR_FAR) ||
|
||||
peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||
.PeerConnectionEventType.SENSOR_NEAR)) {
|
||||
|
||||
/*boolean enableVideo = peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||
.PeerConnectionEventType.SENSOR_FAR);
|
||||
String videoMessage = "videoOff";
|
||||
if (enableVideo) {
|
||||
videoMessage = "videoOn";
|
||||
}
|
||||
|
||||
localMediaStream.videoTracks.get(0).setEnabled(enableVideo);
|
||||
for (int i = 0; i < magicPeerConnectionWrapperList.size(); i++) {
|
||||
magicPeerConnectionWrapperList.get(i).sendChannelData(new DataChannelMessage(videoMessage));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private void endPeerConnection(String sessionId) {
|
||||
|
@ -20,13 +20,21 @@
|
||||
|
||||
package com.nextcloud.talk.events;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PeerConnectionEvent {
|
||||
public enum PeerConnectionEventType {
|
||||
CLOSE_PEER, SENSOR_FAR, SENSOR_NEAR
|
||||
}
|
||||
|
||||
private final PeerConnectionEventType peerConnectionEventType;
|
||||
private final String sessionId;
|
||||
|
||||
public PeerConnectionEvent(String sessionId) {
|
||||
public PeerConnectionEvent(PeerConnectionEventType peerConnectionEventType, @Nullable String sessionId) {
|
||||
this.peerConnectionEventType = peerConnectionEventType;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,9 @@ import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nextcloud.talk.events.PeerConnectionEvent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.webrtc.ThreadUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -137,6 +140,15 @@ public class MagicAudioManager {
|
||||
* e.g. from "NEAR to FAR" or from "FAR to NEAR".
|
||||
*/
|
||||
private void onProximitySensorChangedState() {
|
||||
|
||||
if (proximitySensor.sensorReportsNearState()) {
|
||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||
.SENSOR_NEAR, null));
|
||||
} else {
|
||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||
.SENSOR_FAR, null));
|
||||
}
|
||||
|
||||
if (!useSpeakerphone.equals(SPEAKERPHONE_AUTO)) {
|
||||
return;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class MagicPeerConnectionWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendChannelData(DataChannelMessage dataChannelMessage) {
|
||||
public void sendChannelData(DataChannelMessage dataChannelMessage) {
|
||||
ByteBuffer buffer = null;
|
||||
try {
|
||||
buffer = ByteBuffer.wrap(LoganSquare.serialize(dataChannelMessage).getBytes());
|
||||
@ -184,7 +184,8 @@ public class MagicPeerConnectionWrapper {
|
||||
@Override
|
||||
public void onSignalingChange(PeerConnection.SignalingState signalingState) {
|
||||
if (signalingState.equals(PeerConnection.SignalingState.CLOSED)) {
|
||||
EventBus.getDefault().post(new PeerConnectionEvent(sessionId));
|
||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||
.CLOSE_PEER, sessionId));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user