Kotlin Android Utils


Source link: https://github.com/costular/kotlin-android-utils

Android utilities for easier and faster Kotlin programming.

Download

Gradle

compile 'com.costular:kotlin-utils:0.1'

How to use

It depends on utilities. Some of them just work as function extensions and you don't have to do anything special, just call a method like another one.

API

Activity

setFullScreen() showToolbar() // Support and native hideToolbar() // Support and native

Context

getClipboardManager() copyTextToClipboard(value: String) copyUriToClipboard(uri: Uri) getTextFromClipboard(): CharSequence getUriFromClipboard(): Uri? getPreferences(): SharedPreferences getPreferences(name: String, mode: Int): SharedPreferences

SharedPreferences

SharedPreferences.use(lambda)

It automatically applies after lambda execution

val sharedPrefs = context.getPreferences() sharedPrefs.edit {

  putBoolean("first_use", false) // This refers to sharedPrefs instance 
}

Versions

These methods are static.

doWithVersion(version: Int, lambda) // == doWithAtLeastVersion(version: Int, lambda) // >= doWithHigherVersion(version: Int, lambda) // > doWithLowerVersion(version: Int, lambda) // <

Example

doWithAtLeastVersion(21) {

  // Do something on Lollipop version or higher 
}

Resources

A simple dialog that allows users to choose a directory.

CipherSharedPrefs implements SharedPreferences with encryption layer and some new features.

How it works

When you put value to CipherSharedPreferences it is transformed to String and encrypted by provided ICipherHolder object, encrypted string is saved to SharedPreferences delegate.

A Kotlin library for reactive and boilerplate-free Shared Preferences in Android. With KPreferences you can use Kotlin's marvelous delegate concept to easily use Android's Shared Preferences. Features:

  • Boilerplate-free: Use SharedPreferences properties with one line and without edit, apply or ... boilerplate codes
  • Reactive: Use observables to listen for SharedPreferences changes without any memory leak
  • Custom types: You are not limited to a set of limited types that can be saved to the SharedPreferences .

An Android image picker and cropper library.

Android - FilePickerFilter Library.

Simple text counter animation. You need to set from number and to number! And this library will create animation. Also you can use different modes.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes