Version 1.1

- Status-Bar
- Detaildarstellung für PTR angepasst
This commit is contained in:
fkuepper
2017-03-29 14:42:48 +02:00
parent b76108b016
commit 87e53a0e93
6 changed files with 28 additions and 24 deletions
+1 -1
View File
@@ -109,5 +109,5 @@
"watchface": false "watchface": false
} }
}, },
"version": "1.0.0" "version": "1.1.0"
} }
+15 -15
View File
@@ -157,44 +157,44 @@ bool BahnInterface_handle_app_message(DictionaryIterator *iter, void *context) {
return true; return true;
} }
static int prv_combine_product_code(AllowedProducts* p1, AllowedProducts* p2) { static int prv_get_product_code(AllowedProducts* p) {
if (p->allow_all) {
return 1023;
}
int result = 0; int result = 0;
if (p1->ice || p2->ice || p1->allow_all || p2->allow_all) { if (p->ice) {
result +=1; result +=1;
} }
if (p1->ic || p2->ic || p1->allow_all || p2->allow_all) { if (p->ic) {
result +=2; result +=2;
} }
if (p1->ir || p2->ir || p1->allow_all || p2->allow_all) { if (p->ir) {
result +=4; result +=4;
} }
if (p1->zug || p2->zug || p1->allow_all || p2->allow_all) { if (p->zug) {
result +=8; result +=8;
} }
if (p1->sbahn || p2->sbahn || p1->allow_all || p2->allow_all) { if (p->sbahn) {
result +=16; result +=16;
} }
if (p1->bus || p2->bus || p1->allow_all || p2->allow_all) { if (p->bus) {
result +=32; result +=32;
} }
if (p1->schiff || p2->schiff || p1->allow_all || p2->allow_all) { if (p->schiff) {
result +=64; result +=64;
} }
if (p1->ubahn || p2->ubahn || p1->allow_all || p2->allow_all) { if (p->ubahn) {
result +=128; result +=128;
} }
if (p1->tram || p2->tram || p1->allow_all || p2->allow_all) { if (p->tram) {
result +=256; result +=256;
} }
if (p1->ast || p2->ast || p1->allow_all || p2->allow_all) { if (p->ast) {
result +=512; result +=512;
} }
return result; return result;
} }
static int prv_get_product_code(AllowedProducts* products) {
return prv_combine_product_code(products, products);
}
int get_products_for_connection(int valid_connection_index) { int get_products_for_connection(int valid_connection_index) {
return prv_get_product_code(MyBahnSettings_get_allowed_products_for_connection(valid_connection_index)); return prv_get_product_code(MyBahnSettings_get_allowed_products_for_connection(valid_connection_index));
@@ -205,7 +205,7 @@ int get_products_for_station_to_station(int from_station_index, int to_station_i
StationConfig* s2 = MyBahnSettings_get_valid_station(to_station_index); StationConfig* s2 = MyBahnSettings_get_valid_station(to_station_index);
AllowedProducts* p1 = s1->use_default_products ? MyBahnSettings_get_default_products() : &s1->allowed_products; AllowedProducts* p1 = s1->use_default_products ? MyBahnSettings_get_default_products() : &s1->allowed_products;
AllowedProducts* p2 = s2->use_default_products ? MyBahnSettings_get_default_products() : &s2->allowed_products; AllowedProducts* p2 = s2->use_default_products ? MyBahnSettings_get_default_products() : &s2->allowed_products;
return prv_combine_product_code(p1, p2); return prv_get_product_code(p1) | prv_get_product_code(p2);
} }
void BahnInterface_init() { void BahnInterface_init() {
+2 -2
View File
@@ -3,8 +3,8 @@
#define CONNECTION_RESULT_TITLE_LENGTH 20 #define CONNECTION_RESULT_TITLE_LENGTH 20
#define CONNECTION_RESULT_SUBTITLE_LENGTH 25 #define CONNECTION_RESULT_SUBTITLE_LENGTH 25
#define CONNECTION_RESULT_DETAIL_LINK_LENGTH 172 #define CONNECTION_RESULT_DETAIL_LINK_LENGTH 128
#define CONNECTION_DETAILS_LENGTH 1024 #define CONNECTION_DETAILS_LENGTH 768
#define MAX_CONNECTION_RESULTS 20 #define MAX_CONNECTION_RESULTS 20
typedef struct { typedef struct {
+1 -1
View File
@@ -2,7 +2,7 @@
#include "resources.h" #include "resources.h"
#include "mybahn_settings.h" #include "mybahn_settings.h"
// #define CREATE_DUMMY_SETTINGS //#define CREATE_DUMMY_SETTINGS
static MyBahnSettings settings; static MyBahnSettings settings;
static void prv_validate_station(StationConfig* station) { static void prv_validate_station(StationConfig* station) {
+1 -1
View File
@@ -22,7 +22,7 @@ GRect computeEffectiveWindowBounds(Window* window, StatusBarLayer* status_bar_la
} }
StatusBarLayer* addStatusBar(Window* window) { StatusBarLayer* addStatusBar(Window* window) {
return NULL; //return NULL;
StatusBarLayer* status_bar = status_bar_layer_create(); StatusBarLayer* status_bar = status_bar_layer_create();
Layer *window_layer = window_get_root_layer(window); Layer *window_layer = window_get_root_layer(window);
+8 -4
View File
@@ -1,4 +1,5 @@
var baseUrl = 'http://mobil.bahn.de/bin/query.exe/dox?start=1&rt=1'; var baseUrl = 'http://mobil.bahn.de/bin/query.exe/dox?start=1&rt=1';
var detailsUrlBase = 'http://reiseauskunft.bahn.de/bin/query2.exe/dox?';
function xhrRequest(url, type, callback) { function xhrRequest(url, type, callback) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
@@ -62,7 +63,7 @@ function extractConnectionResultInfos(text) {
var frueherLink = text.match(frueherExp); var frueherLink = text.match(frueherExp);
if (frueherLink) { if (frueherLink) {
frueherLink = frueherLink[1].replace(ampExp, "&"); frueherLink = frueherLink[1].replace(ampExp, "&").substring(detailsUrlBase.length);
results.push({moreLink: frueherLink, earlier: true}); results.push({moreLink: frueherLink, earlier: true});
} }
@@ -73,7 +74,7 @@ function extractConnectionResultInfos(text) {
var detailLink = connectionInfo.match(detailLinkExp); var detailLink = connectionInfo.match(detailLinkExp);
if (detailLink) { if (detailLink) {
result.detailLink = detailLink[1].replace(ampExp, "&"); result.detailLink = detailLink[1].replace(ampExp, "&").substring(detailsUrlBase.length);
} }
zeitExp.lastIndex = 0; zeitExp.lastIndex = 0;
@@ -124,7 +125,7 @@ function extractConnectionResultInfos(text) {
var spaeterLink = text.match(spaeterExp); var spaeterLink = text.match(spaeterExp);
if (spaeterLink) { if (spaeterLink) {
spaeterLink = spaeterLink[1].replace(ampExp, "&"); spaeterLink = spaeterLink[1].replace(ampExp, "&").substring(detailsUrlBase.length);
results.push({moreLink: spaeterLink, later: true}); results.push({moreLink: spaeterLink, later: true});
} }
return results; return results;
@@ -244,6 +245,9 @@ function extractHimDetails(himDetailsUrl) {
} }
function getConnectionsFromUrl(url, resultCallback) { function getConnectionsFromUrl(url, resultCallback) {
if (url.substring(0, 4) != 'http') {
url = detailsUrlBase + url;
}
xhrRequest(url, 'GET', function(responseText) { xhrRequest(url, 'GET', function(responseText) {
var results = extractConnectionResultInfos(responseText); var results = extractConnectionResultInfos(responseText);
resultCallback(results); resultCallback(results);
@@ -260,7 +264,7 @@ function getConnections(startKey, zielKey, journeyProducts, resultCallback) {
} }
function getConnectionDetailInfos(detailLink, resultCallback) { function getConnectionDetailInfos(detailLink, resultCallback) {
xhrRequest(detailLink, 'GET', function(responseText){ xhrRequest(detailsUrlBase + detailLink, 'GET', function(responseText){
var result = extractConnectionDetailInfos(responseText); var result = extractConnectionDetailInfos(responseText);
resultCallback(result); resultCallback(result);
}); });