mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
style(detekt): Shorten methods
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
b0c86cac6c
commit
383bf2a728
@ -128,7 +128,7 @@ class MessageInputFragment : Fragment() {
|
|||||||
private var mentionAutocomplete: Autocomplete<*>? = null
|
private var mentionAutocomplete: Autocomplete<*>? = null
|
||||||
private var xcounter = 0f
|
private var xcounter = 0f
|
||||||
private var ycounter = 0f
|
private var ycounter = 0f
|
||||||
private var isCollapsed = false
|
private var collapsed = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -219,11 +219,7 @@ class MessageInputFragment : Fragment() {
|
|||||||
binding.fragmentCallStarted.callAuthorChipSecondary.text = message.actorDisplayName
|
binding.fragmentCallStarted.callAuthorChipSecondary.text = message.actorDisplayName
|
||||||
val user = userManager.currentUser.blockingGet()
|
val user = userManager.currentUser.blockingGet()
|
||||||
val url: String = if (message.actorType == "guests" || message.actorType == "guest") {
|
val url: String = if (message.actorType == "guests" || message.actorType == "guest") {
|
||||||
ApiUtils.getUrlForGuestAvatar(
|
ApiUtils.getUrlForGuestAvatar(user!!.baseUrl!!, message.actorDisplayName, true)
|
||||||
user!!.baseUrl!!,
|
|
||||||
message.actorDisplayName,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
ApiUtils.getUrlForAvatar(user!!.baseUrl!!, message.actorId, false)
|
ApiUtils.getUrlForAvatar(user!!.baseUrl!!, message.actorId, false)
|
||||||
}
|
}
|
||||||
@ -457,20 +453,12 @@ class MessageInputFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.fragmentCallStarted.callStartedCloseBtn.setOnClickListener {
|
binding.fragmentCallStarted.callStartedCloseBtn.setOnClickListener {
|
||||||
isCollapsed = !isCollapsed
|
collapsed = !collapsed
|
||||||
if (isCollapsed) {
|
binding.fragmentCallStarted.callAuthorLayout.visibility = if (collapsed) View.GONE else View.VISIBLE
|
||||||
binding.fragmentCallStarted.callAuthorLayout.visibility = View.GONE
|
binding.fragmentCallStarted.callBtnLayout.visibility = if (collapsed) View.GONE else View.VISIBLE
|
||||||
binding.fragmentCallStarted.callBtnLayout.visibility = View.GONE
|
binding.fragmentCallStarted.callAuthorChipSecondary.visibility = if (collapsed) View.VISIBLE else View.GONE
|
||||||
binding.fragmentCallStarted.callAuthorChipSecondary.visibility = View.VISIBLE
|
binding.fragmentCallStarted.callStartedSecondaryText.visibility = if (collapsed) View.VISIBLE else View.GONE
|
||||||
binding.fragmentCallStarted.callStartedSecondaryText.visibility = View.VISIBLE
|
setDropDown(collapsed)
|
||||||
} else {
|
|
||||||
binding.fragmentCallStarted.callAuthorLayout.visibility = View.VISIBLE
|
|
||||||
binding.fragmentCallStarted.callBtnLayout.visibility = View.VISIBLE
|
|
||||||
binding.fragmentCallStarted.callAuthorChipSecondary.visibility = View.GONE
|
|
||||||
binding.fragmentCallStarted.callStartedSecondaryText.visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
setDropDown(isCollapsed)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,18 +506,34 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result.second.isNotEmpty()) {
|
if (result.second.isNotEmpty()) {
|
||||||
val chatMessagesJson = result.second
|
chatMessagesFromSync = updateMessagesData(
|
||||||
|
result.second,
|
||||||
|
blockContainingQueriedMessage,
|
||||||
|
lookIntoFuture,
|
||||||
|
hasHistory)
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "no data is updated...")
|
||||||
|
}
|
||||||
|
|
||||||
|
return chatMessagesFromSync
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun OfflineFirstChatRepository.updateMessagesData(
|
||||||
|
chatMessagesJson: List<ChatMessageJson>,
|
||||||
|
blockContainingQueriedMessage: ChatBlockEntity?,
|
||||||
|
lookIntoFuture: Boolean,
|
||||||
|
hasHistory: Boolean
|
||||||
|
): List<ChatMessageEntity> {
|
||||||
handleUpdateMessages(chatMessagesJson)
|
handleUpdateMessages(chatMessagesJson)
|
||||||
|
|
||||||
chatMessagesFromSync = chatMessagesJson.map {
|
val chatMessagesFromSyncToProcess = chatMessagesJson.map {
|
||||||
it.asEntity(currentUser.id!!)
|
it.asEntity(currentUser.id!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
chatDao.upsertChatMessages(chatMessagesFromSync)
|
chatDao.upsertChatMessages(chatMessagesFromSyncToProcess)
|
||||||
|
|
||||||
val oldestIdFromSync = chatMessagesFromSync.minByOrNull { it.id }!!.id
|
val oldestIdFromSync = chatMessagesFromSyncToProcess.minByOrNull { it.id }!!.id
|
||||||
val newestIdFromSync = chatMessagesFromSync.maxByOrNull { it.id }!!.id
|
val newestIdFromSync = chatMessagesFromSyncToProcess.maxByOrNull { it.id }!!.id
|
||||||
Log.d(TAG, "oldestIdFromSync: $oldestIdFromSync")
|
Log.d(TAG, "oldestIdFromSync: $oldestIdFromSync")
|
||||||
Log.d(TAG, "newestIdFromSync: $newestIdFromSync")
|
Log.d(TAG, "newestIdFromSync: $newestIdFromSync")
|
||||||
|
|
||||||
@ -550,11 +566,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
chatBlocksDao.upsertChatBlock(newChatBlock)
|
chatBlocksDao.upsertChatBlock(newChatBlock)
|
||||||
|
|
||||||
updateBlocks(newChatBlock)
|
updateBlocks(newChatBlock)
|
||||||
} else {
|
return chatMessagesFromSyncToProcess
|
||||||
Log.d(TAG, "no data is updated...")
|
|
||||||
}
|
|
||||||
|
|
||||||
return chatMessagesFromSync
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun handleUpdateMessages(messagesJson: List<ChatMessageJson>) {
|
private suspend fun handleUpdateMessages(messagesJson: List<ChatMessageJson>) {
|
||||||
|
@ -21,6 +21,7 @@ import android.view.MenuItem
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
import android.view.View.VISIBLE
|
import android.view.View.VISIBLE
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
@ -204,33 +205,7 @@ class ConversationInfoActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initObservers() {
|
private fun initObservers() {
|
||||||
viewModel.viewState.observe(this) { state ->
|
initViewStateObserver()
|
||||||
when (state) {
|
|
||||||
is ConversationInfoViewModel.GetRoomSuccessState -> {
|
|
||||||
conversation = state.conversationModel
|
|
||||||
viewModel.getCapabilities(conversationUser, conversationToken, conversation!!)
|
|
||||||
if (ConversationUtils.isNoteToSelfConversation(conversation)) {
|
|
||||||
binding.shareConversationButton.visibility = GONE
|
|
||||||
}
|
|
||||||
val canGeneratePrettyURL = CapabilitiesUtil.canGeneratePrettyURL(conversationUser)
|
|
||||||
binding.shareConversationButton.setOnClickListener {
|
|
||||||
ShareUtils.shareConversationLink(
|
|
||||||
this,
|
|
||||||
conversationUser.baseUrl,
|
|
||||||
conversation?.token,
|
|
||||||
conversation?.name,
|
|
||||||
canGeneratePrettyURL
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is ConversationInfoViewModel.GetRoomErrorState -> {
|
|
||||||
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
viewModel.getCapabilitiesViewState.observe(this) { state ->
|
viewModel.getCapabilitiesViewState.observe(this) { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
@ -289,6 +264,36 @@ class ConversationInfoActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initViewStateObserver() {
|
||||||
|
viewModel.viewState.observe(this) { state ->
|
||||||
|
when (state) {
|
||||||
|
is ConversationInfoViewModel.GetRoomSuccessState -> {
|
||||||
|
conversation = state.conversationModel
|
||||||
|
viewModel.getCapabilities(conversationUser, conversationToken, conversation!!)
|
||||||
|
if (ConversationUtils.isNoteToSelfConversation(conversation)) {
|
||||||
|
binding.shareConversationButton.visibility = GONE
|
||||||
|
}
|
||||||
|
val canGeneratePrettyURL = CapabilitiesUtil.canGeneratePrettyURL(conversationUser)
|
||||||
|
binding.shareConversationButton.setOnClickListener {
|
||||||
|
ShareUtils.shareConversationLink(
|
||||||
|
this,
|
||||||
|
conversationUser.baseUrl,
|
||||||
|
conversation?.token,
|
||||||
|
conversation?.name,
|
||||||
|
canGeneratePrettyURL
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is ConversationInfoViewModel.GetRoomErrorState -> {
|
||||||
|
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupActionBar() {
|
private fun setupActionBar() {
|
||||||
setSupportActionBar(binding.conversationInfoToolbar)
|
setSupportActionBar(binding.conversationInfoToolbar)
|
||||||
binding.conversationInfoToolbar.setNavigationOnClickListener {
|
binding.conversationInfoToolbar.setNavigationOnClickListener {
|
||||||
@ -1330,118 +1335,58 @@ class ConversationInfoActivity :
|
|||||||
|
|
||||||
val userItem = adapter?.getItem(position) as ParticipantItem
|
val userItem = adapter?.getItem(position) as ParticipantItem
|
||||||
val participant = userItem.model
|
val participant = userItem.model
|
||||||
|
|
||||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4, 1))
|
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4, 1))
|
||||||
|
|
||||||
if (participant.calculatedActorType == USERS && participant.calculatedActorId == conversationUser.userId) {
|
if (participant.calculatedActorType == USERS && participant.calculatedActorId == conversationUser.userId) {
|
||||||
if (participant.attendeePin?.isNotEmpty() == true) {
|
if (participant.attendeePin?.isNotEmpty() == true) {
|
||||||
val items = mutableListOf(
|
launchRemoveAttendeeFromConversationDialog(
|
||||||
BasicListItemWithImage(
|
participant,
|
||||||
R.drawable.ic_lock_grey600_24px,
|
apiVersion,
|
||||||
context.getString(R.string.nc_attendee_pin, participant.attendeePin)
|
context.getString(R.string.nc_attendee_pin, participant.attendeePin),
|
||||||
|
R.drawable.ic_lock_grey600_24px
|
||||||
)
|
)
|
||||||
)
|
|
||||||
MaterialDialog(this, BottomSheet(WRAP_CONTENT)).show {
|
|
||||||
cornerRadius(res = R.dimen.corner_radius)
|
|
||||||
|
|
||||||
title(text = participant.displayName)
|
|
||||||
viewThemeUtils.material.colorBottomSheetBackground(this.view)
|
|
||||||
listItemsWithImage(items = items) { _, index, _ ->
|
|
||||||
if (index == 0) {
|
|
||||||
removeAttendeeFromConversation(apiVersion, participant)
|
|
||||||
}
|
}
|
||||||
}
|
} else if (participant.type == Participant.ParticipantType.OWNER) {
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (participant.type == Participant.ParticipantType.OWNER) {
|
|
||||||
// Can not moderate owner
|
// Can not moderate owner
|
||||||
return true
|
} else if (participant.calculatedActorType == GROUPS) {
|
||||||
}
|
launchRemoveAttendeeFromConversationDialog(
|
||||||
|
participant,
|
||||||
if (participant.calculatedActorType == GROUPS) {
|
apiVersion,
|
||||||
val items = mutableListOf(
|
|
||||||
BasicListItemWithImage(
|
|
||||||
R.drawable.ic_delete_grey600_24dp,
|
|
||||||
context.getString(R.string.nc_remove_group_and_members)
|
context.getString(R.string.nc_remove_group_and_members)
|
||||||
)
|
)
|
||||||
)
|
} else if (participant.calculatedActorType == CIRCLES) {
|
||||||
MaterialDialog(this, BottomSheet(WRAP_CONTENT)).show {
|
launchRemoveAttendeeFromConversationDialog(
|
||||||
cornerRadius(res = R.dimen.corner_radius)
|
participant,
|
||||||
|
apiVersion,
|
||||||
title(text = participant.displayName)
|
|
||||||
listItemsWithImage(items = items) { _, index, _ ->
|
|
||||||
if (index == 0) {
|
|
||||||
removeAttendeeFromConversation(apiVersion, participant)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (participant.calculatedActorType == CIRCLES) {
|
|
||||||
val items = mutableListOf(
|
|
||||||
BasicListItemWithImage(
|
|
||||||
R.drawable.ic_delete_grey600_24dp,
|
|
||||||
context.getString(R.string.nc_remove_team_and_members)
|
context.getString(R.string.nc_remove_team_and_members)
|
||||||
)
|
)
|
||||||
)
|
} else {
|
||||||
MaterialDialog(this, BottomSheet(WRAP_CONTENT)).show {
|
launchDefaultActions(participant, apiVersion)
|
||||||
cornerRadius(res = R.dimen.corner_radius)
|
|
||||||
|
|
||||||
title(text = participant.displayName)
|
|
||||||
listItemsWithImage(items = items) { _, index, _ ->
|
|
||||||
if (index == 0) {
|
|
||||||
removeAttendeeFromConversation(apiVersion, participant)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
val items = mutableListOf(
|
@SuppressLint("CheckResult", "StringFormatInvalid")
|
||||||
BasicListItemWithImage(
|
private fun launchDefaultActions(participant: Participant, apiVersion: Int) {
|
||||||
R.drawable.ic_lock_grey600_24px,
|
val items = getDefaultActionItems(participant)
|
||||||
context.getString(R.string.nc_attendee_pin, participant.attendeePin)
|
|
||||||
),
|
|
||||||
BasicListItemWithImage(
|
|
||||||
R.drawable.ic_pencil_grey600_24dp,
|
|
||||||
context.getString(R.string.nc_promote)
|
|
||||||
),
|
|
||||||
BasicListItemWithImage(
|
|
||||||
R.drawable.ic_pencil_grey600_24dp,
|
|
||||||
context.getString(R.string.nc_demote)
|
|
||||||
),
|
|
||||||
BasicListItemWithImage(
|
|
||||||
R.drawable.ic_delete_grey600_24dp,
|
|
||||||
context.getString(R.string.nc_remove_participant)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if (CapabilitiesUtil.isBanningAvailable(conversationUser.capabilities?.spreedCapability!!)) {
|
if (CapabilitiesUtil.isBanningAvailable(conversationUser.capabilities?.spreedCapability!!)) {
|
||||||
items.add(
|
items.add(BasicListItemWithImage(R.drawable.baseline_block_24, context.getString(R.string.ban_participant)))
|
||||||
BasicListItemWithImage(
|
|
||||||
R.drawable.baseline_block_24,
|
|
||||||
context.getString(R.string.ban_participant)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.type == Participant.ParticipantType.MODERATOR ||
|
when (participant.type) {
|
||||||
participant.type == Participant.ParticipantType.GUEST_MODERATOR
|
Participant.ParticipantType.MODERATOR, Participant.ParticipantType.GUEST_MODERATOR -> {
|
||||||
) {
|
|
||||||
items.removeAt(1)
|
items.removeAt(1)
|
||||||
} else if (participant.type == Participant.ParticipantType.USER ||
|
}
|
||||||
participant.type == Participant.ParticipantType.GUEST
|
Participant.ParticipantType.USER, Participant.ParticipantType.GUEST -> {
|
||||||
) {
|
|
||||||
items.removeAt(2)
|
items.removeAt(2)
|
||||||
} else {
|
}
|
||||||
|
else -> {
|
||||||
// Self joined users can not be promoted nor demoted
|
// Self joined users can not be promoted nor demoted
|
||||||
items.removeAt(2)
|
items.removeAt(2)
|
||||||
items.removeAt(1)
|
items.removeAt(1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (participant.attendeePin == null || participant.attendeePin!!.isEmpty()) {
|
if (participant.attendeePin == null || participant.attendeePin!!.isEmpty()) {
|
||||||
items.removeAt(0)
|
items.removeAt(0)
|
||||||
@ -1483,7 +1428,53 @@ class ConversationInfoActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
}
|
||||||
|
|
||||||
|
private fun getDefaultActionItems(participant: Participant): MutableList<BasicListItemWithImage> {
|
||||||
|
val items = mutableListOf(
|
||||||
|
BasicListItemWithImage(
|
||||||
|
R.drawable.ic_lock_grey600_24px,
|
||||||
|
context.getString(R.string.nc_attendee_pin, participant.attendeePin)
|
||||||
|
),
|
||||||
|
BasicListItemWithImage(
|
||||||
|
R.drawable.ic_pencil_grey600_24dp,
|
||||||
|
context.getString(R.string.nc_promote)
|
||||||
|
),
|
||||||
|
BasicListItemWithImage(
|
||||||
|
R.drawable.ic_pencil_grey600_24dp,
|
||||||
|
context.getString(R.string.nc_demote)
|
||||||
|
),
|
||||||
|
BasicListItemWithImage(
|
||||||
|
R.drawable.ic_delete_grey600_24dp,
|
||||||
|
context.getString(R.string.nc_remove_participant)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
|
private fun launchRemoveAttendeeFromConversationDialog(
|
||||||
|
participant: Participant,
|
||||||
|
apiVersion: Int,
|
||||||
|
itemText: String,
|
||||||
|
@DrawableRes itemIcon: Int = R.drawable.ic_delete_grey600_24dp,
|
||||||
|
) {
|
||||||
|
val items = mutableListOf(
|
||||||
|
BasicListItemWithImage(
|
||||||
|
itemIcon,
|
||||||
|
itemText
|
||||||
|
)
|
||||||
|
)
|
||||||
|
MaterialDialog(this, BottomSheet(WRAP_CONTENT)).show {
|
||||||
|
cornerRadius(res = R.dimen.corner_radius)
|
||||||
|
|
||||||
|
title(text = participant.displayName)
|
||||||
|
listItemsWithImage(items = items) { _, index, _ ->
|
||||||
|
if (index == 0) {
|
||||||
|
removeAttendeeFromConversation(apiVersion, participant)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun MaterialDialog.handleBan(participant: Participant) {
|
private fun MaterialDialog.handleBan(participant: Participant) {
|
||||||
|
@ -122,6 +122,45 @@ class ConversationInfoEditActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initObservers() {
|
private fun initObservers() {
|
||||||
|
initViewStateObserver()
|
||||||
|
conversationInfoEditViewModel.renameRoomUiState.observe(this) { uiState ->
|
||||||
|
when (uiState) {
|
||||||
|
is ConversationInfoEditViewModel.RenameRoomUiState.None -> {
|
||||||
|
}
|
||||||
|
is ConversationInfoEditViewModel.RenameRoomUiState.Success -> {
|
||||||
|
if (CapabilitiesUtil.isConversationDescriptionEndpointAvailable(spreedCapabilities)) {
|
||||||
|
saveConversationDescription()
|
||||||
|
} else {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConversationInfoEditViewModel.RenameRoomUiState.Error -> {
|
||||||
|
Snackbar
|
||||||
|
.make(binding.root, context.getString(R.string.default_error_msg), Snackbar.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
|
Log.e(TAG, "Error while saving conversation name", uiState.exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
conversationInfoEditViewModel.setConversationDescriptionUiState.observe(this) { uiState ->
|
||||||
|
when (uiState) {
|
||||||
|
is ConversationInfoEditViewModel.SetConversationDescriptionUiState.None -> {
|
||||||
|
}
|
||||||
|
is ConversationInfoEditViewModel.SetConversationDescriptionUiState.Success -> {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
is ConversationInfoEditViewModel.SetConversationDescriptionUiState.Error -> {
|
||||||
|
Snackbar
|
||||||
|
.make(binding.root, context.getString(R.string.default_error_msg), Snackbar.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
|
Log.e(TAG, "Error while saving conversation description", uiState.exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initViewStateObserver() {
|
||||||
conversationInfoEditViewModel.viewState.observe(this) { state ->
|
conversationInfoEditViewModel.viewState.observe(this) { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
is ConversationInfoEditViewModel.GetRoomSuccessState -> {
|
is ConversationInfoEditViewModel.GetRoomSuccessState -> {
|
||||||
@ -131,7 +170,7 @@ class ConversationInfoEditActivity : BaseActivity() {
|
|||||||
|
|
||||||
binding.conversationName.setText(conversation!!.displayName)
|
binding.conversationName.setText(conversation!!.displayName)
|
||||||
|
|
||||||
if (conversation!!.description != null && conversation!!.description!!.isNotEmpty()) {
|
if (conversation!!.description.isNotEmpty()) {
|
||||||
binding.conversationDescription.setText(conversation!!.description)
|
binding.conversationDescription.setText(conversation!!.description)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,45 +206,6 @@ class ConversationInfoEditActivity : BaseActivity() {
|
|||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conversationInfoEditViewModel.renameRoomUiState.observe(this) { uiState ->
|
|
||||||
when (uiState) {
|
|
||||||
is ConversationInfoEditViewModel.RenameRoomUiState.None -> {
|
|
||||||
}
|
|
||||||
is ConversationInfoEditViewModel.RenameRoomUiState.Success -> {
|
|
||||||
if (CapabilitiesUtil.isConversationDescriptionEndpointAvailable(spreedCapabilities)) {
|
|
||||||
saveConversationDescription()
|
|
||||||
} else {
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is ConversationInfoEditViewModel.RenameRoomUiState.Error -> {
|
|
||||||
Snackbar.make(
|
|
||||||
binding.root,
|
|
||||||
context.getString(R.string.default_error_msg),
|
|
||||||
Snackbar.LENGTH_LONG
|
|
||||||
).show()
|
|
||||||
Log.e(TAG, "Error while saving conversation name", uiState.exception)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
conversationInfoEditViewModel.setConversationDescriptionUiState.observe(this) { uiState ->
|
|
||||||
when (uiState) {
|
|
||||||
is ConversationInfoEditViewModel.SetConversationDescriptionUiState.None -> {
|
|
||||||
}
|
|
||||||
is ConversationInfoEditViewModel.SetConversationDescriptionUiState.Success -> {
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
is ConversationInfoEditViewModel.SetConversationDescriptionUiState.Error -> {
|
|
||||||
Snackbar.make(
|
|
||||||
binding.root,
|
|
||||||
context.getString(R.string.default_error_msg),
|
|
||||||
Snackbar.LENGTH_LONG
|
|
||||||
).show()
|
|
||||||
Log.e(TAG, "Error while saving conversation description", uiState.exception)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAvatarOptions() {
|
private fun setupAvatarOptions() {
|
||||||
|
@ -325,18 +325,12 @@ class ConversationsListActivity :
|
|||||||
conversationsListViewModel.getFederationInvitationsViewState.observe(this) { state ->
|
conversationsListViewModel.getFederationInvitationsViewState.observe(this) { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
is ConversationsListViewModel.GetFederationInvitationsStartState -> {
|
is ConversationsListViewModel.GetFederationInvitationsStartState -> {
|
||||||
binding.conversationListHintInclude.conversationListHintLayout.visibility =
|
binding.conversationListHintInclude.conversationListHintLayout.visibility = View.GONE
|
||||||
View.GONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is ConversationsListViewModel.GetFederationInvitationsSuccessState -> {
|
is ConversationsListViewModel.GetFederationInvitationsSuccessState -> {
|
||||||
if (state.showInvitationsHint) {
|
|
||||||
binding.conversationListHintInclude.conversationListHintLayout.visibility =
|
binding.conversationListHintInclude.conversationListHintLayout.visibility =
|
||||||
View.VISIBLE
|
if (state.showInvitationsHint) View.VISIBLE else View.GONE
|
||||||
} else {
|
|
||||||
binding.conversationListHintInclude.conversationListHintLayout.visibility =
|
|
||||||
View.GONE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is ConversationsListViewModel.GetFederationInvitationsErrorState -> {
|
is ConversationsListViewModel.GetFederationInvitationsErrorState -> {
|
||||||
@ -387,6 +381,12 @@ class ConversationsListActivity :
|
|||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
conversationsListViewModel.getRoomsFlow
|
conversationsListViewModel.getRoomsFlow
|
||||||
.onEach { list ->
|
.onEach { list ->
|
||||||
|
setConversationList(list)
|
||||||
|
}.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setConversationList(list: List<ConversationModel>) {
|
||||||
// Update Conversations
|
// Update Conversations
|
||||||
conversationItems.clear()
|
conversationItems.clear()
|
||||||
conversationItemsWithHeader.clear()
|
conversationItemsWithHeader.clear()
|
||||||
@ -408,8 +408,6 @@ class ConversationsListActivity :
|
|||||||
intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1)
|
intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1)
|
||||||
)
|
)
|
||||||
fetchOpenConversations(apiVersion)
|
fetchOpenConversations(apiVersion)
|
||||||
}.collect()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasFilterEnabled(): Boolean {
|
private fun hasFilterEnabled(): Boolean {
|
||||||
|
@ -292,33 +292,11 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
|
|||||||
return hasLinkedAccount
|
return hasLinkedAccount
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createLinkedAccount(lookupKey: String, cloudId: String) {
|
fun createOps(
|
||||||
val lookupUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
|
cloudId: String,
|
||||||
val lookupContactUri = ContactsContract.Contacts.lookupContact(context.contentResolver, lookupUri)
|
numbers: MutableList<String>,
|
||||||
val contactCursor = context.contentResolver.query(
|
displayName: String?
|
||||||
lookupContactUri,
|
): ArrayList<ContentProviderOperation> {
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
)
|
|
||||||
|
|
||||||
if (contactCursor != null) {
|
|
||||||
if (contactCursor.count > 0) {
|
|
||||||
contactCursor.moveToFirst()
|
|
||||||
|
|
||||||
val id = contactCursor.getString(contactCursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID))
|
|
||||||
if (hasLinkedAccount(id)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val numbers = getPhoneNumbersFromDeviceContact(id)
|
|
||||||
val displayName = ContactUtils.getDisplayNameFromDeviceContact(context, id)
|
|
||||||
|
|
||||||
if (displayName == null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val ops = ArrayList<ContentProviderOperation>()
|
val ops = ArrayList<ContentProviderOperation>()
|
||||||
val rawContactsUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon().build()
|
val rawContactsUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon().build()
|
||||||
val dataUri = ContactsContract.Data.CONTENT_URI.buildUpon().build()
|
val dataUri = ContactsContract.Data.CONTENT_URI.buildUpon().build()
|
||||||
@ -369,21 +347,44 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
|
|||||||
.withValue(
|
.withValue(
|
||||||
ContactsContract.Data.DATA2,
|
ContactsContract.Data.DATA2,
|
||||||
String.format(
|
String.format(
|
||||||
context.resources.getString(
|
context.resources.getString(R.string.nc_phone_book_integration_chat_via),
|
||||||
R.string.nc_phone_book_integration_chat_via
|
|
||||||
),
|
|
||||||
accountName
|
accountName
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
|
return ops
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createLinkedAccount(lookupKey: String, cloudId: String) {
|
||||||
|
val lookupUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
|
||||||
|
val lookupContactUri = ContactsContract.Contacts.lookupContact(context.contentResolver, lookupUri)
|
||||||
|
val contactCursor = context.contentResolver.query(lookupContactUri, null, null, null, null)
|
||||||
|
|
||||||
|
if (contactCursor != null) {
|
||||||
|
if (contactCursor.count > 0) {
|
||||||
|
contactCursor.moveToFirst()
|
||||||
|
|
||||||
|
val id = contactCursor.getString(contactCursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID))
|
||||||
|
if (hasLinkedAccount(id)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val numbers = getPhoneNumbersFromDeviceContact(id)
|
||||||
|
val displayName = ContactUtils.getDisplayNameFromDeviceContact(context, id)
|
||||||
|
|
||||||
|
if (displayName == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val ops = createOps(cloudId, numbers, displayName)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.contentResolver.applyBatch(ContactsContract.AUTHORITY, ops)
|
context.contentResolver.applyBatch(ContactsContract.AUTHORITY, ops)
|
||||||
} catch (e: OperationApplicationException) {
|
} catch (e: OperationApplicationException) {
|
||||||
Log.e(javaClass.simpleName, "", e)
|
Log.e(TAG, "", e)
|
||||||
} catch (e: RemoteException) {
|
} catch (e: RemoteException) {
|
||||||
Log.e(javaClass.simpleName, "", e)
|
Log.e(TAG, "", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(
|
Log.d(
|
||||||
|
@ -217,8 +217,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||||||
private fun handleCallPushMessage() {
|
private fun handleCallPushMessage() {
|
||||||
val userBeingCalled = userManager.getUserWithId(signatureVerification.user!!.id!!).blockingGet()
|
val userBeingCalled = userManager.getUserWithId(signatureVerification.user!!.id!!).blockingGet()
|
||||||
|
|
||||||
fun prepareCallNotificationScreen(conversation: ConversationModel) {
|
fun createBundle(conversation: ConversationModel): Bundle {
|
||||||
val fullScreenIntent = Intent(context, CallNotificationActivity::class.java)
|
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString(KEY_ROOM_TOKEN, pushMessage.id)
|
bundle.putString(KEY_ROOM_TOKEN, pushMessage.id)
|
||||||
bundle.putInt(KEY_NOTIFICATION_TIMESTAMP, pushMessage.timestamp.toInt())
|
bundle.putInt(KEY_NOTIFICATION_TIMESTAMP, pushMessage.timestamp.toInt())
|
||||||
@ -248,6 +247,12 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||||||
BundleKeys.KEY_IS_MODERATOR,
|
BundleKeys.KEY_IS_MODERATOR,
|
||||||
ConversationUtils.isParticipantOwnerOrModerator(conversation)
|
ConversationUtils.isParticipantOwnerOrModerator(conversation)
|
||||||
)
|
)
|
||||||
|
return bundle
|
||||||
|
}
|
||||||
|
|
||||||
|
fun prepareCallNotificationScreen(conversation: ConversationModel) {
|
||||||
|
val fullScreenIntent = Intent(context, CallNotificationActivity::class.java)
|
||||||
|
val bundle = createBundle(conversation)
|
||||||
|
|
||||||
fullScreenIntent.putExtras(bundle)
|
fullScreenIntent.putExtras(bundle)
|
||||||
fullScreenIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
fullScreenIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
@ -509,6 +514,42 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||||||
|
|
||||||
val autoCancelOnClick = TYPE_RECORDING != pushMessage.type
|
val autoCancelOnClick = TYPE_RECORDING != pushMessage.type
|
||||||
|
|
||||||
|
val notificationBuilder =
|
||||||
|
createNotificationBuilder(category, contentTitle, contentText, baseUrl, pendingIntent, autoCancelOnClick)
|
||||||
|
val activeStatusBarNotification = findNotificationForRoom(
|
||||||
|
context,
|
||||||
|
signatureVerification.user!!,
|
||||||
|
pushMessage.id!!
|
||||||
|
)
|
||||||
|
|
||||||
|
// NOTE - systemNotificationId is an internal ID used on the device only.
|
||||||
|
// It is NOT the same as the notification ID used in communication with the server.
|
||||||
|
val systemNotificationId: Int =
|
||||||
|
activeStatusBarNotification?.id ?: calculateCRC32(System.currentTimeMillis().toString()).toInt()
|
||||||
|
|
||||||
|
if ((TYPE_CHAT == pushMessage.type || TYPE_REMINDER == pushMessage.type) &&
|
||||||
|
pushMessage.notificationUser != null
|
||||||
|
) {
|
||||||
|
prepareChatNotification(notificationBuilder, activeStatusBarNotification, systemNotificationId)
|
||||||
|
addReplyAction(notificationBuilder, systemNotificationId)
|
||||||
|
addMarkAsReadAction(notificationBuilder, systemNotificationId)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TYPE_RECORDING == pushMessage.type && ncNotification != null) {
|
||||||
|
addDismissRecordingAvailableAction(notificationBuilder, systemNotificationId, ncNotification)
|
||||||
|
addShareRecordingToChatAction(notificationBuilder, systemNotificationId, ncNotification)
|
||||||
|
}
|
||||||
|
sendNotification(systemNotificationId, notificationBuilder.build())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createNotificationBuilder(
|
||||||
|
category: String,
|
||||||
|
contentTitle: CharSequence?,
|
||||||
|
contentText: CharSequence?,
|
||||||
|
baseUrl: String?,
|
||||||
|
pendingIntent: PendingIntent?,
|
||||||
|
autoCancelOnClick: Boolean
|
||||||
|
): NotificationCompat.Builder {
|
||||||
val notificationBuilder = NotificationCompat.Builder(context!!, "1")
|
val notificationBuilder = NotificationCompat.Builder(context!!, "1")
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
.setCategory(category)
|
.setCategory(category)
|
||||||
@ -551,30 +592,7 @@ class NotificationWorker(context: Context, workerParams: WorkerParameters) : Wor
|
|||||||
notificationBuilder.setContentIntent(pendingIntent)
|
notificationBuilder.setContentIntent(pendingIntent)
|
||||||
val groupName = signatureVerification.user!!.id.toString() + "@" + pushMessage.id
|
val groupName = signatureVerification.user!!.id.toString() + "@" + pushMessage.id
|
||||||
notificationBuilder.setGroup(calculateCRC32(groupName).toString())
|
notificationBuilder.setGroup(calculateCRC32(groupName).toString())
|
||||||
val activeStatusBarNotification = findNotificationForRoom(
|
return notificationBuilder
|
||||||
context,
|
|
||||||
signatureVerification.user!!,
|
|
||||||
pushMessage.id!!
|
|
||||||
)
|
|
||||||
|
|
||||||
// NOTE - systemNotificationId is an internal ID used on the device only.
|
|
||||||
// It is NOT the same as the notification ID used in communication with the server.
|
|
||||||
val systemNotificationId: Int =
|
|
||||||
activeStatusBarNotification?.id ?: calculateCRC32(System.currentTimeMillis().toString()).toInt()
|
|
||||||
|
|
||||||
if ((TYPE_CHAT == pushMessage.type || TYPE_REMINDER == pushMessage.type) &&
|
|
||||||
pushMessage.notificationUser != null
|
|
||||||
) {
|
|
||||||
prepareChatNotification(notificationBuilder, activeStatusBarNotification, systemNotificationId)
|
|
||||||
addReplyAction(notificationBuilder, systemNotificationId)
|
|
||||||
addMarkAsReadAction(notificationBuilder, systemNotificationId)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TYPE_RECORDING == pushMessage.type && ncNotification != null) {
|
|
||||||
addDismissRecordingAvailableAction(notificationBuilder, systemNotificationId, ncNotification)
|
|
||||||
addShareRecordingToChatAction(notificationBuilder, systemNotificationId, ncNotification)
|
|
||||||
}
|
|
||||||
sendNotification(systemNotificationId, notificationBuilder.build())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLargeIcon(): Bitmap {
|
private fun getLargeIcon(): Bitmap {
|
||||||
|
@ -74,33 +74,21 @@ class SaveFileToStorageWorker(val context: Context, workerParameters: WorkerPara
|
|||||||
MediaScannerConnection.scanFile(context, arrayOf(cacheFile.absolutePath), null, null)
|
MediaScannerConnection.scanFile(context, arrayOf(cacheFile.absolutePath), null, null)
|
||||||
|
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
Toast.makeText(
|
Toast.makeText(context, R.string.nc_save_success, Toast.LENGTH_SHORT).show()
|
||||||
context,
|
|
||||||
context.resources.getString(R.string.nc_save_success),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success()
|
return Result.success()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.e(TAG, "Something went wrong when trying to save file to internal storage", e)
|
Log.e(TAG, "Something went wrong when trying to save file to internal storage", e)
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
Toast.makeText(
|
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_SHORT).show()
|
||||||
context,
|
|
||||||
context.resources.getString(R.string.nc_common_error_sorry),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
} catch (e: NullPointerException) {
|
} catch (e: NullPointerException) {
|
||||||
Log.e(TAG, "Something went wrong when trying to save file to internal storage", e)
|
Log.e(TAG, "Something went wrong when trying to save file to internal storage", e)
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
Toast.makeText(
|
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_SHORT).show()
|
||||||
context,
|
|
||||||
context.resources.getString(R.string.nc_common_error_sorry),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
|
@ -110,46 +110,10 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||||||
fileName = FileUtils.getFileName(sourceFileUri, context)
|
fileName = FileUtils.getFileName(sourceFileUri, context)
|
||||||
file = FileUtils.getFileFromUri(context, sourceFileUri)
|
file = FileUtils.getFileFromUri(context, sourceFileUri)
|
||||||
val remotePath = getRemotePath(currentUser)
|
val remotePath = getRemotePath(currentUser)
|
||||||
val uploadSuccess: Boolean
|
|
||||||
|
|
||||||
initNotificationSetup()
|
initNotificationSetup()
|
||||||
file?.let { isChunkedUploading = it.length() > CHUNK_UPLOAD_THRESHOLD_SIZE }
|
file?.let { isChunkedUploading = it.length() > CHUNK_UPLOAD_THRESHOLD_SIZE }
|
||||||
if (file == null) {
|
val uploadSuccess: Boolean = uploadFile(sourceFileUri, metaData, remotePath)
|
||||||
uploadSuccess = false
|
|
||||||
} else if (isChunkedUploading) {
|
|
||||||
Log.d(TAG, "starting chunked upload because size is " + file!!.length())
|
|
||||||
|
|
||||||
initNotificationWithPercentage()
|
|
||||||
val mimeType = context.contentResolver.getType(sourceFileUri)?.toMediaTypeOrNull()
|
|
||||||
|
|
||||||
chunkedFileUploader = ChunkedFileUploader(
|
|
||||||
okHttpClient,
|
|
||||||
currentUser,
|
|
||||||
roomToken,
|
|
||||||
metaData,
|
|
||||||
this
|
|
||||||
)
|
|
||||||
|
|
||||||
uploadSuccess = chunkedFileUploader!!.upload(
|
|
||||||
file!!,
|
|
||||||
mimeType,
|
|
||||||
remotePath
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "starting normal upload (not chunked) of $fileName")
|
|
||||||
|
|
||||||
uploadSuccess = FileUploader(
|
|
||||||
context,
|
|
||||||
currentUser,
|
|
||||||
roomToken,
|
|
||||||
ncApi
|
|
||||||
).upload(
|
|
||||||
sourceFileUri,
|
|
||||||
fileName,
|
|
||||||
remotePath,
|
|
||||||
metaData
|
|
||||||
).blockingFirst()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uploadSuccess) {
|
if (uploadSuccess) {
|
||||||
cancelNotification()
|
cancelNotification()
|
||||||
@ -169,16 +133,31 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun uploadFile(sourceFileUri: Uri, metaData: String?, remotePath: String): Boolean {
|
||||||
|
return if (file == null) {
|
||||||
|
false
|
||||||
|
} else if (isChunkedUploading) {
|
||||||
|
Log.d(TAG, "starting chunked upload because size is " + file!!.length())
|
||||||
|
|
||||||
|
initNotificationWithPercentage()
|
||||||
|
val mimeType = context.contentResolver.getType(sourceFileUri)?.toMediaTypeOrNull()
|
||||||
|
|
||||||
|
chunkedFileUploader = ChunkedFileUploader(okHttpClient, currentUser, roomToken, metaData, this)
|
||||||
|
chunkedFileUploader!!.upload(file!!, mimeType, remotePath)
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "starting normal upload (not chunked) of $fileName")
|
||||||
|
|
||||||
|
FileUploader(context, currentUser, roomToken, ncApi)
|
||||||
|
.upload(sourceFileUri, fileName, remotePath, metaData)
|
||||||
|
.blockingFirst()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getRemotePath(currentUser: User): String {
|
private fun getRemotePath(currentUser: User): String {
|
||||||
var remotePath = CapabilitiesUtil.getAttachmentFolder(
|
val remotePath = CapabilitiesUtil.getAttachmentFolder(
|
||||||
currentUser.capabilities!!.spreedCapability!!
|
currentUser.capabilities!!.spreedCapability!!
|
||||||
) + "/" + fileName
|
) + "/" + fileName
|
||||||
remotePath = RemoteFileUtils.getNewPathIfFileExists(
|
return RemoteFileUtils.getNewPathIfFileExists(ncApi, currentUser, remotePath)
|
||||||
ncApi,
|
|
||||||
currentUser,
|
|
||||||
remotePath
|
|
||||||
)
|
|
||||||
return remotePath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTransferProgress(percentage: Int) {
|
override fun onTransferProgress(percentage: Int) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
build:
|
build:
|
||||||
maxIssues: 99
|
maxIssues: 87
|
||||||
weights:
|
weights:
|
||||||
# complexity: 2
|
# complexity: 2
|
||||||
# LongParameterList: 1
|
# LongParameterList: 1
|
||||||
|
Loading…
Reference in New Issue
Block a user