mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
Replace Controller with Activity for chat
chat opens, but quite some todos open. expect crashes. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
b95a0dfbb5
commit
cd2ef40dc8
@ -218,6 +218,10 @@
|
||||
android:name=".contacts.ContactsActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".chat.ChatActivity"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
<receiver android:name=".receivers.PackageReplacedReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
|
@ -39,6 +39,7 @@ import com.nextcloud.talk.BuildConfig
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.controllers.ConversationsListController
|
||||
import com.nextcloud.talk.controllers.LockedController
|
||||
import com.nextcloud.talk.controllers.ServerSelectionController
|
||||
@ -56,7 +57,6 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ACTIVE_CONVERSATION
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
|
||||
import com.nextcloud.talk.utils.remapchat.ConductorRemapping.remapChatController
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.SingleObserver
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@ -93,16 +93,22 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
|
||||
router = Conductor.attachRouter(this, binding.controllerContainer, savedInstanceState)
|
||||
|
||||
// TODO: delete this. open chats directly via intent
|
||||
if (intent.getBooleanExtra(BundleKeys.KEY_OPEN_CHAT, false)) {
|
||||
logRouterBackStack(router!!)
|
||||
remapChatController(
|
||||
router!!,
|
||||
intent.getParcelableExtra<User>(KEY_USER_ENTITY)!!.id!!,
|
||||
intent.getStringExtra(KEY_ROOM_TOKEN)!!,
|
||||
intent.extras!!,
|
||||
true,
|
||||
true
|
||||
)
|
||||
// remapChatController(
|
||||
// router!!,
|
||||
// intent.getParcelableExtra<User>(KEY_USER_ENTITY)!!.id!!,
|
||||
// intent.getStringExtra(KEY_ROOM_TOKEN)!!,
|
||||
// intent.extras!!,
|
||||
// true,
|
||||
// true
|
||||
// )
|
||||
|
||||
val intent = Intent(context, ChatActivity::class.java)
|
||||
intent.putExtras(intent.extras!!)
|
||||
startActivity(intent)
|
||||
|
||||
logRouterBackStack(router!!)
|
||||
}
|
||||
|
||||
@ -306,13 +312,17 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.ocs!!.data)
|
||||
)
|
||||
remapChatController(
|
||||
router!!,
|
||||
currentUser!!.id!!,
|
||||
roomOverall.ocs!!.data!!.token!!,
|
||||
bundle,
|
||||
true
|
||||
)
|
||||
// remapChatController(
|
||||
// router!!,
|
||||
// currentUser!!.id!!,
|
||||
// roomOverall.ocs!!.data!!.token!!,
|
||||
// bundle,
|
||||
// true
|
||||
// )
|
||||
|
||||
val intent = Intent(context, ChatActivity::class.java)
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
@ -367,14 +377,19 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
|
||||
if (intent.getBooleanExtra(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL, false)) {
|
||||
logRouterBackStack(router!!)
|
||||
remapChatController(
|
||||
router!!,
|
||||
intent.getParcelableExtra<User>(KEY_USER_ENTITY)!!.id!!,
|
||||
intent.getStringExtra(KEY_ROOM_TOKEN)!!,
|
||||
intent.extras!!,
|
||||
true,
|
||||
true
|
||||
)
|
||||
// remapChatController(
|
||||
// router!!,
|
||||
// intent.getParcelableExtra<User>(KEY_USER_ENTITY)!!.id!!,
|
||||
// intent.getStringExtra(KEY_ROOM_TOKEN)!!,
|
||||
// intent.extras!!,
|
||||
// true,
|
||||
// true
|
||||
// )
|
||||
|
||||
val intent = Intent(context, ChatActivity::class.java)
|
||||
intent.putExtras(intent.extras!!)
|
||||
startActivity(intent)
|
||||
|
||||
logRouterBackStack(router!!)
|
||||
}
|
||||
|
||||
@ -388,14 +403,19 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
startActivity(callNotificationIntent)
|
||||
} else {
|
||||
logRouterBackStack(router!!)
|
||||
remapChatController(
|
||||
router!!,
|
||||
intent.getParcelableExtra<User>(KEY_USER_ENTITY)!!.id!!,
|
||||
intent.getStringExtra(KEY_ROOM_TOKEN)!!,
|
||||
intent.extras!!,
|
||||
true,
|
||||
true
|
||||
)
|
||||
// remapChatController(
|
||||
// router!!,
|
||||
// intent.getParcelableExtra<User>(KEY_USER_ENTITY)!!.id!!,
|
||||
// intent.getStringExtra(KEY_ROOM_TOKEN)!!,
|
||||
// intent.extras!!,
|
||||
// true,
|
||||
// true
|
||||
// )
|
||||
|
||||
val intent = Intent(context, ChatActivity::class.java)
|
||||
intent.putExtras(intent.extras!!)
|
||||
startActivity(intent)
|
||||
|
||||
logRouterBackStack(router!!)
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import coil.load
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
import com.nextcloud.talk.controllers.ChatController
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.databinding.ItemCustomIncomingTextMessageBinding
|
||||
import com.nextcloud.talk.extensions.loadBotsAvatar
|
||||
import com.nextcloud.talk.extensions.loadChangelogBotAvatar
|
||||
@ -201,8 +201,8 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : MessageHolde
|
||||
}
|
||||
|
||||
binding.messageQuote.quotedChatMessageView.setOnClickListener() {
|
||||
val chatController = commonMessageInterface as ChatController
|
||||
chatController.jumpToQuotedMessage(parentChatMessage)
|
||||
val chatActivity = commonMessageInterface as ChatActivity
|
||||
chatActivity.jumpToQuotedMessage(parentChatMessage)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ import com.google.android.flexbox.FlexboxLayout
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
import com.nextcloud.talk.controllers.ChatController
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingTextMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.chat.ReadStatus
|
||||
@ -172,8 +172,8 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(textColor)
|
||||
|
||||
binding.messageQuote.quotedChatMessageView.setOnClickListener() {
|
||||
val chatController = commonMessageInterface as ChatController
|
||||
chatController.jumpToQuotedMessage(parentChatMessage)
|
||||
val chatActivity = commonMessageInterface as ChatActivity
|
||||
chatActivity.jumpToQuotedMessage(parentChatMessage)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import com.nextcloud.talk.controllers.ChatController;
|
||||
import com.nextcloud.talk.chat.ChatActivity;
|
||||
import com.stfalcon.chatkit.commons.ImageLoader;
|
||||
import com.stfalcon.chatkit.commons.ViewHolder;
|
||||
import com.stfalcon.chatkit.commons.models.IMessage;
|
||||
@ -30,15 +30,15 @@ import com.stfalcon.chatkit.messages.MessagesListAdapter;
|
||||
import java.util.List;
|
||||
|
||||
public class TalkMessagesListAdapter<M extends IMessage> extends MessagesListAdapter<M> {
|
||||
private final ChatController chatController;
|
||||
private final ChatActivity chatActivity;
|
||||
|
||||
public TalkMessagesListAdapter(
|
||||
String senderId,
|
||||
MessageHolders holders,
|
||||
ImageLoader imageLoader,
|
||||
ChatController chatController) {
|
||||
String senderId,
|
||||
MessageHolders holders,
|
||||
ImageLoader imageLoader,
|
||||
ChatActivity chatActivity) {
|
||||
super(senderId, holders, imageLoader);
|
||||
this.chatController = chatController;
|
||||
this.chatActivity = chatActivity;
|
||||
}
|
||||
|
||||
public List<MessagesListAdapter.Wrapper> getItems() {
|
||||
@ -50,30 +50,30 @@ public class TalkMessagesListAdapter<M extends IMessage> extends MessagesListAda
|
||||
super.onBindViewHolder(holder, position);
|
||||
|
||||
if (holder instanceof IncomingTextMessageViewHolder) {
|
||||
((IncomingTextMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((IncomingTextMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingTextMessageViewHolder) {
|
||||
((OutcomingTextMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((OutcomingTextMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
|
||||
} else if (holder instanceof IncomingLocationMessageViewHolder) {
|
||||
((IncomingLocationMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((IncomingLocationMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingLocationMessageViewHolder) {
|
||||
((OutcomingLocationMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((OutcomingLocationMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
|
||||
} else if (holder instanceof IncomingLinkPreviewMessageViewHolder) {
|
||||
((IncomingLinkPreviewMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((IncomingLinkPreviewMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingLinkPreviewMessageViewHolder) {
|
||||
((OutcomingLinkPreviewMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((OutcomingLinkPreviewMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
|
||||
} else if (holder instanceof IncomingVoiceMessageViewHolder) {
|
||||
((IncomingVoiceMessageViewHolder) holder).assignVoiceMessageInterface(chatController);
|
||||
((IncomingVoiceMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((IncomingVoiceMessageViewHolder) holder).assignVoiceMessageInterface(chatActivity);
|
||||
((IncomingVoiceMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingVoiceMessageViewHolder) {
|
||||
((OutcomingVoiceMessageViewHolder) holder).assignVoiceMessageInterface(chatController);
|
||||
((OutcomingVoiceMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((OutcomingVoiceMessageViewHolder) holder).assignVoiceMessageInterface(chatActivity);
|
||||
((OutcomingVoiceMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
|
||||
} else if (holder instanceof PreviewMessageViewHolder) {
|
||||
((PreviewMessageViewHolder) holder).assignPreviewMessageInterface(chatController);
|
||||
((PreviewMessageViewHolder) holder).assignCommonMessageInterface(chatController);
|
||||
((PreviewMessageViewHolder) holder).assignPreviewMessageInterface(chatActivity);
|
||||
((PreviewMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -75,6 +75,7 @@ import com.nextcloud.talk.adapters.items.MessagesTextHeaderItem
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.contacts.ContactsActivity
|
||||
import com.nextcloud.talk.controllers.base.BaseController
|
||||
import com.nextcloud.talk.controllers.util.viewBinding
|
||||
@ -87,7 +88,6 @@ import com.nextcloud.talk.jobs.AccountRemovalWorker
|
||||
import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.run
|
||||
import com.nextcloud.talk.jobs.DeleteConversationWorker
|
||||
import com.nextcloud.talk.jobs.UploadAndShareFilesWorker
|
||||
import com.nextcloud.talk.jobs.UploadAndShareFilesWorker.Companion.requestStoragePermission
|
||||
import com.nextcloud.talk.messagesearch.MessageSearchHelper
|
||||
import com.nextcloud.talk.messagesearch.MessageSearchHelper.MessageSearchResults
|
||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
@ -120,7 +120,6 @@ import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isServerEOL
|
||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isUnifiedSearchAvailable
|
||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isUserStatusAvailable
|
||||
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
||||
import com.nextcloud.talk.utils.remapchat.ConductorRemapping.remapChatController
|
||||
import com.nextcloud.talk.utils.rx.SearchViewObservable.Companion.observeSearchView
|
||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
@ -996,7 +995,8 @@ class ConversationsListController(bundle: Bundle) :
|
||||
)
|
||||
}
|
||||
} else {
|
||||
requestStoragePermission(this@ConversationsListController)
|
||||
// TODO
|
||||
// requestStoragePermission(this@ConversationsListController)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1132,13 +1132,18 @@ class ConversationsListController(bundle: Bundle) :
|
||||
bundle.putString(BundleKeys.KEY_MESSAGE_ID, selectedMessageId)
|
||||
selectedMessageId = null
|
||||
}
|
||||
remapChatController(
|
||||
router,
|
||||
currentUser!!.id!!,
|
||||
selectedConversation!!.token!!,
|
||||
bundle,
|
||||
false
|
||||
)
|
||||
// remapChatController(
|
||||
// router,
|
||||
// currentUser!!.id!!,
|
||||
// selectedConversation!!.token!!,
|
||||
// bundle,
|
||||
// false
|
||||
// )
|
||||
|
||||
val intent = Intent(context, ChatActivity::class.java)
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent)
|
||||
|
||||
clearIntentAction()
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
package com.nextcloud.talk.jobs
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.app.Notification
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
@ -39,7 +40,6 @@ import androidx.work.WorkManager
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import autodagger.AutoInjector
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.activities.MainActivity
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
@ -288,11 +288,11 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
||||
private const val ZERO_PERCENT = 0
|
||||
const val REQUEST_PERMISSION = 3123
|
||||
|
||||
fun requestStoragePermission(controller: Controller) {
|
||||
fun requestStoragePermission(activity: Activity) {
|
||||
when {
|
||||
Build.VERSION
|
||||
.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> {
|
||||
controller.requestPermissions(
|
||||
activity.requestPermissions(
|
||||
arrayOf(
|
||||
Manifest.permission.READ_MEDIA_IMAGES,
|
||||
Manifest.permission.READ_MEDIA_VIDEO,
|
||||
@ -302,7 +302,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
||||
)
|
||||
}
|
||||
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> {
|
||||
controller.requestPermissions(
|
||||
activity.requestPermissions(
|
||||
arrayOf(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
),
|
||||
@ -310,7 +310,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
controller.requestPermissions(
|
||||
activity.requestPermissions(
|
||||
arrayOf(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
),
|
||||
|
@ -28,7 +28,6 @@ import android.util.Log
|
||||
import com.afollestad.materialdialogs.LayoutMode
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.api.NcApi
|
||||
import com.nextcloud.talk.controllers.bottomsheet.items.BasicListItemWithImage
|
||||
@ -42,7 +41,6 @@ import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.PROFI
|
||||
import com.nextcloud.talk.ui.bottom.sheet.ProfileBottomSheet.AllowedAppIds.SPREED
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import com.nextcloud.talk.utils.remapchat.ConductorRemapping
|
||||
import io.reactivex.Observer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
@ -51,7 +49,7 @@ import org.parceler.Parcels
|
||||
|
||||
private const val TAG = "ProfileBottomSheet"
|
||||
|
||||
class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val router: Router) {
|
||||
class ProfileBottomSheet(val ncApi: NcApi, val userModel: User) {
|
||||
|
||||
private val allowedAppIds = listOf(SPREED.stringValue, PROFILE.stringValue, EMAIL.stringValue)
|
||||
|
||||
@ -170,13 +168,15 @@ class ProfileBottomSheet(val ncApi: NcApi, val userModel: User, val router: Rout
|
||||
BundleKeys.KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.ocs!!.data)
|
||||
)
|
||||
ConductorRemapping.remapChatController(
|
||||
router,
|
||||
userModel.id!!,
|
||||
roomOverall.ocs!!.data!!.token!!,
|
||||
bundle,
|
||||
true
|
||||
)
|
||||
|
||||
// TODO
|
||||
// ConductorRemapping.remapChatController(
|
||||
// router,
|
||||
// userModel.id!!,
|
||||
// roomOverall.ocs!!.data!!.token!!,
|
||||
// bundle,
|
||||
// true
|
||||
// )
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
|
@ -32,14 +32,14 @@ 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.ChatController
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.databinding.DialogAttachmentBinding
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
|
||||
import javax.inject.Inject
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class AttachmentDialog(val activity: Activity, var chatController: ChatController) : BottomSheetDialog(activity) {
|
||||
class AttachmentDialog(val activity: Activity, var chatActivity: ChatActivity) : BottomSheetDialog(activity) {
|
||||
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
@ -61,8 +61,8 @@ class AttachmentDialog(val activity: Activity, var chatController: ChatControlle
|
||||
}
|
||||
|
||||
private fun initItemsStrings() {
|
||||
var serverName = CapabilitiesUtilNew.getServerName(chatController.conversationUser)
|
||||
dialogAttachmentBinding.txtAttachFileFromCloud.text = chatController.resources?.let {
|
||||
var serverName = CapabilitiesUtilNew.getServerName(chatActivity.conversationUser)
|
||||
dialogAttachmentBinding.txtAttachFileFromCloud.text = chatActivity.resources?.let {
|
||||
if (serverName.isNullOrEmpty()) {
|
||||
serverName = it.getString(R.string.nc_server_product_name)
|
||||
}
|
||||
@ -72,15 +72,15 @@ class AttachmentDialog(val activity: Activity, var chatController: ChatControlle
|
||||
|
||||
private fun initItemsVisibility() {
|
||||
if (!CapabilitiesUtilNew.hasSpreedFeatureCapability(
|
||||
chatController.conversationUser,
|
||||
chatActivity.conversationUser,
|
||||
"geo-location-sharing"
|
||||
)
|
||||
) {
|
||||
dialogAttachmentBinding.menuShareLocation.visibility = View.GONE
|
||||
}
|
||||
|
||||
if (!CapabilitiesUtilNew.hasSpreedFeatureCapability(chatController.conversationUser, "talk-polls") ||
|
||||
chatController.isOneToOneConversation()
|
||||
if (!CapabilitiesUtilNew.hasSpreedFeatureCapability(chatActivity.conversationUser, "talk-polls") ||
|
||||
chatActivity.isOneToOneConversation()
|
||||
) {
|
||||
dialogAttachmentBinding.menuAttachPoll.visibility = View.GONE
|
||||
}
|
||||
@ -92,37 +92,37 @@ class AttachmentDialog(val activity: Activity, var chatController: ChatControlle
|
||||
|
||||
private fun initItemsClickListeners() {
|
||||
dialogAttachmentBinding.menuShareLocation.setOnClickListener {
|
||||
chatController.showShareLocationScreen()
|
||||
chatActivity.showShareLocationScreen()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
dialogAttachmentBinding.menuAttachFileFromLocal.setOnClickListener {
|
||||
chatController.sendSelectLocalFileIntent()
|
||||
chatActivity.sendSelectLocalFileIntent()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
dialogAttachmentBinding.menuAttachPictureFromCam.setOnClickListener {
|
||||
chatController.sendPictureFromCamIntent()
|
||||
chatActivity.sendPictureFromCamIntent()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
dialogAttachmentBinding.menuAttachVideoFromCam.setOnClickListener {
|
||||
chatController.sendVideoFromCamIntent()
|
||||
chatActivity.sendVideoFromCamIntent()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
dialogAttachmentBinding.menuAttachPoll.setOnClickListener {
|
||||
chatController.createPoll()
|
||||
chatActivity.createPoll()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
dialogAttachmentBinding.menuAttachFileFromCloud.setOnClickListener {
|
||||
chatController.showBrowserScreen()
|
||||
chatActivity.showBrowserScreen()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
dialogAttachmentBinding.menuAttachContact.setOnClickListener {
|
||||
chatController.sendChooseContactIntent()
|
||||
chatActivity.sendChooseContactIntent()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ 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.ChatController
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.databinding.DialogMessageActionsBinding
|
||||
import com.nextcloud.talk.models.domain.ReactionAddedModel
|
||||
@ -59,13 +59,13 @@ import javax.inject.Inject
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class MessageActionsDialog(
|
||||
private val chatController: ChatController,
|
||||
private val chatActivity: ChatActivity,
|
||||
private val message: ChatMessage,
|
||||
private val user: User?,
|
||||
private val currentConversation: Conversation?,
|
||||
private val showMessageDeletionButton: Boolean,
|
||||
private val hasChatPermission: Boolean
|
||||
) : BottomSheetDialog(chatController.activity!!) {
|
||||
) : BottomSheetDialog(chatActivity) {
|
||||
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
@ -233,7 +233,7 @@ class MessageActionsDialog(
|
||||
private fun initMenuMarkAsUnread(visible: Boolean) {
|
||||
if (visible) {
|
||||
dialogMessageActionsBinding.menuMarkAsUnread.setOnClickListener {
|
||||
chatController.markAsUnread(message)
|
||||
chatActivity.markAsUnread(message)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@ -244,7 +244,7 @@ class MessageActionsDialog(
|
||||
private fun initMenuForwardMessage(visible: Boolean) {
|
||||
if (visible) {
|
||||
dialogMessageActionsBinding.menuForwardMessage.setOnClickListener {
|
||||
chatController.forwardMessage(message)
|
||||
chatActivity.forwardMessage(message)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@ -255,7 +255,7 @@ class MessageActionsDialog(
|
||||
private fun initMenuDeleteMessage(visible: Boolean) {
|
||||
if (visible) {
|
||||
dialogMessageActionsBinding.menuDeleteMessage.setOnClickListener {
|
||||
chatController.deleteMessage(message)
|
||||
chatActivity.deleteMessage(message)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ class MessageActionsDialog(
|
||||
private fun initMenuReplyPrivately(visible: Boolean) {
|
||||
if (visible) {
|
||||
dialogMessageActionsBinding.menuReplyPrivately.setOnClickListener {
|
||||
chatController.replyPrivately(message)
|
||||
chatActivity.replyPrivately(message)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@ -277,7 +277,7 @@ class MessageActionsDialog(
|
||||
private fun initMenuReplyToMessage(visible: Boolean) {
|
||||
if (visible) {
|
||||
dialogMessageActionsBinding.menuReplyToMessage.setOnClickListener {
|
||||
chatController.replyToMessage(message)
|
||||
chatActivity.replyToMessage(message)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@ -288,7 +288,7 @@ class MessageActionsDialog(
|
||||
private fun initMenuItemCopy(visible: Boolean) {
|
||||
if (visible) {
|
||||
dialogMessageActionsBinding.menuCopyMessage.setOnClickListener {
|
||||
chatController.copyMessage(message)
|
||||
chatActivity.copyMessage(message)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@ -325,7 +325,7 @@ class MessageActionsDialog(
|
||||
|
||||
override fun onNext(reactionAddedModel: ReactionAddedModel) {
|
||||
if (reactionAddedModel.success) {
|
||||
chatController.updateUiToAddReaction(
|
||||
chatActivity.updateUiToAddReaction(
|
||||
reactionAddedModel.chatMessage,
|
||||
reactionAddedModel.emoji
|
||||
)
|
||||
@ -348,7 +348,7 @@ class MessageActionsDialog(
|
||||
|
||||
override fun onNext(reactionDeletedModel: ReactionDeletedModel) {
|
||||
if (reactionDeletedModel.success) {
|
||||
chatController.updateUiToDeleteReaction(
|
||||
chatActivity.updateUiToDeleteReaction(
|
||||
reactionDeletedModel.chatMessage,
|
||||
reactionDeletedModel.emoji
|
||||
)
|
||||
|
@ -20,128 +20,118 @@
|
||||
|
||||
package com.nextcloud.talk.utils.remapchat
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import com.bluelinelabs.conductor.Router
|
||||
import com.bluelinelabs.conductor.RouterTransaction
|
||||
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
|
||||
import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
|
||||
import com.nextcloud.talk.controllers.ChatController
|
||||
import com.nextcloud.talk.controllers.ConversationsListController
|
||||
import com.nextcloud.talk.controllers.LockedController
|
||||
|
||||
object ConductorRemapping {
|
||||
|
||||
private val TAG = ConductorRemapping::class.simpleName
|
||||
|
||||
fun remapChatController(
|
||||
router: Router,
|
||||
internalUserId: Long,
|
||||
roomTokenOrId: String,
|
||||
bundle: Bundle,
|
||||
replaceTop: Boolean
|
||||
) {
|
||||
remapChatController(router, internalUserId, roomTokenOrId, bundle, replaceTop, false)
|
||||
}
|
||||
// fun remapChatController(
|
||||
// router: Router,
|
||||
// internalUserId: Long,
|
||||
// roomTokenOrId: String,
|
||||
// bundle: Bundle,
|
||||
// replaceTop: Boolean
|
||||
// ) {
|
||||
// remapChatController(router, internalUserId, roomTokenOrId, bundle, replaceTop, false)
|
||||
// }
|
||||
|
||||
fun remapChatController(
|
||||
router: Router,
|
||||
internalUserId: Long,
|
||||
roomTokenOrId: String,
|
||||
bundle: Bundle,
|
||||
replaceTop: Boolean,
|
||||
pushImmediately: Boolean
|
||||
) {
|
||||
val chatControllerTag = "$internalUserId@$roomTokenOrId"
|
||||
|
||||
if (router.getControllerWithTag(chatControllerTag) != null) {
|
||||
moveControllerToTop(router, chatControllerTag)
|
||||
} else {
|
||||
val pushChangeHandler = if (pushImmediately) {
|
||||
SimpleSwapChangeHandler()
|
||||
} else {
|
||||
HorizontalChangeHandler()
|
||||
}
|
||||
|
||||
if (router.hasRootController()) {
|
||||
val backstack = router.backstack
|
||||
val topController = backstack[router.backstackSize - 1].controller
|
||||
|
||||
val remapChatModel = RemapChatModel(
|
||||
router,
|
||||
pushChangeHandler,
|
||||
chatControllerTag,
|
||||
bundle
|
||||
)
|
||||
|
||||
if (topController is ChatController) {
|
||||
if (replaceTop) {
|
||||
topController.leaveRoom(remapChatModel, this::replaceTopController)
|
||||
} else {
|
||||
topController.leaveRoom(remapChatModel, this::pushController)
|
||||
}
|
||||
} else {
|
||||
if (replaceTop) {
|
||||
replaceTopController(remapChatModel)
|
||||
} else {
|
||||
pushController(remapChatModel)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "router has no RootController. creating backstack with ConversationsListController")
|
||||
val newBackstack = listOf(
|
||||
RouterTransaction.with(ConversationsListController(Bundle()))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler()),
|
||||
RouterTransaction.with(ChatController(bundle))
|
||||
.pushChangeHandler(HorizontalChangeHandler())
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
.tag(chatControllerTag)
|
||||
)
|
||||
router.setBackstack(newBackstack, SimpleSwapChangeHandler())
|
||||
}
|
||||
}
|
||||
|
||||
if (router.getControllerWithTag(LockedController.TAG) != null) {
|
||||
moveControllerToTop(router, LockedController.TAG)
|
||||
}
|
||||
}
|
||||
|
||||
fun pushController(remapChatModel: RemapChatModel) {
|
||||
Log.d(TAG, "pushController")
|
||||
remapChatModel.router.pushController(
|
||||
RouterTransaction.with(ChatController(remapChatModel.bundle))
|
||||
.pushChangeHandler(remapChatModel.controllerChangeHandler)
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
.tag(remapChatModel.chatControllerTag)
|
||||
)
|
||||
}
|
||||
|
||||
private fun replaceTopController(remapChatModel: RemapChatModel) {
|
||||
Log.d(TAG, "replaceTopController")
|
||||
remapChatModel.router.replaceTopController(
|
||||
RouterTransaction.with(ChatController(remapChatModel.bundle))
|
||||
.pushChangeHandler(remapChatModel.controllerChangeHandler)
|
||||
.popChangeHandler(HorizontalChangeHandler())
|
||||
.tag(remapChatModel.chatControllerTag)
|
||||
)
|
||||
}
|
||||
|
||||
private fun moveControllerToTop(router: Router, controllerTag: String) {
|
||||
Log.d(TAG, "moving $controllerTag to top...")
|
||||
val backstack = router.backstack
|
||||
var routerTransaction: RouterTransaction? = null
|
||||
for (i in 0 until router.backstackSize) {
|
||||
if (controllerTag == backstack[i].tag()) {
|
||||
routerTransaction = backstack[i]
|
||||
backstack.remove(routerTransaction)
|
||||
Log.d(TAG, "removed controller: " + routerTransaction.controller)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
backstack.add(routerTransaction)
|
||||
Log.d(TAG, "added controller to top: " + routerTransaction!!.controller)
|
||||
router.setBackstack(backstack, HorizontalChangeHandler())
|
||||
}
|
||||
// fun remapChatController(
|
||||
// router: Router,
|
||||
// internalUserId: Long,
|
||||
// roomTokenOrId: String,
|
||||
// bundle: Bundle,
|
||||
// replaceTop: Boolean,
|
||||
// pushImmediately: Boolean
|
||||
// ) {
|
||||
// val chatControllerTag = "$internalUserId@$roomTokenOrId"
|
||||
//
|
||||
// if (router.getControllerWithTag(chatControllerTag) != null) {
|
||||
// moveControllerToTop(router, chatControllerTag)
|
||||
// } else {
|
||||
// val pushChangeHandler = if (pushImmediately) {
|
||||
// SimpleSwapChangeHandler()
|
||||
// } else {
|
||||
// HorizontalChangeHandler()
|
||||
// }
|
||||
//
|
||||
// if (router.hasRootController()) {
|
||||
// val backstack = router.backstack
|
||||
// val topController = backstack[router.backstackSize - 1].controller
|
||||
//
|
||||
// val remapChatModel = RemapChatModel(
|
||||
// router,
|
||||
// pushChangeHandler,
|
||||
// chatControllerTag,
|
||||
// bundle
|
||||
// )
|
||||
//
|
||||
// if (topController is ChatActivity) {
|
||||
// if (replaceTop) {
|
||||
// topController.leaveRoom(remapChatModel, this::replaceTopController)
|
||||
// } else {
|
||||
// topController.leaveRoom(remapChatModel, this::pushController)
|
||||
// }
|
||||
// } else {
|
||||
// if (replaceTop) {
|
||||
// replaceTopController(remapChatModel)
|
||||
// } else {
|
||||
// pushController(remapChatModel)
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// Log.d(TAG, "router has no RootController. creating backstack with ConversationsListController")
|
||||
// val newBackstack = listOf(
|
||||
// RouterTransaction.with(ConversationsListController(Bundle()))
|
||||
// .pushChangeHandler(HorizontalChangeHandler())
|
||||
// .popChangeHandler(HorizontalChangeHandler()),
|
||||
// RouterTransaction.with(ChatActivity(bundle))
|
||||
// .pushChangeHandler(HorizontalChangeHandler())
|
||||
// .popChangeHandler(HorizontalChangeHandler())
|
||||
// .tag(chatControllerTag)
|
||||
// )
|
||||
// router.setBackstack(newBackstack, SimpleSwapChangeHandler())
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (router.getControllerWithTag(LockedController.TAG) != null) {
|
||||
// moveControllerToTop(router, LockedController.TAG)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// fun pushController(remapChatModel: RemapChatModel) {
|
||||
// Log.d(TAG, "pushController")
|
||||
// remapChatModel.router.pushController(
|
||||
// RouterTransaction.with(ChatActivity(remapChatModel.bundle))
|
||||
// .pushChangeHandler(remapChatModel.controllerChangeHandler)
|
||||
// .popChangeHandler(HorizontalChangeHandler())
|
||||
// .tag(remapChatModel.chatControllerTag)
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// private fun replaceTopController(remapChatModel: RemapChatModel) {
|
||||
// Log.d(TAG, "replaceTopController")
|
||||
// remapChatModel.router.replaceTopController(
|
||||
// RouterTransaction.with(ChatActivity(remapChatModel.bundle))
|
||||
// .pushChangeHandler(remapChatModel.controllerChangeHandler)
|
||||
// .popChangeHandler(HorizontalChangeHandler())
|
||||
// .tag(remapChatModel.chatControllerTag)
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// private fun moveControllerToTop(router: Router, controllerTag: String) {
|
||||
// Log.d(TAG, "moving $controllerTag to top...")
|
||||
// val backstack = router.backstack
|
||||
// var routerTransaction: RouterTransaction? = null
|
||||
// for (i in 0 until router.backstackSize) {
|
||||
// if (controllerTag == backstack[i].tag()) {
|
||||
// routerTransaction = backstack[i]
|
||||
// backstack.remove(routerTransaction)
|
||||
// Log.d(TAG, "removed controller: " + routerTransaction.controller)
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// backstack.add(routerTransaction)
|
||||
// Log.d(TAG, "added controller to top: " + routerTransaction!!.controller)
|
||||
// router.setBackstack(backstack, HorizontalChangeHandler())
|
||||
// }
|
||||
}
|
||||
|
@ -32,6 +32,23 @@
|
||||
android:background="@color/bg_default"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/chat_appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/chat_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/appbar"
|
||||
android:theme="?attr/actionBarPopupTheme"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:navigationIconTint="@color/fontAppbar"
|
||||
app:popupTheme="@style/appActionBarPopupMenu"
|
||||
app:titleTextColor="@color/fontAppbar"
|
||||
tools:title="@string/nc_app_product_name" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
|
Loading…
Reference in New Issue
Block a user