Browse Source

replace operationCode's (int) by Enums

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 years ago
parent
commit
4335e44701

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

@@ -45,6 +45,7 @@ import com.nextcloud.talk.adapters.items.UserItem;
 import com.nextcloud.talk.api.NcApi;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.controllers.base.BaseController;
+import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum;
 import com.nextcloud.talk.events.OpenConversationEvent;
 import com.nextcloud.talk.jobs.AddParticipantsToConversation;
 import com.nextcloud.talk.models.RetrofitBucket;
@@ -376,7 +377,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
                 bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_GROUP(), groupIdsArray);
                 bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_EMAIL(), emailsArray);
                 bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_CIRCLE(), circleIdsArray);
-                bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 11);
+                bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), ConversationOperationEnum.INVITE_USERS);
                 prepareAndShowBottomSheetWithBundle(bundle);
             }
         } else {
@@ -934,7 +935,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
     @OnClick(R.id.joinConversationViaLinkRelativeLayout)
     void joinConversationViaLink() {
         Bundle bundle = new Bundle();
-        bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 10);
+        bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), ConversationOperationEnum.GET_JOIN_ROOM);
 
         prepareAndShowBottomSheetWithBundle(bundle);
     }

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

@@ -70,6 +70,7 @@ import com.nextcloud.talk.adapters.items.GenericTextHeaderItem;
 import com.nextcloud.talk.api.NcApi;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.controllers.base.BaseController;
+import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum;
 import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController;
 import com.nextcloud.talk.events.EventStatus;
 import com.nextcloud.talk.interfaces.ConversationMenuInterface;
@@ -1023,7 +1024,7 @@ public class ConversationsListController extends BaseController implements Searc
         if ((selectedConversation.hasPassword
             && selectedConversation.participantType == Participant.ParticipantType.GUEST)
             || selectedConversation.participantType == Participant.ParticipantType.USER_FOLLOWING_LINK) {
-            bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 99);
+            bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), ConversationOperationEnum.JOIN_ROOM);
             prepareAndShowBottomSheetWithBundle(bundle);
 
 

+ 17 - 0
app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt

@@ -0,0 +1,17 @@
+package com.nextcloud.talk.controllers.bottomsheet
+
+enum class ConversationOperationEnum {
+    RENAME_ROOM, // 2
+    MAKE_PUBLIC, // 3
+    CHANGE_PASSWORD, // 4
+    CLEAR_PASSWORD, // 5
+    SET_PASSWORD, // 6
+    SHARE_LINK, // 7
+    MAKE_PRIVATE, // 8
+    GET_JOIN_ROOM, // 10          diff to 99?!
+    INVITE_USERS, // 11
+    MARK_AS_READ, // 96
+    REMOVE_FAVORITE, // 97
+    ADD_FAVORITE, // 98
+    JOIN_ROOM, // 99             diff to 10?!
+}

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

@@ -86,7 +86,7 @@ public class EntryMenuController extends BaseController {
     @Inject
     UserUtils userUtils;
 
-    private int operationCode;
+    private ConversationOperationEnum operation;
     private Conversation conversation;
     private Intent shareIntent;
     private String packageName;
@@ -101,7 +101,7 @@ public class EntryMenuController extends BaseController {
         super(args);
         originalBundle = args;
 
-        this.operationCode = args.getInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE());
+        this.operation = (ConversationOperationEnum) args.getSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE());
         if (args.containsKey(BundleKeys.INSTANCE.getKEY_ROOM())) {
             this.conversation = Parcels.unwrap(args.getParcelable(BundleKeys.INSTANCE.getKEY_ROOM()));
         }
@@ -143,13 +143,13 @@ public class EntryMenuController extends BaseController {
     @OnClick(R.id.ok_button)
     public void onProceedButtonClick() {
         Bundle bundle;
-        if (operationCode == 99) {
+        if (operation == ConversationOperationEnum.JOIN_ROOM) {
             eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
             bundle = new Bundle();
             bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation));
             bundle.putString(BundleKeys.INSTANCE.getKEY_CALL_URL(), callUrl);
             bundle.putString(BundleKeys.INSTANCE.getKEY_CONVERSATION_PASSWORD(), editText.getText().toString());
-            bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), operationCode);
+            bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), operation);
             if (originalBundle.containsKey(BundleKeys.INSTANCE.getKEY_SERVER_CAPABILITIES())) {
                 bundle.putParcelable(BundleKeys.INSTANCE.getKEY_SERVER_CAPABILITIES(), originalBundle.getParcelable(BundleKeys.INSTANCE.getKEY_SERVER_CAPABILITIES()));
             }
@@ -157,20 +157,20 @@ public class EntryMenuController extends BaseController {
             getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle))
                     .pushChangeHandler(new HorizontalChangeHandler())
                     .popChangeHandler(new HorizontalChangeHandler()));
-        } else if (operationCode != 7 && operationCode != 10 && operationCode != 11) {
+        } else if (operation != ConversationOperationEnum.SHARE_LINK && operation != ConversationOperationEnum.GET_JOIN_ROOM && operation != ConversationOperationEnum.INVITE_USERS) {
             eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
             bundle = new Bundle();
-            if (operationCode == 4 || operationCode == 6) {
+            if (operation == ConversationOperationEnum.CHANGE_PASSWORD || operation == ConversationOperationEnum.SET_PASSWORD) {
                 conversation.setPassword(editText.getText().toString());
             } else {
                 conversation.setName(editText.getText().toString());
             }
             bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation));
-            bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), operationCode);
+            bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), operation);
             getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle))
                     .pushChangeHandler(new HorizontalChangeHandler())
                     .popChangeHandler(new HorizontalChangeHandler()));
-        } else if (operationCode == 7) {
+        } else if (operation == ConversationOperationEnum.SHARE_LINK) {
             if (getActivity() != null) {
                 shareIntent.putExtra(Intent.EXTRA_TEXT, ShareUtils.getStringForIntent(getActivity(),
                         editText.getText().toString(), userUtils, conversation));
@@ -180,16 +180,16 @@ public class EntryMenuController extends BaseController {
                 getActivity().startActivity(intent);
                 eventBus.post(new BottomSheetLockEvent(true, 0, false, true));
             }
-        } else if (operationCode != 11) {
+        } else if (operation != ConversationOperationEnum.INVITE_USERS) {
             eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
             bundle = new Bundle();
-            bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), operationCode);
+            bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), operation);
             bundle.putString(BundleKeys.INSTANCE.getKEY_CALL_URL(), editText.getText().toString());
             getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle))
                     .pushChangeHandler(new HorizontalChangeHandler())
                     .popChangeHandler(new HorizontalChangeHandler()));
 
-        } else if (operationCode == 11) {
+        } else if (operation == ConversationOperationEnum.INVITE_USERS) {
             eventBus.post(new BottomSheetLockEvent(false, 0, false, false));
             originalBundle.putString(BundleKeys.INSTANCE.getKEY_CONVERSATION_NAME(), editText.getText().toString());
             getRouter().pushController(RouterTransaction.with(new OperationsMenuController(originalBundle))
@@ -204,7 +204,7 @@ public class EntryMenuController extends BaseController {
         super.onViewBound(view);
         NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
 
-        if (conversation != null && operationCode == 2) {
+        if (conversation != null && operation == ConversationOperationEnum.RENAME_ROOM) {
             editText.setText(conversation.getName());
         }
 
@@ -230,7 +230,7 @@ public class EntryMenuController extends BaseController {
             @Override
             public void afterTextChanged(Editable s) {
                 if (!TextUtils.isEmpty(s)) {
-                    if (operationCode == 2) {
+                    if (operation == ConversationOperationEnum.RENAME_ROOM) {
                         if (conversation.getName() == null || !conversation.getName().equals(s.toString())) {
                             if (!proceedButton.isEnabled()) {
                                 proceedButton.setEnabled(true);
@@ -244,7 +244,7 @@ public class EntryMenuController extends BaseController {
                             }
                             textInputLayout.setError(getResources().getString(R.string.nc_call_name_is_same));
                         }
-                    } else if (operationCode != 10) {
+                    } else if (operation != ConversationOperationEnum.GET_JOIN_ROOM) {
                         if (!proceedButton.isEnabled()) {
                             proceedButton.setEnabled(true);
                             proceedButton.setAlpha(1.0f);
@@ -277,9 +277,9 @@ public class EntryMenuController extends BaseController {
         });
 
         String labelText = "";
-        switch (operationCode) {
-            case 11:
-            case 2:
+        switch (operation) {
+            case INVITE_USERS:
+            case RENAME_ROOM:
                 labelText = getResources().getString(R.string.nc_call_name);
                 editText.setInputType(InputType.TYPE_CLASS_TEXT);
                 smileyButton.setVisibility(View.VISIBLE);
@@ -307,18 +307,18 @@ public class EntryMenuController extends BaseController {
                 }).build(editText);
 
                 break;
-            case 4:
+            case CHANGE_PASSWORD:
                 labelText = getResources().getString(R.string.nc_new_password);
                 editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                 break;
-            case 6:
-            case 7:
-            case 99:
+            case SET_PASSWORD:
+            case SHARE_LINK:
+            case JOIN_ROOM:
                 // 99 is joining a conversation via password
                 labelText = getResources().getString(R.string.nc_password);
                 editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                 break;
-            case 10:
+            case GET_JOIN_ROOM:
                 labelText = getResources().getString(R.string.nc_conversation_link);
                 editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
                 break;
@@ -326,7 +326,10 @@ public class EntryMenuController extends BaseController {
                 break;
         }
 
-        if (operationCode == 99 || operationCode == 4 || operationCode == 6 || operationCode == 7) {
+        if (operation == ConversationOperationEnum.JOIN_ROOM
+            || operation == ConversationOperationEnum.CHANGE_PASSWORD
+            || operation == ConversationOperationEnum.SET_PASSWORD
+            || operation == ConversationOperationEnum.SHARE_LINK) {
             textInputLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE);
         } else {
             textInputLayout.setEndIconMode(TextInputLayout.END_ICON_NONE);

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

@@ -33,7 +33,6 @@ import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.ProgressBar;
 import android.widget.TextView;
-import android.widget.Toast;
 
 import com.bluelinelabs.conductor.RouterTransaction;
 import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
@@ -43,7 +42,6 @@ import com.nextcloud.talk.api.NcApi;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.controllers.base.BaseController;
 import com.nextcloud.talk.events.BottomSheetLockEvent;
-import com.nextcloud.talk.events.CallNotificationClick;
 import com.nextcloud.talk.events.OpenConversationEvent;
 import com.nextcloud.talk.models.RetrofitBucket;
 import com.nextcloud.talk.models.database.CapabilitiesUtil;
@@ -55,7 +53,6 @@ import com.nextcloud.talk.models.json.conversations.RoomOverall;
 import com.nextcloud.talk.models.json.generic.GenericOverall;
 import com.nextcloud.talk.models.json.participants.AddParticipantOverall;
 import com.nextcloud.talk.utils.ApiUtils;
-import com.nextcloud.talk.utils.ConductorRemapping;
 import com.nextcloud.talk.utils.DisplayUtils;
 import com.nextcloud.talk.utils.NoSupportedApiException;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
@@ -77,7 +74,6 @@ import io.reactivex.Observer;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.disposables.Disposable;
 import io.reactivex.schedulers.Schedulers;
-import okhttp3.ResponseBody;
 import retrofit2.HttpException;
 import retrofit2.Response;
 
@@ -110,7 +106,7 @@ public class OperationsMenuController extends BaseController {
     @Inject
     EventBus eventBus;
 
-    private int operationCode;
+    private ConversationOperationEnum operation;
     private Conversation conversation;
 
     private UserEntity currentUser;
@@ -132,7 +128,7 @@ public class OperationsMenuController extends BaseController {
 
     public OperationsMenuController(Bundle args) {
         super(args);
-        this.operationCode = args.getInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE());
+        this.operation = (ConversationOperationEnum) args.getSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE());
         if (args.containsKey(BundleKeys.INSTANCE.getKEY_ROOM())) {
             this.conversation = Parcels.unwrap(args.getParcelable(BundleKeys.INSTANCE.getKEY_ROOM()));
         }
@@ -285,25 +281,8 @@ public class OperationsMenuController extends BaseController {
         int apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {ApiUtils.APIv4, ApiUtils.APIv1});
         int chatApiVersion = ApiUtils.getChatApiVersion(currentUser, new int[] {ApiUtils.APIv1});
 
-
-        /*
-        2: renameRoom
-        3: make public
-        4: change password
-        5: clear password
-        6: set password
-        8: make private
-        10: get/join room
-        11: invite users to conversation
-        96: set chat read marker
-        97: remove favorite
-        98: add favorite
-        99: join room
-         */
-
-
-        switch (operationCode) {
-            case 2:
+        switch (operation) {
+            case RENAME_ROOM:
                 ncApi.renameRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
                                                                      conversation.getToken()),
                         conversation.getName())
@@ -312,7 +291,7 @@ public class OperationsMenuController extends BaseController {
                         .retry(1)
                         .subscribe(genericOperationsObserver);
                 break;
-            case 3:
+            case MAKE_PUBLIC:
                 ncApi.makeRoomPublic(credentials, ApiUtils.getUrlForRoomPublic(apiVersion, currentUser.getBaseUrl(),
                                                                                conversation.getToken()))
                         .subscribeOn(Schedulers.io())
@@ -320,9 +299,9 @@ public class OperationsMenuController extends BaseController {
                         .retry(1)
                         .subscribe(genericOperationsObserver);
                 break;
-            case 4:
-            case 5:
-            case 6:
+            case CHANGE_PASSWORD:
+            case CLEAR_PASSWORD:
+            case SET_PASSWORD:
                 String pass = "";
                 if (conversation.getPassword() != null) {
                     pass = conversation.getPassword();
@@ -334,10 +313,7 @@ public class OperationsMenuController extends BaseController {
                         .retry(1)
                         .subscribe(genericOperationsObserver);
                 break;
-            case 7:
-                // Operation 7 is sharing, so we handle this differently
-                break;
-            case 8:
+            case MAKE_PRIVATE:
                 ncApi.makeRoomPrivate(credentials, ApiUtils.getUrlForRoomPublic(apiVersion,
                                                                                 currentUser.getBaseUrl(),
                                                                                 conversation.getToken()))
@@ -346,7 +322,7 @@ public class OperationsMenuController extends BaseController {
                         .retry(1)
                         .subscribe(genericOperationsObserver);
                 break;
-            case 10:
+            case GET_JOIN_ROOM:
                 ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, baseUrl, conversationToken))
                         .subscribeOn(Schedulers.io())
                         .observeOn(AndroidSchedulers.mainThread())
@@ -374,7 +350,8 @@ public class OperationsMenuController extends BaseController {
                                         Log.e(TAG, "Failed to parse capabilities for guest");
                                         showResultImage(false, false);
                                     }
-                                    bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 99);
+                                    bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(),
+                                                           ConversationOperationEnum.JOIN_ROOM);
                                     getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle))
                                                                        .pushChangeHandler(new HorizontalChangeHandler())
                                                                        .popChangeHandler(new HorizontalChangeHandler()));
@@ -426,7 +403,7 @@ public class OperationsMenuController extends BaseController {
                             }
                         });
                 break;
-            case 11:
+            case INVITE_USERS:
                 RetrofitBucket retrofitBucket;
                 String invite = null;
 
@@ -502,7 +479,7 @@ public class OperationsMenuController extends BaseController {
                         });
 
                 break;
-            case 96:
+            case MARK_AS_READ:
                 ncApi.setChatReadMarker(credentials,
                                         ApiUtils.getUrlForSetChatReadMarker(chatApiVersion,
                                                                             currentUser.getBaseUrl(),
@@ -513,9 +490,9 @@ public class OperationsMenuController extends BaseController {
                     .retry(1)
                     .subscribe(genericOperationsObserver);
                 break;
-            case 97:
-            case 98:
-                if (operationCode == 97) {
+            case REMOVE_FAVORITE:
+            case ADD_FAVORITE:
+                if (operation == ConversationOperationEnum.REMOVE_FAVORITE) {
                     ncApi.removeConversationFromFavorites(credentials,
                                                           ApiUtils.getUrlForRoomFavorite(apiVersion,
                                                                                          currentUser.getBaseUrl(),
@@ -535,7 +512,7 @@ public class OperationsMenuController extends BaseController {
                             .subscribe(genericOperationsObserver);
                 }
                 break;
-            case 99:
+            case JOIN_ROOM:
                 ncApi.joinRoom(credentials, ApiUtils.getUrlForParticipantsActive(apiVersion,
                                                                                  baseUrl,
                                                                                  conversationToken),
@@ -591,8 +568,9 @@ public class OperationsMenuController extends BaseController {
         } else {
             resultImageView.setImageDrawable(DisplayUtils.getTintedDrawable(getResources(), R.drawable
                     .ic_cancel_black_24dp, R.color.nc_darkRed));
-            okButton.setOnClickListener(v -> eventBus.post(new BottomSheetLockEvent(true, 0, operationCode != 99
-                    && operationCode != 10, true)));
+            okButton.setOnClickListener(v -> eventBus.post(new BottomSheetLockEvent(true, 0,
+                                                                                    operation != ConversationOperationEnum.JOIN_ROOM
+                    && operation != ConversationOperationEnum.GET_JOIN_ROOM, true)));
             okButton.setVisibility(View.VISIBLE);
         }
     }
@@ -758,7 +736,7 @@ public class OperationsMenuController extends BaseController {
     }
 
     private void handleObserverError(@io.reactivex.annotations.NonNull Throwable e) {
-        if (operationCode != 99 || !(e instanceof HttpException)) {
+        if (operation != ConversationOperationEnum.JOIN_ROOM || !(e instanceof HttpException)) {
             showResultImage(false, false);
         } else {
             Response<?> response = ((HttpException) e).response();
@@ -783,7 +761,7 @@ public class OperationsMenuController extends BaseController {
 
         @Override
         public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
-            if (operationCode != 99) {
+            if (operation != ConversationOperationEnum.JOIN_ROOM) {
                 showResultImage(true, false);
             } else {
                 throw new IllegalArgumentException("Unsupported operation code observed!");
@@ -811,7 +789,7 @@ public class OperationsMenuController extends BaseController {
         @Override
         public void onNext(@io.reactivex.annotations.NonNull RoomOverall roomOverall) {
             conversation = roomOverall.getOcs().getData();
-            if (operationCode != 99) {
+            if (operation != ConversationOperationEnum.JOIN_ROOM) {
                 showResultImage(true, false);
             } else {
                 conversation = roomOverall.getOcs().getData();

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

@@ -21,6 +21,8 @@
 package com.nextcloud.talk.jobs;
 
 import android.content.Context;
+import android.util.Log;
+
 import androidx.annotation.NonNull;
 import androidx.work.Data;
 import androidx.work.Worker;
@@ -48,6 +50,8 @@ import java.net.CookieManager;
 @AutoInjector(NextcloudTalkApplication.class)
 public class LeaveConversationWorker extends Worker {
 
+    private static String TAG = "LeaveConversationWorker";
+
     @Inject
     Retrofit retrofit;
 
@@ -106,7 +110,7 @@ public class LeaveConversationWorker extends Worker {
 
                         @Override
                         public void onError(Throwable e) {
-
+                            Log.e(TAG, "failed to remove self from room", e);
                         }
 
                         @Override

+ 16 - 21
app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt

@@ -20,6 +20,7 @@ import com.nextcloud.talk.R
 import com.nextcloud.talk.api.NcApi
 import com.nextcloud.talk.application.NextcloudTalkApplication
 import com.nextcloud.talk.controllers.ConversationsListController
+import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum
 import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController
 import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController
 import com.nextcloud.talk.databinding.DialogConversationOperationsBinding
@@ -128,6 +129,9 @@ class ConversationsListBottomDialog(
 
         binding.conversationOperationLeave.visibility = setVisibleIf(
             conversation.canLeave()
+                // leaving is by api not possible for the last user with moderator permissions.
+                // for now, hide this option for all moderators.
+                && !conversation.canModerate(currentUser)
         )
     }
 
@@ -141,11 +145,11 @@ class ConversationsListBottomDialog(
 
     private fun initClickListeners() {
         binding.conversationOperationAddFavorite.setOnClickListener {
-            executeOperationsMenuController(OPS_CODE_ADD_FAVORITE)
+            executeOperationsMenuController(ConversationOperationEnum.ADD_FAVORITE)
         }
 
         binding.conversationOperationRemoveFavorite.setOnClickListener {
-            executeOperationsMenuController(OPS_CODE_REMOVE_FAVORITE)
+            executeOperationsMenuController(ConversationOperationEnum.REMOVE_FAVORITE)
         }
 
         binding.conversationOperationLeave.setOnClickListener {
@@ -179,27 +183,27 @@ class ConversationsListBottomDialog(
         }
 
         binding.conversationOperationMakePublic.setOnClickListener {
-            executeOperationsMenuController(OPS_CODE_MAKE_PUBLIC)
+            executeOperationsMenuController(ConversationOperationEnum.MAKE_PUBLIC)
         }
 
         binding.conversationOperationMakePrivate.setOnClickListener {
-            executeOperationsMenuController(OPS_CODE_MAKE_PRIVATE)
+            executeOperationsMenuController(ConversationOperationEnum.MAKE_PRIVATE)
         }
 
         binding.conversationOperationChangePassword.setOnClickListener {
-            executeEntryMenuController(OPS_CODE_CHANGE_PASSWORD)
+            executeEntryMenuController(ConversationOperationEnum.CHANGE_PASSWORD)
         }
 
         binding.conversationOperationClearPassword.setOnClickListener {
-            executeOperationsMenuController(OPS_CODE_CLEAR_PASSWORD)
+            executeOperationsMenuController(ConversationOperationEnum.CLEAR_PASSWORD)
         }
 
         binding.conversationOperationSetPassword.setOnClickListener {
-            executeEntryMenuController(OPS_CODE_SET_PASSWORD)
+            executeEntryMenuController(ConversationOperationEnum.SET_PASSWORD)
         }
 
         binding.conversationOperationRename.setOnClickListener {
-            executeEntryMenuController(OPS_CODE_RENAME)
+            executeEntryMenuController(ConversationOperationEnum.RENAME_ROOM)
         }
 
         binding.conversationOperationShareLink.setOnClickListener {
@@ -227,10 +231,10 @@ class ConversationsListBottomDialog(
         }
     }
 
-    private fun executeOperationsMenuController(operationCode: Int) {
+    private fun executeOperationsMenuController(operation: ConversationOperationEnum) {
         val bundle = Bundle()
         bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
-        bundle.putInt(KEY_OPERATION_CODE, operationCode)
+        bundle.putSerializable(KEY_OPERATION_CODE, operation)
 
         binding.operationItemsLayout.visibility = View.GONE
 
@@ -245,10 +249,10 @@ class ConversationsListBottomDialog(
         controller.fetchData()
     }
 
-    private fun executeEntryMenuController(operationCode: Int) {
+    private fun executeEntryMenuController(operation: ConversationOperationEnum) {
         val bundle = Bundle()
         bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
-        bundle.putInt(KEY_OPERATION_CODE, operationCode)
+        bundle.putSerializable(KEY_OPERATION_CODE, operation)
 
         binding.operationItemsLayout.visibility = View.GONE
 
@@ -277,14 +281,5 @@ class ConversationsListBottomDialog(
 
     companion object {
         private const val TAG = "ConversationOperationDialog"
-
-        private const val OPS_CODE_RENAME = 2
-        private const val OPS_CODE_MAKE_PUBLIC = 3
-        private const val OPS_CODE_CHANGE_PASSWORD = 4
-        private const val OPS_CODE_CLEAR_PASSWORD = 5
-        private const val OPS_CODE_SET_PASSWORD = 6
-        private const val OPS_CODE_MAKE_PRIVATE = 8
-        private const val OPS_CODE_REMOVE_FAVORITE = 97
-        private const val OPS_CODE_ADD_FAVORITE = 98
     }
 }