Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show labels in UI #322

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class TorrentDetailsFragment :
if (!comment.contentEquals(commentTextView.text)) {
commentTextView.text = comment
}

labelsTextView.text = torrentDetails.labels.joinToString(", ")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ class TorrentsAdapter(
statusTextView.text = it
}
}

if (torrent.labels.isNotEmpty()) {
labelsTextView.visibility = View.VISIBLE
labelsTextView.text = torrent.labels.joinToString(", ")
} else {
labelsTextView.visibility = View.GONE
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_label_16dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/icon_color">
<path
android:fillColor="@android:color/black"
android:pathData="M17.63,5.84C17.27,5.33 16.67,5 16,5L5,5.01C3.9,5.01 3,5.9 3,7v10c0,1.1 0.9,1.99 2,1.99L16,19c0.67,0 1.27,-0.33 1.63,-0.84L22,12l-4.37,-6.16zM16,17H5V7h11l3.55,5L16,17z" />
</vector>
16 changes: 16 additions & 0 deletions app/src/main/res/layout/torrent_details_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,22 @@ SPDX-License-Identifier: GPL-3.0-or-later
android:autoLink="web"
android:textIsSelectable="true"
app:layout_columnWeight="2" />

<TextView
android:layout_width="0dp"
android:layout_marginTop="@dimen/linear_layout_vertical_spacing"
android:maxLines="5"
android:text="@string/labels"
app:layout_columnWeight="1" />

<TextView
android:id="@+id/labels_text_view"
android:layout_width="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="@dimen/linear_layout_vertical_spacing"
android:autoLink="web"
android:textIsSelectable="true"
app:layout_columnWeight="2" />
</androidx.gridlayout.widget.GridLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/torrent_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
-->

<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:checkable="true"
Expand Down Expand Up @@ -92,5 +93,19 @@ SPDX-License-Identifier: GPL-3.0-or-later
android:maxLines="3"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="Nope" />

<TextView
android:id="@+id/labels_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="@id/status_text_view"
android:layout_marginStart="24dp"
android:ellipsize="end"
android:maxLines="1"
android:drawablePadding="2dp"
android:textAppearance="?android:attr/textAppearanceSmall"
app:drawableStartCompat="@drawable/ic_label_16dp"
tools:text="label" />
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
1 change: 1 addition & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="created_by">Created by</string>
<string name="created_on">Created on</string>
<string name="comment">Comment</string>
<string name="labels">Labels</string>

<string name="parent_directory_list_item_label">..</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="created_by">Created by</string>
<string name="created_on">Created on</string>
<string name="comment">Comment</string>
<string name="labels">Labels</string>

<string name="parent_directory_list_item_label">..</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ data class Torrent(
@Serializable(TrackerSitesSerializer::class)
@SerialName("trackers")
val trackerSites: List<String>,
@SerialName("labels")
val labels: List<String> = emptyList(),
) : RpcTorrentFinishedState {
override val isFinished: Boolean get() = leftUntilDone.bytes == 0L
val isDownloadingStalled: Boolean get() = peersSendingToUsCount == 0 && webSeedersSendingToUsCount == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ data class TorrentDetails(
val webSeedersSendingToUsCount: Int,
@SerialName("addedDate")
val addedDate: Instant?,
@SerialName("labels")
val labels: List<String> = emptyList(),

@SerialName("downloadedEver")
val totalDownloaded: FileSize,
Expand Down