add military time option

This commit is contained in:
bigbiff bigbiff 2013-02-20 18:58:11 -05:00
parent 2f9117af30
commit 4efe9c3c7d
14 changed files with 114 additions and 8 deletions

View File

@ -879,6 +879,7 @@ void DataManager::SetDefaultValues()
mConstValues.insert(make_pair("tw_has_brightnesss_file", "0"));
}
#endif
mValues.insert(make_pair(TW_MILITARY_TIME, make_pair("0", 0)));
}
// Magic Values
@ -891,14 +892,22 @@ int DataManager::GetMagicValue(const string varName, string& value)
struct tm *current;
time_t now;
int tw_military_time;
now = time(0);
current = localtime(&now);
if (current->tm_hour >= 12)
sprintf(tmp, "%d:%02d PM", current->tm_hour == 12 ? 12 : current->tm_hour - 12, current->tm_min);
else
sprintf(tmp, "%d:%02d AM", current->tm_hour == 0 ? 12 : current->tm_hour, current->tm_min);
GetValue(TW_MILITARY_TIME, tw_military_time);
if (current->tm_hour >= 12) {
if (tw_military_time == 1)
sprintf(tmp, "%d:%02d", current->tm_hour, current->tm_min);
else
sprintf(tmp, "%d:%02d PM", current->tm_hour == 12 ? 12 : current->tm_hour - 12, current->tm_min);
}
else {
if (tw_military_time == 1)
sprintf(tmp, "%d:%02d", current->tm_hour, current->tm_min);
else
sprintf(tmp, "%d:%02d AM", current->tm_hour == 0 ? 12 : current->tm_hour, current->tm_min);
}
value = tmp;
return 0;
}
@ -1032,7 +1041,6 @@ void DataManager::ReadSettingsFile(void)
if (strcmp(EXPAND(TW_BRIGHTNESS_PATH), "/nobrightness") != 0) {
string brightness_path = EXPAND(TW_BRIGHTNESS_PATH);
string brightness_value = GetStrValue("tw_brightness");
LOGI("writing %s to brightness\n", brightness_value.c_str());
TWFunc::write_file(brightness_path, brightness_value);
}
#endif

View File

@ -2448,6 +2448,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row9_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row2_y%" />

View File

@ -2440,6 +2440,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row9_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row2_y%" />

View File

@ -2440,6 +2440,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row9_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row2_y%" />

View File

@ -2440,6 +2440,15 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row9_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row2_y%" />

View File

@ -2440,6 +2440,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row9_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row2_y%" />

View File

@ -2412,6 +2412,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row8_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row3_y%" />

View File

@ -2411,6 +2411,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row8_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row3_y%" />

View File

@ -2410,6 +2410,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row8_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row3_y%" />

View File

@ -2411,6 +2411,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row8_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row3_y%" />

View File

@ -2424,6 +2424,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row8_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row3_y%" />

View File

@ -2412,6 +2412,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row8_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row3_y%" />

View File

@ -2448,6 +2448,14 @@
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="checkbox">
<placement x="%col1_x%" y="%row9_text_y%" />
<font resource="font" color="%text_color%" />
<text>Use Military Time</text>
<data variable="tw_military_time" />
<image checked="checkbox_true" unchecked="checkbox_false" />
</object>
<object type="button">
<highlight color="%highlight_color%" />
<placement x="%col1_x%" y="%row2_y%" />
@ -2484,7 +2492,7 @@
<touch key="back" />
<action function="page">main</action>
</object>
<object type="template" name="footer" />
</page>

View File

@ -151,6 +151,7 @@
#define TW_CRYPTO_PASSWORD "tw_crypto_password"
#define TW_DATA_BLK_DEVICE "tw_data_blk_device" // Original block device - not decrypted
#define TW_SDEXT_DISABLE_EXT4 "tw_sdext_disable_ext4"
#define TW_MILITARY_TIME "tw_military_time"
// Also used:
// tw_boot_is_mountable