Commit 0d37954e authored by Leonardo Aramaki's avatar Leonardo Aramaki

Fix margins and ellipsize hostname on server list

parent 3d325cdf
...@@ -265,27 +265,29 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract ...@@ -265,27 +265,29 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
if (subPane != null) { if (subPane != null) {
LinearLayout serverListContainer = subPane.findViewById(R.id.server_list_bar); LinearLayout serverListContainer = subPane.findViewById(R.id.server_list_bar);
for (Pair<String, String> server : serverList) { for (Pair<String, String> server : serverList) {
if (serverListContainer.findViewWithTag(server.first) == null) { String serverHostname = server.first;
String serverLogoUrl = server.second;
if (serverListContainer.findViewWithTag(serverHostname) == null) {
int serverCount = serverListContainer.getChildCount(); int serverCount = serverListContainer.getChildCount();
View serverRow = LayoutInflater.from(this).inflate(R.layout.server_row, serverListContainer, false); View serverRow = LayoutInflater.from(this).inflate(R.layout.server_row, serverListContainer, false);
SimpleDraweeView serverButton = serverRow.findViewById(R.id.drawee_server_button); SimpleDraweeView serverButton = serverRow.findViewById(R.id.drawee_server_button);
TextView serverLabel = serverRow.findViewById(R.id.text_view_server_label); TextView serverLabel = serverRow.findViewById(R.id.text_view_server_label);
serverButton.setTag(server.first); serverButton.setTag(serverHostname);
serverLabel.setText(server.first); serverLabel.setText(serverHostname);
// Currently selected server // Currently selected server
if (server.first.equalsIgnoreCase(hostname)) { if (serverHostname.equalsIgnoreCase(hostname)) {
serverLabel.setSelected(true); serverLabel.setSelected(true);
serverLabel.setTypeface(Typeface.DEFAULT_BOLD); serverLabel.setTypeface(Typeface.DEFAULT_BOLD);
} }
serverRow.setOnClickListener(view -> changeServerIfNeeded(server.first)); serverRow.setOnClickListener(view -> changeServerIfNeeded(serverHostname));
Drawable drawable = AvatarHelper.INSTANCE.getTextDrawable(server.first,this); Drawable placeholder = AvatarHelper.INSTANCE.getTextDrawable(serverHostname,this);
FrescoHelper.INSTANCE.loadImage(serverButton, server.second, drawable); FrescoHelper.INSTANCE.loadImage(serverButton, serverLogoUrl, placeholder);
serverListContainer.addView(serverRow, serverCount - 1); serverListContainer.addView(serverRow, serverCount - 1);
serverListContainer.requestLayout(); serverListContainer.requestLayout();
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
android:theme="@style/AppTheme.Dark"> android:theme="@style/AppTheme.Dark">
<android.support.v4.widget.NestedScrollView <android.support.v4.widget.NestedScrollView
android:layout_width="280dp" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="start" android:layout_gravity="start"
android:background="?attr/colorPrimaryDark"> android:background="?attr/colorPrimaryDark">
<LinearLayout <LinearLayout
android:id="@+id/server_list_bar" android:id="@+id/server_list_bar"
android:layout_width="280dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp"> android:layout_height="80dp">
...@@ -11,20 +11,23 @@ ...@@ -11,20 +11,23 @@
style="@style/Base.Widget.AppCompat.Button.Borderless" style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="80dp" android:layout_height="80dp"
android:paddingStart="8dp" android:layout_marginEnd="8dp"
android:paddingEnd="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
fresco:actualImageScaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
fresco:actualImageScaleType="fitXY" />
<TextView <TextView
android:id="@+id/text_view_server_label" android:id="@+id/text_view_server_label"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="8dp" android:layout_marginEnd="16dp"
android:paddingEnd="8dp" android:layout_marginRight="16dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="@color/selector_text_color_multiserver" android:textColor="@color/selector_text_color_multiserver"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment