Public Access
Fn+h on any screen, text fields included, and ? outside Text Entry, open a panel over the content area: the screen's own keys, then the ones that work everywhere. Every App declares its keys for the state it is in (pages, viewers, dialogs and text fields answer for themselves); the App manager opens the panel and takes every key while it is open. About 30 hint lines are gone, from every App. What stays on a screen is state. The first-start Setup keeps its hints and teaches the key; a device set up before gets one Toast, once. The guide and the FAQ open with it. `key help` over the consoles. 476 host tests (8 new). Checked on the device with key help and screenshots: the Launcher, all nine Apps and several of their states. 8.5 KB of flash and 40 bytes of static RAM. Decisions Q196 to Q203 in docs/milestones/U1.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
83 lines
3.3 KiB
C++
83 lines
3.3 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "dialog_model.h"
|
|
#include "event_bus.h"
|
|
#include "key_event.h"
|
|
#include "key_help.h"
|
|
#include "line_editor.h"
|
|
#include "list_model.h"
|
|
#include "saved_networks.h"
|
|
#include "services/wifi_service.h"
|
|
#include "settings.h"
|
|
#include "ui/canvas.h"
|
|
#include "ui/theme.h"
|
|
|
|
namespace roro {
|
|
|
|
// Settings → Wi-Fi: the On/Off switch, the connection and its details, DNS and NTP servers, and
|
|
// the Saved Networks: adding one from a scan or by name (hidden), and each one's own page with its
|
|
// IP setting, Automatic or Fixed (docs/milestones/S1.md, Q113). Owned by the Settings App.
|
|
class WifiSettingsPage {
|
|
public:
|
|
WifiSettingsPage(Settings& settings, SavedNetworks& saved, WifiService& wifi, EventBus& bus)
|
|
: settings_(settings), saved_(saved), wifi_(wifi), bus_(bus) {}
|
|
|
|
void enter();
|
|
bool onKey(const KeyEvent& e); // false: leave the page
|
|
bool textEntryActive() const { return view_ == View::Ssid || view_ == View::Password || view_ == View::Edit; }
|
|
// Redraw periodically: the status, a scan, the connection details.
|
|
bool live() const { return view_ == View::Main || view_ == View::Scan || view_ == View::Details; }
|
|
void draw(Canvas& c);
|
|
void help(std::vector<KeyHelp>& out) const;
|
|
const char* helpTitle() const;
|
|
|
|
private:
|
|
enum class View { Main, Scan, Ssid, Password, Details, Servers, Network, Edit };
|
|
enum Fixed { kToggle, kStatus, kServers, kAddScanned, kAddHidden, kFixedRows };
|
|
enum ServerRow { kDns1, kDns2, kDnsAlways, kNtp1, kNtp2, kServerRows };
|
|
// A Saved Network's page: with Automatic, only kIpMode and kForget are shown.
|
|
enum NetworkRow { kIpMode, kAddress, kPrefix, kGateway, kForget };
|
|
enum class Field { Address, Prefix, Gateway, Dns1, Dns2, Ntp1, Ntp2 };
|
|
|
|
void refreshMain();
|
|
void warn(const std::string& text, NotificationLevel level = NotificationLevel::Warning);
|
|
std::string statusText() const;
|
|
bool mainKey(const KeyEvent& e);
|
|
bool serversKey(const KeyEvent& e);
|
|
bool networkKey(const KeyEvent& e);
|
|
bool editKey(const KeyEvent& e);
|
|
void openNetwork(const SavedNetwork& n);
|
|
bool leaveNetwork(); // checks and applies the draft; false (with a Toast) when it's refused
|
|
NetworkRow networkRow(int i) const;
|
|
void edit(Field field, const std::string& title, const std::string& value, View from);
|
|
void drawDetails(Canvas& c);
|
|
|
|
Settings& settings_;
|
|
SavedNetworks& saved_;
|
|
WifiService& wifi_;
|
|
EventBus& bus_;
|
|
View view_ = View::Main;
|
|
ListModel main_{theme::kContent.h / theme::kLineHeight};
|
|
ListModel scan_{theme::kContent.h / theme::kLineHeight};
|
|
ListModel servers_{theme::kContent.h / theme::kLineHeight};
|
|
ListModel network_{theme::kContent.h / theme::kLineHeight - 1};
|
|
LineEditor editor_{63};
|
|
std::string newSsid_;
|
|
bool newHidden_ = false;
|
|
std::unique_ptr<DialogModel> forgetDialog_;
|
|
// The Saved Network whose page is open, and its IP setting as being typed (a draft: applied on
|
|
// leaving the page, so a half-typed address is never used).
|
|
std::string netSsid_;
|
|
bool draftFixed_ = false;
|
|
std::string draftAddress_, draftPrefix_, draftGateway_;
|
|
// The field being edited, and where Enter and Back return to.
|
|
Field field_ = Field::Address;
|
|
std::string editTitle_;
|
|
View editFrom_ = View::Main;
|
|
};
|
|
|
|
} // namespace roro
|