# -*- coding: utf-8 -*- """修首页「中转设置」按钮:容器名是 box,布局参数要按旁边那种写法。""" from __future__ import annotations import sys from pathlib import Path MAIN = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\android\src" r"\com\lanremote\watch\MainActivity.java") OLD = ''' Button relayButton = bigButton( "中转设置(跨网络用)", C_ACCENT, 14); relayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { promptRelayUrl(); } }); panel.addView(relayButton, bigParams()); ''' NEW = ''' Button relayButton = bigButton("中转设置(跨网络用)", C_ACCENT, 14); LinearLayout.LayoutParams relayParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, dp(52)); relayParams.setMargins(0, 0, 0, dp(8)); relayButton.setLayoutParams(relayParams); relayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { promptRelayUrl(); } }); box.addView(relayButton); ''' def main() -> int: text = MAIN.read_text(encoding="utf-8") if OLD not in text: print(" [失败] 锚点没找到") return 1 MAIN.write_text(text.replace(OLD, NEW, 1), encoding="utf-8") print(" 首页按钮已按实际写法修正") return 0 if __name__ == "__main__": sys.exit(main())