Skip to content
This repository was archived by the owner on Sep 5, 2020. It is now read-only.

Commit 9050445

Browse files
authored
✨ Migrate to SDK4, AppGlance, use Pebble Packages
✨ Add pebble-localize package 💩 Remove redundant localization files (`localize.h`,`localize.c`,`hash.h`) 💄 Update Menu Icons ✨ Added AppGlance -Show last checkin venue (for 24 hours) or "Connect to Foursquare" if not connected. 🔨 Build on SDK 4.0 🔨 Add Diorite target platform
1 parent 06d7385 commit 9050445

File tree

13 files changed

+160
-94
lines changed

13 files changed

+160
-94
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build
22
.lock-waf_darwin_build
3+
.DS_Store
4+
node_modules

package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"dependencies": {
44
"pebble-localize": "^0.1.0"
55
},
6+
"license":"MIT",
7+
"repository":"https://github.com/thunsaker/spoon",
68
"keywords": [],
79
"name": "spoon",
810
"pebble": {
@@ -33,10 +35,9 @@
3335
"resources": {
3436
"media": [
3537
{
36-
"file": "images/spoon_2_menu_icon.png",
38+
"file": "images/spoon_menu_icon.png",
3739
"menuIcon": true,
3840
"name": "IMAGE_MENU",
39-
"targetPlatforms": null,
4041
"type": "bitmap"
4142
},
4243
{
@@ -79,6 +80,18 @@
7980
"name": "LOCALE_ENGLISH",
8081
"type": "raw"
8182
}
83+
],
84+
"publishedMedia": [
85+
{
86+
"name":"ICON_SPOON",
87+
"id":1,
88+
"glance":"IMAGE_MENU"
89+
},
90+
{
91+
"name":"ICON_CHECK",
92+
"id":2,
93+
"glance":"IMAGE_CHECK_ON"
94+
}
8295
]
8396
},
8497
"sdkVersion": "3",

resources/images/check_white.png

122 Bytes
Loading
-301 Bytes
Binary file not shown.
-307 Bytes
Binary file not shown.
321 Bytes
Loading

src/c/checkin.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "src/c/common.h"
77
#include "src/c/libs/pebble-assist.h"
88
#include "src/c/paths.h"
9+
#include "src/c/glance.h"
910

1011
static Window *s_main_window;
1112
#ifdef PBL_SDK_3
@@ -46,6 +47,8 @@ static void countdown_tick(void *ctx);
4647
static int SCREEN_HEIGHT;
4748
static int SCREEN_WIDTH;
4849

50+
char* last_checkin_venue_name;
51+
4952
void checkin_result_receiver(bool result) {
5053
hasResult = true;
5154
checkinResult = result;
@@ -63,7 +66,8 @@ static void countdown_tick(void *ctx) {
6366
if(progress > 0) {
6467
start_countdown();
6568
} else {
66-
// APP_LOG(APP_LOG_LEVEL_DEBUG, "Pop it like it's hot!");
69+
char *venue = last_checkin_venue_name;
70+
update_app_glance(venue, PUBLISHED_ID_ICON_CHECK);
6771
window_stack_pop_all(true);
6872
}
6973
}
@@ -72,10 +76,12 @@ void checkin_send_request(char venue_guid[128], char venue_name[512], int privat
7276
// APP_LOG(APP_LOG_LEVEL_DEBUG, "Private: %i Twitter: %i Facebook: %i", private, twitter, facebook);
7377
if(venue_guid) {
7478
Tuplet guid_tuple = TupletCString(SPOON_ID, venue_guid);
75-
Tuplet name_tuple = TupletCString(SPOON_NAME, venue_name);
76-
79+
Tuplet name_tuple = TupletCString(SPOON_NAME, venue_name);
80+
last_checkin_venue_name = venue_name;
81+
strncpy(last_checkin_venue_name, venue_name, 25);
82+
7783
int broadcast_flag = BROADCAST_DEFAULT;
78-
84+
7985
if(private == 1) {
8086
broadcast_flag = BROADCAST_PRIVATE;
8187
} else if (twitter == 1 && facebook == 1) {
@@ -85,22 +91,22 @@ void checkin_send_request(char venue_guid[128], char venue_name[512], int privat
8591
} else if(facebook == 1) {
8692
broadcast_flag = BROADCAST_FACEBOOK;
8793
}
88-
94+
8995
Tuplet broadcast_tuple = TupletInteger(SPOON_BROADCAST, broadcast_flag);
90-
96+
9197
DictionaryIterator *iter;
9298
app_message_outbox_begin(&iter);
93-
99+
94100
if(iter == NULL) {
95101
return;
96102
}
97103
dict_write_tuplet(iter, &guid_tuple);
98104
dict_write_tuplet(iter, &name_tuple);
99105
dict_write_tuplet(iter, &broadcast_tuple);
100106
dict_write_end(iter);
101-
107+
102108
app_message_outbox_send();
103-
109+
104110
if(show_checkin) {
105111
checkin_show();
106112
}
@@ -129,10 +135,10 @@ void pulse_check_tick() {
129135
#ifdef PBL_COLOR
130136
back_color = checkinResult ? GColorJaegerGreen.argb : GColorSunsetOrange.argb;
131137
#endif
132-
138+
133139
s_check_large_path = gpath_create(&CHECK_LARGE_PATH_POINTS);
134140
text_layer_set_text(text_layer_status, checkinResult ? _("Checked In!") : _("Something went wrong :("));
135-
141+
136142
layer_mark_dirty(layer_check);
137143
app_timer_cancel_safe(pulse_check_timer);
138144
app_timer_cancel_safe(checkin_timeout_timer);
@@ -150,7 +156,7 @@ void checkin_timeout_tick() {
150156
#ifdef PBL_COLOR
151157
back_color = GColorDarkGray.argb;
152158
#endif
153-
159+
154160
text_layer_set_text(text_layer_status, _("Timeout :("));
155161
layer_mark_dirty(layer_check);
156162
}
@@ -208,7 +214,7 @@ void draw_layer_back(Layer *cell_layer, GContext *ctx) {
208214

209215
static void window_load(Window *window) {
210216
Layer *window_layer = window_get_root_layer(window);
211-
217+
212218
GRect bounds = layer_get_frame(window_layer);
213219
SCREEN_HEIGHT = bounds.size.h;
214220
SCREEN_WIDTH = bounds.size.w;
@@ -232,7 +238,11 @@ static void window_load(Window *window) {
232238
// Text Status
233239
text_layer_status = text_layer_create(GRect(10,120 - STATUS_BAR_OFFSET,bounds.size.w-20,60));
234240
#ifdef PBL_COLOR
235-
text_layer_set_text_color(text_layer_status, GColorBlack);
241+
if(back_color == GColorBlack.argb) {
242+
text_layer_set_text_color(text_layer_status, GColorWhite);
243+
} else {
244+
text_layer_set_text_color(text_layer_status, GColorBlack);
245+
}
236246
#else
237247
text_layer_set_text_color(text_layer_status, GColorWhite);
238248
#endif
@@ -263,7 +273,7 @@ static void window_load(Window *window) {
263273
s_status_bar, GColorClear, GColorBlack);
264274
layer_add_child(
265275
window_layer, status_bar_layer_get_layer(s_status_bar));
266-
276+
267277
layer_countdown_bar = layer_create((GRect) {
268278
.origin = GPoint(0, STATUS_BAR_LAYER_HEIGHT - 2),
269279
.size = CHECKIN_COUNTDOWN_BAR_SIZE
@@ -300,4 +310,4 @@ void checkin_deinit(void) {
300310

301311
void checkin_show(void) {
302312
init();
303-
}
313+
}

src/c/common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// 2016 Thomas Hunsaker @thunsaker
22
#pragma once
3-
3+
44
#include <pebble.h>
55
#include <pebble-localize/pebble-localize.h>
66

@@ -43,9 +43,9 @@ enum {
4343
#define KEY_TOKEN 10
4444
#define KEY_THEME 20
4545
#define KEY_UNIT 30
46-
46+
4747
#ifdef PBL_SDK_3
4848
#define STATUS_BAR_OFFSET 0
4949
#else
5050
#define STATUS_BAR_OFFSET 12
51-
#endif
51+
#endif

src/c/glance.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <pebble.h>
2+
#include "src/c/glance.h"
3+
4+
char *glance_text;
5+
uint32_t glance_icon;
6+
7+
static void prv_update_app_glance(AppGlanceReloadSession *session,
8+
size_t limit, void *context) {
9+
if(limit < 1) return;
10+
11+
time_t temp_time = time(NULL);
12+
time_t expiration_time = temp_time + HOUR_IN_SECONDS;
13+
14+
const char *glance_message = context;
15+
const uint32_t final_glance_icon = glance_icon;
16+
17+
const AppGlanceSlice slice = (AppGlanceSlice) {
18+
.layout = {
19+
.subtitle_template_string = glance_message,
20+
.icon = final_glance_icon
21+
},
22+
.expiration_time = expiration_time
23+
};
24+
25+
const AppGlanceResult result = app_glance_add_slice(session, slice);
26+
}
27+
28+
void update_app_glance(char *message, const uint32_t icon) {
29+
#if PBL_API_EXISTS(app_glance_reload)
30+
glance_text = message;
31+
glance_icon = icon;
32+
app_glance_reload(prv_update_app_glance, message);
33+
#endif
34+
}

src/c/glance.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// 2016 Thomas Hunsaker @thunsaker
2+
#pragma once
3+
4+
#include <pebble.h>
5+
6+
#define DAY_IN_SECONDS 86400
7+
#define HOUR_IN_SECONDS 3600;
8+
9+
void update_app_glance(char* message, const uint32_t icon);

0 commit comments

Comments
 (0)