Public Access
S1 #7 step 4: fixed IPv4, DNS and NTP in Settings
Enter on a Saved Network opens its page instead of asking to forget it: "IP address" switches between Automatic and Fixed, with an address, a prefix and an optional gateway. Fixed starts from what the network is giving the device; the draft is checked and applied on leaving the page, so a half-typed address is never used. "DNS and NTP" holds the two DNS servers, "Always use my DNS" and the two NTP servers. Enter on Status shows the connection's details and where each value came from. Address fields take digits and dots only; refusals show as Toasts. Checked on the device through the screens: Fixed 10.39.39.13 applied and reverted to Automatic, a prefix of 99 refused. Measurements in docs/milestones/S1.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -16,8 +16,9 @@
|
||||
|
||||
namespace roro {
|
||||
|
||||
// Settings → Wi-Fi: the On/Off switch, current connection, Saved Networks, and adding networks
|
||||
// from a scan or by name (hidden). Owned by the Settings App.
|
||||
// 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)
|
||||
@@ -25,17 +26,31 @@ class WifiSettingsPage {
|
||||
|
||||
void enter();
|
||||
bool onKey(const KeyEvent& e); // false: leave the page
|
||||
bool textEntryActive() const { return view_ == View::Ssid || view_ == View::Password; }
|
||||
bool live() const { return view_ == View::Main || view_ == View::Scan; } // redraw periodically
|
||||
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);
|
||||
|
||||
private:
|
||||
enum class View { Main, Scan, Ssid, Password };
|
||||
enum Fixed { kToggle, kStatus, kAddScanned, kAddHidden, kFixedRows };
|
||||
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_;
|
||||
@@ -44,10 +59,21 @@ class WifiSettingsPage {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user