mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 20:49:36 +01:00
simplify complex conditions for readability
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
454dbc5db2
commit
6206e4910d
@ -113,10 +113,10 @@ class AccountVerificationController(args: Bundle? = null) :
|
||||
|
||||
actionBar?.hide()
|
||||
|
||||
if (isAccountImport &&
|
||||
if (
|
||||
isAccountImport &&
|
||||
!UriUtils.hasHttpProtocollPrefixed(baseUrl!!) ||
|
||||
!TextUtils.isEmpty(originalProtocol!!) &&
|
||||
!baseUrl!!.startsWith(originalProtocol!!)
|
||||
isSameProtocol(baseUrl!!, originalProtocol!!)
|
||||
) {
|
||||
determineBaseUrlProtocol(true)
|
||||
} else {
|
||||
@ -124,6 +124,10 @@ class AccountVerificationController(args: Bundle? = null) :
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSameProtocol(baseUrl: String, originalProtocol: String ) : Boolean {
|
||||
return !TextUtils.isEmpty(originalProtocol) && !baseUrl.startsWith(originalProtocol)
|
||||
}
|
||||
|
||||
private fun checkEverything() {
|
||||
val credentials = ApiUtils.getCredentials(username, token)
|
||||
cookieManager.cookieStore.removeAll()
|
||||
|
@ -1605,12 +1605,7 @@ class ChatController(args: Bundle) :
|
||||
activity?.findViewById<View>(R.id.toolbar)?.setOnClickListener(null)
|
||||
}
|
||||
|
||||
if (conversationUser != null &&
|
||||
activity != null &&
|
||||
!activity?.isChangingConfigurations!! &&
|
||||
!ApplicationWideCurrentRoomHolder.getInstance().isInCall &&
|
||||
!ApplicationWideCurrentRoomHolder.getInstance().isDialing
|
||||
) {
|
||||
if (conversationUser != null && isActivityNotChangingConfigurations() && isNotInCall()) {
|
||||
ApplicationWideCurrentRoomHolder.getInstance().clear()
|
||||
if (inConversation && validSessionId()) {
|
||||
leaveRoom()
|
||||
@ -1622,6 +1617,15 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
}
|
||||
|
||||
private fun isActivityNotChangingConfigurations(): Boolean {
|
||||
return activity != null && !activity?.isChangingConfigurations!!
|
||||
}
|
||||
|
||||
private fun isNotInCall(): Boolean {
|
||||
return !ApplicationWideCurrentRoomHolder.getInstance().isInCall &&
|
||||
!ApplicationWideCurrentRoomHolder.getInstance().isDialing
|
||||
}
|
||||
|
||||
override val title: String
|
||||
get() =
|
||||
if (currentConversation?.displayName != null) {
|
||||
@ -2118,11 +2122,9 @@ class ChatController(args: Bundle) :
|
||||
|
||||
for (i in chatMessageList.indices) {
|
||||
if (chatMessageList.size > i + 1) {
|
||||
if (TextUtils.isEmpty(chatMessageList[i].systemMessage) &&
|
||||
TextUtils.isEmpty(chatMessageList[i + 1].systemMessage) &&
|
||||
if (isSameDayNonSystemMessages(chatMessageList[i], chatMessageList[i + 1]) &&
|
||||
chatMessageList[i + 1].actorId == chatMessageList[i].actorId &&
|
||||
countGroupedMessages < 4 &&
|
||||
DateFormatter.isSameDay(chatMessageList[i].createdAt, chatMessageList[i + 1].createdAt)
|
||||
countGroupedMessages < 4
|
||||
) {
|
||||
chatMessageList[i].isGrouped = true
|
||||
countGroupedMessages++
|
||||
@ -2254,6 +2256,12 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSameDayNonSystemMessages(messageLeft: ChatMessage, messageRight: ChatMessage): Boolean {
|
||||
return TextUtils.isEmpty(messageLeft.systemMessage) &&
|
||||
TextUtils.isEmpty(messageRight.systemMessage) &&
|
||||
DateFormatter.isSameDay(messageLeft.createdAt,messageRight.createdAt)
|
||||
}
|
||||
|
||||
override fun onLoadMore(page: Int, totalItemsCount: Int) {
|
||||
if (!historyRead && inConversation) {
|
||||
pullChatMessages(0)
|
||||
|
@ -213,9 +213,7 @@ class ServerSelectionController : NewBaseController(R.layout.controller_server_s
|
||||
val productName = resources!!.getString(R.string.nc_server_product_name)
|
||||
val versionString: String = status.getVersion().substring(0, status.getVersion().indexOf("."))
|
||||
val version: Int = versionString.toInt()
|
||||
if (status.isInstalled && !status.isMaintenance &&
|
||||
!status.isNeedsUpgrade && version >= 13
|
||||
) {
|
||||
if (isServerStatusQueryable(status) && version >= 13) {
|
||||
router.pushController(
|
||||
RouterTransaction.with(
|
||||
WebViewLoginController(
|
||||
@ -285,6 +283,10 @@ class ServerSelectionController : NewBaseController(R.layout.controller_server_s
|
||||
}
|
||||
}
|
||||
|
||||
private fun isServerStatusQueryable(status: Status): Boolean {
|
||||
return status.isInstalled && !status.isMaintenance && !status.isNeedsUpgrade
|
||||
}
|
||||
|
||||
private fun setErrorText(text: String) {
|
||||
binding.errorText.text = text
|
||||
binding.errorText.visibility = View.VISIBLE
|
||||
|
@ -51,6 +51,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import com.nextcloud.talk.utils.database.user.UserUtils
|
||||
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder
|
||||
import com.vanniktech.emoji.EmojiPopup
|
||||
import okhttp3.internal.immutableListOf
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.parceler.Parcels
|
||||
import org.parceler.Parcels.unwrap
|
||||
@ -215,15 +216,12 @@ class EntryMenuController(args: Bundle) :
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
if (operation === ConversationOperationEnum.OPS_CODE_JOIN_ROOM ||
|
||||
operation === ConversationOperationEnum.OPS_CODE_CHANGE_PASSWORD ||
|
||||
operation === ConversationOperationEnum.OPS_CODE_SET_PASSWORD ||
|
||||
operation === ConversationOperationEnum.OPS_CODE_SHARE_LINK
|
||||
) {
|
||||
if (PASSWORD_ENTRY_OPERATIONS.contains(operation)) {
|
||||
binding.textInputLayout.endIconMode = TextInputLayout.END_ICON_PASSWORD_TOGGLE
|
||||
} else {
|
||||
binding.textInputLayout.endIconMode = TextInputLayout.END_ICON_NONE
|
||||
}
|
||||
|
||||
binding.textInputLayout.hint = labelText
|
||||
binding.textInputLayout.requestFocus()
|
||||
|
||||
@ -327,4 +325,14 @@ class EntryMenuController(args: Bundle) :
|
||||
packageName = args.getString(BundleKeys.KEY_APP_ITEM_PACKAGE_NAME, "")
|
||||
callUrl = args.getString(BundleKeys.KEY_CALL_URL, "")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val PASSWORD_ENTRY_OPERATIONS: List<ConversationOperationEnum> =
|
||||
immutableListOf(
|
||||
ConversationOperationEnum.OPS_CODE_JOIN_ROOM,
|
||||
ConversationOperationEnum.OPS_CODE_CHANGE_PASSWORD,
|
||||
ConversationOperationEnum.OPS_CODE_SET_PASSWORD,
|
||||
ConversationOperationEnum.OPS_CODE_SHARE_LINK
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
build:
|
||||
maxIssues: 157
|
||||
maxIssues: 151
|
||||
weights:
|
||||
# complexity: 2
|
||||
# LongParameterList: 1
|
||||
|
Loading…
Reference in New Issue
Block a user