Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/fw/apps/system/toggle/shutdown.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* SPDX-FileCopyrightText: 2025 The PebbleOS Contributors */
/* SPDX-License-Identifier: Apache-2.0 */

#include "shutdown.h"

#include "applib/app.h"
#include "applib/ui/dialogs/actionable_dialog.h"
#include "applib/ui/dialogs/dialog.h"
#include "kernel/event_loop.h"
#include "process_management/app_manager.h"
#include "pbl/services/i18n/i18n.h"
#include "resource/resource_ids.auto.h"
#include "shell/normal/battery_ui.h"

static void prv_do_shutdown(void *data) {
battery_ui_handle_shut_down();
}

static void prv_shutdown_confirm_cb(ClickRecognizerRef recognizer, void *context) {
actionable_dialog_pop((ActionableDialog *)context);
launcher_task_add_callback(prv_do_shutdown, NULL);
}

static void prv_shutdown_back_cb(ClickRecognizerRef recognizer, void *context) {
actionable_dialog_pop((ActionableDialog *)context);
}

static void prv_shutdown_click_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_SELECT, prv_shutdown_confirm_cb);
window_single_click_subscribe(BUTTON_ID_BACK, prv_shutdown_back_cb);
}

static void prv_main(void) {
ActionableDialog *a_dialog = actionable_dialog_create("Shutdown");
Dialog *dialog = actionable_dialog_get_dialog(a_dialog);

actionable_dialog_set_action_bar_type(a_dialog, DialogActionBarConfirm, NULL);
actionable_dialog_set_click_config_provider(a_dialog, prv_shutdown_click_provider);

dialog_set_text_color(dialog, GColorWhite);
dialog_set_background_color(dialog, GColorCobaltBlue);
/// Confirmation message shown in the shutdown Quick Launch dialog.
dialog_set_text(dialog, i18n_get("Do you want to shut down?", a_dialog));
dialog_set_icon(dialog, RESOURCE_ID_GENERIC_QUESTION_LARGE);

i18n_free_all(a_dialog);

app_actionable_dialog_push(a_dialog);
app_event_loop();
}

const PebbleProcessMd *shutdown_toggle_get_app_info(void) {
static const PebbleProcessMdSystem s_app_info = {
.common = {
.main_func = &prv_main,
.uuid = SHUTDOWN_TOGGLE_UUID,
.visibility = ProcessVisibilityQuickLaunch,
},
/// Name of the Shutdown Quick Launch option shown in Quick Launch settings.
.name = i18n_noop("Shutdown"),
};
return &s_app_info.common;
}
11 changes: 11 additions & 0 deletions src/fw/apps/system/toggle/shutdown.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* SPDX-FileCopyrightText: 2025 The PebbleOS Contributors */
/* SPDX-License-Identifier: Apache-2.0 */

#pragma once

#include "process_management/app_manager.h"

#define SHUTDOWN_TOGGLE_UUID {0x8b, 0x9a, 0x7c, 0x3e, 0x45, 0xd1, 0x4f, 0x89, \
0xb2, 0x56, 0xee, 0xcc, 0xdd, 0xbb, 0xaa, 0x01}

const PebbleProcessMd *shutdown_toggle_get_app_info(void);
5 changes: 5 additions & 0 deletions src/fw/shell/normal/system_app_registry_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@
"enum": "AIRPLANE_MODE_TOGGLE",
"md_fn": "airplane_mode_toggle_get_app_info"
},
{
"id": -100,
"enum": "SHUTDOWN_TOGGLE",
"md_fn": "shutdown_toggle_get_app_info"
},
{
"id": -96,
"enum": "TIMELINE_PAST",
Expand Down
Loading