ratp: Don't show more than one line for old alerts
This commit is contained in:
parent
67008b9c57
commit
eb90840b54
@ -219,8 +219,8 @@ def display_longtext(draw, pos, text, font, anchor="lt", maxwidth=9999, maxlines
|
|||||||
if len(cur) > 0:
|
if len(cur) > 0:
|
||||||
lines.append(cur)
|
lines.append(cur)
|
||||||
|
|
||||||
maxlines -= 1
|
if len(lines) >= maxlines:
|
||||||
if maxlines <= 0:
|
lines = lines[0:maxlines]
|
||||||
lines[-1] += "…"
|
lines[-1] += "…"
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -264,9 +264,11 @@ class RATPWeatherModule:
|
|||||||
title = ""
|
title = ""
|
||||||
subtitle = ""
|
subtitle = ""
|
||||||
content = ""
|
content = ""
|
||||||
|
oneline = False
|
||||||
|
|
||||||
if "application_periods" in disruption:
|
if "application_periods" in disruption:
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
yesterday = now + timedelta(days=-1)
|
||||||
nextweek = now + timedelta(days=1)
|
nextweek = now + timedelta(days=1)
|
||||||
|
|
||||||
application_periods = []
|
application_periods = []
|
||||||
@ -283,6 +285,9 @@ class RATPWeatherModule:
|
|||||||
else:
|
else:
|
||||||
application_periods.append(ap)
|
application_periods.append(ap)
|
||||||
|
|
||||||
|
if ap["begin"] < yesterday:
|
||||||
|
oneline = True
|
||||||
|
|
||||||
if len(application_periods) == 0:
|
if len(application_periods) == 0:
|
||||||
continue
|
continue
|
||||||
elif len(application_periods) == 1:
|
elif len(application_periods) == 1:
|
||||||
@ -303,6 +308,7 @@ class RATPWeatherModule:
|
|||||||
"subtitle": subtitle,
|
"subtitle": subtitle,
|
||||||
"description": content,
|
"description": content,
|
||||||
"icon": alert_icon(mode, line),
|
"icon": alert_icon(mode, line),
|
||||||
|
"oneline": oneline,
|
||||||
}
|
}
|
||||||
|
|
||||||
def draw_module(self, config, width, height, line_height=19):
|
def draw_module(self, config, width, height, line_height=19):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user