mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Some work on calls
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
e6825275ba
commit
c24ee9e910
@ -260,6 +260,11 @@ public class CallActivity extends AppCompatActivity {
|
||||
|
||||
roomToken = getIntent().getExtras().getString(BundleKeys.KEY_ROOM_TOKEN, "");
|
||||
userEntity = Parcels.unwrap(getIntent().getExtras().getParcelable(BundleKeys.KEY_USER_ENTITY));
|
||||
|
||||
if (userEntity == null) {
|
||||
userEntity = userUtils.getCurrentUser();
|
||||
}
|
||||
|
||||
callSession = getIntent().getExtras().getString(BundleKeys.KEY_CALL_SESSION, "0");
|
||||
credentials = ApiUtils.getCredentials(userEntity.getUsername(), userEntity.getToken());
|
||||
isVoiceOnlyCall = getIntent().getExtras().getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false);
|
||||
@ -280,39 +285,7 @@ public class CallActivity extends AppCompatActivity {
|
||||
Log.e(TAG, "Failed to evict cache");
|
||||
}
|
||||
|
||||
if (!userEntity.getCurrent()) {
|
||||
userUtils.createOrUpdateUser(null,
|
||||
null, null, null,
|
||||
null, true, null, userEntity.getId(), null, null)
|
||||
.subscribe(new Observer<UserEntity>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(UserEntity userEntity) {
|
||||
userUtils.disableAllUsersWithoutId(userEntity.getId());
|
||||
if (getIntent().getExtras().containsKey("fromNotification")) {
|
||||
handleFromNotification();
|
||||
} else {
|
||||
initViews();
|
||||
checkPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} else if (getIntent().getExtras().containsKey("fromNotification")) {
|
||||
if (getIntent().getExtras().containsKey(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
|
||||
handleFromNotification();
|
||||
} else {
|
||||
initViews();
|
||||
@ -928,7 +901,7 @@ public class CallActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
performCall(null);
|
||||
performCall(callSession);
|
||||
}
|
||||
}
|
||||
|
||||
@ -947,9 +920,6 @@ public class CallActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onNext(GenericOverall genericOverall) {
|
||||
inCall = true;
|
||||
if (callSessionId != null) {
|
||||
callSession = callSessionId;
|
||||
}
|
||||
|
||||
// start pinging the call
|
||||
ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken))
|
||||
|
@ -33,12 +33,15 @@ 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;
|
||||
import com.nextcloud.talk.controllers.MagicBottomNavigationController;
|
||||
import com.nextcloud.talk.controllers.ServerSelectionController;
|
||||
import com.nextcloud.talk.controllers.base.providers.ActionBarProvider;
|
||||
import com.nextcloud.talk.events.CertificateEvent;
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||
import com.nextcloud.talk.utils.ssl.MagicTrustManager;
|
||||
import com.yarolegovich.lovelydialog.LovelyStandardDialog;
|
||||
@ -104,22 +107,34 @@ public final class MainActivity extends AppCompatActivity implements ActionBarPr
|
||||
hasDb = false;
|
||||
}
|
||||
|
||||
if (!router.hasRootController()) {
|
||||
if (hasDb) {
|
||||
if (userUtils.anyUserExists()) {
|
||||
router.setRoot(RouterTransaction.with(new MagicBottomNavigationController())
|
||||
.pushChangeHandler(new HorizontalChangeHandler())
|
||||
.popChangeHandler(new HorizontalChangeHandler()));
|
||||
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()));
|
||||
}
|
||||
} 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()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -494,7 +494,6 @@ public class CallsListController extends BaseController implements SearchView.On
|
||||
Room room = callItem.getModel();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, callItem.getModel().getToken());
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
|
||||
|
||||
if (room.hasPassword && (room.participantType.equals(Participant.ParticipantType.GUEST) ||
|
||||
room.participantType.equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {
|
||||
|
@ -71,6 +71,8 @@ import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||
import com.nextcloud.talk.models.json.chat.ChatOverall;
|
||||
import com.nextcloud.talk.models.json.generic.GenericOverall;
|
||||
import com.nextcloud.talk.models.json.mention.Mention;
|
||||
import com.nextcloud.talk.models.json.rooms.Room;
|
||||
import com.nextcloud.talk.models.json.rooms.RoomsOverall;
|
||||
import com.nextcloud.talk.presenters.MentionAutocompletePresenter;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.KeyboardUtils;
|
||||
@ -113,7 +115,7 @@ import retrofit2.Response;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class ChatController extends BaseController implements MessagesListAdapter.OnLoadMoreListener,
|
||||
MessagesListAdapter.Formatter<Date>, MessagesListAdapter.OnMessageLongClickListener{
|
||||
MessagesListAdapter.Formatter<Date>, MessagesListAdapter.OnMessageLongClickListener {
|
||||
private static final String TAG = "ChatController";
|
||||
|
||||
@Inject
|
||||
@ -150,7 +152,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
private boolean lookingIntoFuture = false;
|
||||
|
||||
private int newMessagesCount = 0;
|
||||
private String senderId;
|
||||
private Boolean startCallFromNotification;
|
||||
|
||||
/*
|
||||
TODO:
|
||||
@ -159,18 +161,69 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
public ChatController(Bundle args) {
|
||||
super(args);
|
||||
setHasOptionsMenu(true);
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
UserEntity currentUser = userUtils.getCurrentUser();
|
||||
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 {
|
||||
this.conversationUser = currentUser;
|
||||
}
|
||||
|
||||
this.roomToken = args.getString(BundleKeys.KEY_ROOM_TOKEN);
|
||||
this.roomToken = args.getString(BundleKeys.KEY_ROOM_TOKEN, "");
|
||||
|
||||
if (args.containsKey(BundleKeys.KEY_ACTIVE_CONVERSATION)) {
|
||||
this.currentCall = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION));
|
||||
}
|
||||
|
||||
this.baseUrl = args.getString(BundleKeys.KEY_MODIFIED_BASE_URL, "");
|
||||
|
||||
if (!TextUtils.isEmpty(baseUrl)) {
|
||||
conversationUser.setBaseUrl(baseUrl);
|
||||
conversationUser.setUserId("-1");
|
||||
conversationUser.setDisplayName(currentUser.getDisplayName());
|
||||
} else {
|
||||
baseUrl = conversationUser.getBaseUrl();
|
||||
}
|
||||
|
||||
this.roomPassword = args.getString(BundleKeys.KEY_CONVERSATION_PASSWORD, "");
|
||||
this.startCallFromNotification = args.getBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL);
|
||||
}
|
||||
|
||||
private void handleFromNotification() {
|
||||
ncApi.getRooms(credentials, ApiUtils.getUrlForGetRooms(baseUrl))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<RoomsOverall>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomsOverall roomsOverall) {
|
||||
for (Room room : roomsOverall.getOcs().getData()) {
|
||||
if (roomToken.equals(room.getRoomId())) {
|
||||
roomToken = room.getToken();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setupMentionAutocomplete();
|
||||
joinRoomWithPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -181,16 +234,9 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
@Override
|
||||
protected void onViewBound(@NonNull View view) {
|
||||
super.onViewBound(view);
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
boolean adapterWasNull = false;
|
||||
|
||||
if (conversationUser != null && conversationUser.getUserId() != null) {
|
||||
senderId = conversationUser.getUserId();
|
||||
} else {
|
||||
senderId = "-1";
|
||||
}
|
||||
|
||||
if (adapter == null) {
|
||||
|
||||
try {
|
||||
@ -207,7 +253,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
holdersConfig.setOutcoming(MagicOutcomingTextMessageViewHolder.class,
|
||||
R.layout.item_custom_outcoming_text_message);
|
||||
|
||||
adapter = new MessagesListAdapter<>(senderId, holdersConfig, new ImageLoader() {
|
||||
adapter = new MessagesListAdapter<>(conversationUser.getUserId(), holdersConfig, new ImageLoader() {
|
||||
@Override
|
||||
public void loadImage(ImageView imageView, String url) {
|
||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
@ -269,7 +315,6 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
}
|
||||
});
|
||||
|
||||
setupMentionAutocomplete();
|
||||
|
||||
messageInput.getInputEditText().setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
messageInput.setInputListener(input -> {
|
||||
@ -277,44 +322,15 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
return true;
|
||||
});
|
||||
|
||||
if (adapterWasNull) {
|
||||
UserEntity currentUser = userUtils.getCurrentUser();
|
||||
if (conversationUser != null && !currentUser.equals(conversationUser)) {
|
||||
userUtils.createOrUpdateUser(null,
|
||||
null, null, null,
|
||||
null, true, null, currentUser.getId(), null, null)
|
||||
.subscribe(new Observer<UserEntity>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(UserEntity userEntity) {
|
||||
joinRoomWithPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (conversationUser == null) {
|
||||
conversationUser = new UserEntity();
|
||||
conversationUser.setDisplayName(currentUser.getDisplayName());
|
||||
conversationUser.setBaseUrl(baseUrl);
|
||||
}
|
||||
joinRoomWithPassword();
|
||||
}
|
||||
if (adapterWasNull && startCallFromNotification == null) {
|
||||
setupMentionAutocomplete();
|
||||
joinRoomWithPassword();
|
||||
} else if (adapterWasNull) {
|
||||
handleFromNotification();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupMentionAutocomplete() {
|
||||
float elevation = 6f;
|
||||
Drawable backgroundDrawable = new ColorDrawable(Color.WHITE);
|
||||
@ -387,11 +403,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
password = roomPassword;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(baseUrl)) {
|
||||
baseUrl = conversationUser.getBaseUrl();
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(conversationUser.getUserId())) {
|
||||
if (conversationUser.getUserId().equals("-1")) {
|
||||
credentials = null;
|
||||
} else {
|
||||
credentials = ApiUtils.getCredentials(conversationUser.getUserId(), conversationUser.getToken());
|
||||
@ -414,6 +426,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
currentCall = callOverall.getOcs().getData();
|
||||
startPing();
|
||||
pullChatMessages(0);
|
||||
if (startCallFromNotification != null && startCallFromNotification) {
|
||||
startCallFromNotification = false;
|
||||
startACall(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -433,17 +449,15 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
}
|
||||
}
|
||||
|
||||
private void setSenderId(String guestSenderId) {
|
||||
if (senderId.equals("-1")) {
|
||||
try {
|
||||
final Field senderId = adapter.getClass().getDeclaredField("senderId");
|
||||
senderId.setAccessible(true);
|
||||
senderId.set(adapter, guestSenderId);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e(TAG, "Failed to set sender id");
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(TAG, "Failed to access and set field");
|
||||
}
|
||||
private void setSenderId() {
|
||||
try {
|
||||
final Field senderId = adapter.getClass().getDeclaredField("senderId");
|
||||
senderId.setAccessible(true);
|
||||
senderId.set(adapter, conversationUser.getUserId());
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e(TAG, "Failed to set sender id");
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(TAG, "Failed to access and set field");
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,7 +479,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
|
||||
@Override
|
||||
public void onNext(GenericOverall genericOverall) {
|
||||
if (senderId.equals("-1") && TextUtils.isEmpty(myFirstMessage)) {
|
||||
if (conversationUser.getUserId().equals("-1") && TextUtils.isEmpty(myFirstMessage)) {
|
||||
myFirstMessage = message;
|
||||
}
|
||||
|
||||
@ -478,7 +492,6 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -620,11 +633,12 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
} else {
|
||||
for (int i = 0; i < chatMessageList.size(); i++) {
|
||||
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
||||
if (senderId.equals("-1") && !TextUtils.isEmpty(myFirstMessage)) {
|
||||
if (conversationUser.getUserId().equals("-1") && !TextUtils.isEmpty(myFirstMessage)) {
|
||||
ChatMessage chatMessage = chatMessageList.get(i);
|
||||
if (chatMessage.getActorType().equals("guests") &&
|
||||
chatMessage.getActorDisplayName().equals(conversationUser.getDisplayName())) {
|
||||
setSenderId(chatMessage.getActorId());
|
||||
conversationUser.setUserId(chatMessage.getActorId());
|
||||
setSenderId();
|
||||
}
|
||||
}
|
||||
boolean shouldScroll = layoutManager.findFirstVisibleItemPosition() == 0 ||
|
||||
@ -704,16 +718,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
return true;
|
||||
|
||||
case R.id.conversation_video_call:
|
||||
Intent videoCallIntent = getIntentForCall(false);
|
||||
if (videoCallIntent != null) {
|
||||
startActivity(videoCallIntent);
|
||||
}
|
||||
startACall(false);
|
||||
return true;
|
||||
case R.id.conversation_voice_call:
|
||||
Intent voiceCallIntent = getIntentForCall(true);
|
||||
if (voiceCallIntent != null) {
|
||||
startActivity(voiceCallIntent);
|
||||
}
|
||||
startACall(true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@ -721,11 +729,26 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
}
|
||||
}
|
||||
|
||||
private void startACall(boolean isVoiceOnlyCall) {
|
||||
if (!isVoiceOnlyCall) {
|
||||
Intent videoCallIntent = getIntentForCall(false);
|
||||
if (videoCallIntent != null) {
|
||||
startActivity(videoCallIntent);
|
||||
}
|
||||
} else {
|
||||
Intent voiceCallIntent = getIntentForCall(true);
|
||||
if (voiceCallIntent != null) {
|
||||
startActivity(voiceCallIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Intent getIntentForCall(boolean isVoiceOnlyCall) {
|
||||
if (currentCall != null && !TextUtils.isEmpty(currentCall.getSessionId())) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(conversationUser));
|
||||
bundle.putString(BundleKeys.KEY_CONVERSATION_PASSWORD, roomPassword);
|
||||
bundle.putString(BundleKeys.KEY_CALL_SESSION, currentCall.getSessionId());
|
||||
bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, baseUrl);
|
||||
|
||||
|
@ -296,7 +296,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
Intent conversationIntent = new Intent(getActivity(), CallActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.getOcs().getData().getToken());
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
|
||||
|
||||
if (currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
||||
bundle.putString(BundleKeys.KEY_CONVERSATION_NAME,
|
||||
@ -827,7 +826,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
Intent conversationIntent = new Intent(getActivity(), CallActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.getOcs().getData().getToken());
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
|
||||
conversationIntent.putExtras(bundle);
|
||||
|
||||
if (currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
||||
|
@ -529,12 +529,10 @@ public class OperationsMenuController extends BaseController {
|
||||
private void initiateConversation(boolean dismissView, @Nullable List<String> spreedCapabilities) {
|
||||
Bundle bundle = new Bundle();
|
||||
boolean hasChatCapability;
|
||||
boolean isGuest = false;
|
||||
|
||||
if (baseUrl != null && !baseUrl.equals(currentUser.getBaseUrl())) {
|
||||
bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, baseUrl);
|
||||
hasChatCapability = spreedCapabilities != null && spreedCapabilities.contains("chat-v2");
|
||||
isGuest = true;
|
||||
} else {
|
||||
hasChatCapability = currentUser.hasSpreedCapabilityWithName("chat-v2");
|
||||
}
|
||||
@ -547,10 +545,6 @@ public class OperationsMenuController extends BaseController {
|
||||
Intent conversationIntent = new Intent(getActivity(), CallActivity.class);
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, room.getToken());
|
||||
bundle.putString(BundleKeys.KEY_CONVERSATION_NAME, room.getDisplayName());
|
||||
if (!isGuest) {
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
|
||||
}
|
||||
|
||||
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION, Parcels.wrap(call));
|
||||
|
||||
conversationIntent.putExtras(bundle);
|
||||
|
@ -92,6 +92,7 @@ public class CapabilitiesJob extends Job {
|
||||
|
||||
ncApi.getCapabilities(ApiUtils.getCredentials(internalUserEntity.getUsername(),
|
||||
internalUserEntity.getToken()), ApiUtils.getUrlForCapabilities(internalUserEntity.getBaseUrl()))
|
||||
.retry(3)
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribe(new Observer<CapabilitiesOverall>() {
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ import com.evernote.android.job.Job;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.activities.CallActivity;
|
||||
import com.nextcloud.talk.activities.MainActivity;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.models.SignatureVerification;
|
||||
import com.nextcloud.talk.models.json.push.DecryptedPushMessage;
|
||||
@ -98,13 +99,36 @@ public class NotificationJob extends Job {
|
||||
String category = "";
|
||||
int priority = Notification.PRIORITY_DEFAULT;
|
||||
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
||||
Intent intent;
|
||||
|
||||
Intent intent = new Intent(context, CallActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
boolean hasChatSupport = signatureVerification.getUserEntity().hasSpreedCapabilityWithName
|
||||
("chat-v2");
|
||||
|
||||
if (hasChatSupport) {
|
||||
intent = new Intent(context, MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
} else {
|
||||
intent = new Intent(context, CallActivity.class);
|
||||
bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, true);
|
||||
}
|
||||
|
||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, decryptedPushMessage.getId());
|
||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(signatureVerification
|
||||
.getUserEntity()));
|
||||
bundle.putBoolean("fromNotification", true);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
intent.putExtras(bundle);
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context,
|
||||
@ -126,6 +150,9 @@ 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;
|
||||
|
@ -48,4 +48,5 @@ public class BundleKeys {
|
||||
public static final String KEY_CALL_VOICE_ONLY = "KEY_CALL_VOICE_ONLY";
|
||||
public static final String KEY_ACTIVE_CONVERSATION = "KEY_ACTIVE_CONVERSATION";
|
||||
public static final String KEY_SPREED_CAPABILITIES = "KEY_SPREED_CAPABILITIES";
|
||||
public static final String KEY_FROM_NOTIFICATION_START_CALL = "KEY_FROM_NOTIFICATION_START_CALL";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user