diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 98f15ef0..fa9aec1c 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -305,7 +305,7 @@ PineTimeStyle::~PineTimeStyle() { } bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) { - if (event == Pinetime::Applications::TouchEvents::LongTap) { + if ((event == Pinetime::Applications::TouchEvents::LongTap) && (lv_obj_get_hidden(btnRandom) == true)) { lv_obj_set_hidden(btnSet, false); savedTick = lv_tick_get(); return true; @@ -508,29 +508,28 @@ void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black)); } if (object == btnRandom) { - uint8_t randTime = rand() % 17; - uint8_t randBar = rand() % 17; - uint8_t randBG = rand() % 17; - // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values. - if (randTime == randBG) { - randBG += 1; + valueTime = static_cast(rand() % 17); + valueBar = static_cast(rand() % 17); + valueBG = static_cast(rand() % 17); + if (valueTime == valueBG) { + valueBG = GetNext(valueBG); } - if (randBar == 3) { - randBar -= 1; + if (valueBar == Controllers::Settings::Colors::Black) { + valueBar = GetPrevious(valueBar); } - if (randBar == 0) { + if (valueBar == Controllers::Settings::Colors::White) { needle_colors[0] = LV_COLOR_BLACK; } else { needle_colors[0] = LV_COLOR_WHITE; } - settingsController.SetPTSColorTime(static_cast(randTime)); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); - settingsController.SetPTSColorBar(static_cast(randBar)); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randBar))); - settingsController.SetPTSColorBG(static_cast(randBG)); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randBG))); + settingsController.SetPTSColorTime(static_cast(valueTime)); + lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + settingsController.SetPTSColorBar(static_cast(valueBar)); + lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar)); + settingsController.SetPTSColorBG(static_cast(valueBG)); + lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG)); } if (object == btnClose) { settingsController.SaveSettings();