From 90f21bee3db10888649efc883bbd893bc928c89f Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Wed, 22 Apr 2026 16:57:15 -0700 Subject: [PATCH] fix(bookerly): add SettingsActivity.h patch and Plugins tab setup --- plugins/bookerly/patch.py | 59 ++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/plugins/bookerly/patch.py b/plugins/bookerly/patch.py index 258a3e7..71573f9 100644 --- a/plugins/bookerly/patch.py +++ b/plugins/bookerly/patch.py @@ -229,6 +229,29 @@ def patch_settings_list_h(repo_dir): print(" SettingsList.h patched.") +def patch_settings_activity_h(repo_dir): + path = find_first("SettingsActivity.h", repo_dir) + content = read_file(path) + + if 'categoryCount = 5' in content: + print(" SettingsActivity.h already patched, skipping.") + return + + content = content.replace( + 'static constexpr int categoryCount = 4;', + 'static constexpr int categoryCount = 5;' + ) + + if 'pluginsSettings' not in content: + content = content.replace( + ' std::vector systemSettings;', + ' std::vector systemSettings;\n std::vector pluginsSettings;' + ) + + write_file(path, content) + print(" SettingsActivity.h patched.") + + def patch_settings_activity_cpp(repo_dir): path = find_first("SettingsActivity.cpp", repo_dir) content = read_file(path) @@ -242,18 +265,6 @@ def patch_settings_activity_cpp(repo_dir): '#include "DarkModePlugin.h"\n#include "BookerlyPlugin.h"' ) - if 'categoryCount = 5' not in content: - content = content.replace( - 'static constexpr int categoryCount = 4;', - 'static constexpr int categoryCount = 5;' - ) - - if 'pluginsSettings' not in content: - content = content.replace( - ' std::vector systemSettings;', - ' std::vector systemSettings;\n std::vector pluginsSettings;' - ) - if 'STR_NONE_OPT};' not in content: content = content.replace( 'const StrId SettingsActivity::categoryNames[categoryCount] = {StrId::STR_CAT_DISPLAY, StrId::STR_CAT_READER,\n' @@ -318,17 +329,16 @@ def patch_settings_activity_cpp(repo_dir): ' },' ) - if 'fontFamily.*Bookerly\|"Bookerly"' not in content: - content = content.replace( - ' } else {\n' - ' valueText = I18N.get(setting.enumValues[value]);\n' - ' }', - ' } else if (setting.key && std::string(setting.key) == "fontFamily" && value == CrossPointSettings::BOOKERLY) {\n' - ' valueText = "Bookerly";\n' - ' } else {\n' - ' valueText = I18N.get(setting.enumValues[value]);\n' - ' }' - ) + content = content.replace( + ' } else {\n' + ' valueText = I18N.get(setting.enumValues[value]);\n' + ' }', + ' } else if (setting.key && std::string(setting.key) == "fontFamily" && value == CrossPointSettings::BOOKERLY) {\n' + ' valueText = "Bookerly";\n' + ' } else {\n' + ' valueText = I18N.get(setting.enumValues[value]);\n' + ' }' + ) write_file(path, content) print(" SettingsActivity.cpp patched.") @@ -409,6 +419,9 @@ def patch(repo_dir: str): print(" Patching SettingsList.h...") patch_settings_list_h(repo_dir) + print(" Patching SettingsActivity.h...") + patch_settings_activity_h(repo_dir) + print(" Patching SettingsActivity.cpp...") patch_settings_activity_cpp(repo_dir)