diff options
4 files changed, 80 insertions, 66 deletions
diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index 11b92980c..8a59c824f 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -213,6 +213,7 @@ public class CallActivity extends AppCompatActivity { private boolean audioOn = false; private boolean isMultiSession = false; + private boolean hasChatSupport = false; private boolean isVoiceOnlyCall = false; private Handler handler = new Handler(); @@ -858,6 +859,14 @@ public class CallActivity extends AppCompatActivity { .getCapabilities().getSpreedCapability() .getFeatures().contains("multi-room-users"); + hasChatSupport = capabilitiesOverall.getOcs().getData() + .getCapabilities().getSpreedCapability() != null && + capabilitiesOverall.getOcs().getData() + .getCapabilities().getSpreedCapability() + .getFeatures() != null && capabilitiesOverall.getOcs().getData() + .getCapabilities().getSpreedCapability() + .getFeatures().contains("chat-v2"); + joinRoomAndCall(); } @@ -887,7 +896,7 @@ public class CallActivity extends AppCompatActivity { @Override public void onNext(CallOverall callOverall) { - performCall(callOverall.getOcs().getData().getSessionId()); + performCall(); } @Override @@ -901,11 +910,11 @@ public class CallActivity extends AppCompatActivity { } }); } else { - performCall(callSession); + performCall(); } } - private void performCall(@Nullable String callSessionId) { + private void performCall() { ncApi.joinCall(credentials, ApiUtils.getUrlForCall(baseUrl, roomToken)) .subscribeOn(Schedulers.newThread()) @@ -922,33 +931,35 @@ public class CallActivity extends AppCompatActivity { inCall = true; // start pinging the call - ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken)) - .subscribeOn(Schedulers.newThread()) - .observeOn(AndroidSchedulers.mainThread()) - .repeatWhen(observable -> observable.delay(5000, TimeUnit.MILLISECONDS)) - .takeWhile(observable -> inCall) - .retry(3, observable -> inCall) - .subscribe(new Observer<GenericOverall>() { - @Override - public void onSubscribe(Disposable d) { - pingDisposable = d; - } + if (!hasChatSupport) { + ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken)) + .subscribeOn(Schedulers.newThread()) + .observeOn(AndroidSchedulers.mainThread()) + .repeatWhen(observable -> observable.delay(5000, TimeUnit.MILLISECONDS)) + .takeWhile(observable -> inCall) + .retry(3, observable -> inCall) + .subscribe(new Observer<GenericOverall>() { + @Override + public void onSubscribe(Disposable d) { + pingDisposable = d; + } - @Override - public void onNext(GenericOverall genericOverall) { + @Override + public void onNext(GenericOverall genericOverall) { - } + } - @Override - public void onError(Throwable e) { - dispose(pingDisposable); - } + @Override + public void onError(Throwable e) { + dispose(pingDisposable); + } - @Override - public void onComplete() { - dispose(pingDisposable); - } - }); + @Override + public void onComplete() { + dispose(pingDisposable); + } + }); + } // Start pulling signaling messages String urlToken = null; diff --git a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.java b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.java index df61d9c80..d2b2917e4 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.java @@ -21,6 +21,7 @@ package com.nextcloud.talk.activities; import android.annotation.SuppressLint; +import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; @@ -33,7 +34,6 @@ import com.bluelinelabs.conductor.Conductor; import com.bluelinelabs.conductor.Router; import com.bluelinelabs.conductor.RouterTransaction; import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler; -import com.bluelinelabs.conductor.internal.NoOpControllerChangeHandler; import com.nextcloud.talk.R; import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.controllers.ChatController; @@ -53,6 +53,7 @@ import org.greenrobot.eventbus.ThreadMode; import java.security.cert.CertificateParsingException; import java.security.cert.X509Certificate; import java.text.DateFormat; +import java.util.ArrayList; import java.util.List; import javax.inject.Inject; @@ -108,37 +109,47 @@ public final class MainActivity extends AppCompatActivity implements ActionBarPr } if (getIntent().hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) { - router.setRoot(RouterTransaction.with(new MagicBottomNavigationController()) - .pushChangeHandler(new NoOpControllerChangeHandler()) - .popChangeHandler(new NoOpControllerChangeHandler())); - - router.pushController(RouterTransaction.with(new ChatController(getIntent().getExtras())) - .pushChangeHandler(new HorizontalChangeHandler()) - .popChangeHandler(new HorizontalChangeHandler())); - - } else { - - if (!router.hasRootController()) { - if (hasDb) { - if (userUtils.anyUserExists()) { - router.setRoot(RouterTransaction.with(new MagicBottomNavigationController()) - .pushChangeHandler(new HorizontalChangeHandler()) - .popChangeHandler(new HorizontalChangeHandler())); - } else { - router.setRoot(RouterTransaction.with(new ServerSelectionController()) - .pushChangeHandler(new HorizontalChangeHandler()) - .popChangeHandler(new HorizontalChangeHandler())); - } + onNewIntent(getIntent()); + } else if (!router.hasRootController()) { + if (hasDb) { + if (userUtils.anyUserExists()) { + router.setRoot(RouterTransaction.with(new MagicBottomNavigationController()) + .pushChangeHandler(new HorizontalChangeHandler()) + .popChangeHandler(new HorizontalChangeHandler())); } else { router.setRoot(RouterTransaction.with(new ServerSelectionController()) .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); - } + } else { + router.setRoot(RouterTransaction.with(new ServerSelectionController()) + .pushChangeHandler(new HorizontalChangeHandler()) + .popChangeHandler(new HorizontalChangeHandler())); + } } } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) { + List<RouterTransaction> newBackstack = new ArrayList<>(); + + newBackstack.add(RouterTransaction.with(new MagicBottomNavigationController()) + .pushChangeHandler(new HorizontalChangeHandler()) + .popChangeHandler(new HorizontalChangeHandler())); + + router.setBackstack(newBackstack, new HorizontalChangeHandler()); + + router.pushController(RouterTransaction.with(new ChatController(intent.getExtras())) + .pushChangeHandler(new HorizontalChangeHandler()) + .popChangeHandler(new HorizontalChangeHandler())); + } + } + @Override public void onBackPressed() { if (!router.handleBack()) { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java index f913863ac..de17493e6 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java @@ -164,7 +164,7 @@ public class ChatController extends BaseController implements MessagesListAdapte NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this); UserEntity currentUser = userUtils.getCurrentUser(); - this.conversationName = args.getString(BundleKeys.KEY_CONVERSATION_NAME); + this.conversationName = args.getString(BundleKeys.KEY_CONVERSATION_NAME, ""); if (args.containsKey(BundleKeys.KEY_USER_ENTITY)) { this.conversationUser = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_USER_ENTITY)); } else { @@ -213,6 +213,8 @@ public class ChatController extends BaseController implements MessagesListAdapte for (Room room : roomsOverall.getOcs().getData()) { if (roomToken.equals(room.getRoomId())) { roomToken = room.getToken(); + conversationName = room.getDisplayName(); + setTitle(); break; } } diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationJob.java b/app/src/main/java/com/nextcloud/talk/jobs/NotificationJob.java index b904a9aec..f352850f9 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationJob.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationJob.java @@ -93,6 +93,9 @@ public class NotificationJob extends Job { DecryptedPushMessage decryptedPushMessage = LoganSquare.parse(new String(decryptedSubject), DecryptedPushMessage.class); + boolean hasChatSupport = signatureVerification.getUserEntity().hasSpreedCapabilityWithName + ("chat-v2"); + if (decryptedPushMessage.getApp().equals("spreed")) { int smallIcon; Bitmap largeIcon; @@ -103,8 +106,6 @@ public class NotificationJob extends Job { Bundle bundle = new Bundle(); - boolean hasChatSupport = signatureVerification.getUserEntity().hasSpreedCapabilityWithName - ("chat-v2"); if (hasChatSupport) { intent = new Intent(context, MainActivity.class); @@ -118,21 +119,13 @@ public class NotificationJob extends Job { bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(signatureVerification .getUserEntity())); - - if (hasChatSupport) { - if (decryptedPushMessage.getType().equals("call")) { - bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, true); - } else { - bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false); - } - } else { - bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, true); - } + bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, + decryptedPushMessage.getType().equals("call") || !hasChatSupport); intent.putExtras(bundle); PendingIntent pendingIntent = PendingIntent.getActivity(context, - 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); + 0, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); @@ -150,9 +143,6 @@ public class NotificationJob extends Job { priority = Notification.PRIORITY_HIGH; break; case "chat": - if (hasChatSupport) { - bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false); - } smallIcon = R.drawable.ic_chat_black_24dp; category = Notification.CATEGORY_MESSAGE; break; |