Skip to content

Commit 6ff4145

Browse files
committed
opt: showUnsupportedVersionDialog & ci
1 parent b406700 commit 6ff4145

6 files changed

Lines changed: 115 additions & 30 deletions

File tree

.github/workflows/ci_build.yml

Lines changed: 100 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,30 @@ jobs:
154154
commits = event.get("commits", [])
155155
compare_url = event.get("compare", "")
156156
caption_limit = 1024
157+
branch_text = "Branch: HyperOS 3"
157158
158159
def escape_code_block(text):
159160
return text.replace("\\", "\\\\").replace("`", "\\`")
160161
161162
def parse_commit(commit):
162163
msg = commit.get("message", "").strip() or "(empty commit message)"
163164
164-
authors = {commit.get("author", {}).get("name", "Unknown")}
165+
authors = []
166+
seen_authors = set()
167+
168+
def add_author(name):
169+
author = (name or "").strip() or "Unknown"
170+
if author not in seen_authors:
171+
seen_authors.add(author)
172+
authors.append(author)
173+
174+
add_author(commit.get("author", {}).get("name"))
175+
165176
body_lines = []
166177
for line in msg.splitlines():
167178
m = re.match(r"Co-authored-by:\s*(.+?)\s*<", line)
168179
if m:
169-
authors.add(m.group(1))
180+
add_author(m.group(1))
170181
continue
171182
body_lines.append(line)
172183
@@ -175,49 +186,113 @@ jobs:
175186
(line.strip() for line in clean_msg.splitlines() if line.strip()),
176187
"(empty commit message)",
177188
)
178-
return clean_msg, title, ", ".join(sorted(authors))
189+
return {
190+
"message": clean_msg,
191+
"title": title,
192+
"authors": authors,
193+
}
179194
180195
parsed_commits = [parse_commit(commit) for commit in commits]
181196
182-
def build_full_caption():
183-
lines = ["New push to GitHub", "Branch: OS3"]
184-
for clean_msg, _, authors in parsed_commits:
185-
block = escape_code_block(f"{clean_msg}\nby {authors}")
186-
lines.extend(["```", block, "```"])
197+
def merge_contributors(commits):
198+
contributors = []
199+
seen = set()
200+
for commit in commits:
201+
for author in commit["authors"]:
202+
if author in seen:
203+
continue
204+
seen.add(author)
205+
contributors.append(author)
206+
return contributors
207+
208+
def build_commit_text(entries):
209+
cleaned = [entry.strip() or "(empty commit message)" for entry in entries]
210+
return "\n\n".join(cleaned) if cleaned else "No commit details available"
211+
212+
def build_code_block(text):
213+
return f"```{escape_code_block(text)}```"
214+
215+
def build_caption(commit_entries, contributors_text):
216+
lines = [
217+
"New push to GitHub",
218+
build_code_block(branch_text),
219+
"",
220+
"Commits:",
221+
build_code_block(build_commit_text(commit_entries)),
222+
"",
223+
f"Contributors: {build_code_block(contributors_text)}",
224+
]
187225
if compare_url:
188226
lines.append(f"Details: [compare]({compare_url})")
189227
return "\n".join(lines).strip()
190228
191-
def build_title_only_caption():
192-
footer = f"\nDetails: [compare]({compare_url})" if compare_url else ""
193-
lines = ["New push to GitHub", "Branch: OS3"]
194-
195-
for index, (_, title, _) in enumerate(parsed_commits):
196-
candidate_lines = lines + ["```", escape_code_block(title), "```"]
197-
candidate = "\n".join(candidate_lines) + footer
198-
if len(candidate) <= caption_limit:
199-
lines = candidate_lines
229+
def fit_commit_entries(entries, contributors_text):
230+
included = []
231+
for index, entry in enumerate(entries):
232+
candidate = included + [entry]
233+
if len(build_caption(candidate, contributors_text)) <= caption_limit:
234+
included = candidate
200235
continue
201236
202-
remaining = len(parsed_commits) - index
237+
remaining = len(entries) - index
203238
summary = f"And {remaining} more commits"
204-
if len("\n".join(lines + [summary]) + footer) <= caption_limit:
205-
lines.append(summary)
239+
if len(build_caption(included + [summary], contributors_text)) <= caption_limit:
240+
return included + [summary]
241+
if len(build_caption([summary], contributors_text)) <= caption_limit:
242+
return [summary]
206243
break
207244
208-
return ("\n".join(lines) + footer).strip()
245+
return included or ["No commit details available"]
246+
247+
def fit_contributors(contributors, commit_entries):
248+
if not contributors:
249+
return "Unknown"
250+
251+
included = []
252+
for index, contributor in enumerate(contributors):
253+
candidate = ", ".join(included + [contributor])
254+
if len(build_caption(commit_entries, candidate)) <= caption_limit:
255+
included.append(contributor)
256+
continue
257+
258+
remaining = len(contributors) - index
259+
if included:
260+
summary = f"{', '.join(included)} and {remaining} more contributors"
261+
else:
262+
summary = f"{remaining} contributors"
263+
if len(build_caption(commit_entries, summary)) <= caption_limit:
264+
return summary
265+
break
266+
267+
return ", ".join(included) or "Unknown"
268+
269+
contributors = merge_contributors(parsed_commits)
270+
contributors_text = ", ".join(contributors) or "Unknown"
271+
full_commit_entries = [commit["message"] for commit in parsed_commits] or ["No commit details available"]
272+
273+
caption = build_caption(full_commit_entries, contributors_text)
274+
if len(caption) > caption_limit:
275+
title_entries = [commit["title"] for commit in parsed_commits] or ["No commit details available"]
276+
title_entries = fit_commit_entries(title_entries, contributors_text)
277+
caption = build_caption(title_entries, contributors_text)
278+
279+
if len(caption) > caption_limit:
280+
title_entries = [commit["title"] for commit in parsed_commits] or ["No commit details available"]
281+
title_entries = fit_commit_entries(title_entries, "Unknown")
282+
contributors_text = fit_contributors(contributors, title_entries)
283+
caption = build_caption(title_entries, contributors_text)
209284
210-
caption = build_full_caption()
211285
if len(caption) > caption_limit:
212-
caption = build_title_only_caption()
286+
summary_entries = [f"And {len(parsed_commits)} commits pushed"] if parsed_commits else ["No commit details available"]
287+
contributors_text = fit_contributors(contributors, summary_entries)
288+
caption = build_caption(summary_entries, contributors_text)
213289
214290
if len(caption) > caption_limit:
215291
caption = "\n".join(
216292
line
217293
for line in [
218294
"New push to GitHub",
219-
"Branch: OS3",
220-
"",
295+
build_code_block(branch_text),
221296
f"Details: [compare]({compare_url})" if compare_url else "",
222297
]
223298
if line

app/src/main/java/com/sevtinge/hyperceiler/ui/HomePageActivity.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import static android.os.Process.killProcess;
44
import static android.os.Process.myPid;
5+
import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.System.SUPPORT_FULL;
6+
import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.System.SUPPORT_PARTIAL;
57
import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.System.getAndroidVersion;
68
import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.System.getHyperOSVersion;
79
import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.System.getSmallVersion;
10+
import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.System.getVersionListText;
811
import static com.sevtinge.hyperceiler.libhook.utils.api.DeviceHelper.System.isVersionListed;
912

1013
import android.content.Context;
@@ -194,11 +197,18 @@ private void showUnsupportedVersionDialog() {
194197
getAndroidVersion(),
195198
formatHyperOsVersion()
196199
);
200+
String supportedVersionText = getVersionListText(SUPPORT_FULL);
201+
String partialSupportedVersionText = getVersionListText(SUPPORT_PARTIAL);
202+
if (!partialSupportedVersionText.isEmpty()) {
203+
supportedVersionText = supportedVersionText.isEmpty()
204+
? partialSupportedVersionText
205+
: supportedVersionText + "\n" + partialSupportedVersionText;
206+
}
197207

198208
AlertDialog dialog = new AlertDialog.Builder(this)
199209
.setCancelable(false)
200210
.setTitle(R.string.warn)
201-
.setMessage(getString(R.string.homepage_unsupported_version_message, versionText))
211+
.setMessage(getString(R.string.homepage_unsupported_version_message, versionText, supportedVersionText))
202212
.setPositiveButton(R.string.exit, (d, which) -> exitForUnsupportedVersion())
203213
.create();
204214

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<string name="headtip_tip_fuck_coolapk">历史上的今天:2022 年 7 月 14 日,绀漓发表重要讲话。</string>
9999
<string name="headtip_notice_dead_logger_errcode">当前设备 Log 服务异常,HyperCeiler 功能将被限制。\n请恢复 Log 服务,使其可以正常运行。\n错误代码: %1$s</string>
100100
<string name="headtip_notice_dead_logger">当前设备 Log 服务异常,HyperCeiler 功能将被限制。请恢复 Log 服务,使其可以正常运行。</string>
101-
<string name="homepage_unsupported_version_message">当前系统版本不在 HyperCeiler 内置适配列表中。\n\n%1$s\n\n为避免在未知系统环境下继续运行,HyperCeiler 将在 30 秒后自动退出。</string>
101+
<string name="homepage_unsupported_version_message">当前系统版本不在 HyperCeiler 内置适配列表中。\n\n%1$s\n\n本版本支持的系统版本范围为:\n%2$s\n\n为避免在未知系统环境下继续运行,HyperCeiler 将在 30 秒后自动退出。</string>
102102
<string name="homepage_unsupported_version_current">当前版本:Android SDK %1$d - HyperOS %2$s</string>
103103
<string name="unsupported_system_func">当前系统版本不支持此功能</string>
104104
<string name="supported_system_func">当前系统版本官方已支持此功能</string>

app/src/main/res/values-zh-rHK/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<string name="headtip_tip_fuck_coolapk">歷史上的今日:2022 年 7 月 14 日,紺漓發表重要講話 。</string>
9999
<string name="headtip_notice_dead_logger_errcode">當前裝置 Log 服務異常,HyperCeiler 功能將被限制。\n請復原 Log 服務,使其可以正常運行。\n錯誤代碼: %1$s</string>
100100
<string name="headtip_notice_dead_logger">當前裝置 Log 服務異常,HyperCeiler 功能將被限制。請復原 Log 服務,使其可以正常運行。</string>
101-
<string name="homepage_unsupported_version_message">当前系統版本不在 HyperCeiler 內置系統版本列表中。\n\n%1$s\n\n為避免在未知系統環境下繼續運行,HyperCeiler 程式将在 30 秒后自動退出。</string>
101+
<string name="homepage_unsupported_version_message">当前系統版本不在 HyperCeiler 內置系統版本列表中。\n\n%1$s\n\n本版本支援的系統版本範圍為:\n%2$s\n\n為避免在未知系統環境下繼續運行,HyperCeiler 程式将在 30 秒后自動退出。</string>
102102
<string name="homepage_unsupported_version_current">当前版本:Android SDK %1$d - HyperOS %2$s</string>
103103
<string name="unsupported_system_func">當前系統版本不支持此功能</string>
104104
<string name="supported_system_func">當前系統版本官方已支持此功能</string>

app/src/main/res/values-zh-rTW/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<string name="headtip_tip_fuck_coolapk">歷史上的今天:2022 年 7 月 14 日,绀漓發表重要講話。</string>
9999
<string name="headtip_notice_dead_logger_errcode">當前設備Log服務異常,HyperCeiler 功能將被限制。\n請恢復 Log 服務,使其可以正常運行。 n錯誤代碼: %1$s</string>
100100
<string name="headtip_notice_dead_logger">當前設備 Log 服務異常,HyperCeiler 功能將被限制。 請恢復 Log 服務,使其可以正常運行。</string>
101-
<string name="homepage_unsupported_version_message">当前系統版本不在 HyperCeiler 內置系統版本列表中。\n\n%1$s\n\n為避免在未知系統環境下繼續運行,HyperCeiler 程式将在 30 秒后自動退出。</string>
101+
<string name="homepage_unsupported_version_message">当前系統版本不在 HyperCeiler 內置系統版本列表中。\n\n%1$s\n\n本版本支援的系統版本範圍為:\n%2$s\n\n為避免在未知系統環境下繼續運行,HyperCeiler 程式将在 30 秒后自動退出。</string>
102102
<string name="homepage_unsupported_version_current">当前版本:Android SDK %1$d - HyperOS %2$s</string>
103103
<string name="unsupported_system_func">當前系統版本不支持此功能</string>
104104
<string name="supported_system_func">當前系統版本正式支持此特性</string>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<string name="headtip_tip_fuck_coolapk">Today in history: Sevtinge delivered an important speech on July 14, 2022.</string>
103103
<string name="headtip_notice_dead_logger_errcode">The current device log service is abnormal and HyperCeiler features will be limited. Please restore the log service so that it can run normally.\nError code: %1$s</string>
104104
<string name="headtip_notice_dead_logger">The current device log service is abnormal and HyperCeiler features will be limited. Please restore the log service so that it can run normally.</string>
105-
<string name="homepage_unsupported_version_message">The current system version isn\'t included in HyperCeiler\'s built-in adaptation list.\n\n%1$s\n\nHyperCeiler will exit automatically after 30 seconds to avoid running in an unknown system environment.</string>
105+
<string name="homepage_unsupported_version_message">The current system version isn\'t included in HyperCeiler\'s built-in adaptation list.\n\n%1$s\n\nThe system versions supported by this release are:\n%2$s\n\nHyperCeiler will exit automatically after 30 seconds to avoid running in an unknown system environment.</string>
106106
<string name="homepage_unsupported_version_current">Current version: Android SDK %1$d - HyperOS %2$s</string>
107107
<string name="unsupported_system_func">This feature isn\'t supported in the current system version</string>
108108
<string name="supported_system_func">This feature is officially supported in the current system version</string>

0 commit comments

Comments
 (0)