Skip to content

Commit

Permalink
WIP detekt
Browse files Browse the repository at this point in the history
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
  • Loading branch information
rapterjet2004 committed May 14, 2024
1 parent 5848a79 commit 356f482
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,6 @@ class ConversationInfoActivity :
}

private fun listBans() {
// TODO trigger full screen dialog, need to make custom xml
val fragmentManager = supportFragmentManager
val newFragment = DialogBanListFragment(conversationToken)
val transaction = fragmentManager.beginTransaction()
Expand All @@ -586,7 +585,6 @@ class ConversationInfoActivity :
.add(android.R.id.content, newFragment)
.addToBackStack(null)
.commit()

}

private fun addParticipants() {
Expand Down Expand Up @@ -759,7 +757,9 @@ class ConversationInfoActivity :
ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL != conversation!!.type
) {
VISIBLE
} else GONE
} else {
GONE
}

if (conversation!!.notificationCalls === null) {
binding.notificationSettingsView.callNotificationsSwitch.visibility = GONE
Expand Down Expand Up @@ -1336,7 +1336,7 @@ class ConversationInfoActivity :
actionToTrigger++
}

when(actionToTrigger) {
when (actionToTrigger) {
1 -> {
// Promote/demote
if (apiVersion >= ApiUtils.API_V4) {
Expand All @@ -1345,14 +1345,17 @@ class ConversationInfoActivity :
toggleModeratorStatusLegacy(apiVersion, participant)
}
}

2 -> {
// Remove from conversation
removeAttendeeFromConversation(apiVersion, participant)
}

3 -> {
// Ban from conversation
handleBan(participant)
}

else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class ConversationInfoViewModel @Inject constructor(
PAUSED,
RESUMED
}

lateinit var currentLifeCycleFlag: LifeCycleFlag
public val disposableSet = mutableSetOf<Disposable>()
val disposableSet = mutableSetOf<Disposable>()

override fun onResume(owner: LifecycleOwner) {
super.onResume(owner)
Expand All @@ -54,11 +55,12 @@ class ConversationInfoViewModel @Inject constructor(
class ListBansSuccessState(val talkBans: List<TalkBan>) : ViewState
object ListBansErrorState : ViewState

private val _getTalkBansState: MutableLiveData<ViewState> = MutableLiveData()
private val _getTalkBanState: MutableLiveData<ViewState> = MutableLiveData()
val getTalkBanState: LiveData<ViewState>
get() = _getTalkBansState
get() = _getTalkBanState

class BanActorSuccessState(val talkBan: TalkBan) : ViewState

private val _getBanActorState: MutableLiveData<ViewState> = MutableLiveData()
val getBanActorState: LiveData<ViewState>
get() = _getBanActorState
Expand Down Expand Up @@ -128,15 +130,15 @@ class ConversationInfoViewModel @Inject constructor(
}

override fun onError(e: Throwable) {
_getTalkBansState.value = ListBansErrorState
_getTalkBanState.value = ListBansErrorState
}

override fun onComplete() {
// unused atm
}

override fun onNext(talkBans: List<TalkBan>) {
_getTalkBansState.value = ListBansSuccessState(talkBans)
_getTalkBanState.value = ListBansSuccessState(talkBans)
}
})
}
Expand All @@ -146,7 +148,7 @@ class ConversationInfoViewModel @Inject constructor(
chatRepository.banActor(user.getCredentials(), url, actorType, actorId, internalNote)
.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.subscribe(object: Observer<TalkBan> {
?.subscribe(object : Observer<TalkBan> {
override fun onSubscribe(p0: Disposable) {
// unused atm
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TalkBan(
@JsonField(name = ["bannedTime"])
var bannedTime: Int?,
@JsonField(name = ["internalNote"])
var internalNote: String?,
var internalNote: String?
) : Parcelable {
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
constructor() : this(null, null, null, null, null, null, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlinx.parcelize.Parcelize

@Parcelize
@JsonObject
class TalkBanOverall (
class TalkBanOverall(
@JsonField(name = ["ocs"])
var ocs: TalkBanOCS? = null
) : Parcelable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package com.nextcloud.talk.ui.dialog

import android.annotation.SuppressLint
import android.os.Bundle
import android.text.format.DateUtils
import android.view.LayoutInflater
Expand Down Expand Up @@ -61,10 +62,10 @@ class DialogBanListFragment(val roomToken: String) : DialogFragment() {
return bans[position].bannedTime!!.toLong()
}

@SuppressLint("ViewHolder")
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val binding = BanItemListBinding.inflate(LayoutInflater.from(context))
binding.banActorName.text = bans[position].bannedId
// TODO check if unban works
val time = bans[position].bannedTime!!.toLong()
binding.banTime.text = DateUtils.formatDateTime(
requireContext(),
Expand All @@ -77,10 +78,7 @@ class DialogBanListFragment(val roomToken: String) : DialogFragment() {
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
binding = FragmentDialogBanListBinding.inflate(LayoutInflater.from(context))
viewModel =
Expand All @@ -96,15 +94,15 @@ class DialogBanListFragment(val roomToken: String) : DialogFragment() {

private fun initObservers() {
viewModel.getTalkBanState.observe(viewLifecycleOwner) { state ->
when(state) {
when (state) {
is ConversationInfoViewModel.ListBansSuccessState -> {
adapter.setItems(state.talkBans)
binding.banListView.adapter = adapter

}
is ConversationInfoViewModel.ListBansErrorState -> {

is ConversationInfoViewModel.ListBansErrorState -> {
}

else -> {}
}
}
Expand All @@ -126,7 +124,6 @@ class DialogBanListFragment(val roomToken: String) : DialogFragment() {
viewModel.unbanActor(conversationUser, roomToken, banId)
}


companion object {
@JvmStatic
fun newInstance(roomToken: String) = DialogBanListFragment(roomToken)
Expand Down

0 comments on commit 356f482

Please sign in to comment.