diff --git a/install.py b/install.py index 507cee3..471bf4f 100755 --- a/install.py +++ b/install.py @@ -63,10 +63,10 @@ def get_local_head_sha(): return None -def clone_repo(force: bool = False): +def clone_repo(force: bool = True): print("[1/3] Preparing CrossPoint repository...") - if os.path.exists(REPO_DIR) and not force: + if not force and os.path.exists(REPO_DIR): print(" Existing repo found, checking remote for updates...") remote_sha = get_remote_head_sha() local_sha = get_local_head_sha() @@ -278,9 +278,10 @@ def parse_args(): help="Auto-answer Y to all plugin install prompts", ) parser.add_argument( - "--reclone", + "--no-reclone", action="store_true", - help="Force re-clone of the CrossPoint repository even if it already exists", + dest="no_reclone", + help="Skip re-cloning if CrossPoint repo already exists and matches remote", ) return parser.parse_args() @@ -305,7 +306,7 @@ def main(): print(" Aborted.") sys.exit(0) print() - clone_repo(force=args.reclone) + clone_repo(force=not args.no_reclone) apply_plugins(yes_all=args.yes) build_and_flash(args.environment) print("\nDone.") diff --git a/plugins/bookerly/patch.py b/plugins/bookerly/patch.py index 71573f9..2853b27 100644 --- a/plugins/bookerly/patch.py +++ b/plugins/bookerly/patch.py @@ -216,14 +216,24 @@ def patch_settings_list_h(repo_dir): path = find_first("SettingsList.h", repo_dir) content = read_file(path) - if 'STR_NONE_OPT}, "fontFamily"' in content: + already_patched = 'STR_NONE_OPT}, "fontFamily"' in content and 'bookerlyInstalled' in content + if already_patched: print(" SettingsList.h already patched, skipping.") return - content = content.replace( - '{StrId::STR_NOTO_SERIF, StrId::STR_NOTO_SANS, StrId::STR_OPEN_DYSLEXIC}, "fontFamily"', - '{StrId::STR_NOTO_SERIF, StrId::STR_NOTO_SANS, StrId::STR_OPEN_DYSLEXIC, StrId::STR_NONE_OPT}, "fontFamily"' - ) + if 'STR_NONE_OPT}, "fontFamily"' not in content: + content = content.replace( + '{StrId::STR_NOTO_SERIF, StrId::STR_NOTO_SANS, StrId::STR_OPEN_DYSLEXIC}, "fontFamily"', + '{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.") @@ -312,16 +322,13 @@ def patch_settings_activity_cpp(repo_dir): ' const auto confirmLabel = (selectedSettingIndex == 0) ? nextCatLabel : tr(STR_TOGGLE);' ) - if '"Bookerly"' not in content: + 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 (settings[index].key && std::string(settings[index].key) == "fontFamily") {\n' - ' const uint8_t val = SETTINGS.*(settings[index].valuePtr);\n' - ' if (val == CrossPointSettings::BOOKERLY) return "Bookerly";\n' - ' }\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' ' }\n' @@ -329,16 +336,19 @@ def patch_settings_activity_cpp(repo_dir): ' },' ) - 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' - ' }' - ) + if '"Bookerly"' not in content: + content = content.replace( + ' } 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' + ' valueText = I18N.get(setting.enumValues[value]);\n' + ' }' + ) write_file(path, content) print(" SettingsActivity.cpp patched.")