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