forked from maximuska/Freemap-waze
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roadmap_geo_location_info.c
294 lines (239 loc) · 10.4 KB
/
roadmap_geo_location_info.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/* roadmap_geo_location_info.c
*
* LICENSE:
*
* Copyright 2009 Avi Ben-Shoshan
*
* This file is part of RoadMap.
*
* RoadMap is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License V2 as published by
* the Free Software Foundation.
*
* RoadMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RoadMap; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
*/
#include <stdlib.h>
#include <string.h>
#include "roadmap.h"
#include "roadmap_res.h"
#include "roadmap_canvas.h"
#include "roadmap_config.h"
#include "roadmap_lang.h"
#include "roadmap_geo_location_info.h"
#include "ssd/ssd_widget.h"
#include "ssd/ssd_container.h"
#include "ssd/ssd_dialog.h"
#include "ssd/ssd_bitmap.h"
#include "ssd/ssd_progress.h"
#include "ssd/ssd_button.h"
#include "ssd/ssd_text.h"
static RoadMapConfigDescriptor GEO_LOCATION_DISPLAYED_Var =
ROADMAP_CONFIG_ITEM(
GEO_LOCATION_TAB,
GEO_LOCATION_DISPLAYED_Name);
static RoadMapConfigDescriptor GEO_LOCATION_ENABLED_Var =
ROADMAP_CONFIG_ITEM(
GEO_LOCATION_TAB,
GEO_LOCATION_ENABLED_Name);
typedef struct tag_geo_location_info
{
char metroplolitan[128];
char state[50];
char map_score[50];
char traffic_score[50];
char usage_score[50];
int overall_score;
} geo_location_info, *geo_location_info_ptr;
static geo_location_info g_geo_info;
/////////////////////////////////////////////////////////////////////
static BOOL is_geo_location_enabled(void){
roadmap_config_declare_enumeration( GEO_LOCATION_ENABLE_CONFIG_TYPE,
&GEO_LOCATION_ENABLED_Var,
NULL,
GEO_LOCATION_No,
GEO_LOCATION_Yes,
NULL);
if( 0 == strcmp( roadmap_config_get( &GEO_LOCATION_ENABLED_Var), GEO_LOCATION_Yes))
return TRUE;
return FALSE;
}
/////////////////////////////////////////////////////////////////////
static BOOL geo_location_displayed(void){
roadmap_config_declare_enumeration( GEO_LOCATION_CONFIG_TYPE,
&GEO_LOCATION_DISPLAYED_Var,
NULL,
GEO_LOCATION_No,
GEO_LOCATION_Yes,
NULL);
if( 0 == strcmp( roadmap_config_get( &GEO_LOCATION_DISPLAYED_Var), GEO_LOCATION_Yes))
return TRUE;
return FALSE;
}
/////////////////////////////////////////////////////////////////////
static void set_geo_location_displayed(){
roadmap_config_set(&GEO_LOCATION_DISPLAYED_Var, GEO_LOCATION_Yes);
roadmap_config_save(TRUE);
}
/////////////////////////////////////////////////////////////////////
static SsdWidget space(int height){
SsdWidget space;
space = ssd_container_new ("spacer", NULL, SSD_MAX_SIZE, height, SSD_WIDGET_SPACE|SSD_END_ROW);
ssd_widget_set_color (space, NULL,NULL);
return space;
}
/////////////////////////////////////////////////////////////////////
static int button_callback (SsdWidget widget, const char *new_value) {
set_geo_location_displayed();
ssd_dialog_hide_current(dec_ok);
return 1;
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_metropolitan(const char *metro){
if (!metro)
return;
strcpy(g_geo_info.metroplolitan, metro);
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_map_score(int map_score){
sprintf(g_geo_info.map_score, "%d%%", map_score);
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_map_score_str(const char* map_score_str){
strncpy_safe(g_geo_info.map_score,map_score_str, sizeof(g_geo_info.map_score));
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_state(const char *state){
if (!state)
return;
strcpy(g_geo_info.state, state);
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_traffic_score(int traffic_score){
sprintf(g_geo_info.traffic_score,"%d%%", traffic_score);
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_traffic_score_str(const char* traffic_score_str){
strncpy_safe(g_geo_info.traffic_score, traffic_score_str, sizeof(g_geo_info.traffic_score));
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_usage_score(int usage_score){
sprintf(g_geo_info.usage_score,"%d%%", usage_score);
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_usage_score_str(const char* usage_score_str){
strncpy_safe(g_geo_info.usage_score, usage_score_str, sizeof(g_geo_info.usage_score));
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_set_overall_score(int overall_score){
g_geo_info.overall_score = overall_score;
}
#ifndef TOUCH_SCREEN
static int on_softkey(SsdWidget widget, const char *new_value, void *context){
set_geo_location_displayed();
ssd_dialog_hide_current(dec_ok);
return 1;
}
#endif
/////////////////////////////////////////////////////////////////////
static void roadmap_geo_location_dialog(void){
SsdWidget dialog;
SsdWidget group;
SsdWidget progress;
SsdWidget text;
SsdWidget container;
SsdWidget title;
int width = roadmap_canvas_width() - 20;
dialog = ssd_dialog_new ("geo_location_info",
roadmap_lang_get ("waze status in your area"),
NULL,
SSD_CONTAINER_TITLE|SSD_DIALOG_NO_BACK);
group = ssd_container_new ("geo_location_group", NULL,
width, SSD_MIN_SIZE,SSD_WIDGET_SPACE|SSD_ALIGN_CENTER|SSD_END_ROW|SSD_ROUNDED_CORNERS|SSD_ROUNDED_WHITE|SSD_CONTAINER_BORDER);
ssd_widget_set_color (group, NULL,NULL);
ssd_widget_add (group, space(5));
text = ssd_text_new ("Metro", g_geo_info.metroplolitan, 28,SSD_ALIGN_CENTER);
ssd_widget_add (group, text);
text = ssd_text_new ("Label_label", roadmap_lang_get("Metro"), 28,SSD_ALIGN_CENTER|SSD_END_ROW);
ssd_widget_add (group, text);
ssd_widget_add (group, space(5));
title = ssd_container_new ("title_gr", NULL,
SSD_MIN_SIZE, SSD_MIN_SIZE,SSD_ALIGN_CENTER|SSD_END_ROW);
ssd_widget_set_color(title, NULL, NULL);
text = ssd_text_new ("Label_status", roadmap_lang_get("Status: "), 20, 0);
ssd_widget_add (title, text);
text = ssd_text_new ("Status", g_geo_info.state, 20,SSD_END_ROW);
ssd_widget_set_color(text, "#4886b7", "#4886b7");
ssd_widget_add (title, text);
ssd_widget_add (group, title);
ssd_widget_add (group, space(15));
text = ssd_text_new ("What you get label", roadmap_lang_get("What you get:"), 18,SSD_ALIGN_CENTER|SSD_END_ROW);
ssd_widget_add (group, text);
ssd_widget_add (group, space(5));
text = ssd_text_new ("Map_label", roadmap_lang_get("Navigable map: "), 14,0);
ssd_widget_add (group, text);
text = ssd_text_new ("Map_label_value", g_geo_info.map_score, 14,SSD_END_ROW);
ssd_widget_set_color(text, "#4886b7", "#4886b7");
ssd_widget_add (group, text);
ssd_widget_add (group, space(5));
text = ssd_text_new ("Traffic_label", roadmap_lang_get("Real-Time traffic: "), 14, 0);
ssd_widget_add (group, text);
text = ssd_text_new ("Traffic_label_value", g_geo_info.traffic_score, 14,SSD_END_ROW);
ssd_widget_set_color(text, "#4886b7", "#4886b7");
ssd_widget_add (group, text);
ssd_widget_add (group, space(5));
text = ssd_text_new ("Usage_label", roadmap_lang_get("Community alerts: "), 14,0);
ssd_widget_add (group, text);
text = ssd_text_new ("Usage_label", g_geo_info.usage_score, 14,SSD_END_ROW);
ssd_widget_set_color(text, "#4886b7", "#4886b7");
ssd_widget_add (group, text);
ssd_widget_add (group, space(5));
ssd_widget_add (group, space(20));
progress = ssd_progress_new("progress",SSD_MAX_SIZE, 0);
ssd_progress_set_value(progress, g_geo_info.overall_score);
ssd_widget_add(group, progress);
//ssd_widget_add (group, space(5));
container = ssd_container_new ("text_cont", NULL,
80, SSD_MIN_SIZE,SSD_WIDGET_SPACE);
text = ssd_text_new ("Early building", roadmap_lang_get("Early Building"), -1, SSD_ALIGN_CENTER);
ssd_widget_add (container, text);
ssd_widget_add (group, container);
container = ssd_container_new ("text_cont", NULL,
80, SSD_MIN_SIZE,SSD_WIDGET_SPACE|SSD_ALIGN_CENTER);
text = ssd_text_new ("Partial Value", roadmap_lang_get("Partial Value"), -1, SSD_ALIGN_CENTER);
ssd_widget_add (container, text);
ssd_widget_add (group, container);
container = ssd_container_new ("text_cont", NULL,
40, SSD_MIN_SIZE,SSD_WIDGET_SPACE|SSD_END_ROW);
text = ssd_text_new ("Full Value", roadmap_lang_get("Full Value"), -1, SSD_ALIGN_CENTER);
ssd_widget_add (container, text);
ssd_widget_add (group, container);
#ifdef TOUCH_SCREEN
ssd_widget_add (group, space(15));
ssd_widget_add (group,
ssd_button_label ("Let me in", roadmap_lang_get ("Let me in"),
SSD_WS_TABSTOP|SSD_ALIGN_CENTER|SSD_START_NEW_ROW, button_callback));
#else
ssd_widget_set_right_softkey_text ( dialog, roadmap_lang_get("Let me in"));
ssd_widget_set_right_softkey_callback ( dialog, on_softkey);
#endif
ssd_widget_add (group, space(5));
ssd_widget_add( dialog, group);
ssd_dialog_activate ("geo_location_info", NULL);
}
/////////////////////////////////////////////////////////////////////
void roadmap_geo_location_info(void){
if (!is_geo_location_enabled())
return;
if (geo_location_displayed())
return;
roadmap_geo_location_dialog();
}