mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 14:54: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.application.NextcloudTalkApplication;
|
||||||
import com.nextcloud.talk.controllers.base.BaseController;
|
import com.nextcloud.talk.controllers.base.BaseController;
|
||||||
import com.nextcloud.talk.controllers.bottomsheet.EntryMenuController;
|
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.BottomSheetLockEvent;
|
||||||
import com.nextcloud.talk.events.EventStatus;
|
import com.nextcloud.talk.events.EventStatus;
|
||||||
import com.nextcloud.talk.interfaces.ConversationMenuInterface;
|
import com.nextcloud.talk.interfaces.ConversationMenuInterface;
|
||||||
@ -469,7 +470,7 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("LongLogTag")
|
@SuppressLint("LongLogTag")
|
||||||
private void fetchData(boolean fromBottomSheet) {
|
public void fetchData(boolean fromBottomSheet) {
|
||||||
dispose(null);
|
dispose(null);
|
||||||
|
|
||||||
isRefreshing = true;
|
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
|
@Override
|
||||||
public AppBarLayoutType getAppBarLayoutType() {
|
public AppBarLayoutType getAppBarLayoutType() {
|
||||||
return AppBarLayoutType.SEARCH_BAR;
|
return AppBarLayoutType.SEARCH_BAR;
|
||||||
|
@ -9,9 +9,10 @@ import androidx.work.Data
|
|||||||
import androidx.work.OneTimeWorkRequest
|
import androidx.work.OneTimeWorkRequest
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import autodagger.AutoInjector
|
import autodagger.AutoInjector
|
||||||
|
import com.bluelinelabs.conductor.Conductor
|
||||||
|
import com.bluelinelabs.conductor.Router
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
|
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.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
@ -41,6 +42,9 @@ class ConversationOperationDialog(
|
|||||||
val conversation: Conversation
|
val conversation: Conversation
|
||||||
) : BottomSheetDialog(activity) {
|
) : BottomSheetDialog(activity) {
|
||||||
|
|
||||||
|
private var dialogRouter: Router? = null
|
||||||
|
|
||||||
|
|
||||||
private lateinit var binding: DialogConversationOperationsBinding
|
private lateinit var binding: DialogConversationOperationsBinding
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -132,173 +136,168 @@ class ConversationOperationDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initClickListeners() {
|
private fun initClickListeners() {
|
||||||
// // val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token)
|
// val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token)
|
||||||
// // val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1))
|
// val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv1))
|
||||||
//
|
|
||||||
// binding.conversationOperationAddFavorite.setOnClickListener {
|
binding.conversationOperationAddFavorite.setOnClickListener {
|
||||||
// // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController.
|
|
||||||
// // CallMenuController was replaced with the class you're in here.
|
binding.textEditWrapper.visibility = View.VISIBLE
|
||||||
// // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to.
|
binding.operationItemsLayout.visibility = View.GONE
|
||||||
//
|
|
||||||
// val bundle = Bundle()
|
|
||||||
// bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
// TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController.
|
||||||
// bundle.putInt(KEY_OPERATION_CODE, 98)
|
// 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.
|
||||||
// // controller.router.pushController(
|
|
||||||
// // RouterTransaction.with(OperationsMenuController(bundle))
|
val bundle = Bundle()
|
||||||
// // .pushChangeHandler(HorizontalChangeHandler())
|
bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
||||||
// // .popChangeHandler(HorizontalChangeHandler())
|
bundle.putInt(KEY_OPERATION_CODE, 98)
|
||||||
// // )
|
|
||||||
//
|
dismiss()
|
||||||
//
|
|
||||||
//
|
// just a test
|
||||||
// // var view = activity.layoutInflater.inflate(R.layout.bottom_sheet, null, true)
|
controller.pushSomeOtherController(bundle)
|
||||||
// // controller.getChildRouter((view as ViewGroup?)!!).setRoot(
|
|
||||||
// // RouterTransaction.with(OperationsMenuController(bundle))
|
}
|
||||||
// // .popChangeHandler(VerticalChangeHandler())
|
|
||||||
// // .pushChangeHandler(VerticalChangeHandler())
|
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()
|
||||||
// // dismiss()
|
bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
||||||
// }
|
bundle.putInt(KEY_OPERATION_CODE, 97)
|
||||||
//
|
|
||||||
// binding.conversationOperationRemoveFavorite.setOnClickListener {
|
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.
|
dialogRouter = Conductor.attachRouter(activity, binding.root, null)
|
||||||
// // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to.
|
|
||||||
//
|
dialogRouter!!.pushController(
|
||||||
// val bundle = Bundle()
|
RouterTransaction.with(OperationsMenuController(bundle))
|
||||||
// bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
.pushChangeHandler(HorizontalChangeHandler())
|
||||||
// bundle.putInt(KEY_OPERATION_CODE, 97)
|
.popChangeHandler(HorizontalChangeHandler())
|
||||||
//
|
)
|
||||||
// controller.router.pushController(
|
|
||||||
// RouterTransaction.with(OperationsMenuController(bundle))
|
controller.fetchData(false)
|
||||||
// .pushChangeHandler(HorizontalChangeHandler())
|
}
|
||||||
// .popChangeHandler(HorizontalChangeHandler())
|
|
||||||
// )
|
binding.conversationOperationClearPassword.setOnClickListener {
|
||||||
//
|
conversation.setPassword("")
|
||||||
// dismiss()
|
}
|
||||||
// }
|
|
||||||
//
|
binding.conversationOperationLeave.setOnClickListener {
|
||||||
// binding.conversationOperationClearPassword.setOnClickListener {
|
val dataBuilder = Data.Builder()
|
||||||
// conversation.setPassword("")
|
dataBuilder.putString(KEY_ROOM_TOKEN, conversation.getToken())
|
||||||
// }
|
dataBuilder.putLong(KEY_INTERNAL_USER_ID, currentUser.id)
|
||||||
//
|
val data = dataBuilder.build()
|
||||||
// binding.conversationOperationLeave.setOnClickListener {
|
|
||||||
// val dataBuilder = Data.Builder()
|
val leaveConversationWorker =
|
||||||
// dataBuilder.putString(KEY_ROOM_TOKEN, conversation.getToken())
|
OneTimeWorkRequest.Builder(LeaveConversationWorker::class.java).setInputData(
|
||||||
// dataBuilder.putLong(KEY_INTERNAL_USER_ID, currentUser.id)
|
data
|
||||||
// val data = dataBuilder.build()
|
).build()
|
||||||
//
|
WorkManager.getInstance().enqueue(leaveConversationWorker)
|
||||||
// val leaveConversationWorker =
|
|
||||||
// OneTimeWorkRequest.Builder(LeaveConversationWorker::class.java).setInputData(
|
dismiss()
|
||||||
// data
|
}
|
||||||
// ).build()
|
|
||||||
// WorkManager.getInstance().enqueue(leaveConversationWorker)
|
binding.conversationOperationDelete.setOnClickListener {
|
||||||
//
|
if (!TextUtils.isEmpty(conversation.getToken())) {
|
||||||
// dismiss()
|
val bundle = Bundle()
|
||||||
// }
|
bundle.putLong(KEY_INTERNAL_USER_ID, currentUser.id)
|
||||||
//
|
bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
||||||
// binding.conversationOperationDelete.setOnClickListener {
|
|
||||||
// if (!TextUtils.isEmpty(conversation.getToken())) {
|
controller.openLovelyDialogWithIdAndBundle(
|
||||||
// val bundle = Bundle()
|
ConversationsListController.ID_DELETE_CONVERSATION_DIALOG,
|
||||||
// bundle.putLong(KEY_INTERNAL_USER_ID, currentUser.id)
|
bundle
|
||||||
// bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
)
|
||||||
//
|
}
|
||||||
// controller.openLovelyDialogWithIdAndBundle(
|
|
||||||
// ConversationsListController.ID_DELETE_CONVERSATION_DIALOG,
|
dismiss()
|
||||||
// bundle
|
}
|
||||||
// )
|
|
||||||
// }
|
binding.conversationOperationMakePublic.setOnClickListener {
|
||||||
//
|
// TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController.
|
||||||
// dismiss()
|
// 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.
|
||||||
//
|
|
||||||
// binding.conversationOperationMakePublic.setOnClickListener {
|
val bundle = Bundle()
|
||||||
// // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController.
|
bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
||||||
// // CallMenuController was replaced with the class you're in here.
|
bundle.putInt(KEY_OPERATION_CODE, 3)
|
||||||
// // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to.
|
|
||||||
//
|
controller.router.pushController(
|
||||||
// val bundle = Bundle()
|
RouterTransaction.with(OperationsMenuController(bundle))
|
||||||
// bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
.pushChangeHandler(HorizontalChangeHandler())
|
||||||
// bundle.putInt(KEY_OPERATION_CODE, 3)
|
.popChangeHandler(HorizontalChangeHandler())
|
||||||
//
|
)
|
||||||
// controller.router.pushController(
|
}
|
||||||
// RouterTransaction.with(OperationsMenuController(bundle))
|
|
||||||
// .pushChangeHandler(HorizontalChangeHandler())
|
binding.conversationOperationMakePrivate.setOnClickListener {
|
||||||
// .popChangeHandler(HorizontalChangeHandler())
|
// 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.
|
||||||
//
|
|
||||||
// binding.conversationOperationMakePrivate.setOnClickListener {
|
val bundle = Bundle()
|
||||||
// // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController.
|
bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
||||||
// // CallMenuController was replaced with the class you're in here.
|
bundle.putInt(KEY_OPERATION_CODE, 8)
|
||||||
// // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to.
|
|
||||||
//
|
controller.router.pushController(
|
||||||
// val bundle = Bundle()
|
RouterTransaction.with(OperationsMenuController(bundle))
|
||||||
// bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
.pushChangeHandler(HorizontalChangeHandler())
|
||||||
// bundle.putInt(KEY_OPERATION_CODE, 8)
|
.popChangeHandler(HorizontalChangeHandler())
|
||||||
//
|
)
|
||||||
// controller.router.pushController(
|
}
|
||||||
// RouterTransaction.with(OperationsMenuController(bundle))
|
|
||||||
// .pushChangeHandler(HorizontalChangeHandler())
|
binding.conversationOperationClearPassword.setOnClickListener {
|
||||||
// .popChangeHandler(HorizontalChangeHandler())
|
// 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.
|
||||||
//
|
|
||||||
// binding.conversationOperationClearPassword.setOnClickListener {
|
val bundle = Bundle()
|
||||||
// // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController.
|
bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
||||||
// // CallMenuController was replaced with the class you're in here.
|
bundle.putInt(KEY_OPERATION_CODE, 5)
|
||||||
// // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to.
|
|
||||||
//
|
controller.router.pushController(
|
||||||
// val bundle = Bundle()
|
RouterTransaction.with(OperationsMenuController(bundle))
|
||||||
// bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
.pushChangeHandler(HorizontalChangeHandler())
|
||||||
// bundle.putInt(KEY_OPERATION_CODE, 5)
|
.popChangeHandler(HorizontalChangeHandler())
|
||||||
//
|
)
|
||||||
// controller.router.pushController(
|
}
|
||||||
// RouterTransaction.with(OperationsMenuController(bundle))
|
|
||||||
// .pushChangeHandler(HorizontalChangeHandler())
|
binding.conversationOperationRename.setOnClickListener {
|
||||||
// .popChangeHandler(HorizontalChangeHandler())
|
// 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.
|
||||||
//
|
|
||||||
// binding.conversationOperationRename.setOnClickListener {
|
val bundle = Bundle()
|
||||||
// // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController.
|
bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
||||||
// // CallMenuController was replaced with the class you're in here.
|
bundle.putInt(KEY_OPERATION_CODE, 2)
|
||||||
// // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to.
|
|
||||||
//
|
controller.router.pushController(
|
||||||
// val bundle = Bundle()
|
RouterTransaction.with(EntryMenuController(bundle))
|
||||||
// bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
.pushChangeHandler(HorizontalChangeHandler())
|
||||||
// bundle.putInt(KEY_OPERATION_CODE, 2)
|
.popChangeHandler(HorizontalChangeHandler())
|
||||||
//
|
)
|
||||||
// controller.router.pushController(
|
}
|
||||||
// RouterTransaction.with(EntryMenuController(bundle))
|
|
||||||
// .pushChangeHandler(HorizontalChangeHandler())
|
binding.conversationOperationSetPassword.setOnClickListener {
|
||||||
// .popChangeHandler(HorizontalChangeHandler())
|
// 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.
|
||||||
//
|
|
||||||
// binding.conversationOperationSetPassword.setOnClickListener {
|
val bundle = Bundle()
|
||||||
// // TODO: this weird KEY_OPERATION_CODE stuff came from CallMenuController.
|
bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
||||||
// // CallMenuController was replaced with the class you're in here.
|
bundle.putInt(KEY_OPERATION_CODE, 6)
|
||||||
// // This KEY_OPERATION_CODE stuff still needs to be deleted/rewritten in the classes where it's passed to.
|
|
||||||
//
|
controller.router.pushController(
|
||||||
// val bundle = Bundle()
|
RouterTransaction.with(EntryMenuController(bundle))
|
||||||
// bundle.putParcelable(KEY_ROOM, Parcels.wrap(conversation))
|
.pushChangeHandler(HorizontalChangeHandler())
|
||||||
// bundle.putInt(KEY_OPERATION_CODE, 6)
|
.popChangeHandler(HorizontalChangeHandler())
|
||||||
//
|
)
|
||||||
// controller.router.pushController(
|
}
|
||||||
// RouterTransaction.with(EntryMenuController(bundle))
|
|
||||||
// .pushChangeHandler(HorizontalChangeHandler())
|
binding.conversationOperationShareLink.setOnClickListener {
|
||||||
// .popChangeHandler(HorizontalChangeHandler())
|
// TODO share by intent
|
||||||
// )
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// binding.conversationOperationShareLink.setOnClickListener {
|
|
||||||
// // TODO share by intent
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -10,6 +10,43 @@
|
|||||||
android:paddingEnd="@dimen/standard_padding"
|
android:paddingEnd="@dimen/standard_padding"
|
||||||
android:paddingBottom="@dimen/standard_half_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
|
<TextView
|
||||||
android:id="@+id/conversation_operation_header"
|
android:id="@+id/conversation_operation_header"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -344,3 +381,7 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user