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

Hide disconnect button and clients list if features are unavailable

parent 7c56c424
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ import android.widget.ImageView
import android.widget.TextView
import butterknife.BindView
import butterknife.ButterKnife
import de.kuschku.libquassel.quassel.ExtendedFeature
import de.kuschku.libquassel.quassel.syncables.CoreInfo
import de.kuschku.quasseldroid.R
import de.kuschku.quasseldroid.util.helper.getVectorDrawableCompat
......@@ -102,6 +103,7 @@ class ClientAdapter : ListAdapter<CoreInfo.ConnectedClientData, ClientAdapter.Cl
location.visibleIf(data.location.isNotBlank())
secureIcon.setImageDrawable(if (data.secure) secure else insecure)
disconnect.visibleIf(data.features.hasFeature(ExtendedFeature.RemoteDisconnect))
}
}
}
......@@ -51,15 +51,15 @@ class CoreInfoFragment : ServiceBoundFragment() {
@BindView(R.id.uptime)
lateinit var uptime: TextView
@BindView(R.id.secure_container)
lateinit var secureContainer: View
@BindView(R.id.secure)
lateinit var secureText: TextView
@BindView(R.id.secure_icon)
lateinit var secureIcon: ImageView
@BindView(R.id.clients_title)
lateinit var clientsTitle: View
@BindView(R.id.clients)
lateinit var clients: RecyclerView
......@@ -97,15 +97,14 @@ class CoreInfoFragment : ServiceBoundFragment() {
val sslSession = it?.orNull()
val leafCertificate = sslSession?.peerCertificateChain?.firstOrNull()
val issuerName = leafCertificate?.issuerDN?.name?.let(X509Helper::commonName)
?: requireContext().getString(R.string.label_core_connection_verified_by_unknown)
if (sslSession == null) {
secureText.text = requireContext().getString(R.string.label_core_connection_insecure)
secureIcon.setImageDrawable(insecure)
} else {
secureText.text = requireContext().getString(
R.string.label_core_connection_verified_by,
issuerName
?: requireContext().getString(R.string.label_core_connection_verified_by_unknown)
R.string.label_core_connection_verified_by, issuerName
)
secureIcon.setImageDrawable(secure)
}
......@@ -121,6 +120,7 @@ class CoreInfoFragment : ServiceBoundFragment() {
}
clients.adapter = adapter
viewModel.coreInfoClients.toLiveData().observe(this, Observer {
clientsTitle.visibleIf(it?.isNotEmpty() == true)
adapter.submitList(it)
})
......
......@@ -78,7 +78,6 @@
android:text="@string/label_core_security" />
<LinearLayout
android:id="@+id/secure_container"
style="@style/Widget.Info.Item"
android:orientation="horizontal">
......@@ -104,8 +103,11 @@
android:background="?colorDivider" />
<TextView
android:id="@+id/clients_title"
style="@style/Widget.Info.Section"
android:text="@string/label_core_clients" />
android:text="@string/label_core_clients"
android:visibility="gone"
tools:visibility="visible" />
<android.support.v7.widget.RecyclerView
android:id="@+id/clients"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment