Fixes #258, Fixes #255, Fixes #237, Fixes #234

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-07-29 11:58:40 +02:00
parent a78114ab13
commit b0aaf75109
4 changed files with 47 additions and 14 deletions

View File

@ -82,6 +82,7 @@ import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import okhttp3.Cache;
@AutoInjector(NextcloudTalkApplication.class) @AutoInjector(NextcloudTalkApplication.class)
public class CallNotificationController extends BaseController { public class CallNotificationController extends BaseController {
@ -109,6 +110,9 @@ public class CallNotificationController extends BaseController {
@BindView(R.id.constraintLayout) @BindView(R.id.constraintLayout)
ConstraintLayout constraintLayout; ConstraintLayout constraintLayout;
@Inject
Cache cache;
private List<Disposable> disposablesList = new ArrayList<>(); private List<Disposable> disposablesList = new ArrayList<>();
private Bundle originalBundle; private Bundle originalBundle;
private String roomId; private String roomId;
@ -124,6 +128,7 @@ public class CallNotificationController extends BaseController {
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this); NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
this.roomId = args.getString(BundleKeys.KEY_ROOM_ID, ""); this.roomId = args.getString(BundleKeys.KEY_ROOM_ID, "");
this.currentRoom = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ROOM));
this.userBeingCalled = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_USER_ENTITY)); this.userBeingCalled = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_USER_ENTITY));
this.originalBundle = args; this.originalBundle = args;
@ -236,12 +241,7 @@ public class CallNotificationController extends BaseController {
for (Room room : roomsOverall.getOcs().getData()) { for (Room room : roomsOverall.getOcs().getData()) {
if (roomId.equals(room.getRoomId())) { if (roomId.equals(room.getRoomId())) {
currentRoom = room; currentRoom = room;
if (conversationNameTextView != null) { runAllThings();
conversationNameTextView.setText(currentRoom.getDisplayName());
loadAvatar();
checkIfAnyParticipantsRemainInRoom();
showAnswerControls();
}
break; break;
} }
} }
@ -260,13 +260,34 @@ public class CallNotificationController extends BaseController {
}); });
} }
private void runAllThings() {
if (conversationNameTextView != null) {
conversationNameTextView.setText(currentRoom.getDisplayName());
}
loadAvatar();
checkIfAnyParticipantsRemainInRoom();
showAnswerControls();
}
@SuppressLint("LongLogTag") @SuppressLint("LongLogTag")
@Override @Override
protected void onViewBound(@NonNull View view) { protected void onViewBound(@NonNull View view) {
super.onViewBound(view); super.onViewBound(view);
renderScript = RenderScript.create(getActivity()); renderScript = RenderScript.create(getActivity());
try {
cache.evictAll();
} catch (IOException e) {
Log.e(TAG, "Failed to evict cache");
}
if (currentRoom == null) {
handleFromNotification(); handleFromNotification();
} else {
runAllThings();
}
String callRingtonePreferenceString = appPreferences.getCallRingtoneUri(); String callRingtonePreferenceString = appPreferences.getCallRingtoneUri();
Uri ringtoneUri; Uri ringtoneUri;

View File

@ -494,6 +494,7 @@ public class CallsListController extends BaseController implements SearchView.On
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.putString(BundleKeys.KEY_ROOM_ID, callItem.getModel().getRoomId()); bundle.putString(BundleKeys.KEY_ROOM_ID, callItem.getModel().getRoomId());
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, callItem.getModel().getToken());
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))) {

View File

@ -165,7 +165,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 Boolean startCallFromNotification; private Boolean startCallFromNotification = null;
private String roomId; private String roomId;
private boolean voiceOnly; private boolean voiceOnly;
@ -187,7 +187,6 @@ public class ChatController extends BaseController implements MessagesListAdapte
} }
this.roomId = args.getString(BundleKeys.KEY_ROOM_ID, ""); this.roomId = args.getString(BundleKeys.KEY_ROOM_ID, "");
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)) {
@ -232,6 +231,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
@Override @Override
public void onNext(RoomOverall roomOverall) { public void onNext(RoomOverall roomOverall) {
conversationName = roomOverall.getOcs().getData().getDisplayName(); conversationName = roomOverall.getOcs().getData().getDisplayName();
Log.d("MARIO", getTitle());
setTitle(); setTitle();
setupMentionAutocomplete(); setupMentionAutocomplete();
@ -267,6 +267,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
if (roomId.equals(room.getRoomId())) { if (roomId.equals(room.getRoomId())) {
roomToken = room.getToken(); roomToken = room.getToken();
conversationName = room.getDisplayName(); conversationName = room.getDisplayName();
Log.d("MARIO", getTitle());
setTitle(); setTitle();
break; break;
} }
@ -407,10 +408,16 @@ public class ChatController extends BaseController implements MessagesListAdapte
messageInputView.getButton().setContentDescription(getResources() messageInputView.getButton().setContentDescription(getResources()
.getString(R.string.nc_description_send_message_button)); .getString(R.string.nc_description_send_message_button));
if (adapterWasNull && TextUtils.isEmpty(conversationName) && startCallFromNotification == null) { if (adapterWasNull) {
// we're starting
if (TextUtils.isEmpty(roomToken)) {
handleFromNotification();
} else if (TextUtils.isEmpty(conversationName)){
getRoomInfo(); getRoomInfo();
} else { } else {
handleFromNotification(); setupMentionAutocomplete();
joinRoomWithPassword();
}
} }
} }

View File

@ -217,6 +217,7 @@ public class NotificationJob extends Job {
public void onNext(RoomOverall roomOverall) { public void onNext(RoomOverall roomOverall) {
Room room = roomOverall.getOcs().getData(); Room room = roomOverall.getOcs().getData();
intent.putExtra(BundleKeys.KEY_ROOM, Parcels.wrap(room));
if (room.getType().equals(Room.RoomType.ROOM_TYPE_ONE_TO_ONE_CALL)) { if (room.getType().equals(Room.RoomType.ROOM_TYPE_ONE_TO_ONE_CALL)) {
context.startActivity(intent); context.startActivity(intent);
} else { } else {
@ -226,7 +227,10 @@ public class NotificationJob extends Job {
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
intent.putExtra(BundleKeys.KEY_ROOM_ID, intent.getExtras().getString(BundleKeys
.KEY_ROOM_TOKEN));
intent.removeExtra(BundleKeys.KEY_ROOM_TOKEN);
context.startActivity(intent);
} }
@Override @Override