11 Commits
10 changed files with 61 additions and 113 deletions

No files matched your search

+8
View File
@@ -1,5 +1,13 @@
# 更新日志
## V2.5.0-beta.3
- 修复: 底部导航栏未适配手势导航条(补 viewport-fit=cover 与 edge-to-edge,安全区变量此前恒为 0)
- 修复: 文档预览不渲染 HTML 与 GitHub 提示块(`> [!TIP]` 等)
- 修复: 活动抓取会误抓到系统桌面,现忽略桌面/系统界面/输入法
- 优化: 亮度滑条改为拖动中按 3% 变化实时应用,松手再应用最终值
- 优化: NOTE.txt 去掉过期的版本号
## V2.5.0-beta.2
- 重构: WebUI 全量重写为 **Material Design 3**(基于 `@material/web`),补全颜色/字阶/形状/动效令牌,支持涟漪与状态层反馈
+7 -19
View File
@@ -155,22 +155,13 @@ func (w *Watcher) Add(path, letters string) error {
return nil
}
// Close 释放资源。重复调用安全。
// Close 释放资源。
func (w *Watcher) Close() error {
w.mu.Lock()
defer w.mu.Unlock()
// 先唤醒 Run:直接关闭 fd 会让阻塞中的 poll 拿不到退出信号
if w.wakeW >= 0 {
_, _ = unix.Write(w.wakeW, []byte{1})
}
if w.wakeR >= 0 {
_ = unix.Close(w.wakeR)
w.wakeR = -1
}
if w.wakeW >= 0 {
_ = unix.Close(w.wakeW)
w.wakeW = -1
}
_ = unix.Close(w.wakeR)
_ = unix.Close(w.wakeW)
w.wakeR, w.wakeW = -1, -1
if w.fd >= 0 {
err := unix.Close(w.fd)
w.fd = -1
@@ -179,13 +170,10 @@ func (w *Watcher) Close() error {
return nil
}
// wake 唤醒正在 poll 的 Run。并发/重复调用安全。
// wake 唤醒正在 poll 的 Run。
func (w *Watcher) wake() {
w.mu.Lock()
fd := w.wakeW
w.mu.Unlock()
if fd >= 0 {
_, _ = unix.Write(fd, []byte{1})
if w.wakeW >= 0 {
_, _ = unix.Write(w.wakeW, []byte{1})
}
}
+11 -9
View File
@@ -80,8 +80,6 @@ func startRunner(t *testing.T, w *Watcher, debounce time.Duration, handler func(
_ = w.NewRunner(debounce, nil).Run(handler, stop)
}()
t.Cleanup(func() {
// 必须先让 Run 退出,再关闭 watcher:反过来会先关掉唤醒管道,
// Stop 的唤醒丢失,Run 会卡在 poll 里直到超时(CI 上偶发)
close(stop)
w.Stop()
select {
@@ -89,7 +87,6 @@ func startRunner(t *testing.T, w *Watcher, debounce time.Duration, handler func(
case <-time.After(2 * time.Second):
t.Error("Run 未能退出")
}
w.Close()
})
return stop
}
@@ -116,6 +113,7 @@ func TestWatchModifyDeliversEvent(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "c"); err != nil {
t.Fatal(err)
}
@@ -146,6 +144,7 @@ func TestCloseWriteLetter(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "w"); err != nil {
t.Fatal(err)
}
@@ -182,6 +181,7 @@ func TestCloseNoWriteLetter(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "0"); err != nil {
t.Fatal(err)
}
@@ -216,26 +216,25 @@ func TestDebounceCoalescesBurst(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "c"); err != nil {
t.Fatal(err)
}
c := &collector{}
// 防抖窗口取大一些:CI 上单次写文件可能耗时数十毫秒,
// 窗口过短会让连写跨越窗口边界,产生第 2 次触发(测试因此偶发失败)
const debounceWindow = 800 * time.Millisecond
startRunner(t, w, debounceWindow, c.add)
startRunner(t, w, 200*time.Millisecond, c.add)
for i := 0; i < 5; i++ {
if err := os.WriteFile(path, []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
time.Sleep(10 * time.Millisecond)
}
if !waitFor(t, 3*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
if !waitFor(t, 2*time.Second, func() bool { return len(c.snapshot()) > 0 }) {
t.Fatal("未收到事件")
}
time.Sleep(debounceWindow + 400*time.Millisecond) // 等超过一个防抖窗口
time.Sleep(300 * time.Millisecond) // 等超过一个防抖窗口
if got := len(c.snapshot()); got != 1 {
t.Fatalf("防抖后应只触发 1 次, 实际 %d 次", got)
}
@@ -252,6 +251,7 @@ func TestDrainPreventsRecursion(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "c"); err != nil {
t.Fatal(err)
}
@@ -287,6 +287,7 @@ func TestStopExitsBlockingRun(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(path, "c"); err != nil {
t.Fatal(err)
}
@@ -316,6 +317,7 @@ func TestAddMissingPathFails(t *testing.T) {
if err != nil {
t.Skipf("当前环境不支持 inotify: %v", err)
}
defer w.Close()
if err := w.Add(filepath.Join(t.TempDir(), "不存在"), "c"); err == nil {
t.Fatal("监听不存在的路径应报错")
}
+2 -2
View File
@@ -1,7 +1,7 @@
id=LuminPro
name=LuminPro丨日用屏幕亮度强化
version=V2.5.0-beta.2
versionCode=2050052
version=V2.5.0-beta.3
versionCode=2050053
author=酷安@Yule
description=本模块旨在让你的 Android 设备随时可以使用高亮度显示屏幕内容。无论设备当前亮度如何,只要满足设定的前台触发亮度条件,模块便会自动且平滑地提升屏幕亮度至硬件支持的峰值状态,确保你在强光室外也能获得清晰的显示效果
updateJson=https://raw.githubusercontent.com/YuleBest/LuminPro/main/update.json
+6
View File
@@ -0,0 +1,6 @@
{
"versionCode": 2050053,
"version": "V2.5.0-beta.3",
"zipUrl": "https://github.com/YuleBest/LuminPro/releases/download/v2.5.0-beta.3/LuminPro_V2.5.0-beta.3.zip",
"changelog": "https://raw.githubusercontent.com/YuleBest/LuminPro/beta/changelog.md"
}
+5 -11
View File
@@ -1,4 +1,4 @@
import { exec, moduleInfo } from 'kernelsu'
import { exec, moduleInfo, enableEdgeToEdge } from 'kernelsu'
import { devMock } from './devMock.js'
export const MODULE_DIR = '/data/adb/modules/LuminPro'
@@ -42,19 +42,13 @@ export function shellQuote(value) {
}
/**
* 启用 edge-to-edge:内容延伸至状态栏/手势条区域,insets.css 的
* --window-inset-* / --safe-area-inset-* 随之生效。
*
* 注意:不能直接调用从 npm 包 import 的 enableEdgeToEdge——该绑定总是存在,
* 不支持时是包内部调用 ksu 对象时抛错,会打断后续脚本(FontMM 踩过同样的坑)。
* 这里改为探测全局 ksu 对象,并兼容 KernelSU-Next 的 enableInsets 命名。
* 启用 edge-to-edge:内容延伸至状态栏/手势条区域,
* insets.css 的 --window-inset-* 随之生效,顶栏/底栏据此避让。
* 不同 KernelSU 版本的命名不同,逐个尝试,全部不可用则忽略。
*/
export function applyEdgeToEdge() {
try {
const ksuApi = globalThis.ksu
if (!ksuApi) return
const fn = ksuApi.enableEdgeToEdge ?? ksuApi.enableInsets
if (typeof fn === 'function') fn.call(ksuApi, true)
enableEdgeToEdge(true)
} catch {
/* 老版本没有该 API:布局仍可用,只是安全区取 0 */
}
+12 -14
View File
@@ -16,18 +16,16 @@ const tabs = [
</script>
<template>
<nav class="bottom-nav">
<md-navigation-bar>
<md-navigation-tab
v-for="tab in tabs"
:key="tab.key"
:label="tab.label"
:active="modelValue === tab.key"
@click="emit('update:modelValue', tab.key)"
>
<component :is="tab.icon" slot="active-icon" :size="24" />
<component :is="tab.icon" slot="inactive-icon" :size="24" />
</md-navigation-tab>
</md-navigation-bar>
</nav>
<md-navigation-bar>
<md-navigation-tab
v-for="tab in tabs"
:key="tab.key"
:label="tab.label"
:active="modelValue === tab.key"
@click="emit('update:modelValue', tab.key)"
>
<component :is="tab.icon" slot="active-icon" :size="24" />
<component :is="tab.icon" slot="inactive-icon" :size="24" />
</md-navigation-tab>
</md-navigation-bar>
</template>
+3 -12
View File
@@ -138,20 +138,11 @@
}
/* ── M3 导航栏 ────────────────────────────────────────────────────── */
/* 底栏容器:色块填充法——容器背景延伸至屏幕最底部,手势导航条区域
与导航栏同色;内边距把导航内容抬到手势条之上。
安全区变量在不同 KernelSU 版本命名不同,最后兜底 env()。 */
.bottom-nav {
flex: 0 0 auto;
background-color: var(--md-sys-color-surface-container);
padding-bottom: var(--safe-area-inset-bottom, var(--window-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
md-navigation-bar {
flex: 0 0 auto;
/* 背景延伸到屏幕底部,内容抬到手势条之上 */
padding-bottom: var(--safe-area-inset-bottom, var(--window-inset-bottom, 0px));
--md-navigation-bar-container-color: var(--md-sys-color-surface-container);
/* 去掉容器阴影:手势条区域用同色填充,阴影会在底部露出一条边 */
--md-navigation-bar-container-elevation: 0;
box-shadow: none;
--md-navigation-bar-active-indicator-color: var(--md-sys-color-secondary-container);
--md-navigation-bar-active-icon-color: var(--md-sys-color-on-secondary-container);
--md-navigation-bar-active-label-text-color: var(--md-sys-color-on-surface);
+1 -6
View File
@@ -41,11 +41,6 @@ async function openHelp() {
helpDialog.value?.show()
}
function closeHelp() {
helpDialog.value?.close()
helpOpen.value = false
}
// ── 定时休眠:HHMM 起止时间 ────────────────────────────────────────
const sleepStart = computed(() => config.sleepParts.value[0] + config.sleepParts.value[1])
const sleepEnd = computed(() => config.sleepParts.value[2] + config.sleepParts.value[3])
@@ -321,7 +316,7 @@ async function confirmReset() {
<div slot="headline">支持的事件字母</div>
<pre slot="content" class="help-text">{{ INOTIFY_HELP }}</pre>
<div slot="actions">
<md-filled-button @click="closeHelp">知道了</md-filled-button>
<md-filled-button @click="helpOpen = false">知道了</md-filled-button>
</div>
</md-dialog>
</template>
+6 -40
View File
@@ -49,48 +49,20 @@ let lastApplied = null
/** 拖动中节流:距上次应用超过 3% 才写一次节点,避免每个像素都 exec */
const DRAG_APPLY_STEP_PERCENT = 3
/** 低亮度保护:低于该比例视为伪黑屏风险,需用户确认后才允许 */
const MIN_PERCENT = 5
/** 用户确认过本次会话的低亮度设置(确认后不再重复拦截) */
const lowConfirmed = ref(false)
/** 5% 对应的亮度值,向上取整 */
const lowFloor = computed(() => Math.ceil(((maxBrightness.value || 255) * MIN_PERCENT) / 100))
/** 把滑条与已应用值拉回安全下限 */
function snapToFloor() {
if (sliderEl.value) sliderEl.value.value = lowFloor.value
return lowFloor.value
}
async function applyBrightness(value, { silent = false } = {}) {
try {
await status.setBrightness(value)
lastApplied = value
// 回到安全区以上后重置确认状态:下次再往下滑会重新提醒
// 注意用严格大于:确认后应用的就是下限值本身,等于时不应重置
if (value > lowFloor.value) lowConfirmed.value = false
if (!silent) snackbar(`亮度已设为 ${value}`)
} catch (e) {
if (!silent) snackbar(`设置失败: ${e.message}`)
}
}
/** 拖动过程中(input 事件):先做低亮度拦截,再按比例节流应用 */
/** 拖动过程中(input 事件)按比例阈值应用 */
async function onSliderInput(event) {
const value = Number(event.target.value)
const max = maxBrightness.value || 255
// 低亮度保护:未确认前直接拦在安全下限,避免滑到伪黑屏
if (!lowConfirmed.value && value < lowFloor.value) {
const floored = snapToFloor()
if (!confirmLowOpen.value) {
pendingValue.value = floored
confirmLowOpen.value = true
}
return
}
if (lastApplied === null) {
lastApplied = currentBrightness.value
}
@@ -101,29 +73,23 @@ async function onSliderInput(event) {
async function onSliderChange(event) {
const value = Number(event.target.value)
// 未确认低亮度时,松手也不允许落在安全下限之下
if (!lowConfirmed.value && value < lowFloor.value) {
pendingValue.value = lowFloor.value
snapToFloor()
const pct = Math.round((value / maxBrightness.value) * 100)
if (pct < 5) {
pendingValue.value = value
confirmLowOpen.value = true
return
}
await applyBrightness(value)
lastApplied = value
}
/** 取消:保持在安全下限,不写节点 */
function cancelLow() {
confirmLowOpen.value = false
if (sliderEl.value) sliderEl.value.value = lowFloor.value
if (sliderEl.value) sliderEl.value.value = currentBrightness.value
}
/** 确认:本次会话放开低亮度限制,并应用目标值 */
async function confirmLow() {
confirmLowOpen.value = false
lowConfirmed.value = true
await applyBrightness(pendingValue.value)
}
</script>
@@ -184,7 +150,7 @@ async function confirmLow() {
<ConfirmDialog
:open="confirmLowOpen"
headline="亮度低于 5%"
:description="`低于 ${MIN_PERCENT}% 可能让屏幕看起来像黑屏。\n确认后将临时放开该限制。`"
description="继续可能让屏幕接近黑屏,确定要设置吗?"
confirm-text="仍然设置"
danger
@confirm="confirmLow"