diff --git a/lib/I18n/I18nKeys.h b/lib/I18n/I18nKeys.h index 956b8ee4..aad6c695 100644 --- a/lib/I18n/I18nKeys.h +++ b/lib/I18n/I18nKeys.h @@ -351,6 +351,9 @@ enum class StrId : uint16_t { STR_OVERLAY_GRAY, STR_OVERLAY_BLACK, STR_OVERLAY_OFF, + STR_OVERLAY_READING_PROGRESS, + STR_OVERLAY_READING_PROGRESS_NO_TOTAL, + STR_OVERLAY_CHAPTER_PAGE_SUFFIX, // Sentinel - must be last _COUNT }; @@ -405,8 +408,7 @@ inline const char* const* getStringArray(Language lang) { constexpr uint8_t getLanguageCount() { return static_cast(Language::_COUNT); } // Sorted language indices by code (auto-generated by gen_i18n.py) -// Order: English, Беларуская, Català, Čeština, Dansk, Deutsch, Español, Suomi, Français, Italiano, Қазақша, Nederlands, -// Polski, Português (Brasil), Română, Русский, Svenska, Türkçe, Українська +// Order: English, Беларуская, Català, Čeština, Dansk, Deutsch, Español, Suomi, Français, Italiano, Қазақша, Nederlands, Polski, Português (Brasil), Română, Русский, Svenska, Türkçe, Українська constexpr uint8_t SORTED_LANGUAGE_INDICES[] = {0, 11, 9, 4, 15, 3, 1, 14, 2, 12, 18, 16, 13, 5, 8, 6, 7, 17, 10}; static_assert(sizeof(SORTED_LANGUAGE_INDICES) / sizeof(SORTED_LANGUAGE_INDICES[0]) == getLanguageCount(), diff --git a/lib/I18n/I18nStrings.cpp b/lib/I18n/I18nStrings.cpp index afec9519..3274459d 100644 --- a/lib/I18n/I18nStrings.cpp +++ b/lib/I18n/I18nStrings.cpp @@ -137,7 +137,7 @@ const char* const CHARACTER_SETS[] = { "\xC3" "\xBA" "", // Español - " !%'()*+,./012345:=?ABCDEFGHIJKLMNOPQRSTUVW[]abcdefghijklmnopqrstuvwxyz|\xC2" + " !%'()*+,-./012345:=?ABCDEFGHIJKLMNOPQRSTUVW[]abcdefghijklmnopqrstuvwxyz|\xC2" "\xAB" "\xC3" "\x89" @@ -185,7 +185,7 @@ const char* const CHARACTER_SETS[] = { "\x80" "\xA6" "", // Deutsch - " !%()*+,./012345:=?ABCDEFGHIJKLMNOPQRSTUVWYZ[]abcdefghijklmnoprstuvwxyz|\xC2" + " !%()*+,-./012345:=?ABCDEFGHIJKLMNOPQRSTUVWYZ[]abcdefghijklmnoprstuvwxyz|\xC2" "\xAB" "\xC3" "\x81" @@ -758,7 +758,7 @@ const char* const CHARACTER_SETS[] = { "\xC3" "\xBC" "", // Nederlands - " !\"%'()*+,./012345:=?ABCDEFGHIKLMNOPQRSTUVWYZ[]abcdefghiklmnoprstuvwxyz|\xC2" + " !\"%'()*+,-./012345:=?ABCDEFGHIKLMNOPQRSTUVWYZ[]abcdefghiklmnoprstuvwxyz|\xC2" "\xAB" "\xC3" "\x87" @@ -781,7 +781,7 @@ const char* const CHARACTER_SETS[] = { "\xC5" "\x9F" "", // Türkçe - " !\"%()*+,-./012345:=?ABCDFGHIKLMNOPQRSUW[]abcdefhiklnoprstuvwxyz|\xC2" + " !\"%()*+,-./012345:=?ABCDFGHIKLMNOPQRSUW[]abcdefghiklnoprstuvwxyz|\xC2" "\xAB" "\xD0" "\x86" @@ -1214,6 +1214,9 @@ const char* const STRINGS_EN[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_ES[] = { @@ -1746,6 +1749,9 @@ const char* const STRINGS_ES[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_FR[] = { @@ -2382,6 +2388,9 @@ const char* const STRINGS_FR[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_DE[] = { @@ -2826,6 +2835,9 @@ const char* const STRINGS_DE[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_CS[] = { @@ -4187,6 +4199,9 @@ const char* const STRINGS_CS[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_PO[] = { @@ -4753,6 +4768,9 @@ const char* const STRINGS_PO[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_RU[] = { @@ -11975,6 +11993,9 @@ const char* const STRINGS_RU[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_SV[] = { @@ -12700,6 +12721,9 @@ const char* const STRINGS_SV[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_RO[] = { @@ -13554,6 +13578,9 @@ const char* const STRINGS_RO[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_CA[] = { @@ -14138,6 +14165,9 @@ const char* const STRINGS_CA[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_UK[] = { @@ -22374,6 +22404,9 @@ const char* const STRINGS_UK[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_BE[] = { @@ -29284,6 +29317,9 @@ const char* const STRINGS_BE[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_IT[] = { @@ -29622,6 +29658,9 @@ const char* const STRINGS_IT[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_PL[] = { @@ -30498,6 +30537,9 @@ const char* const STRINGS_PL[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_FI[] = { @@ -31192,6 +31234,9 @@ const char* const STRINGS_FI[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_DA[] = { @@ -31684,6 +31729,9 @@ const char* const STRINGS_DA[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_NL[] = { @@ -31992,6 +32040,9 @@ const char* const STRINGS_NL[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_TR[] = { @@ -33176,6 +33227,9 @@ const char* const STRINGS_TR[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; const char* const STRINGS_KK[] = { @@ -40892,6 +40946,9 @@ const char* const STRINGS_KK[] = { "Gray", "Black", "Off", + "Reading progress: Page %lu/%u - %.0f%%", + "Reading progress: Page %lu", + " - Page %d/%d - %.0f%%", }; } // namespace i18n_strings diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index eb49b310..6b7ea7a5 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -295,3 +295,6 @@ STR_OVERLAY_WHITE: "White" STR_OVERLAY_GRAY: "Gray" STR_OVERLAY_BLACK: "Black" STR_OVERLAY_OFF: "Off" +STR_OVERLAY_READING_PROGRESS: "Reading progress: Page %lu/%u - %.0f%%" +STR_OVERLAY_READING_PROGRESS_NO_TOTAL: "Reading progress: Page %lu" +STR_OVERLAY_CHAPTER_PAGE_SUFFIX: " - Page %d/%d - %.0f%%" diff --git a/src/JsonSettingsIO.cpp b/src/JsonSettingsIO.cpp index a0458043..16ef0f1c 100644 --- a/src/JsonSettingsIO.cpp +++ b/src/JsonSettingsIO.cpp @@ -143,6 +143,19 @@ bool JsonSettingsIO::loadSettings(CrossPointSettings& s, const char* json, bool* applyLegacyStatusBarSettings(s); } + // Legacy migration: sleepCoverOverlay was a Toggle (0=off, 1=on). Now it's a 4-way Enum: + // {WHITE(0), GRAY(1), BLACK(2), OFF(3)}. Translate old values before the generic loop clamps. + if (!doc["sleepCoverOverlay"].isNull()) { + uint8_t legacyOverlay = doc["sleepCoverOverlay"] | (uint8_t)0; + if (legacyOverlay == 0) { + s.sleepCoverOverlay = 3; // OFF + doc["sleepCoverOverlay"] = 3; + if (needsResave) *needsResave = true; + } else if (legacyOverlay == 1) { + s.sleepCoverOverlay = 1; // GRAY (old "on" = gray dither) + } + } + for (const auto& info : getSettingsList()) { if (!info.key) continue; // Dynamic entries (KOReader etc.) are stored in their own files — skip. diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index ff8db6f8..8f4b52d6 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -155,8 +156,8 @@ BookOverlayInfo SleepActivity::getBookOverlayInfo(const std::string& bookPath) c uint32_t totalPages = xtc.getPageCount(); float progress = xtc.calculateProgress(currentPage) * 100.0f; char buf[64]; - snprintf(buf, sizeof(buf), "Reading progress: Page %lu/%u - %.0f%%", (unsigned long)currentPage + 1, - totalPages, progress); + snprintf(buf, sizeof(buf), tr(STR_OVERLAY_READING_PROGRESS), (unsigned long)currentPage + 1, totalPages, + progress); info.progressText = buf; } f.close(); @@ -176,8 +177,15 @@ BookOverlayInfo SleepActivity::getBookOverlayInfo(const std::string& bookPath) c uint32_t totalPages = 0; FsFile indexFile; if (Storage.openFileForRead("SLP", txt.getCachePath() + "/index.bin", indexFile)) { - indexFile.seek(32); - if (indexFile.read(reinterpret_cast(&totalPages), sizeof(totalPages)) == sizeof(totalPages)) { + uint32_t magic; + serialization::readPod(indexFile, magic); + uint8_t version; + serialization::readPod(indexFile, version); + static constexpr uint32_t INDEX_CACHE_MAGIC = 0x54585449; // "TXTI" + static constexpr uint8_t INDEX_CACHE_VERSION = 2; + if (magic == INDEX_CACHE_MAGIC && version == INDEX_CACHE_VERSION) { + indexFile.seek(32); + serialization::readPod(indexFile, totalPages); } indexFile.close(); } @@ -185,12 +193,12 @@ BookOverlayInfo SleepActivity::getBookOverlayInfo(const std::string& bookPath) c if (totalPages > 0) { float progress = (currentPage + 1) * 100.0f / totalPages; char buf[64]; - snprintf(buf, sizeof(buf), "Reading progress: Page %lu/%u - %.0f%%", (unsigned long)currentPage + 1, - totalPages, progress); + snprintf(buf, sizeof(buf), tr(STR_OVERLAY_READING_PROGRESS), (unsigned long)currentPage + 1, totalPages, + progress); info.progressText = buf; } else { char buf[64]; - snprintf(buf, sizeof(buf), "Reading progress: Page %lu", (unsigned long)currentPage + 1); + snprintf(buf, sizeof(buf), tr(STR_OVERLAY_READING_PROGRESS_NO_TOTAL), (unsigned long)currentPage + 1); info.progressText = buf; } } @@ -219,13 +227,14 @@ BookOverlayInfo SleepActivity::getBookOverlayInfo(const std::string& bookPath) c const auto tocItem = epub.getTocItem(tocIndex); info.chapterName = tocItem.title; char suffix[64]; - snprintf(suffix, sizeof(suffix), " - Page %d/%d - %.0f%%", currentPage + 1, pageCount, bookProgress); + snprintf(suffix, sizeof(suffix), tr(STR_OVERLAY_CHAPTER_PAGE_SUFFIX), currentPage + 1, pageCount, + bookProgress); info.progressSuffix = suffix; - info.progressText = "Chapter: " + info.chapterName + info.progressSuffix; + info.progressText = std::string(tr(STR_CHAPTER_PREFIX)) + info.chapterName + info.progressSuffix; } else { char buf[80]; - snprintf(buf, sizeof(buf), "Reading progress: Page %d/%d - %.0f%%", currentPage + 1, pageCount, - bookProgress); + snprintf(buf, sizeof(buf), tr(STR_OVERLAY_READING_PROGRESS), (unsigned long)currentPage + 1, + (unsigned)pageCount, bookProgress); info.progressText = buf; } } @@ -341,7 +350,7 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const { if (hasProgress) { std::string progressStr; if (!overlayInfo.chapterName.empty()) { - const std::string prefix = "Chapter: "; + const std::string prefix = tr(STR_CHAPTER_PREFIX); const int prefixWidth = renderer.getTextWidth(UI_10_FONT_ID, prefix.c_str()); const int suffixWidth = renderer.getTextWidth(UI_10_FONT_ID, overlayInfo.progressSuffix.c_str()); const int maxChapterWidth = availableWidth - prefixWidth - suffixWidth;