Fix #337 and closing websocket connections

This commit is contained in:
Mario Danic 2018-10-26 10:47:59 +02:00
parent 269b879ee4
commit e5532a5842
22 changed files with 31 additions and 12 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -190,6 +190,8 @@ dependencies {
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.kevalpatel2106:emoticongifkeyboard:1.1'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation ('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
exclude group: 'com.android.support', module: 'support-annotations'

View File

@ -21,6 +21,7 @@
package com.nextcloud.talk.activities;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.webkit.SslErrorHandler;
@ -45,6 +46,7 @@ import javax.inject.Inject;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import autodagger.AutoInjector;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
@AutoInjector(NextcloudTalkApplication.class)
public class BaseActivity extends AppCompatActivity {
@ -59,6 +61,11 @@ public class BaseActivity extends AppCompatActivity {
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
public void showCertificateDialog(X509Certificate cert, MagicTrustManager magicTrustManager,
@Nullable SslErrorHandler sslErrorHandler) {
DateFormat formatter = DateFormat.getDateInstance(DateFormat.LONG);

View File

@ -20,6 +20,7 @@
package com.nextcloud.talk.activities;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
@ -45,6 +46,7 @@ import javax.inject.Inject;
import autodagger.AutoInjector;
import butterknife.BindView;
import butterknife.ButterKnife;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
@AutoInjector(NextcloudTalkApplication.class)
public class MagicCallActivity extends BaseActivity {
@ -64,6 +66,11 @@ public class MagicCallActivity extends BaseActivity {
return flags;
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@ -55,6 +55,7 @@ import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager;
import autodagger.AutoComponent;
import autodagger.AutoInjector;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
@AutoComponent(
modules = {
@ -109,6 +110,11 @@ public class NextcloudTalkApplication extends MultiDexApplication implements Lif
public void onCreate() {
super.onCreate();
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Nunito-Regular.ttf")
.build()
);
sharedApplication = this;
initializeWebRtc();

View File

@ -36,7 +36,6 @@ import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage;
import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMessage;
import com.nextcloud.talk.models.json.websocket.JoinedRoomOverallWebSocketMessage;
import com.nextcloud.talk.utils.MagicMap;
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
import org.greenrobot.eventbus.EventBus;
@ -93,7 +92,6 @@ public class MagicWebSocketInstance extends WebSocketListener {
@Override
public void onOpen(WebSocket webSocket, Response response) {
if (isConnected()) {
try {
if (TextUtils.isEmpty(resumeId)) {
webSocket.send(LoganSquare.serialize(webSocketConnectionHelper.getAssembledHelloModel(conversationUser, webSocketTicket)));
@ -104,7 +102,6 @@ public class MagicWebSocketInstance extends WebSocketListener {
Log.e(TAG, "Failed to serialize hello model");
}
}
}
private void restartWebSocket() {
Request request = new Request.Builder().url(connectionUrl).build();
@ -280,7 +277,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
ByeWebSocketMessage byeWebSocketMessage = new ByeWebSocketMessage();
byeWebSocketMessage.setType("bye");
byeWebSocketMessage.setBye(new HashMap<>());
webSocket.send(LoganSquare.serialize(byeWebSocketMessage);
webSocket.send(LoganSquare.serialize(byeWebSocketMessage));
} catch (IOException e) {
Log.e(TAG, "Failed to serialize bye message");
}

View File

@ -67,7 +67,7 @@ public class WebSocketConnectionHelper {
}
MagicWebSocketInstance magicWebSocketInstance;
if ((magicWebSocketInstance = magicWebSocketInstanceMap.get(userEntity.getId())) != null && !magicWebSocketInstance.isPermanentlyClosed()) {
if (magicWebSocketInstanceMap.containsKey(userEntity.getId()) && (magicWebSocketInstance = magicWebSocketInstanceMap.get(userEntity.getId())) != null && !magicWebSocketInstance.isPermanentlyClosed()) {
return magicWebSocketInstance;
} else {
magicWebSocketInstance = new MagicWebSocketInstance(userEntity, generatedURL, webSocketTicket);