status widget remove animation / change appearance

This commit is contained in:
veliymolfar 2020-02-11 12:23:32 +02:00
parent 4b2f0cf266
commit 0566232711
2 changed files with 19 additions and 12 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="shared_string_error_short">ERR</string>
<string name="last_update_from_telegram_date">Last update from Telegram: %1$s</string> <string name="last_update_from_telegram_date">Last update from Telegram: %1$s</string>
<string name="last_response_date">Last response: %1$s</string> <string name="last_response_date">Last response: %1$s</string>
<string name="last_update_from_telegram_duration">Last update from Telegram: %1$s ago</string> <string name="last_update_from_telegram_duration">Last update from Telegram: %1$s ago</string>

View file

@ -49,10 +49,10 @@ class ShowLocationHelper(private val app: TelegramApplication) {
private const val STATUS_WIDGET_MENU_ICON = "widget_location_sharing_night" private const val STATUS_WIDGET_MENU_ICON = "widget_location_sharing_night"
private const val STATUS_WIDGET_MENU_ICON_OLD = "ic_action_relative_bearing" private const val STATUS_WIDGET_MENU_ICON_OLD = "ic_action_relative_bearing"
private const val STATUS_WIDGET_ICON_OLD = "widget_relative_bearing_day" private const val STATUS_WIDGET_ICON_OLD = "widget_relative_bearing_day"
private const val STATUS_WIDGET_ANIM_ICON_DAY = "anim_widget_location_sharing_day" private const val STATUS_WIDGET_ICON_DAY = "widget_location_sharing_day"
private const val STATUS_WIDGET_ANIM_ICON_NIGHT = "anim_widget_location_sharing_night" private const val STATUS_WIDGET_ICON_NIGHT = "widget_location_sharing_night"
private const val STATUS_WIDGET_ON_ANIM_ICON_DAY = "anim_widget_location_sharing_on_day" private const val STATUS_WIDGET_ON_ICON_DAY = "widget_location_sharing_on_day"
private const val STATUS_WIDGET_ON_ANIM_ICON_NIGHT = "anim_widget_location_sharing_on_night" private const val STATUS_WIDGET_ON_ICON_NIGHT = "widget_location_sharing_on_night"
private const val STATUS_WIDGET_OFF_ICON_DAY = "widget_location_sharing_off_day" private const val STATUS_WIDGET_OFF_ICON_DAY = "widget_location_sharing_off_day"
private const val STATUS_WIDGET_OFF_ICON_NIGHT = "widget_location_sharing_off_night" private const val STATUS_WIDGET_OFF_ICON_NIGHT = "widget_location_sharing_off_night"
@ -232,21 +232,27 @@ class ShowLocationHelper(private val app: TelegramApplication) {
STATUS_WIDGET_MENU_ICON_OLD STATUS_WIDGET_MENU_ICON_OLD
} }
val text = when { val text = when {
time > 0L -> { time > 0L && isSending -> {
iconDay = STATUS_WIDGET_ANIM_ICON_DAY iconDay = STATUS_WIDGET_ON_ICON_DAY
iconNight = STATUS_WIDGET_ANIM_ICON_NIGHT iconNight = STATUS_WIDGET_ON_ICON_NIGHT
val diffTime = (System.currentTimeMillis() - time) / 1000
OsmandFormatter.getFormattedDurationForWidget(diffTime)
}
time > 0L && !isSending -> {
iconDay = STATUS_WIDGET_ICON_DAY
iconNight = STATUS_WIDGET_ICON_NIGHT
val diffTime = (System.currentTimeMillis() - time) / 1000 val diffTime = (System.currentTimeMillis() - time) / 1000
OsmandFormatter.getFormattedDurationForWidget(diffTime) OsmandFormatter.getFormattedDurationForWidget(diffTime)
} }
time == 0L && isSending -> { time == 0L && isSending -> {
iconDay = STATUS_WIDGET_ON_ANIM_ICON_DAY iconDay = STATUS_WIDGET_ON_ICON_DAY
iconNight = STATUS_WIDGET_ON_ANIM_ICON_NIGHT iconNight = STATUS_WIDGET_ON_ICON_NIGHT
app.getString(R.string.shared_string_ok) app.getString(R.string.shared_string_ok)
} }
time == 0L && !isSending -> { time == 0L && !isSending -> {
iconDay = STATUS_WIDGET_ANIM_ICON_DAY iconDay = STATUS_WIDGET_ICON_DAY
iconNight = STATUS_WIDGET_ANIM_ICON_NIGHT iconNight = STATUS_WIDGET_ICON_NIGHT
app.getString(R.string.shared_string_ok) app.getString(R.string.shared_string_error_short)
} }
else -> { else -> {
iconDay = STATUS_WIDGET_OFF_ICON_DAY iconDay = STATUS_WIDGET_OFF_ICON_DAY