diff --git a/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/intent/ExternalIntentLauncher.kt b/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/intent/ExternalIntentLauncher.kt index ba34a6a716..acd58c9f64 100644 --- a/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/intent/ExternalIntentLauncher.kt +++ b/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/intent/ExternalIntentLauncher.kt @@ -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) } diff --git a/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/sdk/BuildVersionSdkIntProvider.kt b/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/sdk/BuildVersionSdkIntProvider.kt index 26bbe23548..40b2b2aac8 100644 --- a/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/sdk/BuildVersionSdkIntProvider.kt +++ b/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/sdk/BuildVersionSdkIntProvider.kt @@ -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 } diff --git a/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/strings/StringProvider.kt b/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/strings/StringProvider.kt index 4570e09921..f82d542f7e 100644 --- a/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/strings/StringProvider.kt +++ b/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/strings/StringProvider.kt @@ -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 diff --git a/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/systemclock/SystemClock.kt b/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/systemclock/SystemClock.kt index 5436b44354..52a189f607 100644 --- a/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/systemclock/SystemClock.kt +++ b/services/toolbox/api/src/main/kotlin/io/element/android/services/toolbox/api/systemclock/SystemClock.kt @@ -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 }