Skip to content

Commit

Permalink
Improve server item layout
Browse files Browse the repository at this point in the history
- Allow SSH host address to wrap when space is limited
- Refactor hint icons to use a common style
- Update ConstraintLayout library version

Re: #140
  • Loading branch information
gujjwal00 committed Feb 18, 2023
1 parent 4e4f795 commit ae31db2
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ dependencies {
implementation "androidx.preference:preference-ktx:1.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
implementation "androidx.room:room-runtime:2.4.3"
implementation "androidx.room:room-ktx:2.4.3"
Expand Down
69 changes: 31 additions & 38 deletions app/src/main/res/layout/server_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
android:text='@{profile.host + (profile.port == 5900 ? "" : " | " + profile.port) }'
app:layout_constraintEnd_toStartOf="@id/ssh_address"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/name"
tools:text="192.168.1.1 | 5901" />
Expand All @@ -53,53 +56,43 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_small"
android:ellipsize="middle"
android:singleLine="true"
android:text='@{"(" + profile.sshHost + (profile.sshPort == 22 ? "" : " | " + profile.sshPort) + ")"}'
app:isVisible="@{profile.channelType == ServerProfile.CHANNEL_SSH_TUNNEL && !profile.host.equals(profile.sshHost)}"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@id/hint_icons"
app:layout_constraintStart_toEndOf="@id/address"
app:layout_constraintTop_toTopOf="@id/address"
tools:text="(10.0.5.5 | 23)" />

<ImageView
android:id="@+id/ssh_hint_icon"
android:layout_width="@dimen/server_card_hint_icon_size"
android:layout_height="@dimen/server_card_hint_icon_size"
android:layout_margin="@dimen/margin_normal"
android:importantForAccessibility="no"
android:src="@drawable/ic_ssh"
android:tintMode="src_in"
app:isVisible="@{profile.channelType == ServerProfile.CHANNEL_SSH_TUNNEL}"
<LinearLayout
android:id="@+id/hint_icons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/address"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/ssh_address"
app:layout_constraintTop_toTopOf="@id/address"
app:tint="?android:textColorSecondary" />
app:layout_constraintTop_toTopOf="@id/address">

<ImageView
android:id="@+id/password_hint_icon"
android:layout_width="@dimen/server_card_hint_icon_size"
android:layout_height="@dimen/server_card_hint_icon_size"
android:layout_margin="@dimen/margin_normal"
android:importantForAccessibility="no"
android:src="@drawable/ic_key"
android:tintMode="src_in"
app:isVisible="@{profile.password.length() != 0}"
app:layout_constraintBottom_toBottomOf="@id/address"
app:layout_constraintStart_toEndOf="@id/ssh_hint_icon"
app:layout_constraintTop_toTopOf="@id/address"
app:tint="?android:textColorSecondary" />
<ImageView
style="@style/ServerCardHintIcon"
android:importantForAccessibility="no"
android:src="@drawable/ic_ssh"
app:isVisible="@{profile.channelType == ServerProfile.CHANNEL_SSH_TUNNEL}" />

<ImageView
android:id="@+id/view_only_hint_icon"
android:layout_width="@dimen/server_card_hint_icon_size"
android:layout_height="@dimen/server_card_hint_icon_size"
android:layout_margin="@dimen/margin_normal"
android:importantForAccessibility="no"
android:src="@drawable/ic_visibility"
android:tintMode="src_in"
app:isVisible="@{profile.viewOnly}"
app:layout_constraintBottom_toBottomOf="@id/address"
app:layout_constraintStart_toEndOf="@id/password_hint_icon"
app:layout_constraintTop_toTopOf="@id/address"
app:tint="?android:textColorSecondary" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
style="@style/ServerCardHintIcon"
android:importantForAccessibility="no"
android:src="@drawable/ic_key"
app:isVisible="@{profile.password.length() != 0}" />

<ImageView
style="@style/ServerCardHintIcon"
android:importantForAccessibility="no"
android:src="@drawable/ic_visibility"
app:isVisible="@{profile.viewOnly}" />

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
1 change: 0 additions & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
<dimen name="server_card_elevation">2dp</dimen>
<dimen name="server_card_min_height">68dp</dimen>
<dimen name="server_card_stroke_width">0dp</dimen>
<dimen name="server_card_hint_icon_size">16dp</dimen>
</resources>
10 changes: 10 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@
<item name="strokeColor">@color/colorBorder</item>
</style>

<style name="ServerCardHintIcon">
<item name="android:layout_width">16dp</item>
<item name="android:layout_height">16dp</item>
<item name="android:layout_marginStart">@dimen/margin_normal</item>
<item name="android:layout_marginEnd">@dimen/margin_normal</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="tint">?android:textColorSecondary</item>
<item name="tintMode">src_in</item>
</style>

<style name="VirtualKey">
<item name="android:layout_height">36dp</item>
<item name="android:layout_width">wrap_content</item>
Expand Down

0 comments on commit ae31db2

Please sign in to comment.