contacts export function - save to SD card from contacts screen with toaster pop up confimation once completed

This commit is contained in:
pelgraine
2026-02-25 22:19:44 +11:00
parent fd33aa8d28
commit 90b9045a90
2 changed files with 24 additions and 9 deletions

View File

@@ -1786,14 +1786,22 @@ void handleKeyboardInput() {
// Export contacts to SD card (contacts screen only)
if (ui_task.isOnContactsScreen()) {
Serial.println("Contacts: Exporting to SD...");
// Show "working" toaster immediately (force e-ink render before blocking SD I/O)
ui_task.showAlert("Exporting to SD...", 10000);
ui_task.forceRefresh();
ui_task.loop(); // immediate render so user sees the popup
int exported = exportContactsToSD();
// Update toaster with result
if (exported >= 0) {
char alertBuf[48];
snprintf(alertBuf, sizeof(alertBuf), "Exported %d to SD", exported);
ui_task.showAlert(alertBuf, 2000);
ui_task.showAlert(alertBuf, 2500);
} else {
ui_task.showAlert("Export failed (no SD?)", 2000);
ui_task.showAlert("Export failed (no SD?)", 2500);
}
ui_task.forceRefresh();
}
break;
@@ -1801,9 +1809,15 @@ void handleKeyboardInput() {
// Import/merge contacts from SD backup (contacts screen only)
if (ui_task.isOnContactsScreen()) {
Serial.println("Contacts: Importing from SD...");
// Show "working" toaster immediately (force e-ink render before blocking SD I/O)
ui_task.showAlert("Importing from SD...", 10000);
ui_task.forceRefresh();
ui_task.loop(); // immediate render so user sees the popup
int added = importContactsFromSD();
// Update toaster with result
if (added > 0) {
// Invalidate the contacts screen cache so it rebuilds
ContactsScreen* cs2 = (ContactsScreen*)ui_task.getContactsScreen();
if (cs2) cs2->invalidateCache();
char alertBuf[48];
@@ -1811,10 +1825,11 @@ void handleKeyboardInput() {
added, (int)the_mesh.getNumContacts());
ui_task.showAlert(alertBuf, 2500);
} else if (added == 0) {
ui_task.showAlert("No new contacts to add", 2000);
ui_task.showAlert("No new contacts to add", 2500);
} else {
ui_task.showAlert("Import failed (no backup?)", 2000);
ui_task.showAlert("Import failed (no backup?)", 2500);
}
ui_task.forceRefresh();
}
break;

View File

@@ -286,17 +286,17 @@ public:
display.drawRect(0, footerY - 2, display.width(), 1);
display.setColor(DisplayDriver::YELLOW);
// Left: Q:Bk X:Exp
// Left: Q:Back
display.setCursor(0, footerY);
display.print("Q:Bk X:Exp");
display.print("Q:Back");
// Center: A/D:Filter
const char* mid = "A/D:Filtr";
display.setCursor((display.width() - display.getTextWidth(mid)) / 2, footerY);
display.print(mid);
// Right: R:Imp W/S
const char* right = "R:Imp W/S";
// Right: W/S:Scroll
const char* right = "W/S:Scrll";
display.setCursor(display.width() - display.getTextWidth(right) - 2, footerY);
display.print(right);