Browse Source

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

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 years ago
parent
commit
b0aaf75109

+ 28 - 7
app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java

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

+ 1 - 0
app/src/main/java/com/nextcloud/talk/controllers/CallsListController.java

@@ -494,6 +494,7 @@ public class CallsListController extends BaseController implements SearchView.On
             Bundle bundle = new Bundle();
             bundle.putString(BundleKeys.KEY_ROOM_TOKEN, callItem.getModel().getToken());
             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) ||
                     room.participantType.equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {

+ 13 - 6
app/src/main/java/com/nextcloud/talk/controllers/ChatController.java

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

+ 5 - 1
app/src/main/java/com/nextcloud/talk/jobs/NotificationJob.java

@@ -217,6 +217,7 @@ public class NotificationJob extends Job {
                     public void onNext(RoomOverall roomOverall) {
                         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)) {
                             context.startActivity(intent);
                         } else {
@@ -226,7 +227,10 @@ public class NotificationJob extends Job {
 
                     @Override
                     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