diff --git a/appinfo.json b/appinfo.json index debcf09..af6035f 100644 --- a/appinfo.json +++ b/appinfo.json @@ -108,7 +108,7 @@ "basalt" ], "uuid": "1f4d9835-3b9a-4ddd-907e-41a25d06f19c", - "versionLabel": "2.4", + "versionLabel": "2.5", "watchapp": { "watchface": false } diff --git a/src/base32.h b/src/base32.h index a772fb9..10de0b0 100644 --- a/src/base32.h +++ b/src/base32.h @@ -30,7 +30,6 @@ // output buffer is too small, the result will silently be truncated. #pragma once - #include int base32_decode(const uint8_t *encoded, uint8_t *result, int bufSize) diff --git a/src/google-authenticator.c b/src/google-authenticator.c index 37a9040..f308d45 100644 --- a/src/google-authenticator.c +++ b/src/google-authenticator.c @@ -27,7 +27,6 @@ #include "google-authenticator.h" char *generateCode(const char *key, int timezone_offset) { - //long tm = time(NULL)/30; #ifdef PBL_SDK_2 long tm = (time(NULL) + (timezone_offset*60))/30; @@ -48,17 +47,17 @@ char *generateCode(const char *key, int timezone_offset) { // Sanity check, that our secret will fixed into a reasonably-sized static // array. if (secretLen < 0 || secretLen > 100) { - return "FAILED"; + return "000000"; } // Decode secret from Base32 to a binary representation, and check that we // have at least one byte's worth of secret data. uint8_t secret[100]; if ((secretLen = base32_decode((const uint8_t *)key, secret, secretLen))<1) { - return "FAILED"; + return "000000"; } - // Compute the HMAC_SHA1 of the secrete and the challenge. + // Compute the HMAC_SHA1 of the secret and the challenge. uint8_t hash[SHA1_DIGEST_LENGTH]; hmac_sha1(secret, secretLen, challenge, 8, hash, SHA1_DIGEST_LENGTH); diff --git a/src/js/pebble-js-app.js b/src/js/pebble-js-app.js index 2cfb5e5..744075f 100644 --- a/src/js/pebble-js-app.js +++ b/src/js/pebble-js-app.js @@ -2,7 +2,7 @@ var MAX_OTP_COUNT = 16; var MAX_LABEL_LENGTH = 20; var MAX_KEY_LENGTH = 128; var MAX_MESSAGE_RETRIES = 5; -var APP_VERSION = 24; +var APP_VERSION = 25; var otp_count = 0; var aplite_theme = -1; @@ -321,9 +321,10 @@ Pebble.addEventListener("webviewclosed", if(configuration.label && configuration.secret) { var secret = configuration.secret - .replace(/0/g,"O") // replace 0 with O - .replace(/1/g, "I") // replace 1 with I - .replace(/\W/g, '') // replace non-alphanumeric characters + .replace(/0/g,"O") // replace 0 with O + .replace(/1/g, "I") // replace 1 with I + .replace(/\W/g, '') // replace non-alphanumeric characters + .replace(/_/g, '') // replace underscore .toUpperCase() .substring(0, MAX_KEY_LENGTH); var label = configuration.label diff --git a/src/main.c b/src/main.c index 99832bf..99e97a7 100644 --- a/src/main.c +++ b/src/main.c @@ -9,7 +9,7 @@ #include "main.h" #include "single_code_window.h" #include "multi_code_window.h" -#include +#include "ctype.h" // Colors GColor bg_color; @@ -677,29 +677,15 @@ void main_animate_second_counter(int seconds, bool off_screen) { // update countdown layer GRect start = layer_get_frame(text_layer_get_layer(countdown_layer)); GRect finish = countdown_rect; - finish.size.w = ((float)4.8) * reverse_seconds; // 4.8 == Pebble screen width / 30 + // finish.size.w = ((float)4.8) * reverse_seconds; // 4.8 == Pebble screen width / 30 + finish.size.w = (24 * reverse_seconds) / 5; // Same result as the above line but it avoids floats so is Pebble friendly. #ifdef PBL_COLOR - switch(reverse_seconds) - { - case 6 : - text_layer_set_background_color(countdown_layer, GColorRed); - break; - case 5 : - text_layer_set_background_color(countdown_layer, fg_color); - break; - case 4 : - text_layer_set_background_color(countdown_layer, GColorRed); - break; - case 3 : - text_layer_set_background_color(countdown_layer, fg_color); - break; - case 2 : - text_layer_set_background_color(countdown_layer, GColorRed); - break; - case 1 : - text_layer_set_background_color(countdown_layer, fg_color); - break; + if (reverse_seconds <= 6) { + if (reverse_seconds % 2 == 0) + text_layer_set_background_color(countdown_layer, GColorRed); + else + text_layer_set_background_color(countdown_layer, fg_color); } #endif @@ -762,12 +748,16 @@ void handle_init(void) { void handle_deinit(void) { if (DEBUG) APP_LOG(APP_LOG_LEVEL_DEBUG, "INFO: EXITING"); + tick_timer_service_unsubscribe(); + animation_unschedule_all(); text_layer_destroy(countdown_layer); + if (window_layout == 1) multi_code_window_remove(); else single_code_window_remove(); + if (font_label.isCustom) fonts_unload_custom_font(font_label.font); if (font_pin.isCustom) diff --git a/src/main.h b/src/main.h index 87500d6..e3ddd6b 100644 --- a/src/main.h +++ b/src/main.h @@ -6,7 +6,6 @@ // #pragma once - #include "pebble.h" typedef struct { @@ -14,16 +13,11 @@ typedef struct { bool isCustom; } AppFont; -#define ASCII_0_VALU 48 -#define ASCII_9_VALU 57 -#define ASCII_A_VALU 65 -#define ASCII_F_VALU 70 - #define MAX_OTP 16 #define MAX_LABEL_LENGTH 21 // 20 + termination #define MAX_KEY_LENGTH 129 // 128 + termination #define MAX_COMBINED_LENGTH MAX_LABEL_LENGTH+MAX_KEY_LENGTH -#define APP_VERSION 24 +#define APP_VERSION 25 #define DEBUG false #define MyTupletCString(_key, _cstring) \ diff --git a/src/multi_code_window.c b/src/multi_code_window.c index 989671b..31bfcf7 100644 --- a/src/multi_code_window.c +++ b/src/multi_code_window.c @@ -69,9 +69,6 @@ static void multi_code_menu_selection_changed_callback(struct MenuLayer *menu_la resetIdleTime(); } -AppFont font_pin; -AppFont font_label; - void multi_code_set_fonts(void) { fonts_changed = false; diff --git a/src/multi_code_window.h b/src/multi_code_window.h index 06a5991..0cc9052 100644 --- a/src/multi_code_window.h +++ b/src/multi_code_window.h @@ -1,5 +1,5 @@ #pragma once -#include "pebble.h" + #define MULTI_CODE_CELL_HEIGHT 55 void multi_code_window_push(void); diff --git a/src/sha1.c b/src/sha1.c index 1dab89f..5d7dd0d 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -40,7 +40,7 @@ * ***************************************************************************** */ -#include +#include "string.h" #include "sha1.h" /* SHA f()-functions */ diff --git a/src/sha1.h b/src/sha1.h index bf4a20a..73548e4 100644 --- a/src/sha1.h +++ b/src/sha1.h @@ -16,8 +16,7 @@ // limitations under the License. #pragma once - -#include +#include "stdint.h" #define SHA1_BLOCKSIZE 64 #define SHA1_DIGEST_LENGTH 20 diff --git a/src/single_code_window.c b/src/single_code_window.c index 4c927a7..8aa4ce2 100644 --- a/src/single_code_window.c +++ b/src/single_code_window.c @@ -1,4 +1,4 @@ -#include +#include "pebble.h" #include "single_code_window.h" #include "main.h" #include "select_window.h" diff --git a/src/single_code_window.h b/src/single_code_window.h index e5f420e..b9af7e4 100644 --- a/src/single_code_window.h +++ b/src/single_code_window.h @@ -1,5 +1,4 @@ #pragma once -#include "pebble.h" void single_code_window_push(void); void single_code_window_remove(void);