Skip to content

Commit

Permalink
feat: color completed torrents differently
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Jun 18, 2021
1 parent 39220f0 commit fae193b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package org.equeim.tremotesf.ui.torrentslistfragment

import android.annotation.SuppressLint
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.os.Build
import android.text.TextUtils
Expand Down Expand Up @@ -131,7 +132,16 @@ class TorrentsAdapter(private val fragment: TorrentsListFragment) :
}
etaTextView.text = FormatUtils.formatDuration(context, torrent.eta)

progressBar.progress = (torrent.percentDone * 100).toInt()
val progress = (torrent.percentDone * 100).toInt()
progressBar.progress = progress
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
progressBar.progressTintList = if (progress == 100) {
ColorStateList.valueOf(context.getColor(R.color.color_downloaded_torrents))
} else {
ColorStateList.valueOf(context.getColor(R.color.color_primary))
}
}

downloadSpeedTextView.text = context.getString(
R.string.download_speed_string,
FormatUtils.formatByteSpeed(
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<color name="color_primary">#ef5350</color>
<color name="color_on_primary">#ffffff</color>
<color name="color_background">@color/color_background_dark</color>
<color name="color_downloaded_torrents">#50cf50</color>

<color name="color_primary_old">#80cbc4</color>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<color name="color_on_primary">#ffffff</color>
<color name="color_background">#ffffff</color>
<color name="color_background_dark">#ff202020</color>
<color name="color_downloaded_torrents">#50af50</color>

<color name="color_primary_old">#008577</color>
</resources>
2 changes: 1 addition & 1 deletion bencode

0 comments on commit fae193b

Please sign in to comment.