mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 06:44:09 +01:00
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 <dev@mhibbe.de>
This commit is contained in:
parent
cb9189da19
commit
aedede9ffd
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -10,6 +10,43 @@
|
||||
android:paddingEnd="@dimen/standard_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/text_edit_wrapper"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_edit"
|
||||
android:layout_width="wrap_content"
|
||||
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"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/Id"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="joooo"
|
||||
android:textColor="@color/white"
|
||||
android:background="@android:color/transparent" >
|
||||
</EditText>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/operation_items_layout"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/conversation_operation_header"
|
||||
android:layout_width="wrap_content"
|
||||
@ -343,4 +380,8 @@
|
||||
android:textSize="@dimen/bottom_sheet_text_size" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user