Browse Source

More cleanups

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 years ago
parent
commit
507f9909fa

+ 2 - 2
app/src/main/java/com/nextcloud/talk/activities/CallActivity.java

@@ -239,8 +239,8 @@ public class CallActivity extends AppCompatActivity {
                 .setRepeatCount(PulseAnimation.INFINITE)
                 .setRepeatMode(PulseAnimation.REVERSE);
 
-        roomToken = getIntent().getExtras().getString("roomToken", "");
-        userEntity = Parcels.unwrap(getIntent().getExtras().getParcelable("userEntity"));
+        roomToken = getIntent().getExtras().getString(BundleKeys.KEY_ROOM_TOKEN, "");
+        userEntity = Parcels.unwrap(getIntent().getExtras().getParcelable(BundleKeys.KEY_USER_ENTITY));
         callSession = getIntent().getExtras().getString(BundleKeys.KEY_CALL_SESSION, "0");
         credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken());
 

+ 11 - 14
app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.java

@@ -319,21 +319,18 @@ public class AccountVerificationController extends BaseController {
         } else {
             ApplicationWideMessageHolder.getInstance().setMessageType(
                     ApplicationWideMessageHolder.MessageType.FAILED_TO_IMPORT_ACCOUNT);
-            new Handler().postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    if (getRouter().hasRootController()) {
-                        getRouter().popToRoot();
+            new Handler().postDelayed(() -> {
+                if (getRouter().hasRootController()) {
+                    getRouter().popToRoot();
+                } else {
+                    if (userUtils.anyUserExists()) {
+                        getRouter().setRoot(RouterTransaction.with(new MagicBottomNavigationController())
+                                .pushChangeHandler(new HorizontalChangeHandler())
+                                .popChangeHandler(new HorizontalChangeHandler()));
                     } else {
-                        if (userUtils.anyUserExists()) {
-                            getRouter().setRoot(RouterTransaction.with(new MagicBottomNavigationController())
-                                    .pushChangeHandler(new HorizontalChangeHandler())
-                                    .popChangeHandler(new HorizontalChangeHandler()));
-                        } else {
-                            getRouter().setRoot(RouterTransaction.with(new ServerSelectionController())
-                                    .pushChangeHandler(new HorizontalChangeHandler())
-                                    .popChangeHandler(new HorizontalChangeHandler()));
-                        }
+                        getRouter().setRoot(RouterTransaction.with(new ServerSelectionController())
+                                .pushChangeHandler(new HorizontalChangeHandler())
+                                .popChangeHandler(new HorizontalChangeHandler()));
                     }
                 }
             }, 7500);

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

@@ -442,8 +442,8 @@ public class CallsListController extends BaseController implements SearchView.On
         if (callItem != null && getActivity() != null) {
             Room room = callItem.getModel();
             Bundle bundle = new Bundle();
-            bundle.putString("roomToken", callItem.getModel().getToken());
-            bundle.putParcelable("userEntity", Parcels.wrap(userEntity));
+            bundle.putString(BundleKeys.KEY_ROOM_TOKEN, callItem.getModel().getToken());
+            bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(userEntity));
 
             if (room.hasPassword && (room.participantType.equals(Participant.ParticipantType.GUEST) ||
                     room.participantType.equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {

+ 2 - 2
app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java

@@ -457,8 +457,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ
                         overridePopHandler(new NoOpControllerChangeHandler());
                         Intent callIntent = new Intent(getActivity(), CallActivity.class);
                         Bundle bundle = new Bundle();
-                        bundle.putString("roomToken", roomOverall.getOcs().getData().getToken());
-                        bundle.putParcelable("userEntity", Parcels.wrap(userEntity));
+                        bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.getOcs().getData().getToken());
+                        bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(userEntity));
                         callIntent.putExtras(bundle);
                         startActivity(callIntent);
                     }

+ 1 - 1
app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java

@@ -123,7 +123,7 @@ public class EntryMenuController extends BaseController {
                 eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
                 bundle = new Bundle();
                 bundle.putParcelable(BundleKeys.KEY_ROOM, Parcels.wrap(room));
-                bundle.putParcelable("userEntity", Parcels.wrap(userEntity));
+                bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(userEntity));
                 bundle.putString(BundleKeys.KEY_CALL_PASSWORD, editText.getText().toString());
                 getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)));
             }

+ 4 - 4
app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java

@@ -102,8 +102,8 @@ public class OperationsMenuController extends BaseController {
         this.room = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ROOM));
 
         this.callPassword = args.getString(BundleKeys.KEY_CALL_PASSWORD, "");
-        if (args.containsKey("userEntity")) {
-            this.userEntity = Parcels.unwrap(args.getParcelable("userEntity"));
+        if (args.containsKey(BundleKeys.KEY_USER_ENTITY)) {
+            this.userEntity = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_USER_ENTITY));
         }
     }
 
@@ -255,8 +255,8 @@ public class OperationsMenuController extends BaseController {
                 showResultImage(true);
             } else {
                 Bundle bundle = new Bundle();
-                bundle.putString("roomToken", room.getToken());
-                bundle.putParcelable("userEntity", Parcels.wrap(userEntity));
+                bundle.putString(BundleKeys.KEY_ROOM_TOKEN, room.getToken());
+                bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(userEntity));
                 bundle.putString(BundleKeys.KEY_CALL_SESSION, ((CallOverall) o).getOcs().getData().getSessionId());
                 overridePushHandler(new NoOpControllerChangeHandler());
                 overridePopHandler(new NoOpControllerChangeHandler());

+ 3 - 2
app/src/main/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.java

@@ -45,6 +45,7 @@ import com.nextcloud.talk.api.models.json.push.PushMessage;
 import com.nextcloud.talk.models.SignatureVerification;
 import com.nextcloud.talk.utils.NotificationUtils;
 import com.nextcloud.talk.utils.PushUtils;
+import com.nextcloud.talk.utils.bundle.BundleKeys;
 
 import org.parceler.Parcels;
 
@@ -94,8 +95,8 @@ public class MagicFirebaseMessagingService extends FirebaseMessagingService {
 
                             Intent intent = new Intent(this, CallActivity.class);
                             Bundle bundle = new Bundle();
-                            bundle.putString("roomToken", decryptedPushMessage.getId());
-                            bundle.putParcelable("userEntity", Parcels.wrap(signatureVerification
+                            bundle.putString(BundleKeys.KEY_ROOM_TOKEN, decryptedPushMessage.getId());
+                            bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(signatureVerification
                                     .getUserEntity()));
                             bundle.putBoolean("fromNotification", true);
                             intent.putExtras(bundle);

+ 2 - 0
app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.java

@@ -34,4 +34,6 @@ public class BundleKeys {
     public static final String KEY_APP_ITEM_NAME = "KEY_APP_ITEM_NAME";
     public static final String KEY_CALL_PASSWORD = "KEY_CALL_PASSWORD";
     public static final String KEY_CALL_SESSION = "KEY_CALL_SESSION";
+    public static final String KEY_ROOM_TOKEN = "KEY_ROOM_TOKEN";
+    public static final String KEY_USER_ENTITY = "KEY_USER_ENTITY";
 }