From 90a99d49943fc240b741893e75677a3431ffaa25 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Sat, 22 May 2021 02:19:24 +0200 Subject: [PATCH 01/34] fix design when keyboard is shown - set windowSoftInputMode to adjustResize - comment out everything related to KeyboardUtils this fixes the design when keyboard is shown. At least this breaks the BottomSheet which will be hidden by the keyboard. Signed-off-by: Marcel Hibbe --- app/src/main/AndroidManifest.xml | 2 +- .../talk/controllers/ChatController.kt | 5 - .../talk/controllers/ContactsController.java | 5 +- .../ConversationsListController.java | 3 +- .../nextcloud/talk/utils/KeyboardUtils.java | 92 ------------------- 5 files changed, 3 insertions(+), 104 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/utils/KeyboardUtils.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d6c2e86bc..cda833251 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -97,7 +97,7 @@ + android:windowSoftInputMode="adjustResize"> diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index b47f38cbe..4c99a1ddf 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -149,7 +149,6 @@ import com.nextcloud.talk.utils.ContactUtils import com.nextcloud.talk.utils.DateUtils import com.nextcloud.talk.utils.DisplayUtils import com.nextcloud.talk.utils.ImageEmojiEditText -import com.nextcloud.talk.utils.KeyboardUtils import com.nextcloud.talk.utils.MagicCharPolicy import com.nextcloud.talk.utils.NotificationUtils import com.nextcloud.talk.utils.UriUtils @@ -1541,10 +1540,6 @@ class ChatController(args: Bundle) : cancelReply() } - if (activity != null) { - KeyboardUtils(activity, getView(), false) - } - cancelNotificationsForCurrentConversation() if (inConversation) { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index c9dbaf36a..5a5491f20 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -64,7 +64,6 @@ import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter; import com.nextcloud.talk.models.json.participants.Participant; import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.ConductorRemapping; -import com.nextcloud.talk.utils.KeyboardUtils; import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.database.user.UserUtils; import com.nextcloud.talk.utils.preferences.AppPreferences; @@ -801,8 +800,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ } } - - private void prepareAndShowBottomSheetWithBundle(Bundle bundle, boolean showEntrySheet) { if (view == null) { view = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet, null, false); @@ -826,7 +823,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ bottomSheet.setOnShowListener(dialog -> { if (showEntrySheet) { - new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true); +// new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true); } else { eventBus.post(new BottomSheetLockEvent(false, 0, false, false)); diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 40c3cdf49..cd761b552 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -89,7 +89,6 @@ import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.ClosedInterfaceImpl; import com.nextcloud.talk.utils.ConductorRemapping; import com.nextcloud.talk.utils.DisplayUtils; -import com.nextcloud.talk.utils.KeyboardUtils; import com.nextcloud.talk.utils.UriUtils; import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.database.user.UserUtils; @@ -860,7 +859,7 @@ public class ConversationsListController extends BaseController implements Searc bottomSheet = new BottomSheet.Builder(getActivity()).setView(view).create(); } - bottomSheet.setOnShowListener(dialog -> new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true)); +// bottomSheet.setOnShowListener(dialog -> new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true)); bottomSheet.setOnDismissListener(dialog -> showSearchOrToolbar()); bottomSheet.show(); } diff --git a/app/src/main/java/com/nextcloud/talk/utils/KeyboardUtils.java b/app/src/main/java/com/nextcloud/talk/utils/KeyboardUtils.java deleted file mode 100644 index 5ab0b0138..000000000 --- a/app/src/main/java/com/nextcloud/talk/utils/KeyboardUtils.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2015 Mike Penz All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.nextcloud.talk.utils; - -import android.app.Activity; -import android.graphics.Rect; -import android.view.View; -import android.view.ViewTreeObserver; -import android.view.inputmethod.InputMethodManager; - -/** - * Created by mikepenz on 14.03.15. - * This class implements a hack to change the layout padding on bottom if the keyboard is shown - * to allow long lists with editTextViews - * Basic idea for this solution found here: http://stackoverflow.com/a/9108219/325479 - */ -public class KeyboardUtils { - private View decorView; - private View contentView; - private boolean isUsedInBottomSheet; - //a small helper to allow showing the editText focus - ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - Rect r = new Rect(); - //r will be populated with the coordinates of your view that area still visible. - decorView.getWindowVisibleDisplayFrame(r); - - //get screen height and calculate the difference with the useable area from the r - int height = decorView.getContext().getResources().getDisplayMetrics().heightPixels; - - int diff = height - r.bottom; - - boolean shouldSetBottomPadding = (isUsedInBottomSheet && diff != 0) || (diff > 0); - - if (shouldSetBottomPadding) { - if (contentView.getPaddingBottom() != diff) { - //set the padding of the contentView for the keyboard - contentView.setPadding(0, 0, 0, diff); - } - } else { - //check if the padding is != initialBottomPadding (if yes reset the padding) - if (contentView.getPaddingBottom() != 0) { - //reset the padding of the contentView - contentView.setPadding(0, 0, 0, 0); - } - } - } - }; - - public KeyboardUtils(Activity act, View contentView, boolean isUsedInBottomSheet) { - this.decorView = act.getWindow().getDecorView(); - this.contentView = contentView; - this.isUsedInBottomSheet = isUsedInBottomSheet; - - decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener); - } - - /** - * Helper to hide the keyboard - * - * @param act - */ - public static void hideKeyboard(Activity act) { - if (act != null && act.getCurrentFocus() != null) { - InputMethodManager inputMethodManager = (InputMethodManager) act.getSystemService(Activity.INPUT_METHOD_SERVICE); - inputMethodManager.hideSoftInputFromWindow(act.getCurrentFocus().getWindowToken(), 0); - } - } - - public void enable() { - decorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener); - } - - public void disable() { - decorView.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener); - } -} From cb9189da19f6c220139e944c646e7a43aab883c8 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Wed, 9 Feb 2022 22:30:48 +0100 Subject: [PATCH 02/34] replace CallMenuController with ConversationOperationDialog.kt Signed-off-by: Marcel Hibbe --- .../ConversationsListController.java | 56 +-- .../bottomsheet/CallMenuController.java | 159 ++++---- .../ui/dialog/ConversationOperationDialog.kt | 314 ++++++++++++++++ .../res/layout/controller_operations_menu.xml | 1 + .../layout/dialog_conversation_operations.xml | 346 ++++++++++++++++++ 5 files changed, 775 insertions(+), 101 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt create mode 100644 app/src/main/res/layout/dialog_conversation_operations.xml diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index cd761b552..e82ed3f9d 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -70,11 +70,9 @@ 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.CallMenuController; import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController; import com.nextcloud.talk.events.BottomSheetLockEvent; import com.nextcloud.talk.events.EventStatus; -import com.nextcloud.talk.events.MoreMenuClickEvent; import com.nextcloud.talk.interfaces.ConversationMenuInterface; import com.nextcloud.talk.jobs.AccountRemovalWorker; import com.nextcloud.talk.jobs.ContactAddressBookWorker; @@ -85,6 +83,7 @@ import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.json.conversations.Conversation; import com.nextcloud.talk.models.json.participants.Participant; import com.nextcloud.talk.ui.dialog.ChooseAccountDialogFragment; +import com.nextcloud.talk.ui.dialog.ConversationOperationDialog; import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.ClosedInterfaceImpl; import com.nextcloud.talk.utils.ConductorRemapping; @@ -217,6 +216,8 @@ public class ConversationsListController extends BaseController implements Searc private HashMap callHeaderItems = new HashMap<>(); + private ConversationOperationDialog conversationOperationDialog; + public ConversationsListController(Bundle bundle) { super(); setHasOptionsMenu(true); @@ -828,15 +829,15 @@ public class ConversationsListController extends BaseController implements Searc } } - @Subscribe(threadMode = ThreadMode.MAIN) - public void onMessageEvent(MoreMenuClickEvent moreMenuClickEvent) { - Bundle bundle = new Bundle(); - Conversation conversation = moreMenuClickEvent.getConversation(); - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation)); - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_MENU_TYPE(), Parcels.wrap(CallMenuController.MenuType.REGULAR)); - - prepareAndShowBottomSheetWithBundle(bundle, true); - } +// @Subscribe(threadMode = ThreadMode.MAIN) +// public void onMessageEvent(MoreMenuClickEvent moreMenuClickEvent) { +//// Bundle bundle = new Bundle(); +//// Conversation conversation = moreMenuClickEvent.getConversation(); +//// bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation)); +//// bundle.putParcelable(BundleKeys.INSTANCE.getKEY_MENU_TYPE(), Parcels.wrap(CallMenuController.MenuType.REGULAR)); +//// +//// prepareAndShowBottomSheetWithBundle(bundle, true); +// } private void prepareAndShowBottomSheetWithBundle(Bundle bundle, boolean shouldShowCallMenuController) { if (view == null) { @@ -844,10 +845,12 @@ public class ConversationsListController extends BaseController implements Searc } if (shouldShowCallMenuController) { - getChildRouter((ViewGroup) view).setRoot( - RouterTransaction.with(new CallMenuController(bundle, this)) - .popChangeHandler(new VerticalChangeHandler()) - .pushChangeHandler(new VerticalChangeHandler())); +// getChildRouter((ViewGroup) view).setRoot( +// RouterTransaction.with(new CallMenuController(bundle, this)) +// .popChangeHandler(new VerticalChangeHandler()) +// .pushChangeHandler(new VerticalChangeHandler())); + + } else { getChildRouter((ViewGroup) view).setRoot( RouterTransaction.with(new EntryMenuController(bundle)) @@ -855,13 +858,13 @@ public class ConversationsListController extends BaseController implements Searc .pushChangeHandler(new VerticalChangeHandler())); } - if (bottomSheet == null) { - bottomSheet = new BottomSheet.Builder(getActivity()).setView(view).create(); - } - -// bottomSheet.setOnShowListener(dialog -> new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true)); - bottomSheet.setOnDismissListener(dialog -> showSearchOrToolbar()); - bottomSheet.show(); +// if (bottomSheet == null) { +// bottomSheet = new BottomSheet.Builder(getActivity()).setView(view).create(); +// } +// +//// bottomSheet.setOnShowListener(dialog -> new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true)); +// bottomSheet.setOnDismissListener(dialog -> showSearchOrToolbar()); +// bottomSheet.show(); } @Override @@ -949,8 +952,12 @@ public class ConversationsListController extends BaseController implements Searc Object clickedItem = adapter.getItem(position); if (clickedItem != null) { Conversation conversation = ((ConversationItem) clickedItem).getModel(); - MoreMenuClickEvent moreMenuClickEvent = new MoreMenuClickEvent(conversation); - onMessageEvent(moreMenuClickEvent); + conversationOperationDialog = new ConversationOperationDialog( + getActivity(), + this, + userUtils.getCurrentUser(), + conversation); + conversationOperationDialog.show(); } } } @@ -1239,7 +1246,6 @@ public class ConversationsListController extends BaseController implements Searc default: break; } - } @Override diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java index a958de538..306146992 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java @@ -151,82 +151,82 @@ public class CallMenuController extends BaseController implements FlexibleAdapte menuItems = new ArrayList<>(); if (menuType.equals(MenuType.REGULAR)) { - if (!TextUtils.isEmpty(conversation.getDisplayName())) { - menuItems.add(new MenuItem(conversation.getDisplayName(), 0, null)); - } else if (!TextUtils.isEmpty(conversation.getName())) { - menuItems.add(new MenuItem(conversation.getName(), 0, null)); - } else { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_configure_room), 0, null)); - } - - currentUser = userUtils.getCurrentUser(); - - if (conversation.isFavorite()) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_remove_from_favorites), 97, DisplayUtils.getTintedDrawable(getResources(), R.drawable.ic_star_border_black_24dp, R.color.grey_600))); - } else if (CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "favorites")) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_add_to_favorites), - 98, - DisplayUtils.getTintedDrawable(getResources(), - R.drawable.ic_star_black_24dp, - R.color.grey_600))); - } - - if(conversation.unreadMessages > ALL_MESSAGES_READ && CapabilitiesUtil.canSetChatReadMarker(currentUser)) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_mark_as_read), - 96, - ContextCompat.getDrawable(context, R.drawable.ic_eye))); - } - - if (conversation.isNameEditable(currentUser)) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_rename), - 2, - ContextCompat.getDrawable(context, - R.drawable.ic_pencil_grey600_24dp))); - } - - if (conversation.canModerate(currentUser)) { - if (!conversation.isPublic()) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_make_call_public), - 3, ContextCompat.getDrawable(context, - R.drawable.ic_link_grey600_24px))); - } else { - if (conversation.isHasPassword()) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_change_password), - 4, ContextCompat.getDrawable(context, - R.drawable.ic_lock_grey600_24px))); - menuItems.add(new MenuItem(getResources().getString(R.string.nc_clear_password), - 5, - ContextCompat.getDrawable(context, - R.drawable.ic_lock_open_grey600_24dp))); - } else { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_set_password), - 6, ContextCompat.getDrawable(context, - R.drawable.ic_lock_plus_grey600_24dp))); - } - } - - menuItems.add(new MenuItem(getResources().getString(R.string.nc_delete_call), - 9, ContextCompat.getDrawable(context, - R.drawable.ic_delete_grey600_24dp))); - } - - if (conversation.isPublic()) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_share_link), - 7, ContextCompat.getDrawable(context, - R.drawable.ic_link_grey600_24px))); - if (conversation.canModerate(currentUser)) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_make_call_private), - 8, ContextCompat.getDrawable(context, - R.drawable.ic_group_grey600_24px))); - } - } - - if (conversation.canLeave(currentUser)) { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_leave), 1, - DisplayUtils.getTintedDrawable(getResources(), - R.drawable.ic_exit_to_app_black_24dp, R.color.grey_600) - )); - } +// if (!TextUtils.isEmpty(conversation.getDisplayName())) { +// menuItems.add(new MenuItem(conversation.getDisplayName(), 0, null)); +// } else if (!TextUtils.isEmpty(conversation.getName())) { +// menuItems.add(new MenuItem(conversation.getName(), 0, null)); +// } else { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_configure_room), 0, null)); +// } +// +// currentUser = userUtils.getCurrentUser(); +// +// if (conversation.isFavorite()) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_remove_from_favorites), 97, DisplayUtils.getTintedDrawable(getResources(), R.drawable.ic_star_border_black_24dp, R.color.grey_600))); +// } else if (CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "favorites")) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_add_to_favorites), +// 98, +// DisplayUtils.getTintedDrawable(getResources(), +// R.drawable.ic_star_black_24dp, +// R.color.grey_600))); +// } +// +// if(conversation.unreadMessages > ALL_MESSAGES_READ && CapabilitiesUtil.canSetChatReadMarker(currentUser)) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_mark_as_read), +// 96, +// ContextCompat.getDrawable(context, R.drawable.ic_eye))); +// } +// +// if (conversation.isNameEditable(currentUser)) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_rename), +// 2, +// ContextCompat.getDrawable(context, +// R.drawable.ic_pencil_grey600_24dp))); +// } +// +// if (conversation.canModerate(currentUser)) { +// if (!conversation.isPublic()) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_make_call_public), +// 3, ContextCompat.getDrawable(context, +// R.drawable.ic_link_grey600_24px))); +// } else { +// if (conversation.isHasPassword()) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_change_password), +// 4, ContextCompat.getDrawable(context, +// R.drawable.ic_lock_grey600_24px))); +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_clear_password), +// 5, +// ContextCompat.getDrawable(context, +// R.drawable.ic_lock_open_grey600_24dp))); +// } else { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_set_password), +// 6, ContextCompat.getDrawable(context, +// R.drawable.ic_lock_plus_grey600_24dp))); +// } +// } +// +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_delete_call), +// 9, ContextCompat.getDrawable(context, +// R.drawable.ic_delete_grey600_24dp))); +// } +// +// if (conversation.isPublic()) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_share_link), +// 7, ContextCompat.getDrawable(context, +// R.drawable.ic_link_grey600_24px))); +// if (conversation.canModerate(currentUser)) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_make_call_private), +// 8, ContextCompat.getDrawable(context, +// R.drawable.ic_group_grey600_24px))); +// } +// } +// +// if (conversation.canLeave(currentUser)) { +// menuItems.add(new MenuItem(getResources().getString(R.string.nc_leave), 1, +// DisplayUtils.getTintedDrawable(getResources(), +// R.drawable.ic_exit_to_app_black_24dp, R.color.grey_600) +// )); +// } } else if (menuType.equals(MenuType.SHARE)) { prepareIntent(); List appInfoList = ShareUtils.getShareApps(getActivity(), shareIntent, null, @@ -282,13 +282,20 @@ public class CallMenuController extends BaseController implements FlexibleAdapte } eventBus.post(new BottomSheetLockEvent(true, 0, false, true)); } else { + + // TODO: continue here to extract more setOnClickListeners to ConversationOperationDialog.kt + bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), tag); if (tag != 2 && tag != 4 && tag != 6 && tag != 7) { + // 3=make call public, 5=clear pw, 8=make call private .. eventBus.post(new BottomSheetLockEvent(false, 0, false, false)); getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)) .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); } else if (tag != 7) { + // 3=make call public, 5=clear pw, 8=make call private .. + + // rename and set password !? getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)) .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt new file mode 100644 index 000000000..e776915d5 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt @@ -0,0 +1,314 @@ +package com.nextcloud.talk.ui.dialog + +import android.app.Activity +import android.os.Bundle +import android.text.TextUtils +import android.view.View +import android.view.ViewGroup +import androidx.work.Data +import androidx.work.OneTimeWorkRequest +import androidx.work.WorkManager +import autodagger.AutoInjector +import com.bluelinelabs.conductor.RouterTransaction +import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler +import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler +import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.bottomsheet.BottomSheetDialog +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.CallMenuController +import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController +import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController +import com.nextcloud.talk.databinding.DialogConversationOperationsBinding +import com.nextcloud.talk.jobs.LeaveConversationWorker +import com.nextcloud.talk.models.database.CapabilitiesUtil +import com.nextcloud.talk.models.database.UserEntity +import com.nextcloud.talk.models.json.conversations.Conversation +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_OPERATION_CODE +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN +import org.parceler.Parcels +import javax.inject.Inject + +@AutoInjector(NextcloudTalkApplication::class) +class ConversationOperationDialog( + val activity: Activity, + val controller: ConversationsListController, + val currentUser: UserEntity, + val conversation: Conversation +) : BottomSheetDialog(activity) { + + private lateinit var binding: DialogConversationOperationsBinding + + @Inject + @JvmField + var ncApi: NcApi? = null + + init { + NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = DialogConversationOperationsBinding.inflate(layoutInflater) + setContentView(binding.root) + window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + + initHeaderDescription() + initItemsVisibility() + initClickListeners() + } + + private fun initHeaderDescription() { + if (!TextUtils.isEmpty(conversation.getDisplayName())) { + binding.conversationOperationHeader.text = conversation.getDisplayName() + } else if (!TextUtils.isEmpty(conversation.getName())) { + binding.conversationOperationHeader.text = conversation.getName() + } + } + + private fun initItemsVisibility() { + val hasFavoritesCapability = CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "favorites") + val canModerate = conversation.canModerate(currentUser) + + binding.conversationOperationRemoveFavorite.visibility = setVisibleIf( + hasFavoritesCapability && conversation.isFavorite() + ) + binding.conversationOperationAddFavorite.visibility = setVisibleIf( + hasFavoritesCapability && !conversation.isFavorite() + ) + + binding.conversationOperationMarkAsRead.visibility = setVisibleIf( + conversation.unreadMessages > CallMenuController.ALL_MESSAGES_READ + && CapabilitiesUtil.canSetChatReadMarker(currentUser) + ) + + binding.conversationOperationRename.visibility = setVisibleIf( + conversation.isNameEditable(currentUser) + ) + + binding.conversationOperationMakePublic.visibility = setVisibleIf( + canModerate && !conversation.isPublic + ) + + binding.conversationOperationChangePassword.visibility = setVisibleIf( + canModerate && conversation.isHasPassword + ) + + binding.conversationOperationClearPassword.visibility = setVisibleIf( + canModerate && conversation.isHasPassword + ) + + binding.conversationOperationSetPassword.visibility = setVisibleIf( + canModerate && !conversation.isHasPassword + ) + + binding.conversationOperationDelete.visibility = setVisibleIf( + canModerate + ) + + binding.conversationOperationShareLink.visibility = setVisibleIf( + conversation.isPublic + ) + + binding.conversationOperationMakePrivate.visibility = setVisibleIf( + conversation.isPublic && canModerate + ) + + binding.conversationOperationLeave.visibility = setVisibleIf( + conversation.canLeave(currentUser) + ) + } + + private fun setVisibleIf(boolean: Boolean): Int { + return if (boolean) { + View.VISIBLE + } else { + View.GONE + } + } + + private fun initClickListeners() { + // // val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token) + // // val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1)) + // + // binding.conversationOperationAddFavorite.setOnClickListener { + // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // // CallMenuController was replaced with the class you're in here. + // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + // + // val bundle = Bundle() + // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + // bundle.putInt(KEY_OPERATION_CODE, 98) + // + // // controller.router.pushController( + // // RouterTransaction.with(OperationsMenuController(bundle)) + // // .pushChangeHandler(HorizontalChangeHandler()) + // // .popChangeHandler(HorizontalChangeHandler()) + // // ) + // + // + // + // // var view = activity.layoutInflater.inflate(R.layout.bottom_sheet, null, true) + // // controller.getChildRouter((view as ViewGroup?)!!).setRoot( + // // RouterTransaction.with(OperationsMenuController(bundle)) + // // .popChangeHandler(VerticalChangeHandler()) + // // .pushChangeHandler(VerticalChangeHandler()) + // // ) + // + // + // + // // dismiss() + // } + // + // binding.conversationOperationRemoveFavorite.setOnClickListener { + // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // // CallMenuController was replaced with the class you're in here. + // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + // + // val bundle = Bundle() + // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + // bundle.putInt(KEY_OPERATION_CODE, 97) + // + // controller.router.pushController( + // RouterTransaction.with(OperationsMenuController(bundle)) + // .pushChangeHandler(HorizontalChangeHandler()) + // .popChangeHandler(HorizontalChangeHandler()) + // ) + // + // dismiss() + // } + // + // binding.conversationOperationClearPassword.setOnClickListener { + // conversation.setPassword("") + // } + // + // binding.conversationOperationLeave.setOnClickListener { + // val dataBuilder = Data.Builder() + // dataBuilder.putString(KEY_ROOM_TOKEN, conversation.getToken()) + // dataBuilder.putLong(KEY_INTERNAL_USER_ID, currentUser.id) + // val data = dataBuilder.build() + // + // val leaveConversationWorker = + // OneTimeWorkRequest.Builder(LeaveConversationWorker::class.java).setInputData( + // data + // ).build() + // WorkManager.getInstance().enqueue(leaveConversationWorker) + // + // dismiss() + // } + // + // binding.conversationOperationDelete.setOnClickListener { + // if (!TextUtils.isEmpty(conversation.getToken())) { + // val bundle = Bundle() + // bundle.putLong(KEY_INTERNAL_USER_ID, currentUser.id) + // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + // + // controller.openLovelyDialogWithIdAndBundle( + // ConversationsListController.ID_DELETE_CONVERSATION_DIALOG, + // bundle + // ) + // } + // + // dismiss() + // } + // + // binding.conversationOperationMakePublic.setOnClickListener { + // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // // CallMenuController was replaced with the class you're in here. + // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + // + // val bundle = Bundle() + // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + // bundle.putInt(KEY_OPERATION_CODE, 3) + // + // controller.router.pushController( + // RouterTransaction.with(OperationsMenuController(bundle)) + // .pushChangeHandler(HorizontalChangeHandler()) + // .popChangeHandler(HorizontalChangeHandler()) + // ) + // } + // + // binding.conversationOperationMakePrivate.setOnClickListener { + // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // // CallMenuController was replaced with the class you're in here. + // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + // + // val bundle = Bundle() + // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + // bundle.putInt(KEY_OPERATION_CODE, 8) + // + // controller.router.pushController( + // RouterTransaction.with(OperationsMenuController(bundle)) + // .pushChangeHandler(HorizontalChangeHandler()) + // .popChangeHandler(HorizontalChangeHandler()) + // ) + // } + // + // binding.conversationOperationClearPassword.setOnClickListener { + // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // // CallMenuController was replaced with the class you're in here. + // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + // + // val bundle = Bundle() + // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + // bundle.putInt(KEY_OPERATION_CODE, 5) + // + // controller.router.pushController( + // RouterTransaction.with(OperationsMenuController(bundle)) + // .pushChangeHandler(HorizontalChangeHandler()) + // .popChangeHandler(HorizontalChangeHandler()) + // ) + // } + // + // binding.conversationOperationRename.setOnClickListener { + // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // // CallMenuController was replaced with the class you're in here. + // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + // + // val bundle = Bundle() + // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + // bundle.putInt(KEY_OPERATION_CODE, 2) + // + // controller.router.pushController( + // RouterTransaction.with(EntryMenuController(bundle)) + // .pushChangeHandler(HorizontalChangeHandler()) + // .popChangeHandler(HorizontalChangeHandler()) + // ) + // } + // + // binding.conversationOperationSetPassword.setOnClickListener { + // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // // CallMenuController was replaced with the class you're in here. + // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + // + // val bundle = Bundle() + // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + // bundle.putInt(KEY_OPERATION_CODE, 6) + // + // controller.router.pushController( + // RouterTransaction.with(EntryMenuController(bundle)) + // .pushChangeHandler(HorizontalChangeHandler()) + // .popChangeHandler(HorizontalChangeHandler()) + // ) + // } + // + // binding.conversationOperationShareLink.setOnClickListener { + // // TODO share by intent + // } + } + + override fun onStart() { + super.onStart() + val bottomSheet = findViewById(R.id.design_bottom_sheet) + val behavior = BottomSheetBehavior.from(bottomSheet as View) + behavior.state = BottomSheetBehavior.STATE_EXPANDED + } + + companion object { + private const val TAG = "ConversationOperationDialog" + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/controller_operations_menu.xml b/app/src/main/res/layout/controller_operations_menu.xml index 144df74b6..9ebfb301e 100644 --- a/app/src/main/res/layout/controller_operations_menu.xml +++ b/app/src/main/res/layout/controller_operations_menu.xml @@ -19,6 +19,7 @@ --> diff --git a/app/src/main/res/layout/dialog_conversation_operations.xml b/app/src/main/res/layout/dialog_conversation_operations.xml new file mode 100644 index 000000000..a5d08c28b --- /dev/null +++ b/app/src/main/res/layout/dialog_conversation_operations.xml @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From aedede9ffdf88ea54e1363fa39e71087595bb7ef Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 10 Feb 2022 22:12:45 +0100 Subject: [PATCH 03/34] proof of concept: use conductor with BottomSheetDialog two approaches are added with this commit (just for testing): 1.for conversationOperationAddFavorite - replace UI in ConversationOperationDialog - push another controller via method in ConversationsListController (makes no sense here, but will be useful for other cases) 2. for conversationOperationRemoveFavorite - hide UI - introduce another conductor router for dialog - push new Controller with new router - fetchData in old controller Signed-off-by: Marcel Hibbe --- .../ConversationsListController.java | 13 +- .../ui/dialog/ConversationOperationDialog.kt | 335 +++++---- .../layout/dialog_conversation_operations.xml | 669 ++++++++++-------- 3 files changed, 534 insertions(+), 483 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index e82ed3f9d..c14b097c2 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -71,6 +71,7 @@ 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.EntryMenuController; +import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController; import com.nextcloud.talk.events.BottomSheetLockEvent; import com.nextcloud.talk.events.EventStatus; import com.nextcloud.talk.interfaces.ConversationMenuInterface; @@ -469,7 +470,7 @@ public class ConversationsListController extends BaseController implements Searc } @SuppressLint("LongLogTag") - private void fetchData(boolean fromBottomSheet) { + public void fetchData(boolean fromBottomSheet) { dispose(null); isRefreshing = true; @@ -1248,6 +1249,16 @@ public class ConversationsListController extends BaseController implements Searc } } + + public void pushSomeOtherController(Bundle bundle) { + + getRouter().pushController( + RouterTransaction.with(new OperationsMenuController(bundle)) + .pushChangeHandler(new HorizontalChangeHandler()) + .popChangeHandler(new HorizontalChangeHandler())); + + } + @Override public AppBarLayoutType getAppBarLayoutType() { return AppBarLayoutType.SEARCH_BAR; diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt index e776915d5..7495c2156 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt @@ -9,9 +9,10 @@ import androidx.work.Data import androidx.work.OneTimeWorkRequest import androidx.work.WorkManager import autodagger.AutoInjector +import com.bluelinelabs.conductor.Conductor +import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler -import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.nextcloud.talk.R @@ -41,6 +42,9 @@ class ConversationOperationDialog( val conversation: Conversation ) : BottomSheetDialog(activity) { + private var dialogRouter: Router? = null + + private lateinit var binding: DialogConversationOperationsBinding @Inject @@ -132,173 +136,168 @@ class ConversationOperationDialog( } private fun initClickListeners() { - // // val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token) - // // val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1)) - // - // binding.conversationOperationAddFavorite.setOnClickListener { - // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // // CallMenuController was replaced with the class you're in here. - // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - // - // val bundle = Bundle() - // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - // bundle.putInt(KEY_OPERATION_CODE, 98) - // - // // controller.router.pushController( - // // RouterTransaction.with(OperationsMenuController(bundle)) - // // .pushChangeHandler(HorizontalChangeHandler()) - // // .popChangeHandler(HorizontalChangeHandler()) - // // ) - // - // - // - // // var view = activity.layoutInflater.inflate(R.layout.bottom_sheet, null, true) - // // controller.getChildRouter((view as ViewGroup?)!!).setRoot( - // // RouterTransaction.with(OperationsMenuController(bundle)) - // // .popChangeHandler(VerticalChangeHandler()) - // // .pushChangeHandler(VerticalChangeHandler()) - // // ) - // - // - // - // // dismiss() - // } - // - // binding.conversationOperationRemoveFavorite.setOnClickListener { - // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // // CallMenuController was replaced with the class you're in here. - // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - // - // val bundle = Bundle() - // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - // bundle.putInt(KEY_OPERATION_CODE, 97) - // - // controller.router.pushController( - // RouterTransaction.with(OperationsMenuController(bundle)) - // .pushChangeHandler(HorizontalChangeHandler()) - // .popChangeHandler(HorizontalChangeHandler()) - // ) - // - // dismiss() - // } - // - // binding.conversationOperationClearPassword.setOnClickListener { - // conversation.setPassword("") - // } - // - // binding.conversationOperationLeave.setOnClickListener { - // val dataBuilder = Data.Builder() - // dataBuilder.putString(KEY_ROOM_TOKEN, conversation.getToken()) - // dataBuilder.putLong(KEY_INTERNAL_USER_ID, currentUser.id) - // val data = dataBuilder.build() - // - // val leaveConversationWorker = - // OneTimeWorkRequest.Builder(LeaveConversationWorker::class.java).setInputData( - // data - // ).build() - // WorkManager.getInstance().enqueue(leaveConversationWorker) - // - // dismiss() - // } - // - // binding.conversationOperationDelete.setOnClickListener { - // if (!TextUtils.isEmpty(conversation.getToken())) { - // val bundle = Bundle() - // bundle.putLong(KEY_INTERNAL_USER_ID, currentUser.id) - // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - // - // controller.openLovelyDialogWithIdAndBundle( - // ConversationsListController.ID_DELETE_CONVERSATION_DIALOG, - // bundle - // ) - // } - // - // dismiss() - // } - // - // binding.conversationOperationMakePublic.setOnClickListener { - // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // // CallMenuController was replaced with the class you're in here. - // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - // - // val bundle = Bundle() - // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - // bundle.putInt(KEY_OPERATION_CODE, 3) - // - // controller.router.pushController( - // RouterTransaction.with(OperationsMenuController(bundle)) - // .pushChangeHandler(HorizontalChangeHandler()) - // .popChangeHandler(HorizontalChangeHandler()) - // ) - // } - // - // binding.conversationOperationMakePrivate.setOnClickListener { - // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // // CallMenuController was replaced with the class you're in here. - // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - // - // val bundle = Bundle() - // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - // bundle.putInt(KEY_OPERATION_CODE, 8) - // - // controller.router.pushController( - // RouterTransaction.with(OperationsMenuController(bundle)) - // .pushChangeHandler(HorizontalChangeHandler()) - // .popChangeHandler(HorizontalChangeHandler()) - // ) - // } - // - // binding.conversationOperationClearPassword.setOnClickListener { - // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // // CallMenuController was replaced with the class you're in here. - // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - // - // val bundle = Bundle() - // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - // bundle.putInt(KEY_OPERATION_CODE, 5) - // - // controller.router.pushController( - // RouterTransaction.with(OperationsMenuController(bundle)) - // .pushChangeHandler(HorizontalChangeHandler()) - // .popChangeHandler(HorizontalChangeHandler()) - // ) - // } - // - // binding.conversationOperationRename.setOnClickListener { - // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // // CallMenuController was replaced with the class you're in here. - // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - // - // val bundle = Bundle() - // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - // bundle.putInt(KEY_OPERATION_CODE, 2) - // - // controller.router.pushController( - // RouterTransaction.with(EntryMenuController(bundle)) - // .pushChangeHandler(HorizontalChangeHandler()) - // .popChangeHandler(HorizontalChangeHandler()) - // ) - // } - // - // binding.conversationOperationSetPassword.setOnClickListener { - // // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // // CallMenuController was replaced with the class you're in here. - // // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - // - // val bundle = Bundle() - // bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - // bundle.putInt(KEY_OPERATION_CODE, 6) - // - // controller.router.pushController( - // RouterTransaction.with(EntryMenuController(bundle)) - // .pushChangeHandler(HorizontalChangeHandler()) - // .popChangeHandler(HorizontalChangeHandler()) - // ) - // } - // - // binding.conversationOperationShareLink.setOnClickListener { - // // TODO share by intent - // } + // val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token) + // val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1)) + + binding.conversationOperationAddFavorite.setOnClickListener { + + binding.textEditWrapper.visibility = View.VISIBLE + binding.operationItemsLayout.visibility = View.GONE + + + // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // CallMenuController was replaced with the class you're in here. + // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, 98) + + dismiss() + + // just a test + controller.pushSomeOtherController(bundle) + + } + + binding.conversationOperationRemoveFavorite.setOnClickListener { + // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // CallMenuController was replaced with the class you're in here. + // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, 97) + + binding.operationItemsLayout.visibility = View.GONE + + dialogRouter = Conductor.attachRouter(activity, binding.root, null) + + dialogRouter!!.pushController( + RouterTransaction.with(OperationsMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + + controller.fetchData(false) + } + + binding.conversationOperationClearPassword.setOnClickListener { + conversation.setPassword("") + } + + binding.conversationOperationLeave.setOnClickListener { + val dataBuilder = Data.Builder() + dataBuilder.putString(KEY_ROOM_TOKEN, conversation.getToken()) + dataBuilder.putLong(KEY_INTERNAL_USER_ID, currentUser.id) + val data = dataBuilder.build() + + val leaveConversationWorker = + OneTimeWorkRequest.Builder(LeaveConversationWorker::class.java).setInputData( + data + ).build() + WorkManager.getInstance().enqueue(leaveConversationWorker) + + dismiss() + } + + binding.conversationOperationDelete.setOnClickListener { + if (!TextUtils.isEmpty(conversation.getToken())) { + val bundle = Bundle() + bundle.putLong(KEY_INTERNAL_USER_ID, currentUser.id) + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + + controller.openLovelyDialogWithIdAndBundle( + ConversationsListController.ID_DELETE_CONVERSATION_DIALOG, + bundle + ) + } + + dismiss() + } + + binding.conversationOperationMakePublic.setOnClickListener { + // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // CallMenuController was replaced with the class you're in here. + // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, 3) + + controller.router.pushController( + RouterTransaction.with(OperationsMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + } + + binding.conversationOperationMakePrivate.setOnClickListener { + // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // CallMenuController was replaced with the class you're in here. + // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, 8) + + controller.router.pushController( + RouterTransaction.with(OperationsMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + } + + binding.conversationOperationClearPassword.setOnClickListener { + // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // CallMenuController was replaced with the class you're in here. + // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, 5) + + controller.router.pushController( + RouterTransaction.with(OperationsMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + } + + binding.conversationOperationRename.setOnClickListener { + // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // CallMenuController was replaced with the class you're in here. + // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, 2) + + controller.router.pushController( + RouterTransaction.with(EntryMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + } + + binding.conversationOperationSetPassword.setOnClickListener { + // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. + // CallMenuController was replaced with the class you're in here. + // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, 6) + + controller.router.pushController( + RouterTransaction.with(EntryMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + } + + binding.conversationOperationShareLink.setOnClickListener { + // TODO share by intent + } } override fun onStart() { diff --git a/app/src/main/res/layout/dialog_conversation_operations.xml b/app/src/main/res/layout/dialog_conversation_operations.xml index a5d08c28b..eabf675d9 100644 --- a/app/src/main/res/layout/dialog_conversation_operations.xml +++ b/app/src/main/res/layout/dialog_conversation_operations.xml @@ -10,337 +10,378 @@ android:paddingEnd="@dimen/standard_padding" android:paddingBottom="@dimen/standard_half_padding"> - - + android:layout_height="wrap_content" + android:id="@+id/text_edit_wrapper" + android:orientation="vertical" + android:visibility="gone" + tools:visibility="visible"> - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="start|center_vertical" + android:textColor="@color/medium_emphasis_text_dark_background" + android:textSize="@dimen/bottom_sheet_text_size" + android:text="aaaaaaaaaaa" + tools:text="conversation name"/> - + android:text="joooo" + android:textColor="@color/white" + android:background="@android:color/transparent" > + + + - - - - - - + android:layout_height="wrap_content" + android:id="@+id/operation_items_layout" + android:orientation="vertical"> - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="start|center_vertical" + android:textColor="@color/medium_emphasis_text_dark_background" + android:textSize="@dimen/bottom_sheet_text_size" + tools:text="conversation name"/> - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From d76203a0933bb0430f185a1508bda5925cf1336c Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 11 Feb 2022 12:49:29 +0100 Subject: [PATCH 04/34] remove api v1 variants for conversations canLeave and canDelete methods Signed-off-by: Marcel Hibbe --- .../controllers/ConversationInfoController.kt | 4 ++-- .../json/conversations/Conversation.java | 19 ++++--------------- .../ui/dialog/ConversationOperationDialog.kt | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt index e1ffca885..65b7cd90b 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt @@ -598,13 +598,13 @@ class ConversationInfoController(args: Bundle) : setupWebinaryView() - if (!conversation!!.canLeave(conversationUser)) { + if (!conversation!!.canLeave()) { binding.leaveConversationAction.visibility = View.GONE } else { binding.leaveConversationAction.visibility = View.VISIBLE } - if (!conversation!!.canDelete(conversationUser)) { + if (!conversation!!.canDelete()) { binding.deleteConversationAction.visibility = View.GONE } else { binding.deleteConversationAction.visibility = View.VISIBLE diff --git a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java index 880c37bd1..82e557b29 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java @@ -148,23 +148,12 @@ public class Conversation { return (canModerate(conversationUser) && !ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL.equals(type)); } - public boolean canLeave(UserEntity conversationUser) { - if (canLeaveConversation != null) { - // Available since APIv2 - return canLeaveConversation; - } - // Fallback for APIv1 - return !canModerate(conversationUser) || - (getType() != ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL && this.participants.size() > 1); + public boolean canLeave() { + return canLeaveConversation; } - public boolean canDelete(UserEntity conversationUser) { - if (canDeleteConversation != null) { - // Available since APIv2 - return canDeleteConversation; - } - // Fallback for APIv1 - return canModerate(conversationUser); + public boolean canDelete() { + return canDeleteConversation; } public String getRoomId() { diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt index 7495c2156..f41522f28 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt @@ -123,7 +123,7 @@ class ConversationOperationDialog( ) binding.conversationOperationLeave.visibility = setVisibleIf( - conversation.canLeave(currentUser) + conversation.canLeave() ) } From 76451c1649ee87d68e2a77317e82da268712ddf2 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 11 Feb 2022 13:22:11 +0100 Subject: [PATCH 05/34] fix actions that are clicked in Conversation Bottom Dialog Signed-off-by: Marcel Hibbe --- .../ConversationsListController.java | 19 -- .../ui/dialog/ConversationOperationDialog.kt | 168 ++++++------------ 2 files changed, 55 insertions(+), 132 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index c14b097c2..902e49673 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -566,15 +566,6 @@ public class ConversationsListController extends BaseController implements Searc swipeRefreshLayout.setRefreshing(false); } - if (fromBottomSheet) { - new Handler().postDelayed(() -> { - bottomSheet.setCancelable(true); - if (bottomSheet.isShowing()) { - bottomSheet.cancel(); - } - }, 2500); - } - isRefreshing = false; }); } @@ -1249,16 +1240,6 @@ public class ConversationsListController extends BaseController implements Searc } } - - public void pushSomeOtherController(Bundle bundle) { - - getRouter().pushController( - RouterTransaction.with(new OperationsMenuController(bundle)) - .pushChangeHandler(new HorizontalChangeHandler()) - .popChangeHandler(new HorizontalChangeHandler())); - - } - @Override public AppBarLayoutType getAppBarLayoutType() { return AppBarLayoutType.SEARCH_BAR; diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt index f41522f28..47e43cdd4 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt @@ -44,7 +44,6 @@ class ConversationOperationDialog( private var dialogRouter: Router? = null - private lateinit var binding: DialogConversationOperationsBinding @Inject @@ -99,15 +98,15 @@ class ConversationOperationDialog( ) binding.conversationOperationChangePassword.visibility = setVisibleIf( - canModerate && conversation.isHasPassword + canModerate && conversation.isHasPassword && conversation.isPublic ) binding.conversationOperationClearPassword.visibility = setVisibleIf( - canModerate && conversation.isHasPassword + canModerate && conversation.isHasPassword && conversation.isPublic ) binding.conversationOperationSetPassword.visibility = setVisibleIf( - canModerate && !conversation.isHasPassword + canModerate && !conversation.isHasPassword && conversation.isPublic ) binding.conversationOperationDelete.visibility = setVisibleIf( @@ -136,53 +135,12 @@ class ConversationOperationDialog( } private fun initClickListeners() { - // val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token) - // val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1)) - binding.conversationOperationAddFavorite.setOnClickListener { - - binding.textEditWrapper.visibility = View.VISIBLE - binding.operationItemsLayout.visibility = View.GONE - - - // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // CallMenuController was replaced with the class you're in here. - // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - - val bundle = Bundle() - bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - bundle.putInt(KEY_OPERATION_CODE, 98) - - dismiss() - - // just a test - controller.pushSomeOtherController(bundle) - + executeOperationsMenuController(98) } binding.conversationOperationRemoveFavorite.setOnClickListener { - // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // CallMenuController was replaced with the class you're in here. - // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - val bundle = Bundle() - bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - bundle.putInt(KEY_OPERATION_CODE, 97) - - binding.operationItemsLayout.visibility = View.GONE - - dialogRouter = Conductor.attachRouter(activity, binding.root, null) - - dialogRouter!!.pushController( - RouterTransaction.with(OperationsMenuController(bundle)) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) - - controller.fetchData(false) - } - - binding.conversationOperationClearPassword.setOnClickListener { - conversation.setPassword("") + executeOperationsMenuController(97) } binding.conversationOperationLeave.setOnClickListener { @@ -216,83 +174,27 @@ class ConversationOperationDialog( } binding.conversationOperationMakePublic.setOnClickListener { - // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // CallMenuController was replaced with the class you're in here. - // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - - val bundle = Bundle() - bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - bundle.putInt(KEY_OPERATION_CODE, 3) - - controller.router.pushController( - RouterTransaction.with(OperationsMenuController(bundle)) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) + executeOperationsMenuController(3) } binding.conversationOperationMakePrivate.setOnClickListener { - // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // CallMenuController was replaced with the class you're in here. - // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + executeOperationsMenuController(8) + } - val bundle = Bundle() - bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - bundle.putInt(KEY_OPERATION_CODE, 8) - - controller.router.pushController( - RouterTransaction.with(OperationsMenuController(bundle)) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) + binding.conversationOperationChangePassword.setOnClickListener { + executeEntryMenuController(4) } binding.conversationOperationClearPassword.setOnClickListener { - // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // CallMenuController was replaced with the class you're in here. - // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - - val bundle = Bundle() - bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - bundle.putInt(KEY_OPERATION_CODE, 5) - - controller.router.pushController( - RouterTransaction.with(OperationsMenuController(bundle)) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) - } - - binding.conversationOperationRename.setOnClickListener { - // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // CallMenuController was replaced with the class you're in here. - // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. - - val bundle = Bundle() - bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - bundle.putInt(KEY_OPERATION_CODE, 2) - - controller.router.pushController( - RouterTransaction.with(EntryMenuController(bundle)) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) + executeOperationsMenuController(5) } binding.conversationOperationSetPassword.setOnClickListener { - // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController. - // CallMenuController was replaced with the class you're in here. - // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to. + executeEntryMenuController(6) + } - val bundle = Bundle() - bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) - bundle.putInt(KEY_OPERATION_CODE, 6) - - controller.router.pushController( - RouterTransaction.with(EntryMenuController(bundle)) - .pushChangeHandler(HorizontalChangeHandler()) - .popChangeHandler(HorizontalChangeHandler()) - ) + binding.conversationOperationRename.setOnClickListener { + executeEntryMenuController(2) } binding.conversationOperationShareLink.setOnClickListener { @@ -300,6 +202,46 @@ class ConversationOperationDialog( } } + private fun executeOperationsMenuController(operationCode: Int) { + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, operationCode) + + binding.operationItemsLayout.visibility = View.GONE + + dialogRouter = Conductor.attachRouter(activity, binding.root, null) + + dialogRouter!!.pushController( + RouterTransaction.with(OperationsMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + + controller.fetchData(false) + } + + private fun executeEntryMenuController(operationCode: Int) { + val bundle = Bundle() + bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation)) + bundle.putInt(KEY_OPERATION_CODE, operationCode) + + binding.operationItemsLayout.visibility = View.GONE + + dialogRouter = Conductor.attachRouter(activity, binding.root, null) + + dialogRouter!!.pushController( + + // TODO: refresh conversation list after EntryMenuController finished (throw event? / pass controller + // into EntryMenuController to execute fetch data... ?!) + // for example if you set a password, the dialog items should be refreshed for the next time you open it + // without to manually have to refresh the conversations list + + RouterTransaction.with(EntryMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + } + override fun onStart() { super.onStart() val bottomSheet = findViewById(R.id.design_bottom_sheet) From bec19428e0065d7f8752615a35a3ce2e5c228754 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 11 Feb 2022 16:23:42 +0100 Subject: [PATCH 06/34] share conversation link Signed-off-by: Marcel Hibbe --- .../ui/dialog/ConversationOperationDialog.kt | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt index 47e43cdd4..50bb0efbb 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt @@ -33,6 +33,13 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN import org.parceler.Parcels import javax.inject.Inject +import androidx.core.content.ContextCompat.startActivity + +import android.content.Intent +import androidx.core.content.ContextCompat +import com.nextcloud.talk.utils.ShareUtils +import com.nextcloud.talk.utils.database.user.UserUtils +import kotlinx.android.synthetic.main.activity_take_picture.* @AutoInjector(NextcloudTalkApplication::class) class ConversationOperationDialog( @@ -50,6 +57,10 @@ class ConversationOperationDialog( @JvmField var ncApi: NcApi? = null + @Inject + @JvmField + var userUtils: UserUtils? = null + init { NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this) } @@ -198,7 +209,27 @@ class ConversationOperationDialog( } binding.conversationOperationShareLink.setOnClickListener { - // TODO share by intent + val sendIntent: Intent = Intent().apply { + action = Intent.ACTION_SEND + type = "text/plain" + putExtra( + Intent.EXTRA_SUBJECT, + String.format( + activity.resources.getString(R.string.nc_share_subject), + activity.resources.getString(R.string.nc_app_product_name) + ) + ) + // password should not be shared!! + putExtra( + Intent.EXTRA_TEXT, + ShareUtils.getStringForIntent(activity, null, userUtils, conversation) + ) + } + + val shareIntent = Intent.createChooser(sendIntent, null) + activity.startActivity(shareIntent) + + dismiss() } } From 9423376ca7d1dc56e9c6ed2c78af11efe06f70fb Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 11 Feb 2022 17:49:05 +0100 Subject: [PATCH 07/34] tidy up Signed-off-by: Marcel Hibbe --- .../ConversationsListController.java | 68 +--- .../bottomsheet/CallMenuController.java | 363 ------------------ .../bottomsheet/OperationsMenuController.java | 17 + .../ui/dialog/ConversationOperationDialog.kt | 17 +- .../com/nextcloud/talk/utils/ShareUtils.java | 59 +-- 5 files changed, 41 insertions(+), 483 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 902e49673..94f0577d0 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -62,7 +62,7 @@ import com.facebook.imagepipeline.image.CloseableImage; import com.facebook.imagepipeline.request.ImageRequest; import com.google.android.material.button.MaterialButton; import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.kennyc.bottomsheet.BottomSheet; + import com.nextcloud.talk.R; import com.nextcloud.talk.activities.MainActivity; import com.nextcloud.talk.adapters.items.ConversationItem; @@ -71,8 +71,6 @@ 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.EntryMenuController; -import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController; -import com.nextcloud.talk.events.BottomSheetLockEvent; import com.nextcloud.talk.events.EventStatus; import com.nextcloud.talk.interfaces.ConversationMenuInterface; import com.nextcloud.talk.jobs.AccountRemovalWorker; @@ -185,7 +183,6 @@ public class ConversationsListController extends BaseController implements Searc private List conversationItemsWithHeader = new ArrayList<>(); private final List searchableConversationItems = new ArrayList<>(); - private BottomSheet bottomSheet; private MenuItem searchItem; private SearchView searchView; private String searchQuery; @@ -311,7 +308,7 @@ public class ConversationsListController extends BaseController implements Searc if (getActivity() != null && getActivity() instanceof MainActivity) { loadUserAvatar(((MainActivity) getActivity()).binding.switchAccountButton); } - fetchData(false); + fetchData(); } } @@ -470,7 +467,7 @@ public class ConversationsListController extends BaseController implements Searc } @SuppressLint("LongLogTag") - public void fetchData(boolean fromBottomSheet) { + public void fetchData() { dispose(null); isRefreshing = true; @@ -670,7 +667,7 @@ public class ConversationsListController extends BaseController implements Searc return false; }); - swipeRefreshLayout.setOnRefreshListener(() -> fetchData(false)); + swipeRefreshLayout.setOnRefreshListener(() -> fetchData()); swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary); swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.refresh_spinner_background); @@ -803,60 +800,23 @@ public class ConversationsListController extends BaseController implements Searc return onQueryTextChange(query); } - @Subscribe(threadMode = ThreadMode.MAIN) - public void onMessageEvent(BottomSheetLockEvent bottomSheetLockEvent) { - if (bottomSheet != null) { - if (!bottomSheetLockEvent.isCancelable()) { - bottomSheet.setCancelable(bottomSheetLockEvent.isCancelable()); - } else { - if (bottomSheetLockEvent.getDelay() != 0 && bottomSheetLockEvent.isShouldRefreshData()) { - fetchData(true); - } else { - bottomSheet.setCancelable(bottomSheetLockEvent.isCancelable()); - if (bottomSheet.isShowing() && bottomSheetLockEvent.isCancel()) { - bottomSheet.cancel(); - } - } - } - } - } - -// @Subscribe(threadMode = ThreadMode.MAIN) -// public void onMessageEvent(MoreMenuClickEvent moreMenuClickEvent) { -//// Bundle bundle = new Bundle(); -//// Conversation conversation = moreMenuClickEvent.getConversation(); -//// bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation)); -//// bundle.putParcelable(BundleKeys.INSTANCE.getKEY_MENU_TYPE(), Parcels.wrap(CallMenuController.MenuType.REGULAR)); -//// -//// prepareAndShowBottomSheetWithBundle(bundle, true); -// } - - private void prepareAndShowBottomSheetWithBundle(Bundle bundle, boolean shouldShowCallMenuController) { + private void prepareAndShowBottomSheetWithBundle(Bundle bundle) { if (view == null) { view = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet, null, false); } - if (shouldShowCallMenuController) { +// if (shouldShowCallMenuController) { // getChildRouter((ViewGroup) view).setRoot( // RouterTransaction.with(new CallMenuController(bundle, this)) // .popChangeHandler(new VerticalChangeHandler()) // .pushChangeHandler(new VerticalChangeHandler())); - - - } else { +// } else { getChildRouter((ViewGroup) view).setRoot( RouterTransaction.with(new EntryMenuController(bundle)) .popChangeHandler(new VerticalChangeHandler()) .pushChangeHandler(new VerticalChangeHandler())); - } -// if (bottomSheet == null) { -// bottomSheet = new BottomSheet.Builder(getActivity()).setView(view).create(); // } -// -//// bottomSheet.setOnShowListener(dialog -> new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true)); -// bottomSheet.setOnDismissListener(dialog -> showSearchOrToolbar()); -// bottomSheet.show(); } @Override @@ -1057,11 +1017,15 @@ public class ConversationsListController extends BaseController implements Searc bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), selectedConversation.getRoomId()); bundle.putString(BundleKeys.INSTANCE.getKEY_SHARED_TEXT(), textToPaste); - if (selectedConversation.hasPassword && selectedConversation.participantType == - Participant.ParticipantType.GUEST || - selectedConversation.participantType == Participant.ParticipantType.USER_FOLLOWING_LINK) { + // TODO debug & fix dialog??? + // when is hasPassword && ParticipantType.GUEST true? currently the app can't be used as guest?! + // when is USER_FOLLOWING_LINK true? --> from contactsController via enter link? + if ((selectedConversation.hasPassword + && selectedConversation.participantType == Participant.ParticipantType.GUEST) + || selectedConversation.participantType == Participant.ParticipantType.USER_FOLLOWING_LINK) { bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 99); - prepareAndShowBottomSheetWithBundle(bundle, false); + prepareAndShowBottomSheetWithBundle(bundle); + } else { currentUser = userUtils.getCurrentUser(); @@ -1077,7 +1041,7 @@ public class ConversationsListController extends BaseController implements Searc switch (eventStatus.getEventType()) { case CONVERSATION_UPDATE: if (eventStatus.isAllGood() && !isRefreshing) { - fetchData(false); + fetchData(); } break; default: diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java deleted file mode 100644 index 306146992..000000000 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/CallMenuController.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017 Mario Danic - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.controllers.bottomsheet; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.bluelinelabs.conductor.RouterTransaction; -import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler; -import com.kennyc.bottomsheet.adapters.AppAdapter; -import com.nextcloud.talk.R; -import com.nextcloud.talk.adapters.items.AppItem; -import com.nextcloud.talk.adapters.items.MenuItem; -import com.nextcloud.talk.application.NextcloudTalkApplication; -import com.nextcloud.talk.controllers.ConversationsListController; -import com.nextcloud.talk.controllers.base.BaseController; -import com.nextcloud.talk.events.BottomSheetLockEvent; -import com.nextcloud.talk.interfaces.ConversationMenuInterface; -import com.nextcloud.talk.jobs.LeaveConversationWorker; -import com.nextcloud.talk.models.database.CapabilitiesUtil; -import com.nextcloud.talk.models.database.UserEntity; -import com.nextcloud.talk.models.json.conversations.Conversation; -import com.nextcloud.talk.utils.DisplayUtils; -import com.nextcloud.talk.utils.ShareUtils; -import com.nextcloud.talk.utils.bundle.BundleKeys; -import com.nextcloud.talk.utils.database.user.UserUtils; - -import org.greenrobot.eventbus.EventBus; -import org.parceler.Parcel; -import org.parceler.Parcels; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.work.Data; -import androidx.work.OneTimeWorkRequest; -import androidx.work.WorkManager; -import autodagger.AutoInjector; -import butterknife.BindView; -import eu.davidea.flexibleadapter.FlexibleAdapter; -import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager; -import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; - -@AutoInjector(NextcloudTalkApplication.class) -public class CallMenuController extends BaseController implements FlexibleAdapter.OnItemClickListener { - public static final int ALL_MESSAGES_READ = 0; - @BindView(R.id.recycler_view) - RecyclerView recyclerView; - - @Inject - EventBus eventBus; - - @Inject - UserUtils userUtils; - - @Inject - Context context; - - private Conversation conversation; - private List menuItems; - private FlexibleAdapter adapter; - private MenuType menuType; - private Intent shareIntent; - - private UserEntity currentUser; - private ConversationMenuInterface conversationMenuInterface; - - public CallMenuController(Bundle args) { - super(args); - this.conversation = Parcels.unwrap(args.getParcelable(BundleKeys.INSTANCE.getKEY_ROOM())); - if (args.containsKey(BundleKeys.INSTANCE.getKEY_MENU_TYPE())) { - this.menuType = Parcels.unwrap(args.getParcelable(BundleKeys.INSTANCE.getKEY_MENU_TYPE())); - } - } - - public CallMenuController(Bundle args, @Nullable ConversationMenuInterface conversationMenuInterface) { - super(args); - this.conversation = Parcels.unwrap(args.getParcelable(BundleKeys.INSTANCE.getKEY_ROOM())); - if (args.containsKey(BundleKeys.INSTANCE.getKEY_MENU_TYPE())) { - this.menuType = Parcels.unwrap(args.getParcelable(BundleKeys.INSTANCE.getKEY_MENU_TYPE())); - } - this.conversationMenuInterface = conversationMenuInterface; - } - - @Override - @NonNull - protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) { - return inflater.inflate(R.layout.controller_call_menu, container, false); - } - - @Override - protected void onViewBound(@NonNull View view) { - super.onViewBound(view); - NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this); - prepareViews(); - } - - private void prepareViews() { - LinearLayoutManager layoutManager = new SmoothScrollLinearLayoutManager(getActivity()); - recyclerView.setLayoutManager(layoutManager); - recyclerView.setHasFixedSize(true); - - prepareMenu(); - if (adapter == null) { - adapter = new FlexibleAdapter<>(menuItems, getActivity(), false); - } - - adapter.addListener(this); - recyclerView.setAdapter(adapter); - } - - private void prepareIntent() { - shareIntent = new Intent(Intent.ACTION_SEND); - shareIntent.setType("text/plain"); - shareIntent.putExtra(Intent.EXTRA_SUBJECT, String.format(getResources().getString(R.string.nc_share_subject), - getResources().getString(R.string.nc_app_product_name))); - } - - private void prepareMenu() { - menuItems = new ArrayList<>(); - - if (menuType.equals(MenuType.REGULAR)) { -// if (!TextUtils.isEmpty(conversation.getDisplayName())) { -// menuItems.add(new MenuItem(conversation.getDisplayName(), 0, null)); -// } else if (!TextUtils.isEmpty(conversation.getName())) { -// menuItems.add(new MenuItem(conversation.getName(), 0, null)); -// } else { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_configure_room), 0, null)); -// } -// -// currentUser = userUtils.getCurrentUser(); -// -// if (conversation.isFavorite()) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_remove_from_favorites), 97, DisplayUtils.getTintedDrawable(getResources(), R.drawable.ic_star_border_black_24dp, R.color.grey_600))); -// } else if (CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "favorites")) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_add_to_favorites), -// 98, -// DisplayUtils.getTintedDrawable(getResources(), -// R.drawable.ic_star_black_24dp, -// R.color.grey_600))); -// } -// -// if(conversation.unreadMessages > ALL_MESSAGES_READ && CapabilitiesUtil.canSetChatReadMarker(currentUser)) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_mark_as_read), -// 96, -// ContextCompat.getDrawable(context, R.drawable.ic_eye))); -// } -// -// if (conversation.isNameEditable(currentUser)) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_rename), -// 2, -// ContextCompat.getDrawable(context, -// R.drawable.ic_pencil_grey600_24dp))); -// } -// -// if (conversation.canModerate(currentUser)) { -// if (!conversation.isPublic()) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_make_call_public), -// 3, ContextCompat.getDrawable(context, -// R.drawable.ic_link_grey600_24px))); -// } else { -// if (conversation.isHasPassword()) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_change_password), -// 4, ContextCompat.getDrawable(context, -// R.drawable.ic_lock_grey600_24px))); -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_clear_password), -// 5, -// ContextCompat.getDrawable(context, -// R.drawable.ic_lock_open_grey600_24dp))); -// } else { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_set_password), -// 6, ContextCompat.getDrawable(context, -// R.drawable.ic_lock_plus_grey600_24dp))); -// } -// } -// -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_delete_call), -// 9, ContextCompat.getDrawable(context, -// R.drawable.ic_delete_grey600_24dp))); -// } -// -// if (conversation.isPublic()) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_share_link), -// 7, ContextCompat.getDrawable(context, -// R.drawable.ic_link_grey600_24px))); -// if (conversation.canModerate(currentUser)) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_make_call_private), -// 8, ContextCompat.getDrawable(context, -// R.drawable.ic_group_grey600_24px))); -// } -// } -// -// if (conversation.canLeave(currentUser)) { -// menuItems.add(new MenuItem(getResources().getString(R.string.nc_leave), 1, -// DisplayUtils.getTintedDrawable(getResources(), -// R.drawable.ic_exit_to_app_black_24dp, R.color.grey_600) -// )); -// } - } else if (menuType.equals(MenuType.SHARE)) { - prepareIntent(); - List appInfoList = ShareUtils.getShareApps(getActivity(), shareIntent, null, - null); - menuItems.add(new AppItem(getResources().getString(R.string.nc_share_link_via), - "", - "", - ContextCompat.getDrawable(context, R.drawable.ic_link_grey600_24px))); - if (appInfoList != null) { - for (AppAdapter.AppInfo appInfo : appInfoList) { - menuItems.add(new AppItem(appInfo.title, appInfo.packageName, appInfo.name, appInfo.drawable)); - } - } - } else { - menuItems.add(new MenuItem(getResources().getString(R.string.nc_start_conversation), 0, null)); - menuItems.add(new MenuItem(getResources().getString(R.string.nc_new_conversation), - 1, ContextCompat.getDrawable(context, - R.drawable.ic_add_grey600_24px))); - menuItems.add(new MenuItem(getResources().getString(R.string.nc_join_via_link), - 2, ContextCompat.getDrawable(context, - R.drawable.ic_link_grey600_24px))); - } - } - - @Override - public boolean onItemClick(View view, int position) { - Bundle bundle = new Bundle(); - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation)); - - if (menuType.equals(MenuType.REGULAR)) { - MenuItem menuItem = (MenuItem) adapter.getItem(position); - if (menuItem != null) { - - int tag = menuItem.getTag(); - if (tag == 5) { - conversation.setPassword(""); - } - - if (tag > 0) { - if (tag == 1 || tag == 9) { - if (tag == 1) { - Data data; - if ((data = getWorkerData()) != null) { - OneTimeWorkRequest leaveConversationWorker = - new OneTimeWorkRequest.Builder(LeaveConversationWorker.class).setInputData(data).build(); - WorkManager.getInstance().enqueue(leaveConversationWorker); - } - } else { - Bundle deleteConversationBundle; - if ((deleteConversationBundle = getDeleteConversationBundle()) != null) { - conversationMenuInterface.openLovelyDialogWithIdAndBundle(ConversationsListController.ID_DELETE_CONVERSATION_DIALOG, deleteConversationBundle); - } - } - eventBus.post(new BottomSheetLockEvent(true, 0, false, true)); - } else { - - // TODO: continue here to extract more setOnClickListeners to ConversationOperationDialog.kt - - bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), tag); - if (tag != 2 && tag != 4 && tag != 6 && tag != 7) { - // 3=make call public, 5=clear pw, 8=make call private .. - eventBus.post(new BottomSheetLockEvent(false, 0, false, false)); - getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)) - .pushChangeHandler(new HorizontalChangeHandler()) - .popChangeHandler(new HorizontalChangeHandler())); - } else if (tag != 7) { - // 3=make call public, 5=clear pw, 8=make call private .. - - // rename and set password !? - getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)) - .pushChangeHandler(new HorizontalChangeHandler()) - .popChangeHandler(new HorizontalChangeHandler())); - } else { - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_MENU_TYPE(), Parcels.wrap(MenuType.SHARE)); - getRouter().pushController(RouterTransaction.with(new CallMenuController(bundle, null)) - .pushChangeHandler(new HorizontalChangeHandler()) - .popChangeHandler(new HorizontalChangeHandler())); - } - } - } - } - } else if (menuType.equals(MenuType.SHARE) && position != 0) { - AppItem appItem = (AppItem) adapter.getItem(position); - if (appItem != null && getActivity() != null) { - if (!conversation.hasPassword) { - shareIntent.putExtra(Intent.EXTRA_TEXT, ShareUtils.getStringForIntent(getActivity(), null, - userUtils, conversation)); - Intent intent = new Intent(shareIntent); - intent.setComponent(new ComponentName(appItem.getPackageName(), appItem.getName())); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - eventBus.post(new BottomSheetLockEvent(true, 0, false, true)); - getActivity().startActivity(intent); - } else { - bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 7); - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_SHARE_INTENT(), Parcels.wrap(shareIntent)); - bundle.putString(BundleKeys.INSTANCE.getKEY_APP_ITEM_PACKAGE_NAME(), appItem.getPackageName()); - bundle.putString(BundleKeys.INSTANCE.getKEY_APP_ITEM_NAME(), appItem.getName()); - getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)) - .pushChangeHandler(new HorizontalChangeHandler()) - .popChangeHandler(new HorizontalChangeHandler())); - } - } - } - - return true; - } - - private Data getWorkerData() { - if (!TextUtils.isEmpty(conversation.getToken())) { - Data.Builder data = new Data.Builder(); - data.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), conversation.getToken()); - data.putLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), currentUser.getId()); - return data.build(); - } - - return null; - } - - private Bundle getDeleteConversationBundle() { - if (!TextUtils.isEmpty(conversation.getToken())) { - Bundle bundle = new Bundle(); - bundle.putLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), currentUser.getId()); - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation)); - return bundle; - } - - return null; - } - - @Parcel - public enum MenuType { - REGULAR, SHARE - } -} diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index 3be1a2537..bb32c3d4a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -283,6 +283,23 @@ 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: create conversation ?? + 11: invite users to conversation + 96: set chat read marker + 97: remove favorite + 98: add favorite + 99: join room + */ + + switch (operationCode) { case 2: ncApi.renameRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(), diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt index 50bb0efbb..69e0b89fa 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt @@ -1,6 +1,7 @@ package com.nextcloud.talk.ui.dialog import android.app.Activity +import android.content.Intent import android.os.Bundle import android.text.TextUtils import android.view.View @@ -19,7 +20,6 @@ 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.CallMenuController import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController import com.nextcloud.talk.databinding.DialogConversationOperationsBinding @@ -27,19 +27,14 @@ import com.nextcloud.talk.jobs.LeaveConversationWorker import com.nextcloud.talk.models.database.CapabilitiesUtil import com.nextcloud.talk.models.database.UserEntity import com.nextcloud.talk.models.json.conversations.Conversation +import com.nextcloud.talk.utils.ShareUtils import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_OPERATION_CODE import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN +import com.nextcloud.talk.utils.database.user.UserUtils import org.parceler.Parcels import javax.inject.Inject -import androidx.core.content.ContextCompat.startActivity - -import android.content.Intent -import androidx.core.content.ContextCompat -import com.nextcloud.talk.utils.ShareUtils -import com.nextcloud.talk.utils.database.user.UserUtils -import kotlinx.android.synthetic.main.activity_take_picture.* @AutoInjector(NextcloudTalkApplication::class) class ConversationOperationDialog( @@ -96,8 +91,7 @@ class ConversationOperationDialog( ) binding.conversationOperationMarkAsRead.visibility = setVisibleIf( - conversation.unreadMessages > CallMenuController.ALL_MESSAGES_READ - && CapabilitiesUtil.canSetChatReadMarker(currentUser) + conversation.unreadMessages > 0 && CapabilitiesUtil.canSetChatReadMarker(currentUser) ) binding.conversationOperationRename.visibility = setVisibleIf( @@ -248,7 +242,7 @@ class ConversationOperationDialog( .popChangeHandler(HorizontalChangeHandler()) ) - controller.fetchData(false) + controller.fetchData() } private fun executeEntryMenuController(operationCode: Int) { @@ -266,6 +260,7 @@ class ConversationOperationDialog( // into EntryMenuController to execute fetch data... ?!) // for example if you set a password, the dialog items should be refreshed for the next time you open it // without to manually have to refresh the conversations list + // also see BottomSheetLockEvent ?? RouterTransaction.with(EntryMenuController(bundle)) .pushChangeHandler(HorizontalChangeHandler()) diff --git a/app/src/main/java/com/nextcloud/talk/utils/ShareUtils.java b/app/src/main/java/com/nextcloud/talk/utils/ShareUtils.java index 815f26cd3..30f051512 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ShareUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/ShareUtils.java @@ -16,29 +16,19 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * - * Part of the code in ShareUtils was inspired by BottomSheet under the Apache licence - * located here: https://github.com/Kennyc1012/BottomSheet/blob/master/library/src/main/java/com/kennyc/bottomsheet/BottomSheet.java#L425 */ package com.nextcloud.talk.utils; import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.graphics.drawable.Drawable; import android.text.TextUtils; -import androidx.annotation.Nullable; -import com.kennyc.bottomsheet.adapters.AppAdapter; + import com.nextcloud.talk.R; import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.json.conversations.Conversation; import com.nextcloud.talk.utils.database.user.UserUtils; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; +import androidx.annotation.Nullable; public class ShareUtils { @@ -58,49 +48,4 @@ public class ShareUtils { return shareString; } - - public static List getShareApps(Context context, Intent intent, - @Nullable Set appsFilter, @Nullable Set toExclude) { - - if (context == null || intent == null) return null; - - PackageManager manager = context.getPackageManager(); - List apps = manager.queryIntentActivities(intent, 0); - - if (apps != null && !apps.isEmpty()) { - List appResources = new ArrayList<>(apps.size()); - boolean shouldCheckPackages = appsFilter != null && !appsFilter.isEmpty(); - - for (ResolveInfo resolveInfo : apps) { - String packageName = resolveInfo.activityInfo.packageName; - - if (shouldCheckPackages && !appsFilter.contains(packageName)) { - continue; - } - - String title = resolveInfo.loadLabel(manager).toString(); - String name = resolveInfo.activityInfo.name; - Drawable drawable = resolveInfo.loadIcon(manager); - appResources.add(new AppAdapter.AppInfo(title, packageName, name, drawable)); - } - - if (toExclude != null && !toExclude.isEmpty()) { - List toRemove = new ArrayList<>(); - - for (AppAdapter.AppInfo appInfo : appResources) { - if (toExclude.contains(appInfo.packageName)) { - toRemove.add(appInfo); - } - } - - if (!toRemove.isEmpty()) appResources.removeAll(toRemove); - } - - return appResources; - - } - - return null; - } - } From dbf6b91260cb5411a1604912a05fa0d4262dcd79 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Fri, 11 Feb 2022 22:05:33 +0100 Subject: [PATCH 08/34] rename ConversationOperationDialog to ConversationsListBottomDialog Signed-off-by: Marcel Hibbe --- .../ConversationsListController.java | 19 +++++++++++++++---- ...og.kt => ConversationsListBottomDialog.kt} | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) rename app/src/main/java/com/nextcloud/talk/ui/dialog/{ConversationOperationDialog.kt => ConversationsListBottomDialog.kt} (99%) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 94f0577d0..86e7b920a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -82,7 +82,7 @@ import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.json.conversations.Conversation; import com.nextcloud.talk.models.json.participants.Participant; import com.nextcloud.talk.ui.dialog.ChooseAccountDialogFragment; -import com.nextcloud.talk.ui.dialog.ConversationOperationDialog; +import com.nextcloud.talk.ui.dialog.ConversationsListBottomDialog; import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.ClosedInterfaceImpl; import com.nextcloud.talk.utils.ConductorRemapping; @@ -214,7 +214,7 @@ public class ConversationsListController extends BaseController implements Searc private HashMap callHeaderItems = new HashMap<>(); - private ConversationOperationDialog conversationOperationDialog; + private ConversationsListBottomDialog conversationsListBottomDialog; public ConversationsListController(Bundle bundle) { super(); @@ -904,12 +904,12 @@ public class ConversationsListController extends BaseController implements Searc Object clickedItem = adapter.getItem(position); if (clickedItem != null) { Conversation conversation = ((ConversationItem) clickedItem).getModel(); - conversationOperationDialog = new ConversationOperationDialog( + conversationsListBottomDialog = new ConversationsListBottomDialog( getActivity(), this, userUtils.getCurrentUser(), conversation); - conversationOperationDialog.show(); + conversationsListBottomDialog.show(); } } } @@ -1026,6 +1026,17 @@ public class ConversationsListController extends BaseController implements Searc bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 99); prepareAndShowBottomSheetWithBundle(bundle); + + // instead to use prepareAnd... + // use something like + // + // conversationOperationDialog = new ConversationOperationDialog( + // getActivity(), + // this, + // userUtils.getCurrentUser(), + // conversation); + // conversationOperationDialog.show(); + } else { currentUser = userUtils.getCurrentUser(); diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt similarity index 99% rename from app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt rename to app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index 69e0b89fa..82748caa0 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationOperationDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -37,7 +37,7 @@ import org.parceler.Parcels import javax.inject.Inject @AutoInjector(NextcloudTalkApplication::class) -class ConversationOperationDialog( +class ConversationsListBottomDialog( val activity: Activity, val controller: ConversationsListController, val currentUser: UserEntity, From ac0c961557612d84bcb90047e47f762891903d93 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Sat, 12 Feb 2022 00:45:13 +0100 Subject: [PATCH 09/34] open Conversation after being created via ContactsController Signed-off-by: Marcel Hibbe --- .../talk/controllers/ContactsController.java | 554 ++++++++---------- .../bottomsheet/OperationsMenuController.java | 9 +- .../talk/events/OpenConversationEvent.kt | 52 ++ .../talk/ui/dialog/ContactsBottomDialog.kt | 62 ++ .../res/layout/dialog_bottom_contacts.xml | 13 + .../layout/dialog_conversation_operations.xml | 31 - 6 files changed, 391 insertions(+), 330 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt create mode 100644 app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt create mode 100644 app/src/main/res/layout/dialog_bottom_contacts.xml diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index 5a5491f20..9c8fbcc7a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -25,7 +25,6 @@ import android.content.Context; import android.graphics.PorterDuff; import android.os.Build; import android.os.Bundle; -import android.os.Handler; import android.text.InputType; import android.util.Log; import android.view.LayoutInflater; @@ -50,8 +49,8 @@ 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.EntryMenuController; -import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController; -import com.nextcloud.talk.events.BottomSheetLockEvent; +import com.nextcloud.talk.events.OpenConversationEvent; +import com.nextcloud.talk.events.PeerConnectionEvent; import com.nextcloud.talk.jobs.AddParticipantsToConversation; import com.nextcloud.talk.models.RetrofitBucket; import com.nextcloud.talk.models.database.CapabilitiesUtil; @@ -62,6 +61,7 @@ import com.nextcloud.talk.models.json.conversations.Conversation; import com.nextcloud.talk.models.json.conversations.RoomOverall; import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter; import com.nextcloud.talk.models.json.participants.Participant; +import com.nextcloud.talk.ui.dialog.ContactsBottomDialog; import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.ConductorRemapping; import com.nextcloud.talk.utils.bundle.BundleKeys; @@ -112,7 +112,7 @@ import okhttp3.ResponseBody; @AutoInjector(NextcloudTalkApplication.class) public class ContactsController extends BaseController implements SearchView.OnQueryTextListener, - FlexibleAdapter.OnItemClickListener { + FlexibleAdapter.OnItemClickListener { public static final String TAG = "ContactsController"; @@ -191,6 +191,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ private boolean isAddingParticipantsView; private String conversationToken; + private ContactsBottomDialog contactsBottomDialog; + public ContactsController() { super(); setHasOptionsMenu(true); @@ -265,12 +267,12 @@ public class ContactsController extends BaseController implements SearchView.OnQ private void setupAdapter() { adapter.setNotifyChangeOfUnfilteredItems(true) - .setMode(SelectableAdapter.Mode.MULTI); + .setMode(SelectableAdapter.Mode.MULTI); adapter.setStickyHeaderElevation(5) - .setUnlinkAllItemsOnRemoveHeaders(true) - .setDisplayHeadersAtStartUp(true) - .setStickyHeaders(true); + .setUnlinkAllItemsOnRemoveHeaders(true) + .setDisplayHeadersAtStartUp(true) + .setStickyHeaders(true); adapter.addListener(this); } @@ -293,7 +295,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ userId = selectedUserIds.iterator().next(); } - int apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {ApiUtils.APIv4, 1}); + int apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[]{ApiUtils.APIv4, 1}); RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion, currentUser.getBaseUrl(), roomType, @@ -301,65 +303,65 @@ public class ContactsController extends BaseController implements SearchView.OnQ userId, null); ncApi.createRoom(credentials, - retrofitBucket.getUrl(), retrofitBucket.getQueryMap()) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Observer() { - @Override - public void onSubscribe(Disposable d) { + retrofitBucket.getUrl(), retrofitBucket.getQueryMap()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { - } + } - @Override - public void onNext(RoomOverall roomOverall) { - Bundle bundle = new Bundle(); - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY(), currentUser); - bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), roomOverall.getOcs().getData().getToken()); - bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId()); + @Override + public void onNext(RoomOverall roomOverall) { + Bundle bundle = new Bundle(); + bundle.putParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY(), currentUser); + bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), roomOverall.getOcs().getData().getToken()); + bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId()); - // FIXME once APIv2 or later is used only, the createRoom already returns all the data - ncApi.getRoom(credentials, - ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(), - roomOverall.getOcs().getData().getToken())) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Observer() { + // FIXME once APIv2 or later is used only, the createRoom already returns all the data + ncApi.getRoom(credentials, + ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(), + roomOverall.getOcs().getData().getToken())) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Observer() { - @Override - public void onSubscribe(Disposable d) { + @Override + public void onSubscribe(Disposable d) { - } + } - @Override - public void onNext(RoomOverall roomOverall) { - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), - Parcels.wrap(roomOverall.getOcs().getData())); + @Override + public void onNext(RoomOverall roomOverall) { + bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), + Parcels.wrap(roomOverall.getOcs().getData())); - ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(), - roomOverall.getOcs().getData().getToken(), bundle, true); - } + ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(), + roomOverall.getOcs().getData().getToken(), bundle, true); + } - @Override - public void onError(Throwable e) { + @Override + public void onError(Throwable e) { - } + } - @Override - public void onComplete() { + @Override + public void onComplete() { - } - }); - } + } + }); + } - @Override - public void onError(Throwable e) { + @Override + public void onError(Throwable e) { - } + } - @Override - public void onComplete() { - } - }); + @Override + public void onComplete() { + } + }); } else { Bundle bundle = new Bundle(); @@ -382,7 +384,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_EMAIL(), emailsArray); bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_CIRCLE(), circleIdsArray); bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 11); - prepareAndShowBottomSheetWithBundle(bundle, true); + prepareAndShowBottomSheetWithBundle(bundle); } } else { String[] userIdsArray = selectedUserIds.toArray(new String[selectedUserIds.size()]); @@ -399,7 +401,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_CIRCLES(), circleIdsArray); OneTimeWorkRequest addParticipantsToConversationWorker = - new OneTimeWorkRequest.Builder(AddParticipantsToConversation.class).setInputData(data.build()).build(); + new OneTimeWorkRequest.Builder(AddParticipantsToConversation.class).setInputData(data.build()).build(); WorkManager.getInstance().enqueue(addParticipantsToConversationWorker); getRouter().popCurrentController(); @@ -499,186 +501,186 @@ public class ContactsController extends BaseController implements SearchView.OnQ modifiedQueryMap.put("shareTypes[]", shareTypesList); ncApi.getContactsWithSearchParam( - credentials, - retrofitBucket.getUrl(), shareTypesList, modifiedQueryMap) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .retry(3) - .subscribe(new Observer() { - @Override - public void onSubscribe(Disposable d) { - contactsQueryDisposable = d; - } + credentials, + retrofitBucket.getUrl(), shareTypesList, modifiedQueryMap) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .retry(3) + .subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { + contactsQueryDisposable = d; + } - @Override - public void onNext(ResponseBody responseBody) { - if (responseBody != null) { - Participant participant; + @Override + public void onNext(ResponseBody responseBody) { + if (responseBody != null) { + Participant participant; - List newUserItemList = new ArrayList<>(); - EnumActorTypeConverter actorTypeConverter = new EnumActorTypeConverter(); + List newUserItemList = new ArrayList<>(); + EnumActorTypeConverter actorTypeConverter = new EnumActorTypeConverter(); - try { - AutocompleteOverall autocompleteOverall = LoganSquare.parse( - responseBody.string(), - AutocompleteOverall.class); - autocompleteUsersHashSet.addAll(autocompleteOverall.getOcs().getData()); + try { + AutocompleteOverall autocompleteOverall = LoganSquare.parse( + responseBody.string(), + AutocompleteOverall.class); + autocompleteUsersHashSet.addAll(autocompleteOverall.getOcs().getData()); - for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) { - if (!autocompleteUser.getId().equals(currentUser.getUserId()) - && !existingParticipants.contains(autocompleteUser.getId())) { - participant = new Participant(); - participant.setActorId(autocompleteUser.getId()); - participant.setActorType(actorTypeConverter.getFromString(autocompleteUser.getSource())); - participant.setDisplayName(autocompleteUser.getLabel()); - participant.setSource(autocompleteUser.getSource()); + for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) { + if (!autocompleteUser.getId().equals(currentUser.getUserId()) + && !existingParticipants.contains(autocompleteUser.getId())) { + participant = new Participant(); + participant.setActorId(autocompleteUser.getId()); + participant.setActorType(actorTypeConverter.getFromString(autocompleteUser.getSource())); + participant.setDisplayName(autocompleteUser.getLabel()); + participant.setSource(autocompleteUser.getSource()); - String headerTitle; + String headerTitle; - if (participant.getActorType() == Participant.ActorType.GROUPS) { - headerTitle = getResources().getString(R.string.nc_groups); - } else if (participant.getActorType() == Participant.ActorType.CIRCLES) { - headerTitle = getResources().getString(R.string.nc_circles); - } else { - headerTitle = - participant.getDisplayName().substring(0, 1).toUpperCase(Locale.getDefault()); - } + if (participant.getActorType() == Participant.ActorType.GROUPS) { + headerTitle = getResources().getString(R.string.nc_groups); + } else if (participant.getActorType() == Participant.ActorType.CIRCLES) { + headerTitle = getResources().getString(R.string.nc_circles); + } else { + headerTitle = + participant.getDisplayName().substring(0, 1).toUpperCase(Locale.getDefault()); + } - GenericTextHeaderItem genericTextHeaderItem; - if (!userHeaderItems.containsKey(headerTitle)) { - genericTextHeaderItem = new GenericTextHeaderItem(headerTitle); - userHeaderItems.put(headerTitle, genericTextHeaderItem); - } + GenericTextHeaderItem genericTextHeaderItem; + if (!userHeaderItems.containsKey(headerTitle)) { + genericTextHeaderItem = new GenericTextHeaderItem(headerTitle); + userHeaderItems.put(headerTitle, genericTextHeaderItem); + } - UserItem newContactItem = new UserItem( - participant, - currentUser, - userHeaderItems.get(headerTitle) - ); + UserItem newContactItem = new UserItem( + participant, + currentUser, + userHeaderItems.get(headerTitle) + ); - if (!contactItems.contains(newContactItem)) { - newUserItemList.add(newContactItem); - } + if (!contactItems.contains(newContactItem)) { + newUserItemList.add(newContactItem); } } - } catch (IOException ioe) { - Log.e(TAG, "Parsing response body failed while getting contacts", ioe); + } + } catch (IOException ioe) { + Log.e(TAG, "Parsing response body failed while getting contacts", ioe); + } + + userHeaderItems = new HashMap<>(); + contactItems.addAll(newUserItemList); + + Collections.sort(newUserItemList, (o1, o2) -> { + String firstName; + String secondName; + + if (o1 instanceof UserItem) { + firstName = ((UserItem) o1).getModel().getDisplayName(); + } else { + firstName = ((GenericTextHeaderItem) o1).getModel(); } - userHeaderItems = new HashMap<>(); - contactItems.addAll(newUserItemList); + if (o2 instanceof UserItem) { + secondName = ((UserItem) o2).getModel().getDisplayName(); + } else { + secondName = ((GenericTextHeaderItem) o2).getModel(); + } - Collections.sort(newUserItemList, (o1, o2) -> { - String firstName; - String secondName; - - if (o1 instanceof UserItem) { - firstName = ((UserItem) o1).getModel().getDisplayName(); - } else { - firstName = ((GenericTextHeaderItem) o1).getModel(); - } - - if (o2 instanceof UserItem) { - secondName = ((UserItem) o2).getModel().getDisplayName(); - } else { - secondName = ((GenericTextHeaderItem) o2).getModel(); - } - - if (o1 instanceof UserItem && o2 instanceof UserItem) { - String firstSource = ((UserItem) o1).getModel().getSource(); - String secondSource = ((UserItem) o2).getModel().getSource(); - if (firstSource.equals(secondSource)) { - return firstName.compareToIgnoreCase(secondName); - } - - // First users - if ("users".equals(firstSource)) { - return -1; - } else if ("users".equals(secondSource)) { - return 1; - } - - // Then groups - if ("groups".equals(firstSource)) { - return -1; - } else if ("groups".equals(secondSource)) { - return 1; - } - - // Then circles - if ("circles".equals(firstSource)) { - return -1; - } else if ("circles".equals(secondSource)) { - return 1; - } - - // Otherwise fall back to name sorting + if (o1 instanceof UserItem && o2 instanceof UserItem) { + String firstSource = ((UserItem) o1).getModel().getSource(); + String secondSource = ((UserItem) o2).getModel().getSource(); + if (firstSource.equals(secondSource)) { return firstName.compareToIgnoreCase(secondName); } + // First users + if ("users".equals(firstSource)) { + return -1; + } else if ("users".equals(secondSource)) { + return 1; + } + + // Then groups + if ("groups".equals(firstSource)) { + return -1; + } else if ("groups".equals(secondSource)) { + return 1; + } + + // Then circles + if ("circles".equals(firstSource)) { + return -1; + } else if ("circles".equals(secondSource)) { + return 1; + } + + // Otherwise fall back to name sorting return firstName.compareToIgnoreCase(secondName); - }); + } - Collections.sort(contactItems, (o1, o2) -> { - String firstName; - String secondName; + return firstName.compareToIgnoreCase(secondName); + }); - if (o1 instanceof UserItem) { - firstName = ((UserItem) o1).getModel().getDisplayName(); - } else { - firstName = ((GenericTextHeaderItem) o1).getModel(); - } + Collections.sort(contactItems, (o1, o2) -> { + String firstName; + String secondName; - if (o2 instanceof UserItem) { - secondName = ((UserItem) o2).getModel().getDisplayName(); - } else { - secondName = ((GenericTextHeaderItem) o2).getModel(); - } - - if (o1 instanceof UserItem && o2 instanceof UserItem) { - if ("groups".equals(((UserItem) o1).getModel().getSource()) && "groups".equals(((UserItem) o2).getModel().getSource())) { - return firstName.compareToIgnoreCase(secondName); - } else if ("groups".equals(((UserItem) o1).getModel().getSource())) { - return -1; - } else if ("groups".equals(((UserItem) o2).getModel().getSource())) { - return 1; - } - } - - return firstName.compareToIgnoreCase(secondName); - }); - - if (newUserItemList.size() > 0) { - adapter.updateDataSet(newUserItemList); + if (o1 instanceof UserItem) { + firstName = ((UserItem) o1).getModel().getDisplayName(); } else { - adapter.filterItems(); + firstName = ((GenericTextHeaderItem) o1).getModel(); } - if (swipeRefreshLayout != null) { - swipeRefreshLayout.setRefreshing(false); + if (o2 instanceof UserItem) { + secondName = ((UserItem) o2).getModel().getDisplayName(); + } else { + secondName = ((GenericTextHeaderItem) o2).getModel(); } + + if (o1 instanceof UserItem && o2 instanceof UserItem) { + if ("groups".equals(((UserItem) o1).getModel().getSource()) && "groups".equals(((UserItem) o2).getModel().getSource())) { + return firstName.compareToIgnoreCase(secondName); + } else if ("groups".equals(((UserItem) o1).getModel().getSource())) { + return -1; + } else if ("groups".equals(((UserItem) o2).getModel().getSource())) { + return 1; + } + } + + return firstName.compareToIgnoreCase(secondName); + }); + + if (newUserItemList.size() > 0) { + adapter.updateDataSet(newUserItemList); + } else { + adapter.filterItems(); } - } - @Override - public void onError(Throwable e) { if (swipeRefreshLayout != null) { swipeRefreshLayout.setRefreshing(false); } - dispose(contactsQueryDisposable); } + } - @Override - public void onComplete() { - if (swipeRefreshLayout != null) { - swipeRefreshLayout.setRefreshing(false); - } - dispose(contactsQueryDisposable); - alreadyFetching = false; - - disengageProgressBar(); + @Override + public void onError(Throwable e) { + if (swipeRefreshLayout != null) { + swipeRefreshLayout.setRefreshing(false); } - }); + dispose(contactsQueryDisposable); + } + + @Override + public void onComplete() { + if (swipeRefreshLayout != null) { + swipeRefreshLayout.setRefreshing(false); + } + dispose(contactsQueryDisposable); + alreadyFetching = false; + + disengageProgressBar(); + } + }); } @@ -693,14 +695,14 @@ public class ContactsController extends BaseController implements SearchView.OnQ swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.refresh_spinner_background); joinConversationViaLinkImageView - .getBackground() - .setColorFilter(ResourcesCompat.getColor(getResources(), R.color.colorBackgroundDarker, null), - PorterDuff.Mode.SRC_IN); + .getBackground() + .setColorFilter(ResourcesCompat.getColor(getResources(), R.color.colorBackgroundDarker, null), + PorterDuff.Mode.SRC_IN); publicCallLinkImageView - .getBackground() - .setColorFilter(ResourcesCompat.getColor(getResources(), R.color.colorPrimary, null), - PorterDuff.Mode.SRC_IN); + .getBackground() + .setColorFilter(ResourcesCompat.getColor(getResources(), R.color.colorPrimary, null), + PorterDuff.Mode.SRC_IN); disengageProgressBar(); } @@ -800,57 +802,21 @@ public class ContactsController extends BaseController implements SearchView.OnQ } } - private void prepareAndShowBottomSheetWithBundle(Bundle bundle, boolean showEntrySheet) { - if (view == null) { - view = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet, null, false); - } - - if (bottomSheet == null) { - bottomSheet = new BottomSheet.Builder(getActivity()).setView(view).create(); - } - - if (showEntrySheet) { - getChildRouter((ViewGroup) view).setRoot( - RouterTransaction.with(new EntryMenuController(bundle)) - .popChangeHandler(new VerticalChangeHandler()) - .pushChangeHandler(new VerticalChangeHandler())); - } else { - getChildRouter((ViewGroup) view).setRoot( - RouterTransaction.with(new OperationsMenuController(bundle)) - .popChangeHandler(new VerticalChangeHandler()) - .pushChangeHandler(new VerticalChangeHandler())); - } - - bottomSheet.setOnShowListener(dialog -> { - if (showEntrySheet) { -// new KeyboardUtils(getActivity(), bottomSheet.getLayout(), true); - } else { - eventBus.post(new BottomSheetLockEvent(false, 0, - false, false)); - } - }); - - bottomSheet.setOnDismissListener(dialog -> getActionBar().setDisplayHomeAsUpEnabled(getRouter().getBackstackSize() > 1)); - - bottomSheet.show(); + private void prepareAndShowBottomSheetWithBundle(Bundle bundle) { + // 11: create conversation-enter name for new conversation + // 10: get&join room when enter link + contactsBottomDialog = new ContactsBottomDialog(getActivity(), bundle); + contactsBottomDialog.show(); } + @Subscribe(threadMode = ThreadMode.MAIN) - public void onMessageEvent(BottomSheetLockEvent bottomSheetLockEvent) { - - if (bottomSheet != null) { - if (!bottomSheetLockEvent.isCancelable()) { - bottomSheet.setCancelable(bottomSheetLockEvent.isCancelable()); - } else { - bottomSheet.setCancelable(bottomSheetLockEvent.isCancelable()); - if (bottomSheet.isShowing() && bottomSheetLockEvent.isCancel()) { - new Handler().postDelayed(() -> { - bottomSheet.setOnCancelListener(null); - bottomSheet.cancel(); - - }, bottomSheetLockEvent.getDelay()); - } - } + public void onMessageEvent(OpenConversationEvent openConversationEvent) { + ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(), + openConversationEvent.getConversation().getToken(), + openConversationEvent.getBundle(), true); + if (contactsBottomDialog != null) { + contactsBottomDialog.dismiss(); } } @@ -871,7 +837,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ roomType = "2"; } - int apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {ApiUtils.APIv4, 1}); + int apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[]{ApiUtils.APIv4, 1}); RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion, currentUser.getBaseUrl(), @@ -881,40 +847,40 @@ public class ContactsController extends BaseController implements SearchView.OnQ null); ncApi.createRoom(credentials, - retrofitBucket.getUrl(), retrofitBucket.getQueryMap()) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Observer() { - @Override - public void onSubscribe(Disposable d) { + retrofitBucket.getUrl(), retrofitBucket.getQueryMap()) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Observer() { + @Override + public void onSubscribe(Disposable d) { + } + + @Override + public void onNext(RoomOverall roomOverall) { + if (getActivity() != null) { + Bundle bundle = new Bundle(); + bundle.putParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY(), currentUser); + bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), roomOverall.getOcs().getData().getToken()); + bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId()); + bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), + Parcels.wrap(roomOverall.getOcs().getData())); + + ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(), + roomOverall.getOcs().getData().getToken(), bundle, true); } + } - @Override - public void onNext(RoomOverall roomOverall) { - if (getActivity() != null) { - Bundle bundle = new Bundle(); - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY(), currentUser); - bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), roomOverall.getOcs().getData().getToken()); - bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId()); - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), - Parcels.wrap(roomOverall.getOcs().getData())); + @Override + public void onError(Throwable e) { - ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(), - roomOverall.getOcs().getData().getToken(), bundle, true); - } - } + } - @Override - public void onError(Throwable e) { + @Override + public void onComplete() { - } - - @Override - public void onComplete() { - - } - }); + } + }); } else { Participant participant = ((UserItem) adapter.getItem(position)).getModel(); participant.setSelected(!participant.isSelected()); @@ -946,17 +912,17 @@ public class ContactsController extends BaseController implements SearchView.OnQ } if (CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "last-room-activity") - && !CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "invite-groups-and-mails") && - "groups".equals(((UserItem) adapter.getItem(position)).getModel().getSource()) && - participant.isSelected() && - adapter.getSelectedItemCount() > 1) { + && !CapabilitiesUtil.hasSpreedFeatureCapability(currentUser, "invite-groups-and-mails") && + "groups".equals(((UserItem) adapter.getItem(position)).getModel().getSource()) && + participant.isSelected() && + adapter.getSelectedItemCount() > 1) { List currentItems = adapter.getCurrentItems(); Participant internalParticipant; for (int i = 0; i < currentItems.size(); i++) { internalParticipant = currentItems.get(i).getModel(); if (internalParticipant.getActorId().equals(participant.getActorId()) && - internalParticipant.getActorType() == Participant.ActorType.GROUPS && - internalParticipant.isSelected()) { + internalParticipant.getActorType() == Participant.ActorType.GROUPS && + internalParticipant.isSelected()) { internalParticipant.setSelected(false); selectedGroupIds.remove(internalParticipant.getActorId()); } @@ -977,7 +943,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ Bundle bundle = new Bundle(); bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 10); - prepareAndShowBottomSheetWithBundle(bundle, true); + prepareAndShowBottomSheetWithBundle(bundle); } @Optional @@ -999,7 +965,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ if (currentItems.get(i) instanceof UserItem) { internalParticipant = ((UserItem) currentItems.get(i)).getModel(); if (internalParticipant.getActorType() == Participant.ActorType.GROUPS && - internalParticipant.isSelected()) { + internalParticipant.isSelected()) { internalParticipant.setSelected(false); selectedGroupIds.remove(internalParticipant.getActorId()); } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index bb32c3d4a..bdce56b72 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -43,6 +43,8 @@ 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; import com.nextcloud.talk.models.database.UserEntity; @@ -291,7 +293,7 @@ public class OperationsMenuController extends BaseController { 5: clear password 6: set password 8: make private - 10: create conversation ?? + 10: get/join room 11: invite users to conversation 96: set chat read marker 97: remove favorite @@ -752,10 +754,7 @@ public class OperationsMenuController extends BaseController { bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), Parcels.wrap(conversation)); bundle.putString(BundleKeys.INSTANCE.getKEY_CONVERSATION_PASSWORD(), callPassword); - if (getParentController() != null) { - ConductorRemapping.INSTANCE.remapChatController(getParentController().getRouter(), currentUser.getId(), - conversation.getToken(), bundle, true); - } + eventBus.post(new OpenConversationEvent(conversation, bundle)); } private void handleObserverError(@io.reactivex.annotations.NonNull Throwable e) { diff --git a/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt b/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt new file mode 100644 index 000000000..977a0c571 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt @@ -0,0 +1,52 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2019 Mario Danic + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.talk.events + +import android.os.Bundle +import com.nextcloud.talk.models.json.conversations.Conversation + +class OpenConversationEvent { + var conversation : Conversation? = null + var bundle : Bundle? = null + + constructor(conversation: Conversation?, bundle: Bundle?) { + this.conversation = conversation + this.bundle = bundle + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as OpenConversationEvent + + if (conversation != other.conversation) return false + if (bundle != other.bundle) return false + + return true + } + + override fun hashCode(): Int { + var result = conversation?.hashCode() ?: 0 + result = 31 * result + (bundle?.hashCode() ?: 0) + return result + } +} diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt new file mode 100644 index 000000000..71e2ebe94 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt @@ -0,0 +1,62 @@ +package com.nextcloud.talk.ui.dialog + +import android.app.Activity +import android.os.Bundle +import android.view.View +import android.view.ViewGroup +import autodagger.AutoInjector +import com.bluelinelabs.conductor.Conductor +import com.bluelinelabs.conductor.Router +import com.bluelinelabs.conductor.RouterTransaction +import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler +import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.nextcloud.talk.R +import com.nextcloud.talk.application.NextcloudTalkApplication +import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController +import com.nextcloud.talk.databinding.DialogBottomContactsBinding + +@AutoInjector(NextcloudTalkApplication::class) +class ContactsBottomDialog( + val activity: Activity, + val bundle: Bundle +) : BottomSheetDialog(activity) { + + private var dialogRouter: Router? = null + + private lateinit var binding: DialogBottomContactsBinding + + init { + NextcloudTalkApplication.sharedApplication?.componentApplication?.inject(this) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = DialogBottomContactsBinding.inflate(layoutInflater) + setContentView(binding.root) + window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + + executeEntryMenuController(bundle) + } + + private fun executeEntryMenuController(bundle : Bundle) { + dialogRouter = Conductor.attachRouter(activity, binding.root, null) + + dialogRouter!!.pushController( + RouterTransaction.with(EntryMenuController(bundle)) + .pushChangeHandler(HorizontalChangeHandler()) + .popChangeHandler(HorizontalChangeHandler()) + ) + } + + override fun onStart() { + super.onStart() + val bottomSheet = findViewById(R.id.design_bottom_sheet) + val behavior = BottomSheetBehavior.from(bottomSheet as View) + behavior.state = BottomSheetBehavior.STATE_EXPANDED + } + + companion object { + private const val TAG = "ContactsBottomDialog" + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_bottom_contacts.xml b/app/src/main/res/layout/dialog_bottom_contacts.xml new file mode 100644 index 000000000..393e4fb17 --- /dev/null +++ b/app/src/main/res/layout/dialog_bottom_contacts.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_conversation_operations.xml b/app/src/main/res/layout/dialog_conversation_operations.xml index eabf675d9..7cfc54b08 100644 --- a/app/src/main/res/layout/dialog_conversation_operations.xml +++ b/app/src/main/res/layout/dialog_conversation_operations.xml @@ -10,37 +10,6 @@ android:paddingEnd="@dimen/standard_padding" android:paddingBottom="@dimen/standard_half_padding"> - - - - - - - - - - - Date: Sat, 12 Feb 2022 01:11:19 +0100 Subject: [PATCH 10/34] remove dependency com.github.Kennyc1012:BottomSheet Signed-off-by: Marcel Hibbe --- app/build.gradle | 1 - .../com/nextcloud/talk/controllers/ContactsController.java | 7 ------- app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/styles.xml | 2 +- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8dd4275c6..c1b42c427 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -266,7 +266,6 @@ dependencies { implementation 'com.novoda:merlin:1.2.1' - implementation 'com.github.Kennyc1012:BottomSheet:2.4.1' implementation 'com.github.nextcloud:PopupBubble:1.0.6' implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index 9c8fbcc7a..7c9b095ae 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -38,19 +38,14 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; -import com.bluelinelabs.conductor.RouterTransaction; -import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler; import com.bluelinelabs.logansquare.LoganSquare; -import com.kennyc.bottomsheet.BottomSheet; import com.nextcloud.talk.R; import com.nextcloud.talk.adapters.items.GenericTextHeaderItem; 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.EntryMenuController; import com.nextcloud.talk.events.OpenConversationEvent; -import com.nextcloud.talk.events.PeerConnectionEvent; import com.nextcloud.talk.jobs.AddParticipantsToConversation; import com.nextcloud.talk.models.RetrofitBucket; import com.nextcloud.talk.models.database.CapabilitiesUtil; @@ -166,8 +161,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ private Disposable cacheQueryDisposable; private FlexibleAdapter adapter; private List contactItems; - private BottomSheet bottomSheet; - private View view; private SmoothScrollLinearLayoutManager layoutManager; diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 59b913073..9aaae6ed5 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -24,6 +24,7 @@ 72dp 56dp + 16dp 48dp 48dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b10c1bedf..97de6e786 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -72,7 +72,7 @@ 12sp - From 01ce8ea20f46b670795aa09eacbf5ed4893937a0 Mon Sep 17 00:00:00 2001 From: drone Date: Sat, 12 Feb 2022 00:14:59 +0000 Subject: [PATCH 11/34] Drone: update FindBugs results to reflect reduced error/warning count [skip ci] Signed-off-by: drone --- scripts/analysis/findbugs-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index 4a722e9c7..8be84ab6b 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -552 \ No newline at end of file +544 \ No newline at end of file From d70ac8fe8b13288d402bb019bf10fc5a78d1413b Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sat, 12 Feb 2022 14:26:31 +0100 Subject: [PATCH 12/34] make bottom sheets dark/light themed Signed-off-by: Andy Scherzinger --- .../res/layout/dialog_bottom_contacts.xml | 27 ++++++- .../layout/dialog_conversation_operations.xml | 81 ++++++++++++------- app/src/main/res/values/dimens.xml | 2 +- 3 files changed, 74 insertions(+), 36 deletions(-) diff --git a/app/src/main/res/layout/dialog_bottom_contacts.xml b/app/src/main/res/layout/dialog_bottom_contacts.xml index 393e4fb17..fcb75b6a7 100644 --- a/app/src/main/res/layout/dialog_bottom_contacts.xml +++ b/app/src/main/res/layout/dialog_bottom_contacts.xml @@ -1,13 +1,32 @@ + - \ No newline at end of file + diff --git a/app/src/main/res/layout/dialog_conversation_operations.xml b/app/src/main/res/layout/dialog_conversation_operations.xml index 7cfc54b08..a267d4efe 100644 --- a/app/src/main/res/layout/dialog_conversation_operations.xml +++ b/app/src/main/res/layout/dialog_conversation_operations.xml @@ -1,19 +1,40 @@ + + tools:text="conversation name" /> @@ -71,11 +92,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_add_to_favorites" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -98,11 +119,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_mark_as_read" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -125,11 +146,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_rename" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -152,11 +173,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_make_call_public" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -179,11 +200,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_change_password" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -206,11 +227,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_clear_password" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -233,11 +254,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_set_password" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -260,11 +281,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_delete_call" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -287,11 +308,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_share_link" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -314,11 +335,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_make_call_private" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> @@ -341,16 +362,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start|center_vertical" - android:paddingStart="@dimen/standard_double_padding" + android:paddingStart="40dp" android:paddingEnd="@dimen/zero" android:text="@string/nc_leave" android:textAlignment="viewStart" - android:textColor="@color/high_emphasis_text_dark_background" + android:textColor="@color/high_emphasis_text" android:textSize="@dimen/bottom_sheet_text_size" /> - - - \ No newline at end of file + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 9aaae6ed5..2bcef5826 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -24,7 +24,7 @@ 72dp 56dp - 16dp + 16sp 48dp 48dp From 4fb61ed046874c18dcd55b4de05272f9263a1040 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sat, 12 Feb 2022 14:56:18 +0100 Subject: [PATCH 13/34] improve detekt score Signed-off-by: Andy Scherzinger --- .../firebase/MagicFirebaseMessagingService.kt | 4 ++- .../nextcloud/talk/activities/MainActivity.kt | 24 ++++++++++++----- .../talk/controllers/ChatController.kt | 14 ++++++++-- .../controllers/ConversationInfoController.kt | 20 ++++++++++++++ .../controllers/base/ButterKnifeController.kt | 4 ++- .../ui/bottom/sheet/ProfileBottomSheet.kt | 2 ++ .../dialog/ConversationsListBottomDialog.kt | 27 ++++++++++++------- 7 files changed, 76 insertions(+), 19 deletions(-) diff --git a/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt b/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt index 1cb242863..ea55052db 100644 --- a/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt +++ b/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt @@ -304,7 +304,9 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() { } } - override fun onError(e: Throwable) {} + override fun onError(e: Throwable) { + // unused atm + } override fun onComplete() { stopForeground(true) handler.removeCallbacksAndMessages(null) diff --git a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt index de8dbf73b..7089d6304 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt @@ -246,7 +246,9 @@ class MainActivity : BaseActivity(), ActionBarProvider { .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(object : Observer { - override fun onSubscribe(d: Disposable) {} + override fun onSubscribe(d: Disposable) { + // unused atm + } override fun onNext(roomOverall: RoomOverall) { val bundle = Bundle() bundle.putParcelable(KEY_USER_ENTITY, currentUser) @@ -265,7 +267,9 @@ class MainActivity : BaseActivity(), ActionBarProvider { .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(object : Observer { - override fun onSubscribe(d: Disposable) {} + override fun onSubscribe(d: Disposable) { + // unused atm + } override fun onNext(roomOverall: RoomOverall) { bundle.putParcelable( KEY_ACTIVE_CONVERSATION, @@ -277,13 +281,21 @@ class MainActivity : BaseActivity(), ActionBarProvider { ) } - override fun onError(e: Throwable) {} - override fun onComplete() {} + override fun onError(e: Throwable) { + // unused atm + } + override fun onComplete() { + // unused atm + } }) } - override fun onError(e: Throwable) {} - override fun onComplete() {} + override fun onError(e: Throwable) { + // unused atm + } + override fun onComplete() { + // unused atm + } }) } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 4c99a1ddf..6d2af213b 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -346,6 +346,7 @@ class ChatController(args: Bundle) : } override fun onError(e: Throwable) { + // unused atm } override fun onComplete() { @@ -388,9 +389,11 @@ class ChatController(args: Bundle) : } override fun onError(e: Throwable) { + // unused atm } override fun onComplete() { + // unused atm } }) } @@ -665,6 +668,7 @@ class ChatController(args: Bundle) : } override fun afterTextChanged(s: Editable) { + // unused atm } }) @@ -1261,7 +1265,9 @@ class ChatController(args: Bundle) : UploadAndShareFilesWorker.requestStoragePermission(this) } } - .setNegativeButton(R.string.nc_no) {} + .setNegativeButton(R.string.nc_no) { + // unused atm + } .show() } catch (e: IllegalStateException) { Toast.makeText(context, context?.resources?.getString(R.string.nc_upload_failed), Toast.LENGTH_LONG) @@ -1693,9 +1699,11 @@ class ChatController(args: Bundle) : } override fun onError(e: Throwable) { + // unused atm } override fun onComplete() { + // unused atm } }) } else { @@ -1759,7 +1767,9 @@ class ChatController(args: Bundle) : } } - override fun onError(e: Throwable) {} + override fun onError(e: Throwable) { + // unused atm + } override fun onComplete() { dispose() diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt index 65b7cd90b..37ab07ee8 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt @@ -287,15 +287,19 @@ class ConversationInfoController(args: Bundle) : ?.observeOn(AndroidSchedulers.mainThread()) ?.subscribe(object : Observer { override fun onComplete() { + // unused atm } override fun onSubscribe(d: Disposable) { + // unused atm } override fun onNext(t: GenericOverall) { + // unused atm } override fun onError(e: Throwable) { + // unused atm } }) } @@ -305,6 +309,7 @@ class ConversationInfoController(args: Bundle) : ID_DELETE_CONVERSATION_DIALOG -> showDeleteConversationDialog(savedInstanceState) ID_CLEAR_CHAT_DIALOG -> showClearHistoryDialog(savedInstanceState) else -> { + // unused atm } } } @@ -444,6 +449,7 @@ class ConversationInfoController(args: Bundle) : } override fun onError(e: Throwable) { + // unused atm } override fun onComplete() { @@ -525,6 +531,7 @@ class ConversationInfoController(args: Bundle) : ?.observeOn(AndroidSchedulers.mainThread()) ?.subscribe(object : Observer { override fun onSubscribe(d: Disposable) { + // unused atm } override fun onNext(genericOverall: GenericOverall) { @@ -538,6 +545,7 @@ class ConversationInfoController(args: Bundle) : } override fun onComplete() { + // unused atm } }) } @@ -647,6 +655,7 @@ class ConversationInfoController(args: Bundle) : } override fun onError(e: Throwable) { + // unused atm } override fun onComplete() { @@ -731,6 +740,7 @@ class ConversationInfoController(args: Bundle) : } else -> { + // unused atm } } } @@ -738,6 +748,7 @@ class ConversationInfoController(args: Bundle) : private fun toggleModeratorStatus(apiVersion: Int, participant: Participant) { val subscriber = object : Observer { override fun onSubscribe(d: Disposable) { + // unused atm } override fun onNext(genericOverall: GenericOverall) { @@ -750,6 +761,7 @@ class ConversationInfoController(args: Bundle) : } override fun onComplete() { + // unused atm } } @@ -789,6 +801,7 @@ class ConversationInfoController(args: Bundle) : private fun toggleModeratorStatusLegacy(apiVersion: Int, participant: Participant) { val subscriber = object : Observer { override fun onSubscribe(d: Disposable) { + // unused atm } override fun onNext(genericOverall: GenericOverall) { @@ -801,6 +814,7 @@ class ConversationInfoController(args: Bundle) : } override fun onComplete() { + // unused atm } } @@ -848,6 +862,7 @@ class ConversationInfoController(args: Bundle) : ?.observeOn(AndroidSchedulers.mainThread()) ?.subscribe(object : Observer { override fun onSubscribe(d: Disposable) { + // unused atm } override fun onNext(genericOverall: GenericOverall) { @@ -860,6 +875,7 @@ class ConversationInfoController(args: Bundle) : } override fun onComplete() { + // unused atm } }) } else { @@ -879,6 +895,7 @@ class ConversationInfoController(args: Bundle) : ?.observeOn(AndroidSchedulers.mainThread()) ?.subscribe(object : Observer { override fun onSubscribe(d: Disposable) { + // unused atm } override fun onNext(genericOverall: GenericOverall) { @@ -891,6 +908,7 @@ class ConversationInfoController(args: Bundle) : } override fun onComplete() { + // unused atm } }) } else { @@ -907,6 +925,7 @@ class ConversationInfoController(args: Bundle) : ?.observeOn(AndroidSchedulers.mainThread()) ?.subscribe(object : Observer { override fun onSubscribe(d: Disposable) { + // unused atm } override fun onNext(genericOverall: GenericOverall) { @@ -919,6 +938,7 @@ class ConversationInfoController(args: Bundle) : } override fun onComplete() { + // unused atm } }) } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/base/ButterKnifeController.kt b/app/src/main/java/com/nextcloud/talk/controllers/base/ButterKnifeController.kt index 1acae2aa3..1226965ac 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/base/ButterKnifeController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/base/ButterKnifeController.kt @@ -46,7 +46,9 @@ abstract class ButterKnifeController : Controller { return view } - protected open fun onViewBound(view: View) {} + protected open fun onViewBound(view: View) { + // unused atm + } override fun onDestroyView(view: View) { super.onDestroyView(view) diff --git a/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt b/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt index d9ed5bb59..54c0611c9 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt @@ -63,6 +63,7 @@ class ProfileBottomSheet(val ncApi: NcApi, val userEntity: UserEntity, val route ).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(object : io.reactivex.Observer { override fun onSubscribe(d: Disposable) { + // unused atm } override fun onNext(hoverCardOverall: HoverCardOverall) { @@ -74,6 +75,7 @@ class ProfileBottomSheet(val ncApi: NcApi, val userEntity: UserEntity, val route } override fun onComplete() { + // unused atm } }) } diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index 82748caa0..6ff98d5d6 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -141,11 +141,11 @@ class ConversationsListBottomDialog( private fun initClickListeners() { binding.conversationOperationAddFavorite.setOnClickListener { - executeOperationsMenuController(98) + executeOperationsMenuController(OPS_CODE_ADD_FAVORITE) } binding.conversationOperationRemoveFavorite.setOnClickListener { - executeOperationsMenuController(97) + executeOperationsMenuController(OPS_CODE_REMOVE_FAVORITE) } binding.conversationOperationLeave.setOnClickListener { @@ -179,27 +179,27 @@ class ConversationsListBottomDialog( } binding.conversationOperationMakePublic.setOnClickListener { - executeOperationsMenuController(3) + executeOperationsMenuController(OPS_CODE_MAKE_PUBLIC) } binding.conversationOperationMakePrivate.setOnClickListener { - executeOperationsMenuController(8) + executeOperationsMenuController(OPS_CODE_MAKE_PRIVATE) } binding.conversationOperationChangePassword.setOnClickListener { - executeEntryMenuController(4) + executeEntryMenuController(OPS_CODE_CHANGE_PASSWORD) } binding.conversationOperationClearPassword.setOnClickListener { - executeOperationsMenuController(5) + executeOperationsMenuController(OPS_CODE_CLEAR_PASSWORD) } binding.conversationOperationSetPassword.setOnClickListener { - executeEntryMenuController(6) + executeEntryMenuController(OPS_CODE_SET_PASSWORD) } binding.conversationOperationRename.setOnClickListener { - executeEntryMenuController(2) + executeEntryMenuController(OPS_CODE_RENAME) } binding.conversationOperationShareLink.setOnClickListener { @@ -277,5 +277,14 @@ 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 } -} \ No newline at end of file +} From 66795bb48bb17ad00a4a7e6af7a5507dd70221e4 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sun, 13 Feb 2022 12:21:57 +0100 Subject: [PATCH 14/34] correct code formatting and license header added Signed-off-by: Andy Scherzinger --- .../talk/events/OpenConversationEvent.kt | 4 ++-- .../talk/ui/dialog/ContactsBottomDialog.kt | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt b/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt index 977a0c571..7bc8b6849 100644 --- a/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt +++ b/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt @@ -24,8 +24,8 @@ import android.os.Bundle import com.nextcloud.talk.models.json.conversations.Conversation class OpenConversationEvent { - var conversation : Conversation? = null - var bundle : Bundle? = null + var conversation: Conversation? = null + var bundle: Bundle? = null constructor(conversation: Conversation?, bundle: Bundle?) { this.conversation = conversation diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt index 71e2ebe94..2d24772c2 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt @@ -1,3 +1,23 @@ +/* + * Nextcloud Talk application + * + * @author Marcel Hibbe + * Copyright (C) 2022 Marcel Hibbe + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.nextcloud.talk.ui.dialog import android.app.Activity @@ -39,7 +59,7 @@ class ContactsBottomDialog( executeEntryMenuController(bundle) } - private fun executeEntryMenuController(bundle : Bundle) { + private fun executeEntryMenuController(bundle: Bundle) { dialogRouter = Conductor.attachRouter(activity, binding.root, null) dialogRouter!!.pushController( @@ -59,4 +79,4 @@ class ContactsBottomDialog( companion object { private const val TAG = "ContactsBottomDialog" } -} \ No newline at end of file +} From 4335e44701c87a3e09d899bc15d3e8e7728e6585 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 14 Feb 2022 13:55:45 +0100 Subject: [PATCH 15/34] replace operationCode's (int) by Enums Signed-off-by: Marcel Hibbe --- .../talk/controllers/ContactsController.java | 5 +- .../ConversationsListController.java | 3 +- .../bottomsheet/ConversationOperationEnum.kt | 17 +++++ .../bottomsheet/EntryMenuController.java | 49 +++++++------ .../bottomsheet/OperationsMenuController.java | 70 +++++++------------ .../talk/jobs/LeaveConversationWorker.java | 6 +- .../dialog/ConversationsListBottomDialog.kt | 37 +++++----- 7 files changed, 93 insertions(+), 94 deletions(-) create mode 100644 app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index 7c9b095ae..ebe8b4f94 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/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); } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 86e7b920a..3717b5f8e 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/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); diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt new file mode 100644 index 000000000..238e9006a --- /dev/null +++ b/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?! +} \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java index e57318f31..a3a5866f4 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java +++ b/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); diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index bdce56b72..2b5638e4a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/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(); diff --git a/app/src/main/java/com/nextcloud/talk/jobs/LeaveConversationWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/LeaveConversationWorker.java index 5ddab19f3..826e3b7f8 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/LeaveConversationWorker.java +++ b/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 diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index 6ff98d5d6..a50fe4bd7 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/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 } } From 6bc5d324b5f4fa7452cde3263b427397061ef03c Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 14 Feb 2022 17:50:13 +0100 Subject: [PATCH 16/34] fix to show searchbar after bottom dialog operations Signed-off-by: Marcel Hibbe --- .../talk/controllers/ConversationsListController.java | 1 + .../controllers/bottomsheet/OperationsMenuController.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 3717b5f8e..ec9ff0da3 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -452,6 +452,7 @@ public class ConversationsListController extends BaseController implements Searc return false; } + @Override protected void showSearchOrToolbar() { if (TextUtils.isEmpty(searchQuery)) { super.showSearchOrToolbar(); diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index 2b5638e4a..faf8f78f6 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -807,4 +807,9 @@ public class OperationsMenuController extends BaseController { dispose(); } } + + @Override + public AppBarLayoutType getAppBarLayoutType() { + return AppBarLayoutType.SEARCH_BAR; + } } From 4c882f4f41148432734139c3c9930cec3e708e5a Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 14 Feb 2022 18:17:16 +0100 Subject: [PATCH 17/34] fix light theme color for Entry menu box Signed-off-by: Marcel Hibbe --- app/src/main/res/layout/controller_entry_menu.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/controller_entry_menu.xml b/app/src/main/res/layout/controller_entry_menu.xml index c743fc656..8b0a08bf8 100644 --- a/app/src/main/res/layout/controller_entry_menu.xml +++ b/app/src/main/res/layout/controller_entry_menu.xml @@ -52,7 +52,9 @@ android:layout_marginEnd="@dimen/standard_half_margin" android:layout_toStartOf="@id/smileyButton" app:errorTextAppearance="@style/ErrorAppearance" - app:passwordToggleTint="@color/grey_600"> + app:passwordToggleTint="@color/grey_600" + app:boxStrokeColor="@color/colorPrimary" + app:hintTextColor="@color/colorPrimary"> Date: Mon, 14 Feb 2022 18:23:54 +0100 Subject: [PATCH 18/34] fix to show searchbar after bottom dialog textinput Signed-off-by: Marcel Hibbe --- .../talk/controllers/bottomsheet/EntryMenuController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java index a3a5866f4..97d6020ae 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java @@ -338,4 +338,9 @@ public class EntryMenuController extends BaseController { textInputLayout.setHint(labelText); textInputLayout.requestFocus(); } + + @Override + public AppBarLayoutType getAppBarLayoutType() { + return AppBarLayoutType.SEARCH_BAR; + } } From 8ea9663d5e98b2aae358c2e039af29d2973142f4 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 14 Feb 2022 18:48:52 +0100 Subject: [PATCH 19/34] fix to fetch conversations list after executing bottom sheet operations BottomSheetLockEvent was only used for old bottom dialog with "kennyc" lib instead ConversationsListFetchDataEvent.kt is now used to fetch the data in ConversationsListController whenever needed Signed-off-by: Marcel Hibbe --- .../ConversationsListController.java | 6 + .../bottomsheet/EntryMenuController.java | 6 - .../bottomsheet/OperationsMenuController.java | 18 +-- .../talk/events/BottomSheetLockEvent.java | 116 ------------------ .../events/ConversationsListFetchDataEvent.kt | 23 ++++ 5 files changed, 34 insertions(+), 135 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/events/BottomSheetLockEvent.java create mode 100644 app/src/main/java/com/nextcloud/talk/events/ConversationsListFetchDataEvent.kt diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index ec9ff0da3..160489447 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -72,6 +72,7 @@ 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.ConversationsListFetchDataEvent; import com.nextcloud.talk.events.EventStatus; import com.nextcloud.talk.interfaces.ConversationMenuInterface; import com.nextcloud.talk.jobs.AccountRemovalWorker; @@ -1063,6 +1064,11 @@ public class ConversationsListController extends BaseController implements Searc } } + @Subscribe(threadMode = ThreadMode.BACKGROUND) + public void onMessageEvent(ConversationsListFetchDataEvent conversationsListFetchDataEvent) { + fetchData(); + } + private void showDeleteConversationDialog(Bundle savedInstanceState) { if (getActivity() != null && conversationMenuBundle != null && currentUser != null && conversationMenuBundle.getLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID()) == currentUser.getId()) { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java index 97d6020ae..041ec7525 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java @@ -41,7 +41,6 @@ import com.google.android.material.textfield.TextInputLayout; import com.nextcloud.talk.R; import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.controllers.base.BaseController; -import com.nextcloud.talk.events.BottomSheetLockEvent; import com.nextcloud.talk.models.json.conversations.Conversation; import com.nextcloud.talk.utils.EmojiTextInputEditText; import com.nextcloud.talk.utils.ShareUtils; @@ -144,7 +143,6 @@ public class EntryMenuController extends BaseController { public void onProceedButtonClick() { Bundle bundle; 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); @@ -158,7 +156,6 @@ public class EntryMenuController extends BaseController { .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); } 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 (operation == ConversationOperationEnum.CHANGE_PASSWORD || operation == ConversationOperationEnum.SET_PASSWORD) { conversation.setPassword(editText.getText().toString()); @@ -178,10 +175,8 @@ public class EntryMenuController extends BaseController { intent.setComponent(new ComponentName(packageName, name)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getActivity().startActivity(intent); - eventBus.post(new BottomSheetLockEvent(true, 0, false, true)); } } else if (operation != ConversationOperationEnum.INVITE_USERS) { - eventBus.post(new BottomSheetLockEvent(false, 0, false, false)); bundle = new Bundle(); bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), operation); bundle.putString(BundleKeys.INSTANCE.getKEY_CALL_URL(), editText.getText().toString()); @@ -190,7 +185,6 @@ public class EntryMenuController extends BaseController { .popChangeHandler(new HorizontalChangeHandler())); } 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)) .pushChangeHandler(new HorizontalChangeHandler()) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index faf8f78f6..ecec5116a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -41,7 +41,7 @@ import com.nextcloud.talk.R; 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.ConversationsListFetchDataEvent; import com.nextcloud.talk.events.OpenConversationEvent; import com.nextcloud.talk.models.RetrofitBucket; import com.nextcloud.talk.models.database.CapabilitiesUtil; @@ -337,8 +337,7 @@ public class OperationsMenuController extends BaseController { public void onNext(@io.reactivex.annotations.NonNull RoomOverall roomOverall) { conversation = roomOverall.getOcs().getData(); if (conversation.isHasPassword() && conversation.isGuest()) { - eventBus.post(new BottomSheetLockEvent(true, 0, - true, false)); + eventBus.post(new ConversationsListFetchDataEvent()); Bundle bundle = new Bundle(); bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation)); bundle.putString(BundleKeys.INSTANCE.getKEY_CALL_URL(), callUrl); @@ -553,10 +552,8 @@ public class OperationsMenuController extends BaseController { } else { resultsTextView.setText(R.string.nc_failed_signaling_settings); webButton.setOnClickListener(v -> { - eventBus.post(new BottomSheetLockEvent(true, 0, false, true)); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(callUrl)); startActivity(browserIntent); - new BottomSheetLockEvent(true, 0, false, true); }); webButton.setVisibility(View.VISIBLE); } @@ -564,13 +561,11 @@ public class OperationsMenuController extends BaseController { resultsTextView.setVisibility(View.VISIBLE); if (everythingOK) { - eventBus.post(new BottomSheetLockEvent(true, 2500, true, true)); + eventBus.post(new ConversationsListFetchDataEvent()); } 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, - operation != ConversationOperationEnum.JOIN_ROOM - && operation != ConversationOperationEnum.GET_JOIN_ROOM, true))); + okButton.setOnClickListener(v -> eventBus.post(new ConversationsListFetchDataEvent())); okButton.setVisibility(View.VISIBLE); } } @@ -721,8 +716,7 @@ public class OperationsMenuController extends BaseController { } private void initiateConversation(boolean dismissView) { - eventBus.post(new BottomSheetLockEvent(true, 0, - true, true, dismissView)); + eventBus.post(new ConversationsListFetchDataEvent()); Bundle bundle = new Bundle(); bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), conversation.getToken()); @@ -741,8 +735,6 @@ public class OperationsMenuController extends BaseController { } else { Response response = ((HttpException) e).response(); if (response != null && response.code() == 403) { - eventBus.post(new BottomSheetLockEvent(true, 0, false, - false)); ApplicationWideMessageHolder.getInstance().setMessageType(ApplicationWideMessageHolder.MessageType.CALL_PASSWORD_WRONG); getRouter().popCurrentController(); } else { diff --git a/app/src/main/java/com/nextcloud/talk/events/BottomSheetLockEvent.java b/app/src/main/java/com/nextcloud/talk/events/BottomSheetLockEvent.java deleted file mode 100644 index b9c61e487..000000000 --- a/app/src/main/java/com/nextcloud/talk/events/BottomSheetLockEvent.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017 Mario Danic - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.events; - -public class BottomSheetLockEvent { - private final boolean cancelable; - private final int delay; - private final boolean shouldRefreshData; - private final boolean cancel; - private boolean dismissView; - - public BottomSheetLockEvent(boolean cancelable, int delay, boolean shouldRefreshData, boolean cancel) { - this.cancelable = cancelable; - this.delay = delay; - this.shouldRefreshData = shouldRefreshData; - this.cancel = cancel; - this.dismissView = true; - } - - public BottomSheetLockEvent(boolean cancelable, int delay, boolean shouldRefreshData, boolean cancel, boolean - dismissView) { - this.cancelable = cancelable; - this.delay = delay; - this.shouldRefreshData = shouldRefreshData; - this.cancel = cancel; - this.dismissView = dismissView; - } - - public boolean isCancelable() { - return this.cancelable; - } - - public int getDelay() { - return this.delay; - } - - public boolean isShouldRefreshData() { - return this.shouldRefreshData; - } - - public boolean isCancel() { - return this.cancel; - } - - public boolean isDismissView() { - return this.dismissView; - } - - public void setDismissView(boolean dismissView) { - this.dismissView = dismissView; - } - - public boolean equals(final Object o) { - if (o == this) { - return true; - } - if (!(o instanceof BottomSheetLockEvent)) { - return false; - } - final BottomSheetLockEvent other = (BottomSheetLockEvent) o; - if (!other.canEqual((Object) this)) { - return false; - } - if (this.isCancelable() != other.isCancelable()) { - return false; - } - if (this.getDelay() != other.getDelay()) { - return false; - } - if (this.isShouldRefreshData() != other.isShouldRefreshData()) { - return false; - } - if (this.isCancel() != other.isCancel()) { - return false; - } - - return this.isDismissView() == other.isDismissView(); - } - - protected boolean canEqual(final Object other) { - return other instanceof BottomSheetLockEvent; - } - - public int hashCode() { - final int PRIME = 59; - int result = 1; - result = result * PRIME + (this.isCancelable() ? 79 : 97); - result = result * PRIME + this.getDelay(); - result = result * PRIME + (this.isShouldRefreshData() ? 79 : 97); - result = result * PRIME + (this.isCancel() ? 79 : 97); - result = result * PRIME + (this.isDismissView() ? 79 : 97); - return result; - } - - public String toString() { - return "BottomSheetLockEvent(cancelable=" + this.isCancelable() + ", delay=" + this.getDelay() + ", shouldRefreshData=" + this.isShouldRefreshData() + ", cancel=" + this.isCancel() + ", dismissView=" + this.isDismissView() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/events/ConversationsListFetchDataEvent.kt b/app/src/main/java/com/nextcloud/talk/events/ConversationsListFetchDataEvent.kt new file mode 100644 index 000000000..867b10338 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/events/ConversationsListFetchDataEvent.kt @@ -0,0 +1,23 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2019 Mario Danic + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.talk.events + +class ConversationsListFetchDataEvent From 809e27785546701af4cbad5f9ba6f3c079dc19b9 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 14 Feb 2022 19:21:14 +0100 Subject: [PATCH 20/34] rename enum, add todo Signed-off-by: Marcel Hibbe --- .../talk/controllers/ContactsController.java | 2 +- .../ConversationsListController.java | 3 ++- .../bottomsheet/ConversationOperationEnum.kt | 26 +++++++++---------- .../bottomsheet/EntryMenuController.java | 7 +++-- .../bottomsheet/OperationsMenuController.java | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index ebe8b4f94..be290b3f0 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -935,7 +935,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ @OnClick(R.id.joinConversationViaLinkRelativeLayout) void joinConversationViaLink() { Bundle bundle = new Bundle(); - bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), ConversationOperationEnum.GET_JOIN_ROOM); + bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), ConversationOperationEnum.GET_AND_JOIN_ROOM); prepareAndShowBottomSheetWithBundle(bundle); } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 160489447..2c785a3b4 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -803,6 +803,7 @@ public class ConversationsListController extends BaseController implements Searc return onQueryTextChange(query); } + // TODO check when this is executed and if handling is correct private void prepareAndShowBottomSheetWithBundle(Bundle bundle) { if (view == null) { view = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet, null, false); @@ -1020,7 +1021,7 @@ public class ConversationsListController extends BaseController implements Searc bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), selectedConversation.getRoomId()); bundle.putString(BundleKeys.INSTANCE.getKEY_SHARED_TEXT(), textToPaste); - // TODO debug & fix dialog??? + // TODO check when this is executed and if handling is correct // when is hasPassword && ParticipantType.GUEST true? currently the app can't be used as guest?! // when is USER_FOLLOWING_LINK true? --> from contactsController via enter link? if ((selectedConversation.hasPassword diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt index 238e9006a..d20253a86 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt @@ -1,17 +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?! + RENAME_ROOM, + MAKE_PUBLIC, + CHANGE_PASSWORD, + CLEAR_PASSWORD, + SET_PASSWORD, + SHARE_LINK, + MAKE_PRIVATE, + GET_AND_JOIN_ROOM, + INVITE_USERS, + MARK_AS_READ, + REMOVE_FAVORITE, + ADD_FAVORITE, + JOIN_ROOM } \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java index 041ec7525..e3bbb4f7d 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java @@ -155,7 +155,7 @@ public class EntryMenuController extends BaseController { getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)) .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); - } else if (operation != ConversationOperationEnum.SHARE_LINK && operation != ConversationOperationEnum.GET_JOIN_ROOM && operation != ConversationOperationEnum.INVITE_USERS) { + } else if (operation != ConversationOperationEnum.SHARE_LINK && operation != ConversationOperationEnum.GET_AND_JOIN_ROOM && operation != ConversationOperationEnum.INVITE_USERS) { bundle = new Bundle(); if (operation == ConversationOperationEnum.CHANGE_PASSWORD || operation == ConversationOperationEnum.SET_PASSWORD) { conversation.setPassword(editText.getText().toString()); @@ -238,7 +238,7 @@ public class EntryMenuController extends BaseController { } textInputLayout.setError(getResources().getString(R.string.nc_call_name_is_same)); } - } else if (operation != ConversationOperationEnum.GET_JOIN_ROOM) { + } else if (operation != ConversationOperationEnum.GET_AND_JOIN_ROOM) { if (!proceedButton.isEnabled()) { proceedButton.setEnabled(true); proceedButton.setAlpha(1.0f); @@ -247,7 +247,6 @@ public class EntryMenuController extends BaseController { } else if ((editText.getText().toString().startsWith("http://") || editText.getText().toString().startsWith("https://")) && editText.getText().toString().contains("/call/")) { - // operation code 10 if (!proceedButton.isEnabled()) { proceedButton.setEnabled(true); proceedButton.setAlpha(1.0f); @@ -312,7 +311,7 @@ public class EntryMenuController extends BaseController { labelText = getResources().getString(R.string.nc_password); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); break; - case GET_JOIN_ROOM: + case GET_AND_JOIN_ROOM: labelText = getResources().getString(R.string.nc_conversation_link); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); break; diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index ecec5116a..61729db49 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -322,7 +322,7 @@ public class OperationsMenuController extends BaseController { .retry(1) .subscribe(genericOperationsObserver); break; - case GET_JOIN_ROOM: + case GET_AND_JOIN_ROOM: ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, baseUrl, conversationToken)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) From dcdd0b7b0a9ffed7483969ae5c02de011567d47b Mon Sep 17 00:00:00 2001 From: drone Date: Mon, 14 Feb 2022 18:34:16 +0000 Subject: [PATCH 21/34] Drone: update FindBugs results to reflect reduced error/warning count [skip ci] Signed-off-by: drone --- scripts/analysis/findbugs-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index 8be84ab6b..28621d35a 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -544 \ No newline at end of file +542 \ No newline at end of file From c5abe75a2549db75986fe1b9f0771779ed3afcfc Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 15 Feb 2022 10:23:15 +0100 Subject: [PATCH 22/34] remove unused resource and remove useless parent layout element Signed-off-by: Andy Scherzinger --- .../drawable/ic_mimetype_folder_starred.xml | 34 -- .../layout/dialog_conversation_operations.xml | 570 +++++++++--------- 2 files changed, 281 insertions(+), 323 deletions(-) delete mode 100755 app/src/main/res/drawable/ic_mimetype_folder_starred.xml diff --git a/app/src/main/res/drawable/ic_mimetype_folder_starred.xml b/app/src/main/res/drawable/ic_mimetype_folder_starred.xml deleted file mode 100755 index e836f7cac..000000000 --- a/app/src/main/res/drawable/ic_mimetype_folder_starred.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_conversation_operations.xml b/app/src/main/res/layout/dialog_conversation_operations.xml index a267d4efe..026bb455c 100644 --- a/app/src/main/res/layout/dialog_conversation_operations.xml +++ b/app/src/main/res/layout/dialog_conversation_operations.xml @@ -31,345 +31,337 @@ android:paddingEnd="@dimen/standard_padding" android:paddingBottom="@dimen/standard_half_padding"> + + + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + android:layout_height="wrap_content" + android:contentDescription="@null" + android:src="@drawable/ic_star_border_black_24dp" + app:tint="@color/grey_600" /> - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_remove_from_favorites" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_add_to_favorites" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_mark_as_read" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_rename" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_make_call_public" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_change_password" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_clear_password" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_set_password" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_delete_call" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_share_link" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_make_call_private" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> + - + - - + - - - - - - - + android:layout_height="wrap_content" + android:layout_gravity="start|center_vertical" + android:paddingStart="40dp" + android:paddingEnd="@dimen/zero" + android:text="@string/nc_leave" + android:textAlignment="viewStart" + android:textColor="@color/high_emphasis_text" + android:textSize="@dimen/bottom_sheet_text_size" /> From 142c36247408a79c925ad0f8473a3ec46f89554c Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 15 Feb 2022 10:29:15 +0100 Subject: [PATCH 23/34] solve detekt issues Signed-off-by: Andy Scherzinger --- .../bottomsheet/ConversationOperationEnum.kt | 22 ++++++++++++++++++- .../dialog/ConversationsListBottomDialog.kt | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt index d20253a86..462ff6fe8 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt @@ -1,3 +1,23 @@ +/* + * Nextcloud Talk application + * + * @author Marcel Hibbe + * Copyright (C) 2022 Marcel Hibbe + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.nextcloud.talk.controllers.bottomsheet enum class ConversationOperationEnum { @@ -14,4 +34,4 @@ enum class ConversationOperationEnum { REMOVE_FAVORITE, ADD_FAVORITE, JOIN_ROOM -} \ No newline at end of file +} diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index a50fe4bd7..ee15a805e 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -128,10 +128,10 @@ class ConversationsListBottomDialog( ) binding.conversationOperationLeave.visibility = setVisibleIf( - conversation.canLeave() + 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) + !conversation.canModerate(currentUser) ) } From 59d821c211b54a2ad221722ba2f3abf1a04d06af Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 15 Feb 2022 12:01:25 +0100 Subject: [PATCH 24/34] revert layout change Signed-off-by: Andy Scherzinger --- .../layout/dialog_conversation_operations.xml | 555 +++++++++--------- 1 file changed, 282 insertions(+), 273 deletions(-) diff --git a/app/src/main/res/layout/dialog_conversation_operations.xml b/app/src/main/res/layout/dialog_conversation_operations.xml index 026bb455c..9915d6349 100644 --- a/app/src/main/res/layout/dialog_conversation_operations.xml +++ b/app/src/main/res/layout/dialog_conversation_operations.xml @@ -41,327 +41,336 @@ tools:text="conversation name" /> - - - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - + - + + - + android:layout_height="@dimen/bottom_sheet_item_height" + android:gravity="center_vertical" + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> + + + + + + From eceb545589903b434cbe7fbb7394a5d98381cee3 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 15 Feb 2022 11:49:20 +0100 Subject: [PATCH 25/34] remove (hopefully unused) code regarding GUEST and USER_FOLLOWING_LINK I can't reproduce or think of scenarios when this code was used. because bottom dialog is replaced it wouldn't work anymore anyway. If there appear scenarios when the code would have executed, it should be fixed similar like ConversationsListBottomDialog was implemented. Signed-off-by: Marcel Hibbe --- .../ConversationsListController.java | 50 ++----------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 2c785a3b4..bb3ad8575 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -803,26 +803,6 @@ public class ConversationsListController extends BaseController implements Searc return onQueryTextChange(query); } - // TODO check when this is executed and if handling is correct - private void prepareAndShowBottomSheetWithBundle(Bundle bundle) { - if (view == null) { - view = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet, null, false); - } - -// if (shouldShowCallMenuController) { -// getChildRouter((ViewGroup) view).setRoot( -// RouterTransaction.with(new CallMenuController(bundle, this)) -// .popChangeHandler(new VerticalChangeHandler()) -// .pushChangeHandler(new VerticalChangeHandler())); -// } else { - getChildRouter((ViewGroup) view).setRoot( - RouterTransaction.with(new EntryMenuController(bundle)) - .popChangeHandler(new VerticalChangeHandler()) - .pushChangeHandler(new VerticalChangeHandler())); - -// } - } - @Override protected String getTitle() { return getResources().getString(R.string.nc_app_product_name); @@ -1017,37 +997,13 @@ public class ConversationsListController extends BaseController implements Searc private void openConversation(String textToPaste) { Bundle bundle = new Bundle(); bundle.putParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY(), currentUser); + bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), Parcels.wrap(selectedConversation)); bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), selectedConversation.getToken()); bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), selectedConversation.getRoomId()); bundle.putString(BundleKeys.INSTANCE.getKEY_SHARED_TEXT(), textToPaste); - // TODO check when this is executed and if handling is correct - // when is hasPassword && ParticipantType.GUEST true? currently the app can't be used as guest?! - // when is USER_FOLLOWING_LINK true? --> from contactsController via enter link? - if ((selectedConversation.hasPassword - && selectedConversation.participantType == Participant.ParticipantType.GUEST) - || selectedConversation.participantType == Participant.ParticipantType.USER_FOLLOWING_LINK) { - bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), ConversationOperationEnum.JOIN_ROOM); - prepareAndShowBottomSheetWithBundle(bundle); - - - // instead to use prepareAnd... - // use something like - // - // conversationOperationDialog = new ConversationOperationDialog( - // getActivity(), - // this, - // userUtils.getCurrentUser(), - // conversation); - // conversationOperationDialog.show(); - - } else { - currentUser = userUtils.getCurrentUser(); - - bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), Parcels.wrap(selectedConversation)); - ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(), - selectedConversation.getToken(), bundle, false); - } + ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(), + selectedConversation.getToken(), bundle, false); } @Subscribe(sticky = true, threadMode = ThreadMode.BACKGROUND) From 2348919d97e2c3cf12c7be0faac5e2d24fe67511 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 15 Feb 2022 14:39:43 +0100 Subject: [PATCH 26/34] modify copyright headers authors Signed-off-by: Marcel Hibbe --- app/src/main/AndroidManifest.xml | 2 ++ .../talk/controllers/ContactsController.java | 4 +++- .../ConversationsListController.java | 2 ++ .../bottomsheet/EntryMenuController.java | 2 ++ .../events/ConversationsListFetchDataEvent.kt | 4 ++-- .../talk/events/OpenConversationEvent.kt | 4 ++-- .../dialog/ConversationsListBottomDialog.kt | 20 +++++++++++++++++++ 7 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cda833251..abbf6b73e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,9 @@ ~ Nextcloud Talk application ~ ~ @author Mario Danic + ~ @author Marcel Hibbe ~ Copyright (C) 2017-2019 Mario Danic + ~ Copyright (C) 2021-2022 Marcel Hibbe ~ ~ This program is free software: you can redistribute it and/or modify ~ it under the terms of the GNU General Public License as published by diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index be290b3f0..4e995192b 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -2,7 +2,9 @@ * Nextcloud Talk application * * @author Mario Danic - * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) + * @author Marcel Hibbe + * Copyright (C) 2017 Mario Danic + * Copyright (C) 2022 Marcel Hibbe * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index bb3ad8575..08fb0ae73 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -3,8 +3,10 @@ * * @author Mario Danic * @author Andy Scherzinger + * @author Marcel Hibbe * Copyright (C) 2021 Andy Scherzinger (info@andy-scherzinger.de) * Copyright (C) 2017-2020 Mario Danic (mario@lovelyhq.com) + * Copyright (C) 2022 Marcel Hibbe (dev@mhibbe.de) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java index e3bbb4f7d..9512ec500 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java @@ -2,7 +2,9 @@ * Nextcloud Talk application * * @author Mario Danic + * @author Marcel Hibbe * Copyright (C) 2017 Mario Danic + * Copyright (C) 2022 Marcel Hibbe * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/app/src/main/java/com/nextcloud/talk/events/ConversationsListFetchDataEvent.kt b/app/src/main/java/com/nextcloud/talk/events/ConversationsListFetchDataEvent.kt index 867b10338..f69e5d1d4 100644 --- a/app/src/main/java/com/nextcloud/talk/events/ConversationsListFetchDataEvent.kt +++ b/app/src/main/java/com/nextcloud/talk/events/ConversationsListFetchDataEvent.kt @@ -1,8 +1,8 @@ /* * Nextcloud Talk application * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic + * @author Marcel Hibbe + * Copyright (C) 2022 Marcel Hibbe * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt b/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt index 7bc8b6849..e1d2e33d8 100644 --- a/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt +++ b/app/src/main/java/com/nextcloud/talk/events/OpenConversationEvent.kt @@ -1,8 +1,8 @@ /* * Nextcloud Talk application * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic + * @author Marcel Hibbe + * Copyright (C) 2022 Marcel Hibbe * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index ee15a805e..96c5e8461 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -1,3 +1,23 @@ +/* + * Nextcloud Talk application + * + * @author Marcel Hibbe + * Copyright (C) 2022 Marcel Hibbe + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.nextcloud.talk.ui.dialog import android.app.Activity From 8e442325ba29a22c24a485e77e97eb55f5968cc0 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 15 Feb 2022 16:12:13 +0100 Subject: [PATCH 27/34] fix lint warnings Signed-off-by: Marcel Hibbe --- .../drawable/ic_mimetype_folder_public.xml | 49 ------------------- .../main/res/layout/controller_call_menu.xml | 33 ------------- .../res/layout/controller_operations_menu.xml | 3 +- app/src/main/res/values/strings.xml | 3 -- 4 files changed, 1 insertion(+), 87 deletions(-) delete mode 100755 app/src/main/res/drawable/ic_mimetype_folder_public.xml delete mode 100644 app/src/main/res/layout/controller_call_menu.xml diff --git a/app/src/main/res/drawable/ic_mimetype_folder_public.xml b/app/src/main/res/drawable/ic_mimetype_folder_public.xml deleted file mode 100755 index 3daf0ff42..000000000 --- a/app/src/main/res/drawable/ic_mimetype_folder_public.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/controller_call_menu.xml b/app/src/main/res/layout/controller_call_menu.xml deleted file mode 100644 index 06a836a81..000000000 --- a/app/src/main/res/layout/controller_call_menu.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/layout/controller_operations_menu.xml b/app/src/main/res/layout/controller_operations_menu.xml index 9ebfb301e..b5e636419 100644 --- a/app/src/main/res/layout/controller_operations_menu.xml +++ b/app/src/main/res/layout/controller_operations_menu.xml @@ -21,8 +21,7 @@ + android:layout_height="wrap_content"> Personal Info - Start a conversation - Configure conversation Leave conversation Delete all messages Do you really want to delete all messages in this conversation? @@ -176,7 +174,6 @@ Change password Clear password Share link - Share link via Make conversation public Make conversation private Delete conversation From 5a2c3b3c5adb3d4b1eb76edf31d2353746809998 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 15 Feb 2022 16:46:39 +0100 Subject: [PATCH 28/34] include dialog header in operation_items_layout would otherwise break some dialog scenarios Signed-off-by: Marcel Hibbe --- .../layout/dialog_conversation_operations.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/res/layout/dialog_conversation_operations.xml b/app/src/main/res/layout/dialog_conversation_operations.xml index 9915d6349..16cc0eee9 100644 --- a/app/src/main/res/layout/dialog_conversation_operations.xml +++ b/app/src/main/res/layout/dialog_conversation_operations.xml @@ -31,15 +31,6 @@ android:paddingEnd="@dimen/standard_padding" android:paddingBottom="@dimen/standard_half_padding"> - - + + Date: Tue, 15 Feb 2022 17:02:24 +0100 Subject: [PATCH 29/34] fix to don't partly hide input dialogs behind keyboard Signed-off-by: Marcel Hibbe --- .../com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt | 2 +- .../talk/ui/dialog/ConversationsListBottomDialog.kt | 2 +- app/src/main/res/values/styles.xml | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt index 2d24772c2..7ceb934e6 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ContactsBottomDialog.kt @@ -40,7 +40,7 @@ import com.nextcloud.talk.databinding.DialogBottomContactsBinding class ContactsBottomDialog( val activity: Activity, val bundle: Bundle -) : BottomSheetDialog(activity) { +) : BottomSheetDialog(activity, R.style.BottomSheetDialogThemeNoFloating) { private var dialogRouter: Router? = null diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index 96c5e8461..d1275e3fd 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -63,7 +63,7 @@ class ConversationsListBottomDialog( val controller: ConversationsListController, val currentUser: UserEntity, val conversation: Conversation -) : BottomSheetDialog(activity) { +) : BottomSheetDialog(activity, R.style.BottomSheetDialogThemeNoFloating) { private var dialogRouter: Router? = null diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 97de6e786..89d41e79b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -235,4 +235,9 @@ #ffffff + + From 9b8ea520248a9d0d420cdc7c19ad61e80a73d3e1 Mon Sep 17 00:00:00 2001 From: drone Date: Tue, 15 Feb 2022 16:54:39 +0000 Subject: [PATCH 30/34] Drone: update Lint results to reflect reduced error/warning count [skip ci] Signed-off-by: drone --- scripts/analysis/lint-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt index cd69b2081..437343559 100644 --- a/scripts/analysis/lint-results.txt +++ b/scripts/analysis/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 1 error and 221 warnings + Lint Report: 1 error and 218 warnings From a22b93f363b008adb9e3f447d98e672f787abc34 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 15 Feb 2022 18:18:57 +0100 Subject: [PATCH 31/34] fix to hide dialog automatically after 2,5 seconds Signed-off-by: Marcel Hibbe --- .../talk/controllers/ConversationsListController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 08fb0ae73..0c3b5f707 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -1023,9 +1023,15 @@ public class ConversationsListController extends BaseController implements Searc } } - @Subscribe(threadMode = ThreadMode.BACKGROUND) + @Subscribe(threadMode = ThreadMode.MAIN) public void onMessageEvent(ConversationsListFetchDataEvent conversationsListFetchDataEvent) { fetchData(); + + new Handler().postDelayed(() -> { + if (conversationsListBottomDialog.isShowing()) { + conversationsListBottomDialog.dismiss(); + } + }, 2500); } private void showDeleteConversationDialog(Bundle savedInstanceState) { From 30b34adaf61d156752a032031b16a20f8055cf9f Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 15 Feb 2022 18:34:42 +0100 Subject: [PATCH 32/34] make ConversationOperationEnum imports static rename enums Signed-off-by: Marcel Hibbe --- .../talk/controllers/ContactsController.java | 7 ++-- .../bottomsheet/ConversationOperationEnum.kt | 26 ++++++------ .../bottomsheet/EntryMenuController.java | 42 ++++++++++--------- .../bottomsheet/OperationsMenuController.java | 37 ++++++++-------- .../dialog/ConversationsListBottomDialog.kt | 17 ++++---- 5 files changed, 67 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index 4e995192b..1fe533983 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -22,6 +22,8 @@ package com.nextcloud.talk.controllers; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.*; + import android.app.SearchManager; import android.content.Context; import android.graphics.PorterDuff; @@ -47,7 +49,6 @@ 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; @@ -379,7 +380,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.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), ConversationOperationEnum.INVITE_USERS); + bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), OPS_CODE_INVITE_USERS); prepareAndShowBottomSheetWithBundle(bundle); } } else { @@ -937,7 +938,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ @OnClick(R.id.joinConversationViaLinkRelativeLayout) void joinConversationViaLink() { Bundle bundle = new Bundle(); - bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), ConversationOperationEnum.GET_AND_JOIN_ROOM); + bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), OPS_CODE_GET_AND_JOIN_ROOM); prepareAndShowBottomSheetWithBundle(bundle); } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt index 462ff6fe8..3cd89a8c6 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/ConversationOperationEnum.kt @@ -21,17 +21,17 @@ package com.nextcloud.talk.controllers.bottomsheet enum class ConversationOperationEnum { - RENAME_ROOM, - MAKE_PUBLIC, - CHANGE_PASSWORD, - CLEAR_PASSWORD, - SET_PASSWORD, - SHARE_LINK, - MAKE_PRIVATE, - GET_AND_JOIN_ROOM, - INVITE_USERS, - MARK_AS_READ, - REMOVE_FAVORITE, - ADD_FAVORITE, - JOIN_ROOM + OPS_CODE_RENAME_ROOM, + OPS_CODE_MAKE_PUBLIC, + OPS_CODE_CHANGE_PASSWORD, + OPS_CODE_CLEAR_PASSWORD, + OPS_CODE_SET_PASSWORD, + OPS_CODE_SHARE_LINK, + OPS_CODE_MAKE_PRIVATE, + OPS_CODE_GET_AND_JOIN_ROOM, + OPS_CODE_INVITE_USERS, + OPS_CODE_MARK_AS_READ, + OPS_CODE_REMOVE_FAVORITE, + OPS_CODE_ADD_FAVORITE, + OPS_CODE_JOIN_ROOM } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java index 9512ec500..7c19d1606 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java @@ -22,6 +22,8 @@ package com.nextcloud.talk.controllers.bottomsheet; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.*; + import android.content.ComponentName; import android.content.Intent; import android.graphics.PorterDuff; @@ -144,7 +146,7 @@ public class EntryMenuController extends BaseController { @OnClick(R.id.ok_button) public void onProceedButtonClick() { Bundle bundle; - if (operation == ConversationOperationEnum.JOIN_ROOM) { + if (operation == OPS_CODE_JOIN_ROOM) { bundle = new Bundle(); bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ROOM(), Parcels.wrap(conversation)); bundle.putString(BundleKeys.INSTANCE.getKEY_CALL_URL(), callUrl); @@ -157,9 +159,9 @@ public class EntryMenuController extends BaseController { getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)) .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); - } else if (operation != ConversationOperationEnum.SHARE_LINK && operation != ConversationOperationEnum.GET_AND_JOIN_ROOM && operation != ConversationOperationEnum.INVITE_USERS) { + } else if (operation != OPS_CODE_SHARE_LINK && operation != OPS_CODE_GET_AND_JOIN_ROOM && operation != OPS_CODE_INVITE_USERS) { bundle = new Bundle(); - if (operation == ConversationOperationEnum.CHANGE_PASSWORD || operation == ConversationOperationEnum.SET_PASSWORD) { + if (operation == OPS_CODE_CHANGE_PASSWORD || operation == OPS_CODE_SET_PASSWORD) { conversation.setPassword(editText.getText().toString()); } else { conversation.setName(editText.getText().toString()); @@ -169,7 +171,7 @@ public class EntryMenuController extends BaseController { getRouter().pushController(RouterTransaction.with(new OperationsMenuController(bundle)) .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); - } else if (operation == ConversationOperationEnum.SHARE_LINK) { + } else if (operation == OPS_CODE_SHARE_LINK) { if (getActivity() != null) { shareIntent.putExtra(Intent.EXTRA_TEXT, ShareUtils.getStringForIntent(getActivity(), editText.getText().toString(), userUtils, conversation)); @@ -178,7 +180,7 @@ public class EntryMenuController extends BaseController { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getActivity().startActivity(intent); } - } else if (operation != ConversationOperationEnum.INVITE_USERS) { + } else if (operation != OPS_CODE_INVITE_USERS) { bundle = new Bundle(); bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), operation); bundle.putString(BundleKeys.INSTANCE.getKEY_CALL_URL(), editText.getText().toString()); @@ -186,7 +188,7 @@ public class EntryMenuController extends BaseController { .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); - } else if (operation == ConversationOperationEnum.INVITE_USERS) { + } else if (operation == OPS_CODE_INVITE_USERS) { originalBundle.putString(BundleKeys.INSTANCE.getKEY_CONVERSATION_NAME(), editText.getText().toString()); getRouter().pushController(RouterTransaction.with(new OperationsMenuController(originalBundle)) .pushChangeHandler(new HorizontalChangeHandler()) @@ -200,7 +202,7 @@ public class EntryMenuController extends BaseController { super.onViewBound(view); NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this); - if (conversation != null && operation == ConversationOperationEnum.RENAME_ROOM) { + if (conversation != null && operation == OPS_CODE_RENAME_ROOM) { editText.setText(conversation.getName()); } @@ -226,7 +228,7 @@ public class EntryMenuController extends BaseController { @Override public void afterTextChanged(Editable s) { if (!TextUtils.isEmpty(s)) { - if (operation == ConversationOperationEnum.RENAME_ROOM) { + if (operation == OPS_CODE_RENAME_ROOM) { if (conversation.getName() == null || !conversation.getName().equals(s.toString())) { if (!proceedButton.isEnabled()) { proceedButton.setEnabled(true); @@ -240,7 +242,7 @@ public class EntryMenuController extends BaseController { } textInputLayout.setError(getResources().getString(R.string.nc_call_name_is_same)); } - } else if (operation != ConversationOperationEnum.GET_AND_JOIN_ROOM) { + } else if (operation != OPS_CODE_GET_AND_JOIN_ROOM) { if (!proceedButton.isEnabled()) { proceedButton.setEnabled(true); proceedButton.setAlpha(1.0f); @@ -273,8 +275,8 @@ public class EntryMenuController extends BaseController { String labelText = ""; switch (operation) { - case INVITE_USERS: - case RENAME_ROOM: + case OPS_CODE_INVITE_USERS: + case OPS_CODE_RENAME_ROOM: labelText = getResources().getString(R.string.nc_call_name); editText.setInputType(InputType.TYPE_CLASS_TEXT); smileyButton.setVisibility(View.VISIBLE); @@ -302,18 +304,18 @@ public class EntryMenuController extends BaseController { }).build(editText); break; - case CHANGE_PASSWORD: + case OPS_CODE_CHANGE_PASSWORD: labelText = getResources().getString(R.string.nc_new_password); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); break; - case SET_PASSWORD: - case SHARE_LINK: - case JOIN_ROOM: + case OPS_CODE_SET_PASSWORD: + case OPS_CODE_SHARE_LINK: + case OPS_CODE_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 GET_AND_JOIN_ROOM: + case OPS_CODE_GET_AND_JOIN_ROOM: labelText = getResources().getString(R.string.nc_conversation_link); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); break; @@ -321,10 +323,10 @@ public class EntryMenuController extends BaseController { break; } - if (operation == ConversationOperationEnum.JOIN_ROOM - || operation == ConversationOperationEnum.CHANGE_PASSWORD - || operation == ConversationOperationEnum.SET_PASSWORD - || operation == ConversationOperationEnum.SHARE_LINK) { + if (operation == OPS_CODE_JOIN_ROOM + || operation == OPS_CODE_CHANGE_PASSWORD + || operation == OPS_CODE_SET_PASSWORD + || operation == OPS_CODE_SHARE_LINK) { textInputLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE); } else { textInputLayout.setEndIconMode(TextInputLayout.END_ICON_NONE); diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index 61729db49..d19d90633 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -20,6 +20,8 @@ package com.nextcloud.talk.controllers.bottomsheet; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.*; + import android.annotation.SuppressLint; import android.content.Intent; import android.net.Uri; @@ -282,7 +284,7 @@ public class OperationsMenuController extends BaseController { int chatApiVersion = ApiUtils.getChatApiVersion(currentUser, new int[] {ApiUtils.APIv1}); switch (operation) { - case RENAME_ROOM: + case OPS_CODE_RENAME_ROOM: ncApi.renameRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(), conversation.getToken()), conversation.getName()) @@ -291,7 +293,7 @@ public class OperationsMenuController extends BaseController { .retry(1) .subscribe(genericOperationsObserver); break; - case MAKE_PUBLIC: + case OPS_CODE_MAKE_PUBLIC: ncApi.makeRoomPublic(credentials, ApiUtils.getUrlForRoomPublic(apiVersion, currentUser.getBaseUrl(), conversation.getToken())) .subscribeOn(Schedulers.io()) @@ -299,9 +301,9 @@ public class OperationsMenuController extends BaseController { .retry(1) .subscribe(genericOperationsObserver); break; - case CHANGE_PASSWORD: - case CLEAR_PASSWORD: - case SET_PASSWORD: + case OPS_CODE_CHANGE_PASSWORD: + case OPS_CODE_CLEAR_PASSWORD: + case OPS_CODE_SET_PASSWORD: String pass = ""; if (conversation.getPassword() != null) { pass = conversation.getPassword(); @@ -313,7 +315,7 @@ public class OperationsMenuController extends BaseController { .retry(1) .subscribe(genericOperationsObserver); break; - case MAKE_PRIVATE: + case OPS_CODE_MAKE_PRIVATE: ncApi.makeRoomPrivate(credentials, ApiUtils.getUrlForRoomPublic(apiVersion, currentUser.getBaseUrl(), conversation.getToken())) @@ -322,7 +324,7 @@ public class OperationsMenuController extends BaseController { .retry(1) .subscribe(genericOperationsObserver); break; - case GET_AND_JOIN_ROOM: + case OPS_CODE_GET_AND_JOIN_ROOM: ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, baseUrl, conversationToken)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -349,8 +351,7 @@ public class OperationsMenuController extends BaseController { Log.e(TAG, "Failed to parse capabilities for guest"); showResultImage(false, false); } - bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), - ConversationOperationEnum.JOIN_ROOM); + bundle.putSerializable(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), OPS_CODE_JOIN_ROOM); getRouter().pushController(RouterTransaction.with(new EntryMenuController(bundle)) .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler())); @@ -402,7 +403,7 @@ public class OperationsMenuController extends BaseController { } }); break; - case INVITE_USERS: + case OPS_CODE_INVITE_USERS: RetrofitBucket retrofitBucket; String invite = null; @@ -478,7 +479,7 @@ public class OperationsMenuController extends BaseController { }); break; - case MARK_AS_READ: + case OPS_CODE_MARK_AS_READ: ncApi.setChatReadMarker(credentials, ApiUtils.getUrlForSetChatReadMarker(chatApiVersion, currentUser.getBaseUrl(), @@ -489,9 +490,9 @@ public class OperationsMenuController extends BaseController { .retry(1) .subscribe(genericOperationsObserver); break; - case REMOVE_FAVORITE: - case ADD_FAVORITE: - if (operation == ConversationOperationEnum.REMOVE_FAVORITE) { + case OPS_CODE_REMOVE_FAVORITE: + case OPS_CODE_ADD_FAVORITE: + if (operation == OPS_CODE_REMOVE_FAVORITE) { ncApi.removeConversationFromFavorites(credentials, ApiUtils.getUrlForRoomFavorite(apiVersion, currentUser.getBaseUrl(), @@ -511,7 +512,7 @@ public class OperationsMenuController extends BaseController { .subscribe(genericOperationsObserver); } break; - case JOIN_ROOM: + case OPS_CODE_JOIN_ROOM: ncApi.joinRoom(credentials, ApiUtils.getUrlForParticipantsActive(apiVersion, baseUrl, conversationToken), @@ -730,7 +731,7 @@ public class OperationsMenuController extends BaseController { } private void handleObserverError(@io.reactivex.annotations.NonNull Throwable e) { - if (operation != ConversationOperationEnum.JOIN_ROOM || !(e instanceof HttpException)) { + if (operation != OPS_CODE_JOIN_ROOM || !(e instanceof HttpException)) { showResultImage(false, false); } else { Response response = ((HttpException) e).response(); @@ -753,7 +754,7 @@ public class OperationsMenuController extends BaseController { @Override public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) { - if (operation != ConversationOperationEnum.JOIN_ROOM) { + if (operation != OPS_CODE_JOIN_ROOM) { showResultImage(true, false); } else { throw new IllegalArgumentException("Unsupported operation code observed!"); @@ -781,7 +782,7 @@ public class OperationsMenuController extends BaseController { @Override public void onNext(@io.reactivex.annotations.NonNull RoomOverall roomOverall) { conversation = roomOverall.getOcs().getData(); - if (operation != ConversationOperationEnum.JOIN_ROOM) { + if (operation != OPS_CODE_JOIN_ROOM) { showResultImage(true, false); } else { conversation = roomOverall.getOcs().getData(); diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index d1275e3fd..c328f28b7 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -41,6 +41,7 @@ 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.ConversationOperationEnum.* import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController import com.nextcloud.talk.databinding.DialogConversationOperationsBinding @@ -165,11 +166,11 @@ class ConversationsListBottomDialog( private fun initClickListeners() { binding.conversationOperationAddFavorite.setOnClickListener { - executeOperationsMenuController(ConversationOperationEnum.ADD_FAVORITE) + executeOperationsMenuController(OPS_CODE_ADD_FAVORITE) } binding.conversationOperationRemoveFavorite.setOnClickListener { - executeOperationsMenuController(ConversationOperationEnum.REMOVE_FAVORITE) + executeOperationsMenuController(OPS_CODE_REMOVE_FAVORITE) } binding.conversationOperationLeave.setOnClickListener { @@ -203,27 +204,27 @@ class ConversationsListBottomDialog( } binding.conversationOperationMakePublic.setOnClickListener { - executeOperationsMenuController(ConversationOperationEnum.MAKE_PUBLIC) + executeOperationsMenuController(OPS_CODE_MAKE_PUBLIC) } binding.conversationOperationMakePrivate.setOnClickListener { - executeOperationsMenuController(ConversationOperationEnum.MAKE_PRIVATE) + executeOperationsMenuController(OPS_CODE_MAKE_PRIVATE) } binding.conversationOperationChangePassword.setOnClickListener { - executeEntryMenuController(ConversationOperationEnum.CHANGE_PASSWORD) + executeEntryMenuController(OPS_CODE_CHANGE_PASSWORD) } binding.conversationOperationClearPassword.setOnClickListener { - executeOperationsMenuController(ConversationOperationEnum.CLEAR_PASSWORD) + executeOperationsMenuController(OPS_CODE_CLEAR_PASSWORD) } binding.conversationOperationSetPassword.setOnClickListener { - executeEntryMenuController(ConversationOperationEnum.SET_PASSWORD) + executeEntryMenuController(OPS_CODE_SET_PASSWORD) } binding.conversationOperationRename.setOnClickListener { - executeEntryMenuController(ConversationOperationEnum.RENAME_ROOM) + executeEntryMenuController(OPS_CODE_RENAME_ROOM) } binding.conversationOperationShareLink.setOnClickListener { From 0f6efabf38c7dedfeed3211e8ca390595f30beb2 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Wed, 16 Feb 2022 11:33:46 +0100 Subject: [PATCH 33/34] avoid wildcard imports Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/controllers/ContactsController.java | 3 ++- .../controllers/bottomsheet/EntryMenuController.java | 8 +++++++- .../bottomsheet/OperationsMenuController.java | 3 ++- .../talk/ui/dialog/ConversationsListBottomDialog.kt | 9 ++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index 1fe533983..3adbb0903 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -22,7 +22,8 @@ package com.nextcloud.talk.controllers; -import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.*; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_INVITE_USERS; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_GET_AND_JOIN_ROOM; import android.app.SearchManager; import android.content.Context; diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java index 7c19d1606..cdd15dd88 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.java @@ -22,7 +22,13 @@ package com.nextcloud.talk.controllers.bottomsheet; -import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.*; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_JOIN_ROOM; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_GET_AND_JOIN_ROOM; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_INVITE_USERS; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_CHANGE_PASSWORD; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_SET_PASSWORD; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_SHARE_LINK; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_RENAME_ROOM; import android.content.ComponentName; import android.content.Intent; diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index d19d90633..7b84fed2e 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -20,7 +20,8 @@ package com.nextcloud.talk.controllers.bottomsheet; -import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.*; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_JOIN_ROOM; +import static com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_REMOVE_FAVORITE; import android.annotation.SuppressLint; import android.content.Intent; diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index c328f28b7..bfab8a88b 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -41,7 +41,14 @@ 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.ConversationOperationEnum.* +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_ADD_FAVORITE +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_REMOVE_FAVORITE +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_CHANGE_PASSWORD +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_SET_PASSWORD +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_CLEAR_PASSWORD +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_MAKE_PRIVATE +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_MAKE_PUBLIC +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_RENAME_ROOM import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController import com.nextcloud.talk.databinding.DialogConversationOperationsBinding From e1f8c41b600ae9c07dc7953a04133ebc7d456c5f Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Wed, 16 Feb 2022 11:45:58 +0100 Subject: [PATCH 34/34] fix to mark conversation as read Signed-off-by: Marcel Hibbe --- .../talk/ui/dialog/ConversationsListBottomDialog.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index bfab8a88b..ff2b9db97 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -49,6 +49,7 @@ import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_ import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_MAKE_PRIVATE import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_MAKE_PUBLIC import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_RENAME_ROOM +import com.nextcloud.talk.controllers.bottomsheet.ConversationOperationEnum.OPS_CODE_MARK_AS_READ import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController import com.nextcloud.talk.controllers.bottomsheet.OperationsMenuController import com.nextcloud.talk.databinding.DialogConversationOperationsBinding @@ -234,6 +235,10 @@ class ConversationsListBottomDialog( executeEntryMenuController(OPS_CODE_RENAME_ROOM) } + binding.conversationOperationMarkAsRead.setOnClickListener { + executeOperationsMenuController(OPS_CODE_MARK_AS_READ) + } + binding.conversationOperationShareLink.setOnClickListener { val sendIntent: Intent = Intent().apply { action = Intent.ACTION_SEND