You've already forked intuiclock
Closes #2
This commit is contained in:
@@ -40,6 +40,7 @@ static bool hide_seconds_hand = false;
|
||||
static bool hide_battery_indicator = false;
|
||||
static char date_format[2];
|
||||
static bool use_wide_layout = false;
|
||||
static bool use_xen_style = false;
|
||||
|
||||
static const GPathInfo MINUTE_HAND_POINTS = {
|
||||
4,
|
||||
@@ -71,6 +72,7 @@ static const GPathInfo HOUR_HAND_POINTS = {
|
||||
#define KEY_BATTERY_INDICATOR 1
|
||||
#define KEY_DATE_FORMAT 2
|
||||
#define KEY_WIDE_LAYOUT 3
|
||||
#define KEY_XEN_STYLE 4
|
||||
|
||||
static void update_date_text_layer() {
|
||||
static char date_text[DATE_TEXT_SIZE];
|
||||
@@ -205,17 +207,27 @@ static void update_geometry() {
|
||||
}
|
||||
|
||||
if (use_wide_layout == false) {
|
||||
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BACKGROUND);
|
||||
if (use_xen_style == false) {
|
||||
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BKG_CLASSIC_NARROW);
|
||||
} else {
|
||||
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BKG_XEN_NARROW);
|
||||
}
|
||||
|
||||
layer_set_frame(text_layer_get_layer(s_title_layer), GRect(36, 2, 46, 18));
|
||||
layer_set_frame(text_layer_get_layer(s_date_layer), GRect(17, 130, 109, 16));
|
||||
layer_set_frame(text_layer_get_layer(s_ampm_layer), GRect(107, 26, 16, 16));
|
||||
layer_set_frame(text_layer_get_layer(s_ampm_layer), GRect(108, 26, 16, 16));
|
||||
layer_set_frame(bitmap_layer_get_layer(s_battery_icon_layer), GRect(20, 26, 16, 7));
|
||||
layer_set_frame(s_battery_indicator_layer, GRect(21, 27, 13, 5));
|
||||
} else {
|
||||
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BACKGROUND_WIDE);
|
||||
if (use_xen_style == false) {
|
||||
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BKG_CLASSIC_WIDE);
|
||||
} else {
|
||||
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BKG_XEN_WIDE);
|
||||
}
|
||||
|
||||
layer_set_frame(text_layer_get_layer(s_title_layer), GRect(24, 2, 71, 18));
|
||||
layer_set_frame(text_layer_get_layer(s_date_layer), GRect(4, 130, 136, 16));
|
||||
layer_set_frame(text_layer_get_layer(s_ampm_layer), GRect(122, 25, 16, 16));
|
||||
layer_set_frame(text_layer_get_layer(s_ampm_layer), GRect(123, 25, 16, 16));
|
||||
layer_set_frame(bitmap_layer_get_layer(s_battery_icon_layer), GRect(7, 26, 16, 7));
|
||||
layer_set_frame(s_battery_indicator_layer, GRect(8, 27, 13, 5));
|
||||
}
|
||||
@@ -264,6 +276,18 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||
}
|
||||
|
||||
persist_write_bool(KEY_WIDE_LAYOUT, use_wide_layout);
|
||||
|
||||
// Handling xen_style setting.
|
||||
Tuple *xen_style_t = dict_find(iter, KEY_XEN_STYLE);
|
||||
if (xen_style_t && xen_style_t->value->int32 > 0) {
|
||||
use_xen_style = true;
|
||||
} else {
|
||||
use_xen_style = false;
|
||||
}
|
||||
|
||||
persist_write_bool(KEY_XEN_STYLE, use_xen_style);
|
||||
|
||||
// Updating geometry according to settings.
|
||||
update_geometry();
|
||||
}
|
||||
|
||||
@@ -322,8 +346,9 @@ static void main_window_load(Window *window) {
|
||||
layer_set_update_proc(s_battery_indicator_layer, s_battery_indicator_layer_update);
|
||||
layer_add_child(window_layer, s_battery_indicator_layer);
|
||||
|
||||
// Update geometry according to wide_layout setting.
|
||||
// Update geometry according to wide_layout and xen_style settings.
|
||||
use_wide_layout = persist_read_bool(KEY_WIDE_LAYOUT);
|
||||
use_xen_style = persist_read_bool(KEY_XEN_STYLE);
|
||||
update_geometry();
|
||||
|
||||
// Read date_format setting from persistent storage.
|
||||
|
||||
@@ -24,19 +24,20 @@
|
||||
// });
|
||||
|
||||
Pebble.addEventListener('showConfiguration', function(e) {
|
||||
Pebble.openURL('http://127.0.0.1/u/bilbo/pebble/iclock/index.html');
|
||||
Pebble.openURL('http://192.168.1.113/u/bilbo/pebble/iclock/index.html');
|
||||
// Pebble.openURL('https://pconf.bthlabs.pl/intuiclock/index.html');
|
||||
});
|
||||
|
||||
Pebble.addEventListener('webviewclosed', function(e) {
|
||||
var config_data = JSON.parse(decodeURIComponent(e.response));
|
||||
// console.log('Configuration page returned: ' + JSON.stringify(config_data));
|
||||
console.log('Configuration page returned: ' + JSON.stringify(config_data));
|
||||
|
||||
var dict = {};
|
||||
dict['KEY_SECONDS_HAND'] = config_data['seconds_hand'];
|
||||
dict['KEY_BATTERY_INDICATOR'] = config_data['battery_indicator'];
|
||||
dict['KEY_DATE_FORMAT'] = config_data['date_format'];
|
||||
dict['KEY_WIDE_LAYOUT'] = config_data['wide_layout'];
|
||||
dict['KEY_XEN_STYLE'] = config_data['xen_style'];
|
||||
|
||||
Pebble.sendAppMessage(dict, function() {
|
||||
// console.log('Send successful!');
|
||||
|
||||
Reference in New Issue
Block a user