diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-06-05 14:06:49 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-06-08 13:46:41 +0000 |
| commit | bda2b2046f28579ff7d62477fa42ec0fb359e48a (patch) | |
| tree | eaf4456ca16d5ddcd17bb5643f50066e4d7e0693 /android/src | |
| parent | 70a52232c22b6f4933ea1e7de91edcaf5a068ba0 (diff) | |
| download | mullvadvpn-bda2b2046f28579ff7d62477fa42ec0fb359e48a.tar.xz mullvadvpn-bda2b2046f28579ff7d62477fa42ec0fb359e48a.zip | |
Use `TimeLeftFormatter` in `RemainingTimeLabel`
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/RemainingTimeLabel.kt | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/RemainingTimeLabel.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/RemainingTimeLabel.kt index f20f6974fd..20a5c62e6e 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/RemainingTimeLabel.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/RemainingTimeLabel.kt @@ -4,12 +4,13 @@ import android.content.Context import android.view.View import android.widget.TextView import net.mullvad.mullvadvpn.R +import net.mullvad.mullvadvpn.util.TimeLeftFormatter import org.joda.time.DateTime import org.joda.time.Duration -import org.joda.time.PeriodType class RemainingTimeLabel(val context: Context, val view: View) { private val resources = context.resources + private val formatter = TimeLeftFormatter(resources) private val expiredColor = resources.getColor(R.color.red) private val normalColor = resources.getColor(R.color.white60) @@ -32,21 +33,7 @@ class RemainingTimeLabel(val context: Context, val view: View) { label.setText(R.string.out_of_time) label.setTextColor(expiredColor) } else { - val remainingTimeInfo = - remainingTime.toPeriodTo(expiry, PeriodType.yearMonthDayTime()) - - if (remainingTimeInfo.years > 0) { - label.setText(getRemainingText(R.plurals.years_left, remainingTimeInfo.years)) - } else if (remainingTimeInfo.months >= 3) { - label.setText(getRemainingText(R.plurals.months_left, remainingTimeInfo.months)) - } else if (remainingTimeInfo.months > 0 || remainingTimeInfo.days >= 1) { - label.setText( - getRemainingText(R.plurals.days_left, remainingTime.standardDays.toInt()) - ) - } else { - label.setText(R.string.less_than_a_day_left) - } - + label.setText(formatter.format(expiry, remainingTime)) label.setTextColor(normalColor) } } else { |
