diff --git a/applications/archive/helpers/archive_browser.c b/applications/archive/helpers/archive_browser.c index 10f5ea3e294..6a6ad947739 100644 --- a/applications/archive/helpers/archive_browser.c +++ b/applications/archive/helpers/archive_browser.c @@ -391,14 +391,7 @@ void archive_enter_dir(ArchiveBrowserView* browser, string_t name) { furi_assert(browser); furi_assert(name); - uint8_t browser_depth = 0; - with_view_model( - browser->view, (ArchiveBrowserViewModel * model) { - browser_depth = idx_last_array_size(model->idx_last); - return false; - }); - - if(browser_depth > BROWSER_DEPTH_MAX) { + if(string_size(name) >= (MAX_NAME_LEN - 1)) { return; } diff --git a/applications/archive/helpers/archive_browser.h b/applications/archive/helpers/archive_browser.h index e74357f8d4b..593a9be0db7 100644 --- a/applications/archive/helpers/archive_browser.h +++ b/applications/archive/helpers/archive_browser.h @@ -4,7 +4,6 @@ #define TAB_RIGHT InputKeyRight //default tab swith direction #define FILE_LIST_BUF_LEN 100 -#define BROWSER_DEPTH_MAX 8 static const char* tab_default_paths[] = { [ArchiveTabFavorites] = "/any/favorites", diff --git a/applications/desktop/desktop.c b/applications/desktop/desktop.c index d6c220831a4..1c1ce04f7d8 100644 --- a/applications/desktop/desktop.c +++ b/applications/desktop/desktop.c @@ -117,6 +117,7 @@ static void desktop_auto_lock_inhibit(Desktop* desktop) { } void desktop_lock(Desktop* desktop) { + furi_hal_rtc_set_pin_fails(0); desktop_auto_lock_inhibit(desktop); scene_manager_set_scene_state( desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER); diff --git a/applications/gui/elements.c b/applications/gui/elements.c index 48d70b3a79b..58b446038d2 100644 --- a/applications/gui/elements.c +++ b/applications/gui/elements.c @@ -197,7 +197,11 @@ static size_t uint16_t len_px = canvas_string_width(canvas, string_get_cstr(str)); uint8_t px_left = 0; if(horizontal == AlignCenter) { - px_left = canvas_width(canvas) - (x - len_px / 2); + if(x > (canvas_width(canvas) / 2)) { + px_left = (canvas_width(canvas) - x) * 2; + } else { + px_left = x * 2; + } } else if(horizontal == AlignLeft) { px_left = canvas_width(canvas) - x; } else if(horizontal == AlignRight) { @@ -208,13 +212,13 @@ static size_t if(len_px > px_left) { uint8_t excess_symbols_approximately = - ((float)len_px - px_left) / ((float)len_px / text_size); + roundf((float)(len_px - px_left) / ((float)len_px / (float)text_size)); // reduce to 5 to be sure dash fit, and next line will be at least 5 symbols long - excess_symbols_approximately = MAX(excess_symbols_approximately, 5); - if(text_size > (excess_symbols_approximately + 5)) { - result = text_size - excess_symbols_approximately - 5; + if(excess_symbols_approximately > 0) { + excess_symbols_approximately = MAX(excess_symbols_approximately, 5); + result = text_size - excess_symbols_approximately - 1; } else { - result = text_size - 1; + result = text_size; } } else { result = text_size; @@ -258,12 +262,17 @@ void elements_multiline_text_aligned( if((start[chars_fit] == '\n') || (start[chars_fit] == 0)) { string_init_printf(line, "%.*s", chars_fit, start); + } else if((y + font_height) > canvas_height(canvas)) { + string_init_printf(line, "%.*s...\n", chars_fit, start); } else { string_init_printf(line, "%.*s-\n", chars_fit, start); } canvas_draw_str_aligned(canvas, x, y, horizontal, vertical, string_get_cstr(line)); string_clear(line); y += font_height; + if(y > canvas_height(canvas)) { + break; + } start += chars_fit; start += start[0] == '\n' ? 1 : 0; diff --git a/applications/nfc/scenes/nfc_scene_emulate_uid.c b/applications/nfc/scenes/nfc_scene_emulate_uid.c index 362cb128ab1..58ac138e7ef 100755 --- a/applications/nfc/scenes/nfc_scene_emulate_uid.c +++ b/applications/nfc/scenes/nfc_scene_emulate_uid.c @@ -37,7 +37,7 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) { string_init(info_str); widget_add_icon_element(widget, 0, 3, &I_RFIDDolphinSend_97x61); - widget_add_string_element(widget, 56, 32, AlignLeft, AlignTop, FontPrimary, "Emulating UID"); + widget_add_string_element(widget, 89, 32, AlignCenter, AlignTop, FontPrimary, "Emulating UID"); if(strcmp(nfc->dev->dev_name, "")) { string_printf(info_str, "%s", nfc->dev->dev_name); } else { @@ -47,7 +47,7 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) { } string_strim(info_str); widget_add_text_box_element( - widget, 56, 43, 70, 21, AlignLeft, AlignTop, string_get_cstr(info_str), true); + widget, 56, 43, 70, 21, AlignCenter, AlignTop, string_get_cstr(info_str), true); string_clear(info_str); if(data_received) { widget_add_button_element( diff --git a/applications/notification/notification.h b/applications/notification/notification.h index 10a32976b7c..b73efad20a9 100644 --- a/applications/notification/notification.h +++ b/applications/notification/notification.h @@ -59,6 +59,8 @@ typedef enum { NotificationMessageTypeForceSpeakerVolumeSetting, NotificationMessageTypeForceVibroSetting, NotificationMessageTypeForceDisplayBrightnessSetting, + + NotificationMessageTypeLedBrightnessSettingApply, } NotificationMessageType; typedef struct { diff --git a/applications/notification/notification_app.c b/applications/notification/notification_app.c index 1e2e2dde9c7..75be20b1617 100644 --- a/applications/notification/notification_app.c +++ b/applications/notification/notification_app.c @@ -212,18 +212,21 @@ void notification_process_notification_message( // store and send on delay or after seq led_active = true; led_values[0] = notification_message->data.led.value; + app->led[0].value_last[LayerNotification] = led_values[0]; reset_mask |= reset_red_mask; break; case NotificationMessageTypeLedGreen: // store and send on delay or after seq led_active = true; led_values[1] = notification_message->data.led.value; + app->led[1].value_last[LayerNotification] = led_values[1]; reset_mask |= reset_green_mask; break; case NotificationMessageTypeLedBlue: // store and send on delay or after seq led_active = true; led_values[2] = notification_message->data.led.value; + app->led[2].value_last[LayerNotification] = led_values[2]; reset_mask |= reset_blue_mask; break; case NotificationMessageTypeVibro: @@ -273,6 +276,16 @@ void notification_process_notification_message( case NotificationMessageTypeForceDisplayBrightnessSetting: display_brightness_setting = notification_message->data.forced_settings.display_brightness; + break; + case NotificationMessageTypeLedBrightnessSettingApply: + led_active = true; + for(uint8_t i = 0; i < NOTIFICATION_LED_COUNT; i++) { + led_values[i] = app->led[i].value_last[LayerNotification]; + } + reset_mask |= reset_red_mask; + reset_mask |= reset_green_mask; + reset_mask |= reset_blue_mask; + break; } notification_message_index++; notification_message = (*message->sequence)[notification_message_index]; @@ -316,23 +329,33 @@ void notification_process_internal_message(NotificationApp* app, NotificationApp app, notification_message->data.led.value)); break; case NotificationMessageTypeLedRed: + app->led[0].value_last[LayerInternal] = notification_message->data.led.value; notification_apply_internal_led_layer( &app->led[0], notification_settings_get_rgb_led_brightness( app, notification_message->data.led.value)); break; case NotificationMessageTypeLedGreen: + app->led[1].value_last[LayerInternal] = notification_message->data.led.value; notification_apply_internal_led_layer( &app->led[1], notification_settings_get_rgb_led_brightness( app, notification_message->data.led.value)); break; case NotificationMessageTypeLedBlue: + app->led[2].value_last[LayerInternal] = notification_message->data.led.value; notification_apply_internal_led_layer( &app->led[2], notification_settings_get_rgb_led_brightness( app, notification_message->data.led.value)); break; + case NotificationMessageTypeLedBrightnessSettingApply: + for(uint8_t i = 0; i < NOTIFICATION_LED_COUNT; i++) { + uint8_t new_val = notification_settings_get_rgb_led_brightness( + app, app->led[i].value_last[LayerInternal]); + notification_apply_internal_led_layer(&app->led[i], new_val); + } + break; default: break; } diff --git a/applications/notification/notification_app.h b/applications/notification/notification_app.h index 2c41bc823a5..b56b7e3b7eb 100644 --- a/applications/notification/notification_app.h +++ b/applications/notification/notification_app.h @@ -25,6 +25,7 @@ typedef enum { } NotificationLedLayerIndex; typedef struct { + uint8_t value_last[LayerMAX]; uint8_t value[LayerMAX]; NotificationLedLayerIndex index; Light light; diff --git a/applications/notification/notification_settings_app.c b/applications/notification/notification_settings_app.c index 1522628d1ff..e7a57aa6138 100644 --- a/applications/notification/notification_settings_app.c +++ b/applications/notification/notification_settings_app.c @@ -82,12 +82,22 @@ static void screen_changed(VariableItem* item) { notification_message(app->notification, &sequence_display_on); } +const NotificationMessage apply_message = { + .type = NotificationMessageTypeLedBrightnessSettingApply, +}; +const NotificationSequence apply_sequence = { + &apply_message, + NULL, +}; + static void led_changed(VariableItem* item) { NotificationAppSettings* app = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); variable_item_set_current_value_text(item, backlight_text[index]); app->notification->settings.led_brightness = backlight_value[index]; + notification_message(app->notification, &apply_sequence); + notification_internal_message(app->notification, &apply_sequence); notification_message(app->notification, &sequence_blink_white_100); }