Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

UI improvements #948

wants to merge 3 commits into from

Conversation

Altonss
Copy link
Collaborator

@Altonss Altonss commented May 25, 2024

Fixes:

Improves:

  • Intermediate stops design
  • Platform indications

Screenshots:

Before After
Screenshot_20240525-215914 Screenshot_20240525-215921

@Altonss Altonss requested review from grote and ialokim May 25, 2024 20:10
@cla-bot cla-bot bot added the cla-signed ✔️ The Contributor Licence Agreement was signed by all contributors. label May 25, 2024
@Altonss Altonss linked an issue Nov 1, 2024 that may be closed by this pull request
@Altonss Altonss mentioned this pull request Nov 4, 2024
4 tasks
@@ -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)
Copy link

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".

Copy link
Collaborator Author

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^^)...

Copy link

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.

Copy link
Collaborator Author

@Altonss Altonss Nov 6, 2024

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()

// get colors
val foregroundColor = line.style?.foregroundColor
val backgroundColor = line.style?.backgroundColor
val foregroundColor = getTextColorBasedOnBackground(backgroundColor)
Copy link

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".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link

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))

Copy link
Collaborator Author

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 :)

Copy link
Collaborator Author

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 :)

Comment on lines +120 to +125
val colorsToCheck = listOfNotNull(
line.style?.backgroundColor,
line.style?.backgroundColor2,
line.style?.foregroundColor,
line.style?.borderColor
)
Copy link

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?

Copy link
Collaborator Author

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:

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed ✔️ The Contributor Licence Agreement was signed by all contributors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UX] Prevent white lines on (almost) white background
2 participants