mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 13:03:13 +00:00
[FL-2463, FL-2471, FL-2472, FL-2473] Notifications, GUI elements, archive fixes #1137
This commit is contained in:
parent
cea118cf2d
commit
ad1ee8a5c6
9 changed files with 55 additions and 17 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -59,6 +59,8 @@ typedef enum {
|
|||
NotificationMessageTypeForceSpeakerVolumeSetting,
|
||||
NotificationMessageTypeForceVibroSetting,
|
||||
NotificationMessageTypeForceDisplayBrightnessSetting,
|
||||
|
||||
NotificationMessageTypeLedBrightnessSettingApply,
|
||||
} NotificationMessageType;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ typedef enum {
|
|||
} NotificationLedLayerIndex;
|
||||
|
||||
typedef struct {
|
||||
uint8_t value_last[LayerMAX];
|
||||
uint8_t value[LayerMAX];
|
||||
NotificationLedLayerIndex index;
|
||||
Light light;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue