fix(bookerly): rewrite patch_settings_activity_cpp with correct string escaping
This commit is contained in:
+27
-67
@@ -271,97 +271,57 @@ def patch_settings_activity_cpp(repo_dir):
|
|||||||
|
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
'#include "fontIds.h"',
|
'#include "fontIds.h"',
|
||||||
'#include "fontIds.h"
|
'#include "fontIds.h"\n#include "BookerlyPlugin.h"'
|
||||||
#include "BookerlyPlugin.h"'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if 'pluginsSettings.push_back' not in content:
|
if 'SettingAction::BookerlyInstalled' not in content:
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
' readerSettings.push_back(SettingInfo::Action(StrId::STR_CUSTOMISE_STATUS_BAR, SettingAction::CustomiseStatusBar));
|
' readerSettings.push_back(SettingInfo::Action(StrId::STR_CUSTOMISE_STATUS_BAR, SettingAction::CustomiseStatusBar));\n',
|
||||||
',
|
' readerSettings.push_back(SettingInfo::Action(StrId::STR_CUSTOMISE_STATUS_BAR, SettingAction::CustomiseStatusBar));\n'
|
||||||
' readerSettings.push_back(SettingInfo::Action(StrId::STR_CUSTOMISE_STATUS_BAR, SettingAction::CustomiseStatusBar));
|
' pluginsSettings.push_back(SettingInfo::Action(\n'
|
||||||
'
|
' StrId::STR_NONE_OPT, SettingAction::BookerlyInstalled\n'
|
||||||
' pluginsSettings.push_back(SettingInfo::Action(
|
' ));\n'
|
||||||
'
|
|
||||||
' StrId::STR_NONE_OPT, SettingAction::BookerlyInstalled
|
|
||||||
'
|
|
||||||
' ));
|
|
||||||
'
|
|
||||||
)
|
|
||||||
elif 'BookerlyInstalled' not in content:
|
|
||||||
content = content.replace(
|
|
||||||
' readerSettings.push_back(SettingInfo::Action(StrId::STR_CUSTOMISE_STATUS_BAR, SettingAction::CustomiseStatusBar));
|
|
||||||
',
|
|
||||||
' readerSettings.push_back(SettingInfo::Action(StrId::STR_CUSTOMISE_STATUS_BAR, SettingAction::CustomiseStatusBar));
|
|
||||||
'
|
|
||||||
' pluginsSettings.push_back(SettingInfo::Action(
|
|
||||||
'
|
|
||||||
' StrId::STR_NONE_OPT, SettingAction::BookerlyInstalled
|
|
||||||
'
|
|
||||||
' ));
|
|
||||||
'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if '"Bookerly Plugin"' not in content:
|
if '"Bookerly Plugin"' not in content:
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
' [&settings](int index) { return std::string(I18N.get(settings[index].nameId)); }, nullptr, nullptr,',
|
' [&settings](int index) { return std::string(I18N.get(settings[index].nameId)); }, nullptr, nullptr,',
|
||||||
' [&settings, this](int index) -> std::string {
|
' [&settings, this](int index) -> std::string {\n'
|
||||||
'
|
' if (selectedCategoryIndex == 4) {\n'
|
||||||
' if (selectedCategoryIndex == 4) {
|
' const auto& s = settings[index];\n'
|
||||||
'
|
' if (s.type == SettingType::ACTION && s.action == SettingAction::BookerlyInstalled) return "Bookerly Plugin";\n'
|
||||||
' const auto& s = settings[index];
|
' }\n'
|
||||||
'
|
' return std::string(I18N.get(settings[index].nameId));\n'
|
||||||
' if (s.type == SettingType::ACTION && s.action == SettingAction::BookerlyInstalled) return "Bookerly Plugin";
|
|
||||||
'
|
|
||||||
' }
|
|
||||||
'
|
|
||||||
' return std::string(I18N.get(settings[index].nameId));
|
|
||||||
'
|
|
||||||
' }, nullptr, nullptr,'
|
' }, nullptr, nullptr,'
|
||||||
)
|
)
|
||||||
|
|
||||||
if '"Bookerly"' not in content:
|
if '"Bookerly"' not in content:
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
' const uint8_t value = SETTINGS.*(setting.valuePtr);
|
' const uint8_t value = SETTINGS.*(setting.valuePtr);\n'
|
||||||
'
|
' valueText = I18N.get(setting.enumValues[value]);\n',
|
||||||
' valueText = I18N.get(setting.enumValues[value]);
|
' const uint8_t value = SETTINGS.*(setting.valuePtr);\n'
|
||||||
',
|
' if (setting.key && std::string(setting.key) == "fontFamily" && value == CrossPointSettings::BOOKERLY) {\n'
|
||||||
' const uint8_t value = SETTINGS.*(setting.valuePtr);
|
' valueText = "Bookerly";\n'
|
||||||
'
|
' } else {\n'
|
||||||
' if (setting.key && std::string(setting.key) == "fontFamily" && value == CrossPointSettings::BOOKERLY) {
|
' valueText = I18N.get(setting.enumValues[value]);\n'
|
||||||
'
|
' }\n'
|
||||||
' valueText = "Bookerly";
|
|
||||||
'
|
|
||||||
' } else {
|
|
||||||
'
|
|
||||||
' valueText = I18N.get(setting.enumValues[value]);
|
|
||||||
'
|
|
||||||
' }
|
|
||||||
'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if '"Installed"' not in content:
|
if '"Installed"' not in content:
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
' } else if (setting.type == SettingType::VALUE && setting.valuePtr != nullptr) {
|
' } else if (setting.type == SettingType::VALUE && setting.valuePtr != nullptr) {\n'
|
||||||
'
|
' valueText = std::to_string(SETTINGS.*(setting.valuePtr));\n'
|
||||||
' valueText = std::to_string(SETTINGS.*(setting.valuePtr));
|
|
||||||
'
|
|
||||||
' }',
|
' }',
|
||||||
' } else if (setting.type == SettingType::ACTION && setting.action == SettingAction::BookerlyInstalled) {
|
' } else if (setting.type == SettingType::ACTION && setting.action == SettingAction::BookerlyInstalled) {\n'
|
||||||
'
|
' valueText = "Installed";\n'
|
||||||
' valueText = "Installed";
|
' } else if (setting.type == SettingType::VALUE && setting.valuePtr != nullptr) {\n'
|
||||||
'
|
' valueText = std::to_string(SETTINGS.*(setting.valuePtr));\n'
|
||||||
' } else if (setting.type == SettingType::VALUE && setting.valuePtr != nullptr) {
|
|
||||||
'
|
|
||||||
' valueText = std::to_string(SETTINGS.*(setting.valuePtr));
|
|
||||||
'
|
|
||||||
' }'
|
' }'
|
||||||
)
|
)
|
||||||
|
|
||||||
write_file(path, content)
|
write_file(path, content)
|
||||||
print(" SettingsActivity.cpp patched.")
|
print(" SettingsActivity.cpp patched.")
|
||||||
|
|
||||||
|
|
||||||
def patch_web_server(repo_dir):
|
def patch_web_server(repo_dir):
|
||||||
path = find_first("CrossPointWebServer.cpp", repo_dir)
|
path = find_first("CrossPointWebServer.cpp", repo_dir)
|
||||||
content = read_file(path)
|
content = read_file(path)
|
||||||
|
|||||||
Reference in New Issue
Block a user