Skip to content

Commit 2ee058a

Browse files
committed
Open webpage dialog when user clicks https//hams.at text on Sat Alerts
1 parent 26ab987 commit 2ee058a

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

ESPHamClock/hamsat.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ typedef struct {
5858
static HamsatAlert *hamsat_alerts; // malloced list, sorted by aos_at
5959
static int n_hamsat; // n entries
6060
static ScrollState hamsat_ss; // scrolling context
61+
static SBox hamsat_url_b; // tappable region over the subtitle text
6162
static char hamsat_key[NV_HAMSATKEY_LEN]; // API key, may be empty
6263

6364

@@ -484,6 +485,12 @@ static void drawHamsatPane (const SBox &box)
484485
tft.setCursor (box.x + (box.w-sw)/2, box.y + SUBTITLE_Y0);
485486
tft.print (sub);
486487

488+
// remember where this was drawn so a tap can offer to open the web page
489+
hamsat_url_b.x = box.x + (box.w-sw)/2;
490+
hamsat_url_b.y = box.y + SUBTITLE_Y0 - 2;
491+
hamsat_url_b.w = sw;
492+
hamsat_url_b.h = 12;
493+
487494
drawHamsatVisAlerts (box);
488495
}
489496

@@ -559,6 +566,26 @@ bool checkHamsatTouch (const SCoord &s, const SBox &box)
559566
return (false);
560567
}
561568

569+
// tap on the "https://hams.at" subtitle: offer to open the web page
570+
if (inBox (s, hamsat_url_b)) {
571+
572+
typedef enum {
573+
UEX_PAGE,
574+
UEX_N
575+
} UrlExInfo;
576+
577+
MenuItem mitems[UEX_N];
578+
mitems[UEX_PAGE] = {MENU_TOGGLE, false, 1, 2, "Open webpage?", 0};
579+
580+
SBox menu_b = {s.x, s.y, 0, 0};
581+
SBox ok_b;
582+
MenuInfo menu = {menu_b, ok_b, UF_CLOCKSOK, M_CANCELOK, 1, UEX_N, mitems};
583+
if (runMenu (menu) && mitems[UEX_PAGE].set)
584+
openURL ("https://hams.at");
585+
586+
return (true);
587+
}
588+
562589
// row tap: offer to set DX (and track this satellite) and/or open the alert's web page
563590
int row = (s.y - (box.y + LISTING_Y0)) / ALERT_DY;
564591
int array_index;

0 commit comments

Comments
 (0)