|
@@ -100,6 +100,7 @@ import com.nextcloud.talk.models.json.status.Status
|
|
import com.nextcloud.talk.models.json.statuses.StatusesOverall
|
|
import com.nextcloud.talk.models.json.statuses.StatusesOverall
|
|
import com.nextcloud.talk.repositories.unifiedsearch.UnifiedSearchRepository
|
|
import com.nextcloud.talk.repositories.unifiedsearch.UnifiedSearchRepository
|
|
import com.nextcloud.talk.ui.dialog.ChooseAccountDialogFragment
|
|
import com.nextcloud.talk.ui.dialog.ChooseAccountDialogFragment
|
|
|
|
+import com.nextcloud.talk.ui.dialog.ChooseAccountShareToDialogFragment
|
|
import com.nextcloud.talk.ui.dialog.ConversationsListBottomDialog
|
|
import com.nextcloud.talk.ui.dialog.ConversationsListBottomDialog
|
|
import com.nextcloud.talk.users.UserManager
|
|
import com.nextcloud.talk.users.UserManager
|
|
import com.nextcloud.talk.utils.ApiUtils
|
|
import com.nextcloud.talk.utils.ApiUtils
|
|
@@ -180,6 +181,7 @@ class ConversationsListController(bundle: Bundle) :
|
|
private var conversationItemsWithHeader: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
|
private var conversationItemsWithHeader: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
|
private val searchableConversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
|
private val searchableConversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
|
private var searchItem: MenuItem? = null
|
|
private var searchItem: MenuItem? = null
|
|
|
|
+ private var chooseAccountItem: MenuItem? = null
|
|
private var searchView: SearchView? = null
|
|
private var searchView: SearchView? = null
|
|
private var searchQuery: String? = null
|
|
private var searchQuery: String? = null
|
|
private var credentials: String? = null
|
|
private var credentials: String? = null
|
|
@@ -250,6 +252,43 @@ class ConversationsListController(bundle: Bundle) :
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun loadUserAvatar(menuItem: MenuItem) {
|
|
|
|
+ if (activity != null) {
|
|
|
|
+ val imageRequest = DisplayUtils.getImageRequestForUrl(
|
|
|
|
+ ApiUtils.getUrlForAvatar(
|
|
|
|
+ currentUser!!.baseUrl,
|
|
|
|
+ currentUser!!.userId,
|
|
|
|
+ true
|
|
|
|
+ ),
|
|
|
|
+ currentUser
|
|
|
|
+ )
|
|
|
|
+ val imagePipeline = Fresco.getImagePipeline()
|
|
|
|
+ val dataSource = imagePipeline.fetchDecodedImage(imageRequest, null)
|
|
|
|
+ dataSource.subscribe(
|
|
|
|
+ object : BaseBitmapDataSubscriber() {
|
|
|
|
+ override fun onNewResultImpl(bitmap: Bitmap?) {
|
|
|
|
+ if (bitmap != null && resources != null) {
|
|
|
|
+ val roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(
|
|
|
|
+ resources!!,
|
|
|
|
+ bitmap
|
|
|
|
+ )
|
|
|
|
+ roundedBitmapDrawable.isCircular = true
|
|
|
|
+ roundedBitmapDrawable.setAntiAlias(true)
|
|
|
|
+ menuItem.icon = roundedBitmapDrawable
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage?>>) {
|
|
|
|
+ if (resources != null) {
|
|
|
|
+ menuItem.icon = ResourcesCompat.getDrawable(resources!!, R.drawable.ic_user, null)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ UiThreadImmediateExecutorService.getInstance()
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
override fun onAttach(view: View) {
|
|
override fun onAttach(view: View) {
|
|
Log.d(
|
|
Log.d(
|
|
TAG,
|
|
TAG,
|
|
@@ -257,6 +296,9 @@ class ConversationsListController(bundle: Bundle) :
|
|
" Activity: " + System.identityHashCode(activity)
|
|
" Activity: " + System.identityHashCode(activity)
|
|
)
|
|
)
|
|
super.onAttach(view)
|
|
super.onAttach(view)
|
|
|
|
+
|
|
|
|
+ showShareToScreen = hasActivityActionSendIntent()
|
|
|
|
+
|
|
ClosedInterfaceImpl().setUpPushTokenRegistration()
|
|
ClosedInterfaceImpl().setUpPushTokenRegistration()
|
|
if (!eventBus.isRegistered(this)) {
|
|
if (!eventBus.isRegistered(this)) {
|
|
eventBus.register(this)
|
|
eventBus.register(this)
|
|
@@ -328,15 +370,32 @@ class ConversationsListController(bundle: Bundle) :
|
|
|
|
|
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
super.onCreateOptionsMenu(menu, inflater)
|
|
super.onCreateOptionsMenu(menu, inflater)
|
|
|
|
+
|
|
inflater.inflate(R.menu.menu_conversation_plus_filter, menu)
|
|
inflater.inflate(R.menu.menu_conversation_plus_filter, menu)
|
|
searchItem = menu.findItem(R.id.action_search)
|
|
searchItem = menu.findItem(R.id.action_search)
|
|
|
|
+ chooseAccountItem = menu.findItem(R.id.action_choose_account)
|
|
|
|
+ loadUserAvatar(chooseAccountItem!!)
|
|
|
|
+
|
|
|
|
+ chooseAccountItem?.setOnMenuItemClickListener {
|
|
|
|
+ if (resources != null && resources!!.getBoolean(R.bool.multiaccount_support)) {
|
|
|
|
+ val newFragment: DialogFragment = ChooseAccountShareToDialogFragment.newInstance()
|
|
|
|
+ newFragment.show(
|
|
|
|
+ (activity as MainActivity?)!!.supportFragmentManager,
|
|
|
|
+ ChooseAccountShareToDialogFragment.TAG
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ true
|
|
|
|
+ }
|
|
initSearchView()
|
|
initSearchView()
|
|
}
|
|
}
|
|
|
|
|
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
super.onPrepareOptionsMenu(menu)
|
|
super.onPrepareOptionsMenu(menu)
|
|
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
|
|
searchView = MenuItemCompat.getActionView(searchItem) as SearchView
|
|
- showShareToScreen = !showShareToScreen && hasActivityActionSendIntent()
|
|
|
|
|
|
+
|
|
|
|
+ val moreAccountsAvailable = userManager.users.blockingGet().size > 1
|
|
|
|
+ menu.findItem(R.id.action_choose_account).isVisible = showShareToScreen && moreAccountsAvailable
|
|
|
|
+
|
|
if (showShareToScreen) {
|
|
if (showShareToScreen) {
|
|
hideSearchBar()
|
|
hideSearchBar()
|
|
actionBar?.setTitle(R.string.send_to_three_dots)
|
|
actionBar?.setTitle(R.string.send_to_three_dots)
|
|
@@ -679,7 +738,7 @@ class ConversationsListController(bundle: Bundle) :
|
|
val newFragment: DialogFragment = ChooseAccountDialogFragment.newInstance()
|
|
val newFragment: DialogFragment = ChooseAccountDialogFragment.newInstance()
|
|
newFragment.show(
|
|
newFragment.show(
|
|
(getActivity() as MainActivity?)!!.supportFragmentManager,
|
|
(getActivity() as MainActivity?)!!.supportFragmentManager,
|
|
- "ChooseAccountDialogFragment"
|
|
|
|
|
|
+ ChooseAccountDialogFragment.TAG
|
|
)
|
|
)
|
|
} else {
|
|
} else {
|
|
router.pushController(
|
|
router.pushController(
|
|
@@ -858,7 +917,7 @@ class ConversationsListController(bundle: Bundle) :
|
|
loadMoreMessages()
|
|
loadMoreMessages()
|
|
}
|
|
}
|
|
ConversationItem.VIEW_TYPE -> {
|
|
ConversationItem.VIEW_TYPE -> {
|
|
- showConversation((Objects.requireNonNull(item) as ConversationItem).model)
|
|
|
|
|
|
+ handleConversation((Objects.requireNonNull(item) as ConversationItem).model)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -870,21 +929,24 @@ class ConversationsListController(bundle: Bundle) :
|
|
val conversationItem = absItem as ConversationItem
|
|
val conversationItem = absItem as ConversationItem
|
|
if (conversationItem.model.token == conversationToken) {
|
|
if (conversationItem.model.token == conversationToken) {
|
|
val conversation = conversationItem.model
|
|
val conversation = conversationItem.model
|
|
- showConversation(conversation)
|
|
|
|
|
|
+ handleConversation(conversation)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private fun showConversation(conversation: Conversation?) {
|
|
|
|
|
|
+ @Suppress("Detekt.ComplexMethod")
|
|
|
|
+ private fun handleConversation(conversation: Conversation?) {
|
|
selectedConversation = conversation
|
|
selectedConversation = conversation
|
|
if (selectedConversation != null && activity != null) {
|
|
if (selectedConversation != null && activity != null) {
|
|
val hasChatPermission = AttendeePermissionsUtil(selectedConversation!!.permissions).hasChatPermission(
|
|
val hasChatPermission = AttendeePermissionsUtil(selectedConversation!!.permissions).hasChatPermission(
|
|
currentUser!!
|
|
currentUser!!
|
|
)
|
|
)
|
|
if (showShareToScreen) {
|
|
if (showShareToScreen) {
|
|
- if (hasChatPermission && !isReadOnlyConversation(selectedConversation!!)) {
|
|
|
|
|
|
+ if (hasChatPermission &&
|
|
|
|
+ !isReadOnlyConversation(selectedConversation!!) &&
|
|
|
|
+ !selectedConversation!!.shouldShowLobby(currentUser!!)
|
|
|
|
+ ) {
|
|
handleSharedData()
|
|
handleSharedData()
|
|
- showShareToScreen = false
|
|
|
|
} else {
|
|
} else {
|
|
Toast.makeText(context, R.string.send_to_forbidden, Toast.LENGTH_LONG).show()
|
|
Toast.makeText(context, R.string.send_to_forbidden, Toast.LENGTH_LONG).show()
|
|
}
|
|
}
|
|
@@ -947,7 +1009,6 @@ class ConversationsListController(bundle: Bundle) :
|
|
}
|
|
}
|
|
.setNegativeButton(R.string.nc_no) { _, _ ->
|
|
.setNegativeButton(R.string.nc_no) { _, _ ->
|
|
Log.d(TAG, "sharing files aborted, going back to share-to screen")
|
|
Log.d(TAG, "sharing files aborted, going back to share-to screen")
|
|
- showShareToScreen = true
|
|
|
|
}
|
|
}
|
|
viewThemeUtils.dialog
|
|
viewThemeUtils.dialog
|
|
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
|
.colorMaterialAlertDialogBackground(binding.floatingActionButton.context, dialogBuilder)
|
|
@@ -961,6 +1022,10 @@ class ConversationsListController(bundle: Bundle) :
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun clearIntentAction() {
|
|
|
|
+ activity!!.intent.action = ""
|
|
|
|
+ }
|
|
|
|
+
|
|
override fun onItemLongClick(position: Int) {
|
|
override fun onItemLongClick(position: Int) {
|
|
if (showShareToScreen) {
|
|
if (showShareToScreen) {
|
|
Log.d(TAG, "sharing to multiple rooms not yet implemented. onItemLongClick is ignored.")
|
|
Log.d(TAG, "sharing to multiple rooms not yet implemented. onItemLongClick is ignored.")
|
|
@@ -1085,6 +1150,7 @@ class ConversationsListController(bundle: Bundle) :
|
|
bundle,
|
|
bundle,
|
|
false
|
|
false
|
|
)
|
|
)
|
|
|
|
+ clearIntentAction()
|
|
}
|
|
}
|
|
|
|
|
|
@Subscribe(sticky = true, threadMode = ThreadMode.BACKGROUND)
|
|
@Subscribe(sticky = true, threadMode = ThreadMode.BACKGROUND)
|