mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-07 12:59:55 +01:00
New work on contacts
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
f2694869a8
commit
cf7f1dde96
app/src/main
java/com/nextcloud/talk
res/values
@ -161,7 +161,7 @@ class UserItem(
|
|||||||
))
|
))
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if ("groups" == model.source) {
|
} else if ("groups" == model.source || "circles" == model.source) {
|
||||||
holder.avatarImageView?.load(Images().getImageWithBackground(activityContext, R.drawable.ic_people_group_white_24px))
|
holder.avatarImageView?.load(Images().getImageWithBackground(activityContext, R.drawable.ic_people_group_white_24px))
|
||||||
} else if ("emails" == model.source) {
|
} else if ("emails" == model.source) {
|
||||||
holder.avatarImageView?.load(Images().getImageWithBackground(activityContext, R.drawable.ic_baseline_email_24))
|
holder.avatarImageView?.load(Images().getImageWithBackground(activityContext, R.drawable.ic_baseline_email_24))
|
||||||
|
@ -27,7 +27,6 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
import android.text.TextUtils
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
@ -51,7 +50,6 @@ import com.kennyc.bottomsheet.BottomSheet
|
|||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.activities.MagicCallActivity
|
import com.nextcloud.talk.activities.MagicCallActivity
|
||||||
import com.nextcloud.talk.adapters.items.GenericTextHeaderItem
|
import com.nextcloud.talk.adapters.items.GenericTextHeaderItem
|
||||||
import com.nextcloud.talk.adapters.items.ProgressItem
|
|
||||||
import com.nextcloud.talk.adapters.items.UserItem
|
import com.nextcloud.talk.adapters.items.UserItem
|
||||||
import com.nextcloud.talk.api.NcApi
|
import com.nextcloud.talk.api.NcApi
|
||||||
import com.nextcloud.talk.controllers.base.BaseController
|
import com.nextcloud.talk.controllers.base.BaseController
|
||||||
@ -65,7 +63,6 @@ import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
|||||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||||
import com.nextcloud.talk.models.json.participants.Participant
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
import com.nextcloud.talk.models.json.sharees.Sharee
|
|
||||||
import com.nextcloud.talk.newarch.domain.repository.offline.UsersRepository
|
import com.nextcloud.talk.newarch.domain.repository.offline.UsersRepository
|
||||||
import com.nextcloud.talk.newarch.local.models.UserNgEntity
|
import com.nextcloud.talk.newarch.local.models.UserNgEntity
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
@ -100,7 +97,7 @@ import kotlin.String
|
|||||||
class ContactsController : BaseController,
|
class ContactsController : BaseController,
|
||||||
SearchView.OnQueryTextListener,
|
SearchView.OnQueryTextListener,
|
||||||
FlexibleAdapter.OnItemClickListener,
|
FlexibleAdapter.OnItemClickListener,
|
||||||
FastScroller.OnScrollStateChangeListener{
|
FastScroller.OnScrollStateChangeListener {
|
||||||
|
|
||||||
val usersRepository: UsersRepository by inject()
|
val usersRepository: UsersRepository by inject()
|
||||||
val ncApi: NcApi by inject()
|
val ncApi: NcApi by inject()
|
||||||
@ -160,8 +157,6 @@ class ContactsController : BaseController,
|
|||||||
|
|
||||||
private val selectedUserIds: MutableSet<String> = mutableSetOf()
|
private val selectedUserIds: MutableSet<String> = mutableSetOf()
|
||||||
private val selectedGroupIds: MutableSet<String> = mutableSetOf()
|
private val selectedGroupIds: MutableSet<String> = mutableSetOf()
|
||||||
private var existingParticipants: List<String>? = null
|
|
||||||
private var isAddingParticipantsView: Boolean = false
|
|
||||||
private var conversationToken: String? = null
|
private var conversationToken: String? = null
|
||||||
|
|
||||||
constructor() : super() {
|
constructor() : super() {
|
||||||
@ -172,16 +167,9 @@ class ContactsController : BaseController,
|
|||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
if (args.containsKey(BundleKeys.KEY_NEW_CONVERSATION)) {
|
if (args.containsKey(BundleKeys.KEY_NEW_CONVERSATION)) {
|
||||||
isNewConversationView = true
|
isNewConversationView = true
|
||||||
existingParticipants = ArrayList()
|
} else {
|
||||||
} else if (args.containsKey(BundleKeys.KEY_ADD_PARTICIPANTS)) {
|
isNewConversationView = false
|
||||||
isAddingParticipantsView = true
|
|
||||||
conversationToken = args.getString(BundleKeys.KEY_TOKEN)
|
conversationToken = args.getString(BundleKeys.KEY_TOKEN)
|
||||||
|
|
||||||
existingParticipants = ArrayList()
|
|
||||||
|
|
||||||
if (args.containsKey(BundleKeys.KEY_EXISTING_PARTICIPANTS)) {
|
|
||||||
existingParticipants = args.getStringArrayList(BundleKeys.KEY_EXISTING_PARTICIPANTS)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,9 +191,7 @@ class ContactsController : BaseController,
|
|||||||
|
|
||||||
if (isNewConversationView) {
|
if (isNewConversationView) {
|
||||||
toggleNewCallHeaderVisibility(!isPublicCall)
|
toggleNewCallHeaderVisibility(!isPublicCall)
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (isAddingParticipantsView) {
|
|
||||||
joinConversationViaLinkLayout!!.visibility = View.GONE
|
joinConversationViaLinkLayout!!.visibility = View.GONE
|
||||||
conversationPrivacyToogleLayout!!.visibility = View.GONE
|
conversationPrivacyToogleLayout!!.visibility = View.GONE
|
||||||
}
|
}
|
||||||
@ -246,7 +232,7 @@ class ContactsController : BaseController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun selectionDone() {
|
private fun selectionDone() {
|
||||||
if (!isAddingParticipantsView) {
|
if (isNewConversationView) {
|
||||||
if (!isPublicCall && selectedGroupIds.size + selectedUserIds.size == 1) {
|
if (!isPublicCall && selectedGroupIds.size + selectedUserIds.size == 1) {
|
||||||
val userId: String
|
val userId: String
|
||||||
var roomType = "1"
|
var roomType = "1"
|
||||||
@ -457,7 +443,7 @@ class ContactsController : BaseController,
|
|||||||
|
|
||||||
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForContactsSearchFor14(currentUser!!.baseUrl, query)
|
val retrofitBucket: RetrofitBucket = ApiUtils.getRetrofitBucketForContactsSearchFor14(currentUser!!.baseUrl, query)
|
||||||
val modifiedQueryMap = HashMap<String, Any>(retrofitBucket.queryMap)
|
val modifiedQueryMap = HashMap<String, Any>(retrofitBucket.queryMap)
|
||||||
modifiedQueryMap["limit"] = 100
|
modifiedQueryMap["limit"] = 50
|
||||||
|
|
||||||
var shareTypesList: MutableList<String> = mutableListOf()
|
var shareTypesList: MutableList<String> = mutableListOf()
|
||||||
// user
|
// user
|
||||||
@ -467,8 +453,8 @@ class ContactsController : BaseController,
|
|||||||
// remote/circles
|
// remote/circles
|
||||||
shareTypesList.add("7");
|
shareTypesList.add("7");
|
||||||
|
|
||||||
if (!isNewConversationView) {
|
conversationToken?.let {
|
||||||
modifiedQueryMap["itemId"] = "difz"
|
modifiedQueryMap["itemId"] = it
|
||||||
// emails
|
// emails
|
||||||
shareTypesList.add("4")
|
shareTypesList.add("4")
|
||||||
}
|
}
|
||||||
@ -497,25 +483,26 @@ class ContactsController : BaseController,
|
|||||||
autocompleteUsersHashSet.addAll(autocompleteOverall.ocs.data)
|
autocompleteUsersHashSet.addAll(autocompleteOverall.ocs.data)
|
||||||
|
|
||||||
for (autocompleteUser in autocompleteUsersHashSet) {
|
for (autocompleteUser in autocompleteUsersHashSet) {
|
||||||
if (autocompleteUser.id != currentUser!!.userId && !existingParticipants!!.contains(
|
|
||||||
autocompleteUser.id
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
participant = Participant()
|
participant = Participant()
|
||||||
participant.userId = autocompleteUser.id
|
participant.userId = autocompleteUser.id
|
||||||
participant.displayName = autocompleteUser.label
|
participant.displayName = autocompleteUser.label
|
||||||
participant.source = autocompleteUser.source
|
participant.source = autocompleteUser.source
|
||||||
|
|
||||||
val headerTitle: String
|
var headerTitle: String?
|
||||||
|
|
||||||
if (autocompleteUser.source != "groups") {
|
|
||||||
headerTitle = participant.displayName
|
if (autocompleteUser.source == "groups") {
|
||||||
.substring(0, 1)
|
headerTitle = resources?.getString(R.string.nc_groups)
|
||||||
.toUpperCase()
|
} else if (autocompleteUser.source == "users") {
|
||||||
|
headerTitle = resources?.getString(R.string.nc_contacts)
|
||||||
|
} else if (autocompleteUser.source == "emails") {
|
||||||
|
headerTitle = resources?.getString(R.string.nc_emails)
|
||||||
} else {
|
} else {
|
||||||
headerTitle = resources!!.getString(R.string.nc_groups)
|
headerTitle = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
headerTitle as String
|
||||||
|
|
||||||
val genericTextHeaderItem: GenericTextHeaderItem
|
val genericTextHeaderItem: GenericTextHeaderItem
|
||||||
if (!userHeaderItems.containsKey(headerTitle)) {
|
if (!userHeaderItems.containsKey(headerTitle)) {
|
||||||
genericTextHeaderItem = GenericTextHeaderItem(headerTitle)
|
genericTextHeaderItem = GenericTextHeaderItem(headerTitle)
|
||||||
@ -531,7 +518,6 @@ class ContactsController : BaseController,
|
|||||||
newUserItemList.add(newContactItem)
|
newUserItemList.add(newContactItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
Log.e(TAG, "Parsing response body failed while getting contacts")
|
Log.e(TAG, "Parsing response body failed while getting contacts")
|
||||||
}
|
}
|
||||||
@ -714,11 +700,7 @@ class ContactsController : BaseController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getTitle(): String? {
|
override fun getTitle(): String? {
|
||||||
return if (!isNewConversationView && !isAddingParticipantsView) {
|
return resources?.getString(R.string.nc_select_contacts)
|
||||||
resources!!.getString(R.string.nc_app_name)
|
|
||||||
} else {
|
|
||||||
resources!!.getString(R.string.nc_select_contacts)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFastScrollerStateChange(scrolling: Boolean) {
|
override fun onFastScrollerStateChange(scrolling: Boolean) {
|
||||||
@ -797,74 +779,6 @@ class ContactsController : BaseController,
|
|||||||
view: View,
|
view: View,
|
||||||
position: Int
|
position: Int
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (adapter!!.getItem(position) is UserItem) {
|
|
||||||
if (!isNewConversationView && !isAddingParticipantsView) {
|
|
||||||
val userItem = adapter!!.getItem(position) as UserItem?
|
|
||||||
var roomType = "1"
|
|
||||||
|
|
||||||
if ("groups" == userItem!!.model.source) {
|
|
||||||
roomType = "2"
|
|
||||||
}
|
|
||||||
|
|
||||||
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
|
||||||
currentUser!!.baseUrl, roomType,
|
|
||||||
userItem.model.userId, null
|
|
||||||
)
|
|
||||||
|
|
||||||
ncApi.createRoom(
|
|
||||||
credentials,
|
|
||||||
retrofitBucket.url, retrofitBucket.queryMap
|
|
||||||
)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.`as`(AutoDispose.autoDisposable(scopeProvider))
|
|
||||||
.subscribe(object : Observer<RoomOverall> {
|
|
||||||
override fun onSubscribe(d: Disposable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNext(roomOverall: RoomOverall) {
|
|
||||||
if (activity != null) {
|
|
||||||
val conversationIntent = Intent(activity, MagicCallActivity::class.java)
|
|
||||||
val bundle = Bundle()
|
|
||||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, currentUser)
|
|
||||||
bundle.putString(
|
|
||||||
BundleKeys.KEY_ROOM_TOKEN,
|
|
||||||
roomOverall.ocs.data.token
|
|
||||||
)
|
|
||||||
bundle.putString(
|
|
||||||
BundleKeys.KEY_ROOM_ID,
|
|
||||||
roomOverall.ocs.data.conversationId
|
|
||||||
)
|
|
||||||
conversationIntent.putExtras(bundle)
|
|
||||||
|
|
||||||
if (currentUser!!.hasSpreedFeatureCapability("chat-v2")) {
|
|
||||||
bundle.putParcelable(
|
|
||||||
BundleKeys.KEY_ACTIVE_CONVERSATION,
|
|
||||||
Parcels.wrap(roomOverall.ocs.data)
|
|
||||||
)
|
|
||||||
|
|
||||||
ConductorRemapping.remapChatController(
|
|
||||||
router,
|
|
||||||
currentUser!!.id!!,
|
|
||||||
roomOverall.ocs.data.token!!, bundle, true
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
startActivity(conversationIntent)
|
|
||||||
Handler().postDelayed({ router.popCurrentController() }, 100)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
val participant = (adapter!!.getItem(position) as UserItem).model
|
val participant = (adapter!!.getItem(position) as UserItem).model
|
||||||
participant.selected = !participant.selected
|
participant.selected = !participant.selected
|
||||||
|
|
||||||
@ -903,12 +817,10 @@ class ContactsController : BaseController,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
adapter!!.notifyDataSetChanged()
|
adapter!!.notifyDataSetChanged()
|
||||||
checkAndHandleDoneMenuItem()
|
checkAndHandleDoneMenuItem()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,15 +501,6 @@ class ConversationInfoController(args: Bundle) : BaseController(),
|
|||||||
adapter!!.addListener(this)
|
adapter!!.addListener(this)
|
||||||
actionTextView.setOnClickListener {
|
actionTextView.setOnClickListener {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
val existingParticipantsId = arrayListOf<String>()
|
|
||||||
|
|
||||||
recyclerViewItems.forEach {
|
|
||||||
val userItem = it as UserItem
|
|
||||||
existingParticipantsId.add(userItem.model.userId)
|
|
||||||
}
|
|
||||||
|
|
||||||
bundle.putBoolean(BundleKeys.KEY_ADD_PARTICIPANTS, true)
|
|
||||||
bundle.putStringArrayList(BundleKeys.KEY_EXISTING_PARTICIPANTS, existingParticipantsId)
|
|
||||||
bundle.putString(BundleKeys.KEY_TOKEN, conversation!!.token)
|
bundle.putString(BundleKeys.KEY_TOKEN, conversation!!.token)
|
||||||
|
|
||||||
router.pushController(
|
router.pushController(
|
||||||
|
@ -285,6 +285,9 @@
|
|||||||
<!-- Other -->
|
<!-- Other -->
|
||||||
<string name="nc_limit_hit">%s characters limit has been hit</string>
|
<string name="nc_limit_hit">%s characters limit has been hit</string>
|
||||||
<string name="nc_groups">Groups</string>
|
<string name="nc_groups">Groups</string>
|
||||||
|
<string name="nc_contacts">Contacts</string>
|
||||||
|
<string name="nc_circles">Circles</string>
|
||||||
|
<string name="nc_emails">Emails</string>
|
||||||
<string name="nc_participants">Participants</string>
|
<string name="nc_participants">Participants</string>
|
||||||
|
|
||||||
<string name="nc_owner">Owner</string>
|
<string name="nc_owner">Owner</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user