[FL-2463, FL-2471, FL-2472, FL-2473] Notifications, GUI elements, archive fixes #1137
This commit is contained in:
		
							parent
							
								
									cea118cf2d
								
							
						
					
					
						commit
						ad1ee8a5c6
					
				| @ -391,14 +391,7 @@ void archive_enter_dir(ArchiveBrowserView* browser, string_t name) { | |||||||
|     furi_assert(browser); |     furi_assert(browser); | ||||||
|     furi_assert(name); |     furi_assert(name); | ||||||
| 
 | 
 | ||||||
|     uint8_t browser_depth = 0; |     if(string_size(name) >= (MAX_NAME_LEN - 1)) { | ||||||
|     with_view_model( |  | ||||||
|         browser->view, (ArchiveBrowserViewModel * model) { |  | ||||||
|             browser_depth = idx_last_array_size(model->idx_last); |  | ||||||
|             return false; |  | ||||||
|         }); |  | ||||||
| 
 |  | ||||||
|     if(browser_depth > BROWSER_DEPTH_MAX) { |  | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -4,7 +4,6 @@ | |||||||
| 
 | 
 | ||||||
| #define TAB_RIGHT InputKeyRight //default tab swith direction
 | #define TAB_RIGHT InputKeyRight //default tab swith direction
 | ||||||
| #define FILE_LIST_BUF_LEN 100 | #define FILE_LIST_BUF_LEN 100 | ||||||
| #define BROWSER_DEPTH_MAX 8 |  | ||||||
| 
 | 
 | ||||||
| static const char* tab_default_paths[] = { | static const char* tab_default_paths[] = { | ||||||
|     [ArchiveTabFavorites] = "/any/favorites", |     [ArchiveTabFavorites] = "/any/favorites", | ||||||
|  | |||||||
| @ -117,6 +117,7 @@ static void desktop_auto_lock_inhibit(Desktop* desktop) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void desktop_lock(Desktop* desktop) { | void desktop_lock(Desktop* desktop) { | ||||||
|  |     furi_hal_rtc_set_pin_fails(0); | ||||||
|     desktop_auto_lock_inhibit(desktop); |     desktop_auto_lock_inhibit(desktop); | ||||||
|     scene_manager_set_scene_state( |     scene_manager_set_scene_state( | ||||||
|         desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER); |         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)); |     uint16_t len_px = canvas_string_width(canvas, string_get_cstr(str)); | ||||||
|     uint8_t px_left = 0; |     uint8_t px_left = 0; | ||||||
|     if(horizontal == AlignCenter) { |     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) { |     } else if(horizontal == AlignLeft) { | ||||||
|         px_left = canvas_width(canvas) - x; |         px_left = canvas_width(canvas) - x; | ||||||
|     } else if(horizontal == AlignRight) { |     } else if(horizontal == AlignRight) { | ||||||
| @ -208,13 +212,13 @@ static size_t | |||||||
| 
 | 
 | ||||||
|     if(len_px > px_left) { |     if(len_px > px_left) { | ||||||
|         uint8_t excess_symbols_approximately = |         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
 |         // 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(excess_symbols_approximately > 0) { | ||||||
|         if(text_size > (excess_symbols_approximately + 5)) { |             excess_symbols_approximately = MAX(excess_symbols_approximately, 5); | ||||||
|             result = text_size - excess_symbols_approximately - 5; |             result = text_size - excess_symbols_approximately - 1; | ||||||
|         } else { |         } else { | ||||||
|             result = text_size - 1; |             result = text_size; | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         result = text_size; |         result = text_size; | ||||||
| @ -258,12 +262,17 @@ void elements_multiline_text_aligned( | |||||||
| 
 | 
 | ||||||
|         if((start[chars_fit] == '\n') || (start[chars_fit] == 0)) { |         if((start[chars_fit] == '\n') || (start[chars_fit] == 0)) { | ||||||
|             string_init_printf(line, "%.*s", chars_fit, start); |             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 { |         } else { | ||||||
|             string_init_printf(line, "%.*s-\n", chars_fit, start); |             string_init_printf(line, "%.*s-\n", chars_fit, start); | ||||||
|         } |         } | ||||||
|         canvas_draw_str_aligned(canvas, x, y, horizontal, vertical, string_get_cstr(line)); |         canvas_draw_str_aligned(canvas, x, y, horizontal, vertical, string_get_cstr(line)); | ||||||
|         string_clear(line); |         string_clear(line); | ||||||
|         y += font_height; |         y += font_height; | ||||||
|  |         if(y > canvas_height(canvas)) { | ||||||
|  |             break; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         start += chars_fit; |         start += chars_fit; | ||||||
|         start += start[0] == '\n' ? 1 : 0; |         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); |     string_init(info_str); | ||||||
| 
 | 
 | ||||||
|     widget_add_icon_element(widget, 0, 3, &I_RFIDDolphinSend_97x61); |     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, "")) { |     if(strcmp(nfc->dev->dev_name, "")) { | ||||||
|         string_printf(info_str, "%s", nfc->dev->dev_name); |         string_printf(info_str, "%s", nfc->dev->dev_name); | ||||||
|     } else { |     } else { | ||||||
| @ -47,7 +47,7 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) { | |||||||
|     } |     } | ||||||
|     string_strim(info_str); |     string_strim(info_str); | ||||||
|     widget_add_text_box_element( |     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); |     string_clear(info_str); | ||||||
|     if(data_received) { |     if(data_received) { | ||||||
|         widget_add_button_element( |         widget_add_button_element( | ||||||
|  | |||||||
| @ -59,6 +59,8 @@ typedef enum { | |||||||
|     NotificationMessageTypeForceSpeakerVolumeSetting, |     NotificationMessageTypeForceSpeakerVolumeSetting, | ||||||
|     NotificationMessageTypeForceVibroSetting, |     NotificationMessageTypeForceVibroSetting, | ||||||
|     NotificationMessageTypeForceDisplayBrightnessSetting, |     NotificationMessageTypeForceDisplayBrightnessSetting, | ||||||
|  | 
 | ||||||
|  |     NotificationMessageTypeLedBrightnessSettingApply, | ||||||
| } NotificationMessageType; | } NotificationMessageType; | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|  | |||||||
| @ -212,18 +212,21 @@ void notification_process_notification_message( | |||||||
|             // store and send on delay or after seq
 |             // store and send on delay or after seq
 | ||||||
|             led_active = true; |             led_active = true; | ||||||
|             led_values[0] = notification_message->data.led.value; |             led_values[0] = notification_message->data.led.value; | ||||||
|  |             app->led[0].value_last[LayerNotification] = led_values[0]; | ||||||
|             reset_mask |= reset_red_mask; |             reset_mask |= reset_red_mask; | ||||||
|             break; |             break; | ||||||
|         case NotificationMessageTypeLedGreen: |         case NotificationMessageTypeLedGreen: | ||||||
|             // store and send on delay or after seq
 |             // store and send on delay or after seq
 | ||||||
|             led_active = true; |             led_active = true; | ||||||
|             led_values[1] = notification_message->data.led.value; |             led_values[1] = notification_message->data.led.value; | ||||||
|  |             app->led[1].value_last[LayerNotification] = led_values[1]; | ||||||
|             reset_mask |= reset_green_mask; |             reset_mask |= reset_green_mask; | ||||||
|             break; |             break; | ||||||
|         case NotificationMessageTypeLedBlue: |         case NotificationMessageTypeLedBlue: | ||||||
|             // store and send on delay or after seq
 |             // store and send on delay or after seq
 | ||||||
|             led_active = true; |             led_active = true; | ||||||
|             led_values[2] = notification_message->data.led.value; |             led_values[2] = notification_message->data.led.value; | ||||||
|  |             app->led[2].value_last[LayerNotification] = led_values[2]; | ||||||
|             reset_mask |= reset_blue_mask; |             reset_mask |= reset_blue_mask; | ||||||
|             break; |             break; | ||||||
|         case NotificationMessageTypeVibro: |         case NotificationMessageTypeVibro: | ||||||
| @ -273,6 +276,16 @@ void notification_process_notification_message( | |||||||
|         case NotificationMessageTypeForceDisplayBrightnessSetting: |         case NotificationMessageTypeForceDisplayBrightnessSetting: | ||||||
|             display_brightness_setting = |             display_brightness_setting = | ||||||
|                 notification_message->data.forced_settings.display_brightness; |                 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_index++; | ||||||
|         notification_message = (*message->sequence)[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)); |                     app, notification_message->data.led.value)); | ||||||
|             break; |             break; | ||||||
|         case NotificationMessageTypeLedRed: |         case NotificationMessageTypeLedRed: | ||||||
|  |             app->led[0].value_last[LayerInternal] = notification_message->data.led.value; | ||||||
|             notification_apply_internal_led_layer( |             notification_apply_internal_led_layer( | ||||||
|                 &app->led[0], |                 &app->led[0], | ||||||
|                 notification_settings_get_rgb_led_brightness( |                 notification_settings_get_rgb_led_brightness( | ||||||
|                     app, notification_message->data.led.value)); |                     app, notification_message->data.led.value)); | ||||||
|             break; |             break; | ||||||
|         case NotificationMessageTypeLedGreen: |         case NotificationMessageTypeLedGreen: | ||||||
|  |             app->led[1].value_last[LayerInternal] = notification_message->data.led.value; | ||||||
|             notification_apply_internal_led_layer( |             notification_apply_internal_led_layer( | ||||||
|                 &app->led[1], |                 &app->led[1], | ||||||
|                 notification_settings_get_rgb_led_brightness( |                 notification_settings_get_rgb_led_brightness( | ||||||
|                     app, notification_message->data.led.value)); |                     app, notification_message->data.led.value)); | ||||||
|             break; |             break; | ||||||
|         case NotificationMessageTypeLedBlue: |         case NotificationMessageTypeLedBlue: | ||||||
|  |             app->led[2].value_last[LayerInternal] = notification_message->data.led.value; | ||||||
|             notification_apply_internal_led_layer( |             notification_apply_internal_led_layer( | ||||||
|                 &app->led[2], |                 &app->led[2], | ||||||
|                 notification_settings_get_rgb_led_brightness( |                 notification_settings_get_rgb_led_brightness( | ||||||
|                     app, notification_message->data.led.value)); |                     app, notification_message->data.led.value)); | ||||||
|             break; |             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: |         default: | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -25,6 +25,7 @@ typedef enum { | |||||||
| } NotificationLedLayerIndex; | } NotificationLedLayerIndex; | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|  |     uint8_t value_last[LayerMAX]; | ||||||
|     uint8_t value[LayerMAX]; |     uint8_t value[LayerMAX]; | ||||||
|     NotificationLedLayerIndex index; |     NotificationLedLayerIndex index; | ||||||
|     Light light; |     Light light; | ||||||
|  | |||||||
| @ -82,12 +82,22 @@ static void screen_changed(VariableItem* item) { | |||||||
|     notification_message(app->notification, &sequence_display_on); |     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) { | static void led_changed(VariableItem* item) { | ||||||
|     NotificationAppSettings* app = variable_item_get_context(item); |     NotificationAppSettings* app = variable_item_get_context(item); | ||||||
|     uint8_t index = variable_item_get_current_value_index(item); |     uint8_t index = variable_item_get_current_value_index(item); | ||||||
| 
 | 
 | ||||||
|     variable_item_set_current_value_text(item, backlight_text[index]); |     variable_item_set_current_value_text(item, backlight_text[index]); | ||||||
|     app->notification->settings.led_brightness = backlight_value[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); |     notification_message(app->notification, &sequence_blink_white_100); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nikolay Minaylov
						Nikolay Minaylov