Skip to content
Snippets Groups Projects
Verified Commit 8a294b16 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Cleaned up code

parent f8a34e74
Branches
Tags
No related merge requests found
......@@ -47,7 +47,6 @@ import de.kuschku.libquassel.protocol.Buffer_Type
import de.kuschku.libquassel.protocol.Message
import de.kuschku.libquassel.protocol.Message_Type
import de.kuschku.libquassel.protocol.message.HandshakeMessage
import de.kuschku.libquassel.quassel.ExtendedFeature
import de.kuschku.libquassel.session.Error
import de.kuschku.libquassel.util.Optional
import de.kuschku.libquassel.util.flag.and
......@@ -69,8 +68,8 @@ import de.kuschku.quasseldroid.ui.setup.accounts.selection.AccountSelectionActiv
import de.kuschku.quasseldroid.ui.setup.user.UserSetupActivity
import de.kuschku.quasseldroid.util.helper.*
import de.kuschku.quasseldroid.util.irc.format.IrcFormatDeserializer
import de.kuschku.quasseldroid.util.missingfeatures.MissingFeature
import de.kuschku.quasseldroid.util.missingfeatures.MissingFeaturesDialog
import de.kuschku.quasseldroid.util.missingfeatures.RequiredFeatures
import de.kuschku.quasseldroid.util.service.ServiceBoundActivity
import de.kuschku.quasseldroid.util.ui.DragInterceptBottomSheetBehavior
import de.kuschku.quasseldroid.util.ui.MaterialContentLoadingProgressBar
......@@ -464,58 +463,20 @@ class ChatActivity : ServiceBoundActivity(), SharedPreferences.OnSharedPreferenc
drawerLayout.openDrawer(Gravity.START)
}
connectedAccount = accountId
viewModel.session.value?.orNull()?.let {
if (it.identities.isEmpty()) {
viewModel.session.value?.orNull()?.let { session ->
if (session.identities.isEmpty()) {
UserSetupActivity.launch(this)
}
val missingFeatures = listOf(
ExtendedFeature.SynchronizedMarkerLine,
ExtendedFeature.SaslAuthentication,
ExtendedFeature.SaslExternal,
ExtendedFeature.HideInactiveNetworks,
ExtendedFeature.PasswordChange,
ExtendedFeature.CapNegotiation,
ExtendedFeature.VerifyServerSSL,
ExtendedFeature.CustomRateLimits,
ExtendedFeature.AwayFormatTimestamp,
ExtendedFeature.BufferActivitySync,
ExtendedFeature.CoreSideHighlights,
ExtendedFeature.SenderPrefixes,
ExtendedFeature.RemoteDisconnect,
ExtendedFeature.RichMessages,
ExtendedFeature.BacklogFilterType
) - it.features.core.enabledFeatures
val missingFeatures = RequiredFeatures.features.filter {
it.feature !in session.features.core.enabledFeatures
}
if (missingFeatures.isNotEmpty()) {
runInBackground {
val accounts = accountDatabase.accounts()
val account = accounts.findById(accountId)
if (account?.acceptedMissingFeatures == false) {
val dialog = MissingFeaturesDialog.Builder(this)
.missingFeatures(missingFeatures.mapNotNull { feature ->
when (feature) {
ExtendedFeature.SynchronizedMarkerLine -> R.string.label_feature_synchronizedmarkerline
ExtendedFeature.SaslAuthentication -> R.string.label_feature_saslauthentication
ExtendedFeature.SaslExternal -> R.string.label_feature_saslexternal
ExtendedFeature.HideInactiveNetworks -> R.string.label_feature_hideinactivenetworks
ExtendedFeature.PasswordChange -> R.string.label_feature_passwordchange
ExtendedFeature.CapNegotiation -> R.string.label_feature_capnegotiation
ExtendedFeature.VerifyServerSSL -> R.string.label_feature_verifyserverssl
ExtendedFeature.CustomRateLimits -> R.string.label_feature_customratelimits
ExtendedFeature.AwayFormatTimestamp -> R.string.label_feature_awayformattimestamp
ExtendedFeature.BufferActivitySync -> R.string.label_feature_bufferactivitysync
ExtendedFeature.CoreSideHighlights -> R.string.label_feature_coresidehighlights
ExtendedFeature.SenderPrefixes -> R.string.label_feature_senderprefixes
ExtendedFeature.RemoteDisconnect -> R.string.label_feature_remotedisconnect
ExtendedFeature.RichMessages -> R.string.label_feature_richmessages
ExtendedFeature.BacklogFilterType -> R.string.label_feature_backlogfiltertype
else -> null
}?.let {
MissingFeature(
feature = feature,
description = it
)
}
})
.missingFeatures(missingFeatures)
.positiveListener(MaterialDialog.SingleButtonCallback { _, _ ->
runInBackground {
accounts.save(account.copy(acceptedMissingFeatures = true))
......
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2018 Janne Koschinski
* Copyright (c) 2018 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.quasseldroid.util.missingfeatures
import de.kuschku.libquassel.quassel.ExtendedFeature
import de.kuschku.quasseldroid.R
object RequiredFeatures {
val features = listOf(
MissingFeature(ExtendedFeature.SynchronizedMarkerLine,
R.string.label_feature_synchronizedmarkerline),
MissingFeature(ExtendedFeature.SaslAuthentication,
R.string.label_feature_saslauthentication),
MissingFeature(ExtendedFeature.SaslExternal,
R.string.label_feature_saslexternal),
MissingFeature(ExtendedFeature.HideInactiveNetworks,
R.string.label_feature_hideinactivenetworks),
MissingFeature(ExtendedFeature.PasswordChange,
R.string.label_feature_passwordchange),
MissingFeature(ExtendedFeature.CapNegotiation,
R.string.label_feature_capnegotiation),
MissingFeature(ExtendedFeature.VerifyServerSSL,
R.string.label_feature_verifyserverssl),
MissingFeature(ExtendedFeature.CustomRateLimits,
R.string.label_feature_customratelimits),
MissingFeature(ExtendedFeature.AwayFormatTimestamp,
R.string.label_feature_awayformattimestamp),
MissingFeature(ExtendedFeature.BufferActivitySync,
R.string.label_feature_bufferactivitysync),
MissingFeature(ExtendedFeature.CoreSideHighlights,
R.string.label_feature_coresidehighlights),
MissingFeature(ExtendedFeature.SenderPrefixes,
R.string.label_feature_senderprefixes),
MissingFeature(ExtendedFeature.RemoteDisconnect,
R.string.label_feature_remotedisconnect),
MissingFeature(ExtendedFeature.RichMessages,
R.string.label_feature_richmessages),
MissingFeature(ExtendedFeature.BacklogFilterType,
R.string.label_feature_backlogfiltertype)
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment