fix(bookerly): use SettingAction for Plugins page display and fix font family Bookerly label

This commit is contained in:
Justin Oros
2026-04-22 17:13:57 -07:00
parent d802b830ae
commit f2bd2915ba
+57 -24
View File
@@ -227,13 +227,6 @@ def patch_settings_list_h(repo_dir):
'{StrId::STR_NOTO_SERIF, StrId::STR_NOTO_SANS, StrId::STR_OPEN_DYSLEXIC, StrId::STR_NONE_OPT}, "fontFamily"'
)
if 'bookerlyInstalled' not in content:
content = content.replace(
' };\n return list;\n}\n',
' SettingInfo::Enum(StrId::STR_NONE_OPT, &CrossPointSettings::fontFamily,\n'
' {StrId::STR_NONE_OPT}, "bookerlyInstalled"),\n'
' };\n return list;\n}\n'
)
write_file(path, content)
print(" SettingsList.h patched.")
@@ -243,14 +236,15 @@ def patch_settings_activity_h(repo_dir):
path = find_first("SettingsActivity.h", repo_dir)
content = read_file(path)
if 'categoryCount = 5' in content:
if 'BookerlyInstalled' in content:
print(" SettingsActivity.h already patched, skipping.")
return
content = content.replace(
'static constexpr int categoryCount = 4;',
'static constexpr int categoryCount = 5;'
)
if 'categoryCount = 4' in content:
content = content.replace(
'static constexpr int categoryCount = 4;',
'static constexpr int categoryCount = 5;'
)
if 'pluginsSettings' not in content:
content = content.replace(
@@ -258,6 +252,11 @@ def patch_settings_activity_h(repo_dir):
' std::vector<SettingInfo> systemSettings;\n std::vector<SettingInfo> pluginsSettings;'
)
content = content.replace(
' HardcoverSync,\n};',
' HardcoverSync,\n BookerlyInstalled,\n};'
)
write_file(path, content)
print(" SettingsActivity.h patched.")
@@ -266,7 +265,7 @@ def patch_settings_activity_cpp(repo_dir):
path = find_first("SettingsActivity.cpp", repo_dir)
content = read_file(path)
if "BookerlyPlugin" in content:
if '"Bookerly Plugin"' in content:
print(" SettingsActivity.cpp already patched, skipping.")
return
@@ -324,16 +323,37 @@ def patch_settings_activity_cpp(repo_dir):
if '"Bookerly Plugin"' not in content:
content = content.replace(
' [&settings](int index) { return std::string(I18N.get(settings[index].nameId)); },',
' [&settings, this](int index) -> std::string {\n'
' if (selectedCategoryIndex == 4) {\n'
' const auto& s = settings[index];\n'
' if (s.key && std::string(s.key) == "bookerlyInstalled") return "Bookerly Plugin";\n'
' if (s.key && std::string(s.key) == "darkModeState") return "Dark Mode";\n'
' if (s.key && std::string(s.key) == "smallerFontsMode") return "Smaller Fonts";\n',
' if (s.key && std::string(s.key) == "smallerFontsMode") return "Smaller Fonts";\n'
' }\n'
' return std::string(I18N.get(settings[index].nameId));\n'
' },'
' if (s.type == SettingType::ACTION &&\n'
' s.action == SettingAction::BookerlyInstalled) return "Bookerly Plugin";\n'
)
if 'SettingAction::BookerlyInstalled' not in content:
content = content.replace(
' pluginsSettings.push_back(SettingInfo::Enum(\n'
' StrId::STR_NONE_OPT, &CrossPointSettings::smallerFontsMode,\n'
' {StrId::STR_NONE_OPT, StrId::STR_NONE_OPT, StrId::STR_NONE_OPT}, "smallerFontsMode"\n'
' ));\n',
' pluginsSettings.push_back(SettingInfo::Enum(\n'
' StrId::STR_NONE_OPT, &CrossPointSettings::smallerFontsMode,\n'
' {StrId::STR_NONE_OPT, StrId::STR_NONE_OPT, StrId::STR_NONE_OPT}, "smallerFontsMode"\n'
' ));\n'
' pluginsSettings.push_back(SettingInfo::Action(\n'
' StrId::STR_NONE_OPT, SettingAction::BookerlyInstalled\n'
' ));\n'
)
if 'SettingAction::BookerlyInstalled' not in content or 'case SettingAction::BookerlyInstalled' not in content:
content = content.replace(
' case SettingAction::None:\n'
' // Do nothing\n'
' break;',
' case SettingAction::BookerlyInstalled:\n'
' break;\n'
' case SettingAction::None:\n'
' // Do nothing\n'
' break;'
)
if '"Bookerly"' not in content:
@@ -341,8 +361,6 @@ def patch_settings_activity_cpp(repo_dir):
' } else {\n'
' valueText = I18N.get(setting.enumValues[value]);\n'
' }',
' } else if (setting.key && std::string(setting.key) == "bookerlyInstalled") {\n'
' valueText = "Installed";\n'
' } else if (setting.key && std::string(setting.key) == "fontFamily" && value == CrossPointSettings::BOOKERLY) {\n'
' valueText = "Bookerly";\n'
' } else {\n'
@@ -350,6 +368,21 @@ def patch_settings_activity_cpp(repo_dir):
' }'
)
if '"Installed"' not in content:
content = content.replace(
' } else if (setting.type == SettingType::ACTION &&\n'
' setting.action == SettingAction::HardcoverSync) {\n'
' valueText = "Sync";\n'
' }',
' } else if (setting.type == SettingType::ACTION &&\n'
' setting.action == SettingAction::HardcoverSync) {\n'
' valueText = "Sync";\n'
' } else if (setting.type == SettingType::ACTION &&\n'
' setting.action == SettingAction::BookerlyInstalled) {\n'
' valueText = "Installed";\n'
' }'
)
write_file(path, content)
print(" SettingsActivity.cpp patched.")