mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
open Conversation after being created via ContactsController
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
dbf6b91260
commit
ac0c961557
@ -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;
|
||||
@ -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);
|
||||
@ -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()]);
|
||||
@ -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);
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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
|
||||
}
|
||||
}
|
@ -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<View>(R.id.design_bottom_sheet)
|
||||
val behavior = BottomSheetBehavior.from(bottomSheet as View)
|
||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ContactsBottomDialog"
|
||||
}
|
||||
}
|
13
app/src/main/res/layout/dialog_bottom_contacts.xml
Normal file
13
app/src/main/res/layout/dialog_bottom_contacts.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/bg_call_screen_dialog"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/standard_padding"
|
||||
android:paddingEnd="@dimen/standard_padding"
|
||||
android:paddingBottom="@dimen/standard_half_padding">
|
||||
|
||||
</LinearLayout>
|
@ -10,37 +10,6 @@
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user