mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2025-02-17 05:48:33 +00:00
Setting to change fonts in TOTP
opensource != selling plugin builds / do you agree? If you don't agree - and you think I did a bad thing here by allowing users to select fonts without payment, let me know Why I did that? - cuz I'm not making private "donation only" builds myself, while having no main job, and living only on donations, so I don't like stuff like that in opensource projects You should support author if you like this plugin here: https://github.com/akopachov/flipper-zero_authenticator
This commit is contained in:
parent
24ad48d390
commit
b9397693a2
11 changed files with 163 additions and 39 deletions
4
applications/external/totp/features_config.h
vendored
4
applications/external/totp/features_config.h
vendored
|
@ -7,8 +7,8 @@
|
||||||
// List of compatible firmwares
|
// List of compatible firmwares
|
||||||
#define TOTP_FIRMWARE_OFFICIAL_STABLE 1
|
#define TOTP_FIRMWARE_OFFICIAL_STABLE 1
|
||||||
#define TOTP_FIRMWARE_OFFICIAL_DEV 2
|
#define TOTP_FIRMWARE_OFFICIAL_DEV 2
|
||||||
#define TOTP_FIRMWARE_XTREME 3
|
#define TOTP_FIRMWARE_UL_XFW 3 // XFW and UL now has same bluetooth mac/advname changing API
|
||||||
// End of list
|
// End of list
|
||||||
|
|
||||||
// Target firmware to build for
|
// Target firmware to build for
|
||||||
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME
|
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_UL_XFW
|
||||||
|
|
|
@ -177,6 +177,10 @@ static bool totp_open_config_file(Storage* storage, FlipperFormat** file) {
|
||||||
flipper_format_write_uint32(
|
flipper_format_write_uint32(
|
||||||
fff_data_file, TOTP_CONFIG_KEY_AUTOMATION_METHOD, &tmp_uint32, 1);
|
fff_data_file, TOTP_CONFIG_KEY_AUTOMATION_METHOD, &tmp_uint32, 1);
|
||||||
|
|
||||||
|
// Default Font = 0
|
||||||
|
tmp_uint32 = 0;
|
||||||
|
flipper_format_write_uint32(fff_data_file, TOTP_CONFIG_KEY_SELECTED_FONT, &tmp_uint32, 1);
|
||||||
|
|
||||||
if(!flipper_format_rewind(fff_data_file)) {
|
if(!flipper_format_rewind(fff_data_file)) {
|
||||||
totp_close_config_file(fff_data_file);
|
totp_close_config_file(fff_data_file);
|
||||||
FURI_LOG_E(LOGGING_TAG, "Rewind error");
|
FURI_LOG_E(LOGGING_TAG, "Rewind error");
|
||||||
|
@ -259,6 +263,24 @@ bool totp_config_file_update_automation_method(const PluginState* plugin_state)
|
||||||
return update_result;
|
return update_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool totp_config_file_update_selected_font(const PluginState* plugin_state) {
|
||||||
|
FlipperFormat* file = plugin_state->config_file_context->config_file;
|
||||||
|
flipper_format_rewind(file);
|
||||||
|
bool update_result = false;
|
||||||
|
|
||||||
|
do {
|
||||||
|
uint32_t tmp_uint32 = plugin_state->selected_font;
|
||||||
|
if(!flipper_format_insert_or_update_uint32(
|
||||||
|
file, TOTP_CONFIG_KEY_SELECTED_FONT, &tmp_uint32, 1)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
update_result = true;
|
||||||
|
} while(false);
|
||||||
|
|
||||||
|
return update_result;
|
||||||
|
}
|
||||||
|
|
||||||
bool totp_config_file_update_user_settings(const PluginState* plugin_state) {
|
bool totp_config_file_update_user_settings(const PluginState* plugin_state) {
|
||||||
FlipperFormat* file = plugin_state->config_file_context->config_file;
|
FlipperFormat* file = plugin_state->config_file_context->config_file;
|
||||||
flipper_format_rewind(file);
|
flipper_format_rewind(file);
|
||||||
|
@ -280,6 +302,12 @@ bool totp_config_file_update_user_settings(const PluginState* plugin_state) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmp_uint32 = plugin_state->selected_font;
|
||||||
|
if(!flipper_format_insert_or_update_uint32(
|
||||||
|
file, TOTP_CONFIG_KEY_SELECTED_FONT, &tmp_uint32, 1)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
update_result = true;
|
update_result = true;
|
||||||
} while(false);
|
} while(false);
|
||||||
|
|
||||||
|
@ -428,6 +456,16 @@ bool totp_config_file_load(PluginState* const plugin_state) {
|
||||||
|
|
||||||
plugin_state->automation_method = tmp_uint32;
|
plugin_state->automation_method = tmp_uint32;
|
||||||
|
|
||||||
|
// Load selected font
|
||||||
|
flipper_format_rewind(fff_data_file);
|
||||||
|
|
||||||
|
if(!flipper_format_read_uint32(
|
||||||
|
fff_data_file, TOTP_CONFIG_KEY_SELECTED_FONT, &tmp_uint32, 1)) {
|
||||||
|
tmp_uint32 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin_state->selected_font = tmp_uint32;
|
||||||
|
|
||||||
plugin_state->config_file_context = malloc(sizeof(ConfigFileContext));
|
plugin_state->config_file_context = malloc(sizeof(ConfigFileContext));
|
||||||
furi_check(plugin_state->config_file_context != NULL);
|
furi_check(plugin_state->config_file_context != NULL);
|
||||||
plugin_state->config_file_context->storage = storage;
|
plugin_state->config_file_context->storage = storage;
|
||||||
|
|
|
@ -44,6 +44,13 @@ bool totp_config_file_update_notification_method(const PluginState* plugin_state
|
||||||
*/
|
*/
|
||||||
bool totp_config_file_update_automation_method(const PluginState* plugin_state);
|
bool totp_config_file_update_automation_method(const PluginState* plugin_state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Updates selected font in an application config file
|
||||||
|
* @param plugin_state application state
|
||||||
|
* @return Config file update result
|
||||||
|
*/
|
||||||
|
bool totp_config_file_update_selected_font(const PluginState* plugin_state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Updates application user settings
|
* @brief Updates application user settings
|
||||||
* @param plugin_state application state
|
* @param plugin_state application state
|
||||||
|
|
|
@ -18,3 +18,4 @@
|
||||||
#define TOTP_CONFIG_KEY_PINSET "PinIsSet"
|
#define TOTP_CONFIG_KEY_PINSET "PinIsSet"
|
||||||
#define TOTP_CONFIG_KEY_NOTIFICATION_METHOD "NotificationMethod"
|
#define TOTP_CONFIG_KEY_NOTIFICATION_METHOD "NotificationMethod"
|
||||||
#define TOTP_CONFIG_KEY_AUTOMATION_METHOD "AutomationMethod"
|
#define TOTP_CONFIG_KEY_AUTOMATION_METHOD "AutomationMethod"
|
||||||
|
#define TOTP_CONFIG_KEY_SELECTED_FONT "SelectedFont"
|
||||||
|
|
|
@ -58,6 +58,15 @@ bool totp_config_migrate_to_latest(
|
||||||
|
|
||||||
flipper_format_rewind(fff_backup_data_file);
|
flipper_format_rewind(fff_backup_data_file);
|
||||||
|
|
||||||
|
// Font
|
||||||
|
|
||||||
|
if(flipper_format_read_string(
|
||||||
|
fff_backup_data_file, TOTP_CONFIG_KEY_SELECTED_FONT, temp_str)) {
|
||||||
|
flipper_format_write_string(fff_data_file, TOTP_CONFIG_KEY_SELECTED_FONT, temp_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
flipper_format_rewind(fff_backup_data_file);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
if(!flipper_format_read_string(
|
if(!flipper_format_read_string(
|
||||||
fff_backup_data_file, TOTP_CONFIG_KEY_TOKEN_NAME, temp_str)) {
|
fff_backup_data_file, TOTP_CONFIG_KEY_TOKEN_NAME, temp_str)) {
|
||||||
|
|
1
applications/external/totp/totp_app.c
vendored
1
applications/external/totp/totp_app.c
vendored
|
@ -107,6 +107,7 @@ static bool totp_activate_initial_scene(PluginState* const plugin_state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool totp_plugin_state_init(PluginState* const plugin_state) {
|
static bool totp_plugin_state_init(PluginState* const plugin_state) {
|
||||||
|
plugin_state->selected_font = 0;
|
||||||
plugin_state->gui = furi_record_open(RECORD_GUI);
|
plugin_state->gui = furi_record_open(RECORD_GUI);
|
||||||
plugin_state->notification_app = furi_record_open(RECORD_NOTIFICATION);
|
plugin_state->notification_app = furi_record_open(RECORD_NOTIFICATION);
|
||||||
plugin_state->dialogs_app = furi_record_open(RECORD_DIALOGS);
|
plugin_state->dialogs_app = furi_record_open(RECORD_DIALOGS);
|
||||||
|
|
|
@ -80,6 +80,11 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
NotificationMethod notification_method;
|
NotificationMethod notification_method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Numbers Font
|
||||||
|
*/
|
||||||
|
uint8_t selected_font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Main rendering loop mutex
|
* @brief Main rendering loop mutex
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,25 +3,10 @@
|
||||||
#include "../../features_config.h"
|
#include "../../features_config.h"
|
||||||
#include "font_info.h"
|
#include "font_info.h"
|
||||||
|
|
||||||
#if TOTP_FONT == TOTP_FONT_MODENINE
|
|
||||||
#include "mode_nine/mode_nine.h"
|
#include "mode_nine/mode_nine.h"
|
||||||
#define TOTP_CODE_FONT_INFO modeNine_15ptFontInfo
|
|
||||||
#elif TOTP_FONT == TOTP_FONT_REDHATMONO
|
|
||||||
#include "redhat_mono/redhat_mono.h"
|
#include "redhat_mono/redhat_mono.h"
|
||||||
#define TOTP_CODE_FONT_INFO redHatMono_16ptFontInfo
|
|
||||||
#elif TOTP_FONT == TOTP_FONT_BEDSTEAD
|
|
||||||
#include "bedstead/bedstead.h"
|
#include "bedstead/bedstead.h"
|
||||||
#define TOTP_CODE_FONT_INFO bedstead_17ptFontInfo
|
|
||||||
#elif TOTP_FONT == TOTP_FONT_ZECTOR
|
|
||||||
#include "zector/zector.h"
|
#include "zector/zector.h"
|
||||||
#define TOTP_CODE_FONT_INFO zector_18ptFontInfo
|
|
||||||
#elif TOTP_FONT == TOTP_FONT_712SERIF
|
|
||||||
#include "712serif/712serif.h"
|
#include "712serif/712serif.h"
|
||||||
#define TOTP_CODE_FONT_INFO _712Serif_24ptFontInfo
|
|
||||||
#elif TOTP_FONT == TOTP_FONT_GRAPH35PIX
|
|
||||||
#include "graph35pix/graph35pix.h"
|
#include "graph35pix/graph35pix.h"
|
||||||
#define TOTP_CODE_FONT_INFO graph35pix_12ptFontInfo
|
|
||||||
#elif TOTP_FONT == TOTP_FONT_KARMAFUTURE
|
|
||||||
#include "karma_future/karma_future.h"
|
#include "karma_future/karma_future.h"
|
||||||
#define TOTP_CODE_FONT_INFO karmaFuture_14ptFontInfo
|
|
||||||
#endif
|
|
|
@ -22,6 +22,7 @@ typedef enum {
|
||||||
MinutesInput,
|
MinutesInput,
|
||||||
Sound,
|
Sound,
|
||||||
Vibro,
|
Vibro,
|
||||||
|
FontSelector,
|
||||||
BadUsb,
|
BadUsb,
|
||||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||||
BadBt,
|
BadBt,
|
||||||
|
@ -34,6 +35,7 @@ typedef struct {
|
||||||
uint8_t tz_offset_minutes;
|
uint8_t tz_offset_minutes;
|
||||||
bool notification_sound;
|
bool notification_sound;
|
||||||
bool notification_vibro;
|
bool notification_vibro;
|
||||||
|
uint8_t selected_font;
|
||||||
bool badusb_enabled;
|
bool badusb_enabled;
|
||||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||||
bool badbt_enabled;
|
bool badbt_enabled;
|
||||||
|
@ -54,6 +56,7 @@ void totp_scene_app_settings_activate(PluginState* plugin_state) {
|
||||||
scene_state->notification_sound = plugin_state->notification_method & NotificationMethodSound;
|
scene_state->notification_sound = plugin_state->notification_method & NotificationMethodSound;
|
||||||
scene_state->notification_vibro = plugin_state->notification_method & NotificationMethodVibro;
|
scene_state->notification_vibro = plugin_state->notification_method & NotificationMethodVibro;
|
||||||
scene_state->badusb_enabled = plugin_state->automation_method & AutomationMethodBadUsb;
|
scene_state->badusb_enabled = plugin_state->automation_method & AutomationMethodBadUsb;
|
||||||
|
scene_state->selected_font = plugin_state->selected_font;
|
||||||
#ifdef TOTP_BADBT_TYPE_ENABLED
|
#ifdef TOTP_BADBT_TYPE_ENABLED
|
||||||
scene_state->badbt_enabled = plugin_state->automation_method & AutomationMethodBadBt;
|
scene_state->badbt_enabled = plugin_state->automation_method & AutomationMethodBadBt;
|
||||||
#endif
|
#endif
|
||||||
|
@ -111,27 +114,38 @@ void totp_scene_app_settings_render(Canvas* const canvas, const PluginState* plu
|
||||||
|
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
canvas_draw_str_aligned(
|
canvas_draw_str_aligned(
|
||||||
canvas, 0, 64 - scene_state->y_offset, AlignLeft, AlignTop, "Notifications");
|
canvas, 0, 64 - scene_state->y_offset, AlignLeft, AlignTop, "Notifications / UI");
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
|
||||||
canvas_draw_str_aligned(canvas, 0, 81 - scene_state->y_offset, AlignLeft, AlignTop, "Sound:");
|
canvas_draw_str_aligned(canvas, 0, 78 - scene_state->y_offset, AlignLeft, AlignTop, "Sound:");
|
||||||
ui_control_select_render(
|
ui_control_select_render(
|
||||||
canvas,
|
canvas,
|
||||||
36,
|
36,
|
||||||
74 - scene_state->y_offset,
|
71 - scene_state->y_offset,
|
||||||
SCREEN_WIDTH - 36,
|
SCREEN_WIDTH - 36,
|
||||||
YES_NO_LIST[scene_state->notification_sound],
|
YES_NO_LIST[scene_state->notification_sound],
|
||||||
scene_state->selected_control == Sound);
|
scene_state->selected_control == Sound);
|
||||||
|
|
||||||
canvas_draw_str_aligned(canvas, 0, 99 - scene_state->y_offset, AlignLeft, AlignTop, "Vibro:");
|
canvas_draw_str_aligned(canvas, 0, 94 - scene_state->y_offset, AlignLeft, AlignTop, "Vibro:");
|
||||||
ui_control_select_render(
|
ui_control_select_render(
|
||||||
canvas,
|
canvas,
|
||||||
36,
|
36,
|
||||||
92 - scene_state->y_offset,
|
87 - scene_state->y_offset,
|
||||||
SCREEN_WIDTH - 36,
|
SCREEN_WIDTH - 36,
|
||||||
YES_NO_LIST[scene_state->notification_vibro],
|
YES_NO_LIST[scene_state->notification_vibro],
|
||||||
scene_state->selected_control == Vibro);
|
scene_state->selected_control == Vibro);
|
||||||
|
|
||||||
|
two_digit_to_str(scene_state->selected_font, &tmp_str[0]);
|
||||||
|
canvas_draw_str_aligned(
|
||||||
|
canvas, 0, 110 - scene_state->y_offset, AlignLeft, AlignTop, "UI Font:");
|
||||||
|
ui_control_select_render(
|
||||||
|
canvas,
|
||||||
|
36,
|
||||||
|
103 - scene_state->y_offset,
|
||||||
|
SCREEN_WIDTH - 36,
|
||||||
|
&tmp_str[0],
|
||||||
|
scene_state->selected_control == FontSelector);
|
||||||
|
|
||||||
canvas_draw_icon(
|
canvas_draw_icon(
|
||||||
canvas, SCREEN_WIDTH_CENTER - 5, 123 - scene_state->y_offset, &I_totp_arrow_bottom_10x5);
|
canvas, SCREEN_WIDTH_CENTER - 5, 123 - scene_state->y_offset, &I_totp_arrow_bottom_10x5);
|
||||||
|
|
||||||
|
@ -192,7 +206,7 @@ bool totp_scene_app_settings_handle_event(
|
||||||
HoursInput,
|
HoursInput,
|
||||||
ConfirmButton,
|
ConfirmButton,
|
||||||
RollOverflowBehaviorStop);
|
RollOverflowBehaviorStop);
|
||||||
if(scene_state->selected_control > Vibro) {
|
if(scene_state->selected_control > FontSelector) {
|
||||||
scene_state->y_offset = 128;
|
scene_state->y_offset = 128;
|
||||||
} else if(scene_state->selected_control > MinutesInput) {
|
} else if(scene_state->selected_control > MinutesInput) {
|
||||||
scene_state->y_offset = 64;
|
scene_state->y_offset = 64;
|
||||||
|
@ -207,7 +221,7 @@ bool totp_scene_app_settings_handle_event(
|
||||||
HoursInput,
|
HoursInput,
|
||||||
ConfirmButton,
|
ConfirmButton,
|
||||||
RollOverflowBehaviorStop);
|
RollOverflowBehaviorStop);
|
||||||
if(scene_state->selected_control > Vibro) {
|
if(scene_state->selected_control > FontSelector) {
|
||||||
scene_state->y_offset = 128;
|
scene_state->y_offset = 128;
|
||||||
} else if(scene_state->selected_control > MinutesInput) {
|
} else if(scene_state->selected_control > MinutesInput) {
|
||||||
scene_state->y_offset = 64;
|
scene_state->y_offset = 64;
|
||||||
|
@ -234,6 +248,10 @@ bool totp_scene_app_settings_handle_event(
|
||||||
scene_state->badbt_enabled = !scene_state->badbt_enabled;
|
scene_state->badbt_enabled = !scene_state->badbt_enabled;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else if(scene_state->selected_control == FontSelector) {
|
||||||
|
totp_roll_value_uint8_t(
|
||||||
|
&scene_state->selected_font, 1, 0, 6, RollOverflowBehaviorStop);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case InputKeyLeft:
|
case InputKeyLeft:
|
||||||
if(scene_state->selected_control == HoursInput) {
|
if(scene_state->selected_control == HoursInput) {
|
||||||
|
@ -254,6 +272,10 @@ bool totp_scene_app_settings_handle_event(
|
||||||
scene_state->badbt_enabled = !scene_state->badbt_enabled;
|
scene_state->badbt_enabled = !scene_state->badbt_enabled;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
else if(scene_state->selected_control == FontSelector) {
|
||||||
|
totp_roll_value_uint8_t(
|
||||||
|
&scene_state->selected_font, -1, 0, 6, RollOverflowBehaviorStop);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case InputKeyOk:
|
case InputKeyOk:
|
||||||
break;
|
break;
|
||||||
|
@ -280,6 +302,7 @@ bool totp_scene_app_settings_handle_event(
|
||||||
plugin_state->automation_method |= scene_state->badbt_enabled ? AutomationMethodBadBt :
|
plugin_state->automation_method |= scene_state->badbt_enabled ? AutomationMethodBadBt :
|
||||||
AutomationMethodNone;
|
AutomationMethodNone;
|
||||||
#endif
|
#endif
|
||||||
|
plugin_state->selected_font = scene_state->selected_font;
|
||||||
|
|
||||||
if(!totp_config_file_update_user_settings(plugin_state)) {
|
if(!totp_config_file_update_user_settings(plugin_state)) {
|
||||||
totp_dialogs_config_updating_error(plugin_state);
|
totp_dialogs_config_updating_error(plugin_state);
|
||||||
|
|
|
@ -142,19 +142,46 @@ static void draw_totp_code(Canvas* const canvas, const PluginState* const plugin
|
||||||
totp_config_get_token_iterator_context(plugin_state);
|
totp_config_get_token_iterator_context(plugin_state);
|
||||||
uint8_t code_length = totp_token_info_iterator_get_current_token(iterator_context)->digits;
|
uint8_t code_length = totp_token_info_iterator_get_current_token(iterator_context)->digits;
|
||||||
uint8_t offset_x = scene_state->ui_precalculated_dimensions.code_offset_x;
|
uint8_t offset_x = scene_state->ui_precalculated_dimensions.code_offset_x;
|
||||||
uint8_t char_width = TOTP_CODE_FONT_INFO.charInfo[0].width;
|
const FONT_INFO* current_font;
|
||||||
|
switch(plugin_state->selected_font) {
|
||||||
|
case 0:
|
||||||
|
current_font = &modeNine_15ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
current_font = &redHatMono_16ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
current_font = &bedstead_17ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
current_font = &zector_18ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
current_font = &_712Serif_24ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
current_font = &graph35pix_12ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
current_font = &karmaFuture_14ptFontInfo;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
current_font = &modeNine_15ptFontInfo;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
uint8_t char_width = current_font->charInfo[0].width;
|
||||||
uint8_t offset_x_inc = scene_state->ui_precalculated_dimensions.code_offset_x_inc;
|
uint8_t offset_x_inc = scene_state->ui_precalculated_dimensions.code_offset_x_inc;
|
||||||
for(uint8_t i = 0; i < code_length; i++) {
|
for(uint8_t i = 0; i < code_length; i++) {
|
||||||
char ch = scene_state->last_code[i];
|
char ch = scene_state->last_code[i];
|
||||||
if(ch >= TOTP_CODE_FONT_INFO.startChar && ch <= TOTP_CODE_FONT_INFO.endChar) {
|
if(ch >= current_font->startChar && ch <= current_font->endChar) {
|
||||||
uint8_t char_index = ch - TOTP_CODE_FONT_INFO.startChar;
|
uint8_t char_index = ch - current_font->startChar;
|
||||||
canvas_draw_xbm(
|
canvas_draw_xbm(
|
||||||
canvas,
|
canvas,
|
||||||
offset_x,
|
offset_x,
|
||||||
scene_state->ui_precalculated_dimensions.code_offset_y,
|
scene_state->ui_precalculated_dimensions.code_offset_y,
|
||||||
char_width,
|
char_width,
|
||||||
TOTP_CODE_FONT_INFO.height,
|
current_font->height,
|
||||||
&TOTP_CODE_FONT_INFO.data[TOTP_CODE_FONT_INFO.charInfo[char_index].offset]);
|
¤t_font->data[current_font->charInfo[char_index].offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_x += offset_x_inc;
|
offset_x += offset_x_inc;
|
||||||
|
@ -172,15 +199,43 @@ static void on_new_token_code_generated(bool time_left, void* context) {
|
||||||
SceneState* scene_state = plugin_state->current_scene_state;
|
SceneState* scene_state = plugin_state->current_scene_state;
|
||||||
const TokenInfo* current_token = totp_token_info_iterator_get_current_token(iterator_context);
|
const TokenInfo* current_token = totp_token_info_iterator_get_current_token(iterator_context);
|
||||||
|
|
||||||
uint8_t char_width = TOTP_CODE_FONT_INFO.charInfo[0].width;
|
const FONT_INFO* current_font;
|
||||||
|
switch(plugin_state->selected_font) {
|
||||||
|
case 0:
|
||||||
|
current_font = &modeNine_15ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
current_font = &redHatMono_16ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
current_font = &bedstead_17ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
current_font = &zector_18ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
current_font = &_712Serif_24ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
current_font = &graph35pix_12ptFontInfo;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
current_font = &karmaFuture_14ptFontInfo;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
current_font = &modeNine_15ptFontInfo;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t char_width = current_font->charInfo[0].width;
|
||||||
scene_state->ui_precalculated_dimensions.code_total_length =
|
scene_state->ui_precalculated_dimensions.code_total_length =
|
||||||
current_token->digits * (char_width + TOTP_CODE_FONT_INFO.spacePixels);
|
current_token->digits * (char_width + current_font->spacePixels);
|
||||||
scene_state->ui_precalculated_dimensions.code_offset_x =
|
scene_state->ui_precalculated_dimensions.code_offset_x =
|
||||||
(SCREEN_WIDTH - scene_state->ui_precalculated_dimensions.code_total_length) >> 1;
|
(SCREEN_WIDTH - scene_state->ui_precalculated_dimensions.code_total_length) >> 1;
|
||||||
scene_state->ui_precalculated_dimensions.code_offset_x_inc =
|
scene_state->ui_precalculated_dimensions.code_offset_x_inc =
|
||||||
char_width + TOTP_CODE_FONT_INFO.spacePixels;
|
char_width + current_font->spacePixels;
|
||||||
scene_state->ui_precalculated_dimensions.code_offset_y =
|
scene_state->ui_precalculated_dimensions.code_offset_y =
|
||||||
SCREEN_HEIGHT_CENTER - (TOTP_CODE_FONT_INFO.height >> 1);
|
SCREEN_HEIGHT_CENTER - (current_font->height >> 1);
|
||||||
|
|
||||||
if(time_left) {
|
if(time_left) {
|
||||||
notification_message(
|
notification_message(
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "../type_code_common.h"
|
#include "../type_code_common.h"
|
||||||
#include "../../features_config.h"
|
#include "../../features_config.h"
|
||||||
|
|
||||||
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
|
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
|
||||||
#define TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN FURI_HAL_BT_ADV_NAME_LENGTH
|
#define TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN FURI_HAL_BT_ADV_NAME_LENGTH
|
||||||
#define TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN GAP_MAC_ADDR_SIZE
|
#define TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN GAP_MAC_ADDR_SIZE
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,7 @@ struct TotpBtTypeCodeWorkerContext {
|
||||||
Bt* bt;
|
Bt* bt;
|
||||||
bool is_advertising;
|
bool is_advertising;
|
||||||
bool is_connected;
|
bool is_connected;
|
||||||
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
|
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
|
||||||
char previous_bt_name[TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN];
|
char previous_bt_name[TOTP_BT_WORKER_BT_ADV_NAME_MAX_LEN];
|
||||||
uint8_t previous_bt_mac[TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN];
|
uint8_t previous_bt_mac[TOTP_BT_WORKER_BT_MAC_ADDRESS_LEN];
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,7 +39,7 @@ static inline bool totp_type_code_worker_stop_requested() {
|
||||||
return furi_thread_flags_get() & TotpBtTypeCodeWorkerEventStop;
|
return furi_thread_flags_get() & TotpBtTypeCodeWorkerEventStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
|
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
|
||||||
static void totp_type_code_worker_bt_set_app_mac(uint8_t* mac) {
|
static void totp_type_code_worker_bt_set_app_mac(uint8_t* mac) {
|
||||||
uint8_t max_i;
|
uint8_t max_i;
|
||||||
size_t uid_size = furi_hal_version_uid_size();
|
size_t uid_size = furi_hal_version_uid_size();
|
||||||
|
@ -161,7 +161,7 @@ TotpBtTypeCodeWorkerContext* totp_bt_type_code_worker_init() {
|
||||||
furi_delay_ms(200);
|
furi_delay_ms(200);
|
||||||
bt_keys_storage_set_storage_path(context->bt, HID_BT_KEYS_STORAGE_PATH);
|
bt_keys_storage_set_storage_path(context->bt, HID_BT_KEYS_STORAGE_PATH);
|
||||||
|
|
||||||
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
|
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
|
||||||
memcpy(
|
memcpy(
|
||||||
&context->previous_bt_name[0],
|
&context->previous_bt_name[0],
|
||||||
furi_hal_bt_get_profile_adv_name(FuriHalBtProfileHidKeyboard),
|
furi_hal_bt_get_profile_adv_name(FuriHalBtProfileHidKeyboard),
|
||||||
|
@ -184,7 +184,7 @@ TotpBtTypeCodeWorkerContext* totp_bt_type_code_worker_init() {
|
||||||
|
|
||||||
furi_hal_bt_start_advertising();
|
furi_hal_bt_start_advertising();
|
||||||
|
|
||||||
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
|
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
|
||||||
bt_enable_peer_key_update(context->bt);
|
bt_enable_peer_key_update(context->bt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ void totp_bt_type_code_worker_free(TotpBtTypeCodeWorkerContext* context) {
|
||||||
furi_delay_ms(200);
|
furi_delay_ms(200);
|
||||||
bt_keys_storage_set_default_path(context->bt);
|
bt_keys_storage_set_default_path(context->bt);
|
||||||
|
|
||||||
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_XTREME
|
#if TOTP_TARGET_FIRMWARE == TOTP_FIRMWARE_UL_XFW
|
||||||
furi_hal_bt_set_profile_adv_name(FuriHalBtProfileHidKeyboard, context->previous_bt_name);
|
furi_hal_bt_set_profile_adv_name(FuriHalBtProfileHidKeyboard, context->previous_bt_name);
|
||||||
furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, context->previous_bt_mac);
|
furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, context->previous_bt_mac);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue