mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Add KDoc to the services/toolbox API interfaces
Add the interface level docs that StringProvider, SystemClock and BuildVersionSdkIntProvider were missing, document ExternalIntentLauncher.launch, and add the remaining @param entries. Each doc says why the abstraction exists rather than restating the signature: these wrap Context, Build.VERSION and the clock so that presenters can be tested without them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
@@ -14,5 +14,10 @@ import android.content.Intent
|
||||
* Used to launch external intents from anywhere in the app.
|
||||
*/
|
||||
interface ExternalIntentLauncher {
|
||||
/**
|
||||
* Starts the given intent, doing nothing when no installed app can handle it.
|
||||
*
|
||||
* @param intent the intent to hand over to the system.
|
||||
*/
|
||||
fun launch(intent: Intent)
|
||||
}
|
||||
|
||||
+11
@@ -10,6 +10,9 @@ package io.element.android.services.toolbox.api.sdk
|
||||
|
||||
import androidx.annotation.ChecksSdkIntAtLeast
|
||||
|
||||
/**
|
||||
* Exposes the running Android API level, injected rather than read from `Build.VERSION` so tests can pretend to be on any version.
|
||||
*/
|
||||
interface BuildVersionSdkIntProvider {
|
||||
/**
|
||||
* Return the current version of the Android SDK.
|
||||
@@ -18,6 +21,9 @@ interface BuildVersionSdkIntProvider {
|
||||
|
||||
/**
|
||||
* Checks the if the current OS version is equal or greater than [version].
|
||||
*
|
||||
* @param version the minimum API level required.
|
||||
* @param result computed and returned only when the requirement is met.
|
||||
* @return A `non-null` result if true, `null` otherwise.
|
||||
*/
|
||||
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
|
||||
@@ -29,6 +35,11 @@ interface BuildVersionSdkIntProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the current OS version is equal or greater than [version].
|
||||
*
|
||||
* @param version the minimum API level to test against.
|
||||
*/
|
||||
@ChecksSdkIntAtLeast(parameter = 0)
|
||||
fun isAtLeast(version: Int) = get() >= version
|
||||
}
|
||||
|
||||
+7
@@ -11,6 +11,9 @@ package io.element.android.services.toolbox.api.strings
|
||||
import androidx.annotation.PluralsRes
|
||||
import androidx.annotation.StringRes
|
||||
|
||||
/**
|
||||
* Resolves Android string resources outside of Composable and Context-aware code, so presenters stay testable.
|
||||
*/
|
||||
interface StringProvider {
|
||||
/**
|
||||
* Returns a localized string from the application's package's
|
||||
@@ -39,6 +42,10 @@ interface StringProvider {
|
||||
* Returns a localized formatted string from the application's package's
|
||||
* default string table, substituting the format arguments as defined in
|
||||
* [java.util.Formatter] and [java.lang.String.format], based on the given quantity.
|
||||
*
|
||||
* @param resId Resource id for the plurals.
|
||||
* @param quantity The quantity used to select the plural form.
|
||||
* @param formatArgs The format arguments that will be used for substitution.
|
||||
*/
|
||||
fun getQuantityString(@PluralsRes resId: Int, quantity: Int, vararg formatArgs: Any?): String
|
||||
|
||||
|
||||
+4
@@ -8,6 +8,10 @@
|
||||
|
||||
package io.element.android.services.toolbox.api.systemclock
|
||||
|
||||
/**
|
||||
* Reads the current time, injected rather than called statically so that tests can control it.
|
||||
*/
|
||||
fun interface SystemClock {
|
||||
/** The current wall-clock time in milliseconds since the epoch. */
|
||||
fun epochMillis(): Long
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user