Use both .sleep and sleep directory
This commit is contained in:
@@ -554,11 +554,21 @@ void SleepActivity::renderOverlaySleepScreen() const {
|
|||||||
return rc == PNG_SUCCESS;
|
return rc == PNG_SUCCESS;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Try /sleep/ directory first (random selection, same as renderCustomSleepScreen).
|
// Try /.sleep/ (preferred) or /sleep/ directory (random selection, same as renderCustomSleepScreen).
|
||||||
// Accepts both .bmp and .png files; .bmp headers are validated during the scan.
|
// Accepts both .bmp and .png files; .bmp headers are validated during the scan.
|
||||||
bool overlayDrawn = false;
|
bool overlayDrawn = false;
|
||||||
auto dir = Storage.open("/sleep");
|
const char* sleepDir = nullptr;
|
||||||
|
auto dir = Storage.open("/.sleep");
|
||||||
if (dir && dir.isDirectory()) {
|
if (dir && dir.isDirectory()) {
|
||||||
|
sleepDir = "/.sleep";
|
||||||
|
} else {
|
||||||
|
if (dir) dir.close();
|
||||||
|
dir = Storage.open("/sleep");
|
||||||
|
if (dir && dir.isDirectory()) {
|
||||||
|
sleepDir = "/sleep";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sleepDir) {
|
||||||
std::vector<std::string> files;
|
std::vector<std::string> files;
|
||||||
char name[500];
|
char name[500];
|
||||||
for (auto file = dir.openNextFile(); file; file = dir.openNextFile()) {
|
for (auto file = dir.openNextFile(); file; file = dir.openNextFile()) {
|
||||||
@@ -596,7 +606,7 @@ void SleepActivity::renderOverlaySleepScreen() const {
|
|||||||
}
|
}
|
||||||
APP_STATE.lastSleepImage = randomFileIndex;
|
APP_STATE.lastSleepImage = randomFileIndex;
|
||||||
APP_STATE.saveToFile();
|
APP_STATE.saveToFile();
|
||||||
const std::string selected = "/sleep/" + files[randomFileIndex];
|
const std::string selected = std::string(sleepDir) + "/" + files[randomFileIndex];
|
||||||
if (FsHelpers::checkFileExtension(selected, ".png")) {
|
if (FsHelpers::checkFileExtension(selected, ".png")) {
|
||||||
overlayDrawn = tryDrawPngOverlay(selected);
|
overlayDrawn = tryDrawPngOverlay(selected);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user