-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
UI improvements #948
base: master
Are you sure you want to change the base?
UI improvements #948
Conversation
@@ -60,7 +61,7 @@ internal class TripDrawer(context: Context) : MapDrawer(context) { | |||
|
|||
// get colors | |||
val backgroundColor = getBackgroundColor(leg) | |||
val foregroundColor = getForegroundColor(leg) | |||
val foregroundColor = TransportrUtils.getTextColorBasedOnBackground(backgroundColor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good idea that this completely ignores the foreground color? I would expect something more like "If the foreground is too similar to the background, invert it".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get what you mean, this line sets the foregroundcolor (see corresponding method, to either white or black depending on what is better^^)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant that it does not take into consideration leg.line.style.foregroundColor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line style in the context of the TripDrawer, is being considered in the backgroundColor variable through getBackgroundColor()
app/src/main/java/de/grobox/transportr/trips/detail/TripDrawer.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/de/grobox/transportr/trips/detail/TripUtils.kt
Outdated
Show resolved
Hide resolved
// get colors | ||
val foregroundColor = line.style?.foregroundColor | ||
val backgroundColor = line.style?.backgroundColor | ||
val foregroundColor = getTextColorBasedOnBackground(backgroundColor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good idea that this completely ignores the foreground color? I would expect something more like "If the foreground is too similar to the background, invert it".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #948 (comment)
import de.schildbach.pte.dto.Line | ||
|
||
class LineView(context: Context, attr: AttributeSet?) : AppCompatTextView(context, attr) { | ||
|
||
fun setLine(line: Line) { | ||
fun setLine(line: Line, backgroundColor: Int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo a setter ("setLine") receiving having more than one parameter is very unintuitive and makes for the caller code harder to read. I would expect the function to be called setLineOverBackground
(or something like that) and/or to explicitly give the parameter name at the caller's site (setLine(leg.line, backgroundColor=foo)
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I can rename it if its cleaner that way :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I thought about it, and for it makes sense like it is right now.
The parameter called "backgroundColor" here, actually just represents the color of the line. It doesn't represent some "background" over which the "line" would be drawn. Does it make more sense with this explanation? I could add some comment in the code to explain this a little bit more :)
val colorsToCheck = listOfNotNull( | ||
line.style?.backgroundColor, | ||
line.style?.backgroundColor2, | ||
line.style?.foregroundColor, | ||
line.style?.borderColor | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the thought process behind this? This doesn't seem to align with the behavior before in any way. For example, why is the background color a "higher priority" than the foreground color?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are line colors, and I think I followed the current behavior well, see here:
Transportr/app/src/main/java/de/grobox/transportr/trips/detail/LegViewHolder.kt
Lines 216 to 222 in b8e78c2
private fun getLineColor(line: Line): Int { | |
if (line.style == null) return DEFAULT_LINE_COLOR | |
if (line.style!!.backgroundColor != 0) return line.style!!.backgroundColor | |
if (line.style!!.backgroundColor2 != 0) return line.style!!.backgroundColor2 | |
if (line.style!!.foregroundColor != 0) return line.style!!.foregroundColor | |
return if (line.style!!.borderColor != 0) line.style!!.borderColor else DEFAULT_LINE_COLOR | |
} |
Fixes:
Improves:
Screenshots: