diff --git a/applications/bt/bt_service/bt.c b/applications/bt/bt_service/bt.c index 76d4ae10..785573f2 100644 --- a/applications/bt/bt_service/bt.c +++ b/applications/bt/bt_service/bt.c @@ -48,11 +48,11 @@ int32_t bt_srv() { furi_record_create("bt", bt); furi_hal_bt_init(); - if(bt->bt_settings.enabled) { - if(!furi_hal_bt_wait_startup()) { - FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed"); - } else { - view_port_enabled_set(bt->statusbar_view_port, true); + if(!furi_hal_bt_wait_startup()) { + FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed"); + } else { + view_port_enabled_set(bt->statusbar_view_port, true); + if(bt->bt_settings.enabled) { bool bt_app_started = furi_hal_bt_start_app(); if(!bt_app_started) { FURI_LOG_E(BT_SERVICE_TAG, "BT App start failed"); diff --git a/applications/gui/elements.c b/applications/gui/elements.c index d4dc9aa7..332baa71 100644 --- a/applications/gui/elements.c +++ b/applications/gui/elements.c @@ -332,12 +332,12 @@ void elements_string_fit_width(Canvas* canvas, string_t string, uint8_t width) { furi_assert(string); uint16_t len_px = canvas_string_width(canvas, string_get_cstr(string)); - if(len_px > width) { - size_t s_len = string_size(string); - uint8_t end_pos = s_len - ((len_px - width) / ((len_px / s_len) + 2) + 2); - - string_mid(string, 0, end_pos); + width -= canvas_string_width(canvas, "..."); + do { + string_left(string, string_size(string) - 1); + len_px = canvas_string_width(canvas, string_get_cstr(string)); + } while(len_px > width); string_cat(string, "..."); } } diff --git a/applications/gui/modules/button_menu.c b/applications/gui/modules/button_menu.c index e342162e..81958f0d 100644 --- a/applications/gui/modules/button_menu.c +++ b/applications/gui/modules/button_menu.c @@ -78,13 +78,20 @@ static void button_menu_draw_common_button( } else { canvas_draw_rframe(canvas, item_x, item_y, ITEM_WIDTH, ITEM_HEIGHT, 5); } + + string_t disp_str; + string_init_set_str(disp_str, text); + elements_string_fit_width(canvas, disp_str, ITEM_WIDTH - 6); + canvas_draw_str_aligned( canvas, item_x + (ITEM_WIDTH / 2), item_y + (ITEM_HEIGHT / 2), AlignCenter, AlignCenter, - text); + string_get_cstr(disp_str)); + + string_clear(disp_str); } static void button_menu_view_draw_callback(Canvas* canvas, void* _model) { @@ -110,7 +117,11 @@ static void button_menu_view_draw_callback(Canvas* canvas, void* _model) { canvas_draw_icon(canvas, 28, 123, &I_IrdaArrowDown_4x8); } - canvas_draw_str_aligned(canvas, 32, 10, AlignCenter, AlignCenter, model->header); + string_t disp_str; + string_init_set_str(disp_str, model->header); + elements_string_fit_width(canvas, disp_str, ITEM_WIDTH - 6); + canvas_draw_str_aligned(canvas, 32, 10, AlignCenter, AlignCenter, string_get_cstr(disp_str)); + string_clear(disp_str); for(ButtonMenuItemArray_it(it, model->items); !ButtonMenuItemArray_end_p(it); ButtonMenuItemArray_next(it), ++item_position) { diff --git a/applications/gui/modules/submenu.c b/applications/gui/modules/submenu.c index c1920662..7c12eebc 100644 --- a/applications/gui/modules/submenu.c +++ b/applications/gui/modules/submenu.c @@ -65,11 +65,18 @@ static void submenu_view_draw_callback(Canvas* canvas, void* _model) { } else { canvas_set_color(canvas, ColorBlack); } + + string_t disp_str; + string_init_set_str(disp_str, SubmenuItemArray_cref(it)->label); + elements_string_fit_width(canvas, disp_str, item_width - 20); + canvas_draw_str( canvas, 6, y_offset + (item_position * item_height) + item_height - 4, - SubmenuItemArray_cref(it)->label); + string_get_cstr(disp_str)); + + string_clear(disp_str); } position++; diff --git a/applications/irda/irda-app-remote-manager.h b/applications/irda/irda-app-remote-manager.h index b2a0197f..2b157329 100644 --- a/applications/irda/irda-app-remote-manager.h +++ b/applications/irda/irda-app-remote-manager.h @@ -47,8 +47,8 @@ class IrdaAppRemoteManager { std::string make_remote_name(const std::string& full_name) const; public: - static inline const uint32_t max_button_name_length = 31; - static inline const uint32_t max_remote_name_length = 31; + static inline const uint32_t max_button_name_length = 22; + static inline const uint32_t max_remote_name_length = 22; bool add_remote_with_button(const char* button_name, const IrdaAppSignal& signal); bool add_button(const char* button_name, const IrdaAppSignal& signal);