Shorten Home screen title when needed#309
Conversation
| { | ||
| static const char prefix[] = "Jade "; | ||
| // Match the status-bar title column width from make_status_bar(). | ||
| const int title_width_percent = HOME_SCREEN_DEEP_STATUS_BAR ? 35 : 57; |
There was a problem hiding this comment.
I'm a bit uncomfortable with this magic number existing in main/gui.c as well as here. I think you should add a constant for it to main/gui.h and use it in both places.
| return device_name; | ||
| } | ||
|
|
||
| return strncmp(device_name, prefix, sizeof(prefix) - 1) == 0 ? device_name + sizeof(prefix) - 1 |
There was a problem hiding this comment.
You can hardcode the prefix and use strlen for one-off string constant use like this - the compiler will emit the same code for e.g. strncmp(device_name, "Jade ", strlen("Jade ")) and its shorter. We use the longer form for large if blocks typically.
The ternary operator is a little unclear here, it would be better to add the strncmp condition to the if above and return device_name + strlen("Jade ") unconditionally here, with a comment above like // Remove "Jade " prefix to allow the device ID to be shown.
7989340 to
e15c7f4
Compare
|
Updated, thanks! |
Note: opening this now so it is ready for review after the 1.0.41 release, as discussed in #274.
Description
The Home status bar title can be clipped on displays where the full
Jade <fingerprint>device name does not fit.This keeps the full
Jade <fingerprint>title when it fits. If it would be clipped, the Home screen falls back to showing only the fingerprint. The full device name remains unchanged elsewhere.Approach
GUI_TITLE_FONT.Jadeprefix when the full title would not fit.Testing
git diff --check