Package-level declarations

Types

Link copied to clipboard

A BroadcastReceiver that calls goAsync and launches a coroutine to execute long-running tasks. The receive method is still executed on main thread, move to another thread as needed.

Link copied to clipboard
data class Email(val recipients: List<String>? = null, val subject: String? = null, val body: String? = null)

An object representing an email about to be senta with sendEmail.

Link copied to clipboard

Type of the Uri's scheme

Link copied to clipboard

Contract for picking ringtones. Returns one of:

Link copied to clipboard
open class WebClient(allowedHosts: List<String?>) : WebViewClient, DownloadListener

A web client that solves many problems of WebViewClient and provides a nice API to use. This client automatically sets JS as enabled. You can override this behavior by calling WebSettings.setJavaScriptEnabled. Only domains in allowedHosts will be opened in the webview, others will trigger WebClientListener.onForeignUrlEncountered. Don't forget to attach the client in onViewCreated and detach it in onDestroyView.

Link copied to clipboard

A listener for events that happen in WebClient

Properties

Link copied to clipboard

Create an android Spanned from this string by parsing it as an html text

Link copied to clipboard

If this uri is an http uri, will convert it to an https uri, otherwise do nothing

Link copied to clipboard

Get the current system AutofillManager if present.

Link copied to clipboard

Returns the currently used locale on the device. Returns the first locale the user has listed in the system settings.

Link copied to clipboard

Whether this uri is an http uri

Link copied to clipboard

Returns whether the system is set to 24-hour time format right now.

Link copied to clipboard

Get the LinkType of the current URI

Link copied to clipboard

Get the uri of this app's package.

Link copied to clipboard

Create a spannable string

Functions

Link copied to clipboard

Allows background activity start for this intent starting with SDK 34 (Upside down cake). On previous versions, does nothing.

Link copied to clipboard
fun Int.asColor(context: Context): Int

Uses the value of this int as a resource id to parse an android.graphics.Color object

Link copied to clipboard
fun Uri.asDeeplinkIntent(requestCode: Int, context: Context): PendingIntent

Use this Uri as a deeplink intent, i.e. open this uri in a new task.

Link copied to clipboard
fun Int.asDrawable(context: Context): Drawable?

Uses this int as a resource id to get a drawable

Link copied to clipboard

Changes the background color of the text to color.

Link copied to clipboard

Applies bold style to this string

Link copied to clipboard
Link copied to clipboard

If this is a color int, turns it into a hex string.

Link copied to clipboard
inline fun Context.dialNumber(numberUri: Uri, onNotFound: (e: ActivityNotFoundException) -> Unit)
Link copied to clipboard
inline fun Context.downloadFile(url: Uri, fileName: String, userAgent: String? = null, title: String = fileName, description: String? = null, mimeType: String? = null, notificationMode: Int = DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED, directory: String = Environment.DIRECTORY_DOWNLOADS, onFailure: (Exception) -> Unit)

Saves file using DownloadManager to users /sdcard/directory

Link copied to clipboard

Changes the color of the text to color.

Link copied to clipboard
@RequiresPermission(value = "android.permission.QUERY_ALL_PACKAGES")
fun PackageManager.getAppInfoCompat(packageName: String, flags: Int): ApplicationInfo

This function will query the ApplicationInfo of the packageName provided.

Link copied to clipboard

Get dimension dp value from your xml. When you use Resources.getDimension you get the amount of pixels for that dimen. This function returns a proper dp value just like what you wrote in your dimen.xml

Link copied to clipboard

Get an uri to a google play store page of this app.

Link copied to clipboard
@RequiresPermission(value = "android.permission.QUERY_ALL_PACKAGES")
fun PackageManager.getInstalledPackagesCompat(flags: Int = 0): List<PackageInfo>

Will get a full list of userspace apps installed on the device + some of the system apps that can be resolved.

Link copied to clipboard
fun Context.getResourceUri(resourceId: Int): Uri

Returns an uri to the given resourceId. This uri is NOT safe to store outside of app lifecycle!

Link copied to clipboard
fun ByteArray.hash(algorithm: String): ByteArray?
Link copied to clipboard

If this is a valid hex color string representation, returns its R, G and B components

Link copied to clipboard

Create a view intent from this uri.

Link copied to clipboard
inline fun <T : Any> intentFor(context: Context): Intent

Creates an intent to launch a given class. The type must be of an Android system component, such as an Activity.

Link copied to clipboard

Applies italic style to this string

Link copied to clipboard
inline fun <I> ActivityResultLauncher<I>.launchCatching(input: I, options: ActivityOptionsCompat? = null, onNotFound: (ActivityNotFoundException) -> Unit)

Start activity safely and handle errors where an activity is not found.

Link copied to clipboard

Open system notification settings for the current app.

Link copied to clipboard
inline fun Context.openAppPlayStorePage(onNotFound: (Exception) -> Unit)

Open the app's play store page.

Link copied to clipboard
inline fun Context.openBrowser(url: Uri, onAppNotFound: (e: ActivityNotFoundException) -> Unit)

Open the system browser for the specified url.

Link copied to clipboard

Open system notification settings for this app.

Link copied to clipboard

Open system overlay (SYSTEM_ALERT_WINDOW) settings.

Link copied to clipboard
inline fun <T : Parcelable> Intent.parcelable(key: String): T?

Obtain a parcelable object of type T from this Intent's extras

inline fun <T : Parcelable> Bundle.parcelable(key: String): T?

Obtain a parcelable object of type T from this Bundle.

Link copied to clipboard
@RequiresPermission(value = "android.permission.QUERY_ALL_PACKAGES")
fun PackageManager.queryIntentActivitiesCompat(intent: Intent, flags: Int = 0): List<ResolveInfo>

This function will query the resolvable (exported) activities of the target intent using this PackageManager. This is useful when you want to start another app.

Link copied to clipboard
fun Int.raw(context: Context): Uri

Returns an URI to this raw resource id.

Link copied to clipboard

Sets the size of this string to relative size size, which is a multiplier fraction larger than 0

Link copied to clipboard

Request a permission too schedule exact alarms from the user. This will bring the user to a page that prompts them to flip a switch for your app.

Link copied to clipboard

Display a prompt to ignore Doze mode optimizations and unrestrict AlarmManager APIs for this app.

Link copied to clipboard

Obtain a parcelable object of type T from this Intent's extras.

Obtain a parcelable object of type T from this Bundle.

Link copied to clipboard

Obtain a serializable object of type T from this Intent's extras

Obtain a serializable object of type T from this Bundle

Link copied to clipboard

Restart the current activity in a new task.

Link copied to clipboard
suspend fun Bitmap.scale(maxSize: Int): Bitmap

Rescales the bitmap

Link copied to clipboard
inline fun Context.sendEmail(mail: Email, onAppNotFound: (e: ActivityNotFoundException) -> Unit)

Open an email app to send the specified mail.

Link copied to clipboard
inline fun <T : Serializable> Intent.serializable(key: String): T?

Obtain a serializable object of type T from this Intent's extras

inline fun <T : Serializable> Bundle.serializable(key: String): T?

Obtain a serializable object of type T from this Bundle

Link copied to clipboard

span is a ..Span object like a ForegroundColorSpan or a SuperscriptSpan Spans this whole string

Link copied to clipboard
inline fun Context.shareAsText(text: String, onAppNotFound: (e: ActivityNotFoundException) -> Unit)

Open the system share sheet for sharing the specified text.

Link copied to clipboard

span is a ..Span object like a ForegroundColorSpan or a SuperscriptSpan Spans this whole string

Link copied to clipboard
inline fun Context.startActivityCatching(intent: Intent, onNotFound: (ActivityNotFoundException) -> Unit)

Start activity safely and handle errors where an activity is not found.

Link copied to clipboard

Strikes this string through

Link copied to clipboard

Sets this string to be drawn as a superscript (smaller font aligned to the bottom of the text)

Link copied to clipboard

Sets this string to be drawn as a superscript (smaller font aligned to the top of the text, such as numeric power)

Link copied to clipboard

Adds an underline to this string

Link copied to clipboard
@RequiresPermission(value = "android.permission.VIBRATE")
fun Vibrator.vibrateCompat(lengthMs: Long, usage: Int, amplitude: Int? = null)

Vibrates using this Vibrator for lengthMs milliseconds.

@RequiresPermission(value = "android.permission.VIBRATE")
fun Vibrator.vibrateCompat(waveform: LongArray, usage: Int, repeat: Int = -1)

Vibrates using this Vibrator using provided waveform.

Link copied to clipboard
@ChecksSdkIntAtLeast(parameter = 0, lambda = 1)
inline fun withApiLevel(versionCode: Int, since: () -> Unit)

Execute since if the current sdk version is at least versionCode. Version code comes from Build.VERSION_CODES.

@ChecksSdkIntAtLeast(parameter = 0, lambda = 2)
inline fun <R> withApiLevel(versionCode: Int, below: () -> R, since: () -> R): R

Execute since if the current sdk version is at least versionCode, otherwise execute below

Link copied to clipboard
fun SpannableString.withClickableSpan(clickablePart: String, onClickListener: () -> Unit): SpannableString

Create a span with a clickablePart of the text, and invokes the onClickListener on click.

Link copied to clipboard
@RequiresApi(value = 23)
inline fun Context.withPermission(permission: String, ifGranted: Context.(String) -> Unit)

Execute ifGranted if the permission has been granted, otherwise do nothing.

@RequiresApi(value = 23)
inline fun <T> Context.withPermission(permission: String, ifDenied: Context.(String) -> T, ifGranted: Context.(String) -> T): T

Execute ifGranted if the permission has been granted, otherwise execute ifDenied.