Android Utils is a library of useful helpers that allow to decrease amount of boilerplate code in Android development. Helpers are divided into modules according to their specifics.
Contains helpers related to Kotlin language.
Notable examples:
- valueOrNull runs operation and returns its result catching expected exception.
- Size information size units abstraction, allowing for basic arithmetic operations, conversions and formatting
implementation("com.github.forasoft.android-utils:kotlin-common:<version>")
Contains helpers related to Kotlin Coroutines library.
Notable examples:
- JobHolder
provides thread-safe methods to interact with
Job
. - OperationTracker tracks ongoing operations.
implementation("com.github.forasoft.android-utils:kotlin-coroutines:<version>")
Contains components that implement Clean Architecture patterns.
Notable examples:
implementation("com.github.forasoft.android-utils:clean:<version>")
Min SDK: 14
Contains helpers related to Android platform.
Notable examples:
- Context extensions
- ToastLogger
displays messages with
Toast
s. - Timber.plantTree allows to plant custom logging trees.
- Throttler allows to throttle operations with a certain delay.
implementation("com.github.forasoft.android-utils:platform-android:<version>")
Min SDK: 14
Contains helpers related to Android View framework.
Notable examples:
- Text allows to present text in different forms.
- View.fade* extensions allow to show and hide views with fade effect.
implementation("com.github.forasoft.android-utils:ui-view:<version>")
Min SDK: 16
Contains helpers related to Jetpack Compose framework.
Notable examples:
- Text allows to present text in different forms.
- Navigation helpers
constructs abstraction layer over Jetpack Navigation providing components such as
Destination
andNavGraphBuilder
extensions. - Side-effects for frequently used actions such as observing Lifecycle events, requesting screen orientation, controlling system bars state, etc.
- CollapsingTopBarLayout is Jetpack Compose implementation of CollapsingTopBar layout.
- Behavior is a set of components created to describe the behavior of some component and to manage its current behavior.
- PopupAnimated is Jetpack Compose Popup wrapper that allows to add enter/exit animations for the content.
implementation("com.github.forasoft.android-utils:ui-compose:<version>")
Min SDK: 21
Library that automatically saves application logs on the device.
Default limits:
- 5 MB — the maximum size of a single log file. When the limit is reached, the current file is closed and a new one is created.
- 20 — the maximum number of log files that can be stored on the device at the same time. When the limit is reached, the oldest file will be deleted to free space for a new one.
Default limits can be overridden with resources. See Customization paragraph for more information.
Log files are stored in the cache directory.
- Add the dependency for build types you need, for example, using
debugImplementation
. - Run the application.
- Open Logs activity either via launcher icon or application main activity shortcut.
Override the following resources within your application to change LogPecker default behavior:
forasoftandroidutils_log_pecker_is_enabled
— boolean resource that specifies if LogPecker is enabled and should write logs. Default value istrue
.forasoftandroidutils_log_pecker_is_dynamic_shortcut_enabled
— boolean resource that specifies if a dynamic shortcut that leads to LogPecker activity should be added to the application main activity. Default value istrue
.forasoftandroidutils_log_pecker_file_max_size_bytes
— integer resource that specifies the maximum size of a single log file in bytes. When the limit is reached, the current file is closed and a new one is created. Default value is5000000
, which corresponds to 5 MB.forasoftandroidutils_log_pecker_file_max_count
— integer resource that specifies the maximum number of log files that can be stored on the device at the same time. When the limit is reached, the oldest file will be deleted to free space for a new one. Default value is20
.
debugImplementation("com.github.forasoft.android-utils:logpecker:<version>")
Min SDK: 14
Contains helpers related to Android WebRTC library.
implementation("com.github.forasoft.android-utils:webrtc:<version>")
Min SDK: 21
Contains helpers related to OkHttp.
Notable examples:
- LoggingInterceptor for logging HTTP requests, responses and request exceptions in an opinionated way.
- UriRequestBody quick way to convert the Uri's content to RequestBody
implementation("com.github.forasoft.android-utils:thirdparty-okhttp:<version>")
Min SDK: 21
A wrapper around Android permissions that allows to work with permissions outside of the UI layer.
implementation("com.github.forasoft.android-utils:permissionmanager:<version>")
Min SDK: 21
- Add Jitpack repository to the repository list in your project-level
settings.gradle
filedependencyResolutionManagement { repositories { // ... maven { url = URI.create("https://jitpack.io") } } }
- Add the dependency of the needed module