The same pass the server had, on the Kotlin side: comments restating what the code says are gone, and the ones recording a measurement, a constraint or an incident are kept but cut to a few lines each. 6540 comment lines to 5674, and 920 lines off the app. Two doc comments had drifted onto the item above the one they describe -- `contextAfter`'s onto `sessionWorking` in Events.kt, and `UsageMonitor`'s equivalent on the server was fixed in the previous commit. Each is back on its own item, which is the only non-comment line this diff moves. The comments are reflowed to the column limit at their own indentation: several were written wide, and ktfmt re-wrapped them into lines holding a single orphan word. `/tmp` script, not kept -- ktfmt is idempotent over the result, which is the check. Left alone deliberately: this codebase's remaining comment density is high because the comments carry things the code cannot say -- what a null means, what a number was measured against, which bug a guard exists for. Of the 238 one-line doc comments in the app, five were pure restatement of the name and were removed; the rest each say something the signature does not. ktfmtFormat, compileDebugKotlin, lintDebug and testDebugUnitTest pass; cargo test (127), clippy --all-targets and fmt still clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
28 lines
1.1 KiB
Kotlin
28 lines
1.1 KiB
Kotlin
package com.example.aiapp
|
|
|
|
import android.content.Context
|
|
import android.net.Uri
|
|
import com.example.wgapplink.ServerStore
|
|
|
|
/**
|
|
* Where the backend is and how to authenticate to it. Absent until the phone is enrolled -- by
|
|
* scanning the server's terminal QR (an `aiapp://enroll` URI the camera app hands to MainActivity)
|
|
* or by typing the fields into the settings screen.
|
|
*/
|
|
typealias ServerSettings = com.example.wgapplink.ServerSettings
|
|
|
|
/**
|
|
* This app's enrollment, which is the whole of what is product-specific about it.
|
|
*
|
|
* Both values are load-bearing. The scheme is what routes a scanned QR here rather than to Dev
|
|
* Updater, and the key alias names the Android Keystore key the token is already sealed under on
|
|
* every enrolled phone -- changing it would leave those phones reading as not enrolled.
|
|
*/
|
|
private val store = ServerStore(scheme = "aiapp", keyAlias = "aiapp-token-key")
|
|
|
|
fun loadServerSettings(context: Context): ServerSettings? = store.load(context)
|
|
|
|
fun saveServerSettings(context: Context, settings: ServerSettings) = store.save(context, settings)
|
|
|
|
fun parseEnrollmentUri(uri: Uri): ServerSettings? = store.parseEnrollmentUri(uri)
|