Repository navigation
KsuWebUI-SN 1.2-50
·
24 commits
to main
since this release
Tip
Highlights: this release adds a built-in WebUI file editor. A new Editor tab in the module console lets you browse a module's webroot folder, open text files with syntax colors, search, undo/redo and save them as root, all without leaving the app. Messages no longer pile up when shown quickly, and the APK is smaller. The new texts are translated in all five languages.
✨ New
- WebUI editor: open the module console and use the new Editor tab (placed before Network) with the Open Editor button. It opens a file browser for that module's WebUI files (
/data/adb/modules/<id>/webroot). Folders come first, files show their size, and the back button goes up one folder at a time. - Edit and save as root: tap a file to edit it. Files are saved with root access, so you can fix a module's WebUI directly on the device. The Save button is only active when something changed, and leaving with unsaved changes asks whether to Save, Discard or Cancel.
- Syntax colors: HTML, XML, SVG, CSS, JavaScript (
js,mjs,cjs,ts) and JSON files are colored, with separate colors for light and dark mode. Other file types open as plain text. - Undo and redo: step back and forward through your edits. Typing and deleting in a row are grouped together, and undoing back to the saved text marks the file as unchanged again.
- Find in file: the search bar finds text without caring about upper or lower case, highlights every match, shows the match count and jumps to the previous or next one. If text is selected when you open it, it is used as the search word.
- Safe file handling: only plain UTF-8 text files up to 1 MB can be edited. Larger or binary files show a clear message instead of opening. Files with Windows line endings (CRLF) are saved with the same line endings.
- Editor messages: new texts for an empty folder, a file that can't be opened, too large or not text, saved, and save failed.
🔁 Changed
- One message at a time: a new app message now replaces the one still on screen instead of waiting in line behind it. This applies to Copied, Refreshed, live reload, download and error messages.
- Smaller APK: only the app's own languages (English, Arabic, French, Polish, Japanese and Simplified Chinese) are packed into the app. Extra languages from libraries are left out.
- Translations: the new Editor texts are translated in Arabic, French, Polish, Japanese and Simplified Chinese with DeepL.
⚙️ Under the hood
For developers ⚠️ (Click to expand)
WebUI editor (new)
assets/eruda/editor.js(new): injected witherudaJs("editor")afternetworkin the console setup. It registers anEditortool in Eruda with a hint text and an Open Editor button, then moves its tab beforenetworkand callsupdateSlider(). The button sendsprompt('__ksu_editor__', ''). All of it is wrapped intry/catchand skipped if it was already added. Cost: it is only loaded together with the console (Eruda), so modules with the console off are not affected.WebViewHelper.kt: newPROMPT_EDITOR. The handler startsFileBrowserActivitywithEXTRA_ID(module id) andEXTRA_NAME(module name, or the id if empty), then confirms the prompt.ksuTexthas newopenEditorandeditorHintentries.FileBrowserActivity.kt(new): lists/data/adb/modules/<id>/webrootthrough the rootFileSystemManagerfromFileSystemService. It rejects an empty id or one containing/or... Entries are sorted folders first, then by lowercase name, and the list is loaded onApp.executor. A back callback goes up one folder and never leaveswebroot. The list reloads inonResumeso changes made in the editor show up. Files open inEditorActivity.EditorActivity.kt(new): loads and saves through the rootFileSystemManager(newOutputStream(false)to save).- Path check: the path must start with
/data/adb/modules/, contain/webroot/and contain no/../or trailing/.., otherwise the activity finishes. - Loading: files over
1_000_000bytes are refused (TooLarge). A0byte in the first 8192 bytes, or bytes that don't survive a UTF-8 round trip, are refused asNotText. CRLF is turned into\nwhile editing and turned back on save. - History:
Edit(start, removed, added)records from aTextWatcher. Typing and deleting in a row merge up to 200 characters, newlines break a merge. At most 300 edits and 3,000,000 characters are kept.isClean()compares the last edit and a signature with the saved marker, so undoing back to the saved text clears the dirty state. - Search: case-insensitive
indexOf, at most 3000 matches, 150 ms debounce, shown asMatchSpanandCurrentMatchSpanbackground spans. The count readsn/3000+when the limit is hit. - Highlighting: tokens are built on
Dispatchers.Defaultafter a 350 ms debounce (900 ms above 300,000 characters) and dropped if the text changed meanwhile. Only a window of the visible lines plus 20,000 characters on each side getsSyntaxSpans, and it is moved when scrolling gets within a quarter of the margin of its edge (80 ms debounce). - UI: edge-to-edge with the bottom padding following the keyboard,
adjustResize, andconfigChangesfororientation|screenSize|keyboardHidden|uiMode(the colors are redone on a dark mode switch). Back runs the search close, then the unsaved dialog (dialog_unsaved.xml).
- Path check: the path must start with
SyntaxHighlighter.kt(new): regex based tokenizer withLanguage(PLAIN,HTML,CSS,JS,JSON) chosen from the file extension (html,htm,xml,svg→ HTML;css;js,mjs,cjs,ts;json). Token kinds: comment, string, keyword, number, tag, attribute, property. HTML handles embedded script and style content by tokenizing it again with the matching language.AndroidManifest.xml: registersFileBrowserActivityandEditorActivity, bothexported="false".- Resources: new layouts
activity_file_browser,activity_editor,item_fileanddialog_unsaved, new menueditor_menu(save, undo, redo, search) and new iconsic_arrow_back,ic_arrow_down,ic_arrow_up,ic_close,ic_file,ic_folder,ic_redo,ic_saveandic_undo.
Messages
App.kt: newshowToast(context, text|@StringRes, duration). It keeps the lastToast, cancels it before showing the new one, uses the application context, and posts to the main thread when called from another thread.WebUIActivity.kt,WebViewHelper.kt,WebViewInterface.kt: everyToast.makeText(...).show()(root request, live reload, copied, refreshed, WebView crash, download start and failure, interface messages) now callsshowToast.
Build
app/build.gradle.kts:appLocalesis read from thevalues-*folders insrc/main/res(patternvalues-xx,values-xxx, with an optional region).localeFilters += listOf("en") + appLocaleskeeps only those languages in the APK, so a new language added withscripts/add_language.pyis included automatically.proguard-rules.pro:-assumenosideeffectsfor the fourkotlin.jvm.internal.Intrinsicsnull-check functions (checkNotNullParameter,checkNotNullExpressionValue,checkParameterIsNotNull,checkExpressionValueIsNotNull), which removes those checks from release builds.
Strings
- Strings: 20 new strings in English, Arabic, French, Polish, Japanese and Simplified Chinese:
eruda_open_editor,eruda_editor_hint,folder_empty,file_open_failed,file_too_large,file_not_text,file_saved,file_save_failed,unsaved_title,unsaved_message,action_save,action_discard,action_cancel,navigate_back,action_undo,action_redo,action_search,search_hint,search_previousandsearch_next. There are noTODO translatemarkers.