mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 15:11:51 +02:00
Music: Replace placeholder text
Replaces the dev placeholder with waiting text, ensures it won't show 00:00/00:00 for consistency, and allows the waiting text to reappear when data becomes blank
This commit is contained in:
parent
2b1eae7f59
commit
fb48e3557b
|
@ -70,9 +70,9 @@ namespace Pinetime {
|
|||
|
||||
uint16_t eventHandle {};
|
||||
|
||||
std::string artistName {"Waiting for"};
|
||||
std::string artistName {};
|
||||
std::string albumName {};
|
||||
std::string trackName {"track information.."};
|
||||
std::string trackName {};
|
||||
|
||||
bool playing {false};
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
|
|||
txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
|
||||
lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20);
|
||||
lv_label_set_text_static(txtTrackDuration, "--:--/--:--");
|
||||
lv_label_set_text_static(txtTrackDuration, lengthDefault);
|
||||
lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID);
|
||||
lv_obj_set_width(txtTrackDuration, LV_HOR_RES);
|
||||
|
||||
|
@ -117,7 +117,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
|
|||
lv_obj_align(txtArtist, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT);
|
||||
lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID);
|
||||
lv_obj_set_width(txtArtist, LV_HOR_RES - 12);
|
||||
lv_label_set_text_static(txtArtist, "Artist Name");
|
||||
lv_label_set_text_static(txtArtist, artistDefault);
|
||||
|
||||
txtTrack = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SROLL_CIRC);
|
||||
|
@ -125,7 +125,7 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
|
|||
|
||||
lv_label_set_align(txtTrack, LV_ALIGN_IN_LEFT_MID);
|
||||
lv_obj_set_width(txtTrack, LV_HOR_RES - 12);
|
||||
lv_label_set_text_static(txtTrack, "This is a very long getTrack name");
|
||||
lv_label_set_text_static(txtTrack, trackDefault);
|
||||
|
||||
/** Init animation */
|
||||
imgDisc = lv_img_create(lv_scr_act(), nullptr);
|
||||
|
@ -150,14 +150,24 @@ Music::~Music() {
|
|||
}
|
||||
|
||||
void Music::Refresh() {
|
||||
if (artist != musicService.getArtist()) {
|
||||
if (musicDidExist != musicExists || artist != musicService.getArtist()) {
|
||||
artist = musicService.getArtist();
|
||||
lv_label_set_text(txtArtist, artist.data());
|
||||
|
||||
if (musicExists) {
|
||||
lv_label_set_text(txtArtist, artist.data());
|
||||
} else {
|
||||
lv_label_set_text_static(txtArtist, artistDefault);
|
||||
}
|
||||
}
|
||||
|
||||
if (track != musicService.getTrack()) {
|
||||
if (musicDidExist != musicExists || track != musicService.getTrack()) {
|
||||
track = musicService.getTrack();
|
||||
lv_label_set_text(txtTrack, track.data());
|
||||
|
||||
if (musicExists) {
|
||||
lv_label_set_text(txtTrack, track.data());
|
||||
} else {
|
||||
lv_label_set_text_static(txtTrack, trackDefault);
|
||||
}
|
||||
}
|
||||
|
||||
if (album != musicService.getAlbum()) {
|
||||
|
@ -173,8 +183,13 @@ void Music::Refresh() {
|
|||
UpdateLength();
|
||||
}
|
||||
|
||||
if (musicDidExist != musicExists) {
|
||||
musicDidExist = musicExists;
|
||||
}
|
||||
|
||||
if (totalLength != musicService.getTrackLength()) {
|
||||
totalLength = musicService.getTrackLength();
|
||||
musicExists = totalLength > 0;
|
||||
UpdateLength();
|
||||
}
|
||||
|
||||
|
@ -202,7 +217,9 @@ void Music::Refresh() {
|
|||
}
|
||||
|
||||
void Music::UpdateLength() {
|
||||
if (totalLength > (99 * 60 * 60)) {
|
||||
if (!musicExists) {
|
||||
lv_label_set_text_static(txtTrackDuration, lengthDefault);
|
||||
} else if (totalLength > (99 * 60 * 60)) {
|
||||
lv_label_set_text_static(txtTrackDuration, "Inf/Inf");
|
||||
} else if (totalLength > (99 * 60)) {
|
||||
lv_label_set_text_fmt(txtTrackDuration,
|
||||
|
|
|
@ -68,6 +68,12 @@ namespace Pinetime {
|
|||
std::string album;
|
||||
std::string track;
|
||||
|
||||
bool musicExists = false;
|
||||
bool musicDidExist = false;
|
||||
static constexpr const char* artistDefault = "Waiting for";
|
||||
static constexpr const char* trackDefault = "track information..";
|
||||
static constexpr const char* lengthDefault = "--:--/--:--";
|
||||
|
||||
/** Total length in seconds */
|
||||
int totalLength = 0;
|
||||
/** Current position in seconds */
|
||||
|
|
Loading…
Reference in a new issue