All Projects → cioccarellia → Kite

cioccarellia / Kite

Licence: apache-2.0
🪁 Android Resources Wrapper Library

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Kite

Localizer-Android
Gradle plugin which simplifies Android string resources & translations synchronization with POEditor.
Stars: ✭ 21 (-83.46%)
Mutual labels:  strings, resources
Dynamic Support
A complete library to build Android apps with a built-in theme engine.
Stars: ✭ 218 (+71.65%)
Mutual labels:  library, color
Colored
🎨 Mirror of colored library repository
Stars: ✭ 98 (-22.83%)
Mutual labels:  library, color
tasarimcilar-ve-yazilimcilar-icin-kaynak-arsivim
Tasarım ve yazılım ile ilgili 2017 yılından günümüze kadar geçen zamanda toplamış olduğum arşivimi sizle ile paylaşıyorum. Ne mi var her şey...
Stars: ✭ 276 (+117.32%)
Mutual labels:  color, resources
Swiftuix
Extensions and additions to the standard SwiftUI library.
Stars: ✭ 4,087 (+3118.11%)
Mutual labels:  library, color
Bashmultitool
A library for bash shell program containing useful functions. Can be imported into scripts to create colourful and functional scripts and TUIs.
Stars: ✭ 27 (-78.74%)
Mutual labels:  library, color
Smartmaterialspinner
The powerful android spinner library for your application
Stars: ✭ 108 (-14.96%)
Mutual labels:  library, color
Livesplit Core
livesplit-core is a library that provides a lot of functionality for creating a speedrun timer.
Stars: ✭ 124 (-2.36%)
Mutual labels:  library
Parser Php
Browser sniffing gone too far — A useragent parser library for PHP
Stars: ✭ 1,626 (+1180.31%)
Mutual labels:  library
Keita
My personal toolkit for PyTorch development.
Stars: ✭ 124 (-2.36%)
Mutual labels:  library
Awesome Sweden
A curated list of awesome things to use when coding for the Swedish market.
Stars: ✭ 124 (-2.36%)
Mutual labels:  resources
Awesome Data Science Viz
💥 📈 A curated list of data science, analysis and visualization tools
Stars: ✭ 124 (-2.36%)
Mutual labels:  resources
Yowish.vim
A dark & yellowish vim colorscheme
Stars: ✭ 125 (-1.57%)
Mutual labels:  color
Round Anything
A set of OpenSCAD utilities for adding radii and fillets, that embodies a robust approach to developing OpenSCAD parts.
Stars: ✭ 122 (-3.94%)
Mutual labels:  library
Pulsesensorplayground
A PulseSensor library (for Arduino) that collects our most popular projects in one place.
Stars: ✭ 126 (-0.79%)
Mutual labels:  library
Typed
The TypeScript Standard Library
Stars: ✭ 124 (-2.36%)
Mutual labels:  library
Libideviceactivation
A library to handle the activation process of iOS devices
Stars: ✭ 126 (-0.79%)
Mutual labels:  library
Arduinoxinput
XInput library for USB capable Arduino boards
Stars: ✭ 126 (-0.79%)
Mutual labels:  library
Java Ds Algorithms
Data Structures and Algorithms in Java
Stars: ✭ 125 (-1.57%)
Mutual labels:  strings
Ui Ux
📝 Curated list for UI/UX Designers
Stars: ✭ 125 (-1.57%)
Mutual labels:  resources

Kite

Android Resource Wrapper Library.

Download from MavenCentral Android Arsenal CircleCI Android CI Codacy Kotlin Android Min Sdk Android Compile Version License

TLDR

Fed up with typing ContextCompat, resources and context all over your apps to access your resources? Say no more.

Gradle
dependencies {
    implementation 'com.github.cioccarellia:kite:1.1.2'
}
Kotlin DSL
dependencies {
    implementation("com.github.cioccarellia:kite:1.1.2")
}
Maven
<dependency>
    <groupId>com.github.cioccarellia</groupId>
    <artifactId>kite</artifactId>
    <version>1.1.2</version>
    <type>pom</type>
</dependency>
  • :kite: Access all app resources with one unified syntax.
  • :dna: Null safe layer between the Android framework java code and your app.
  • :ice_cube: Transparent and lightweight wrapper.
  • 🔒 Extensive built-in checks.
  • ⚡️ Easy to implement in existing apps.
  • ❤️ Kotlin powered, 100%.
val text = Kite.string[R.string.welcome_back]

Usage

Kite is a handy and lightweight android library which aims at reducing redundancy and decreasing android code complexity. It encloses and simplifies resource access within the Kite domain, and abstracts away the implementation logic needed to fetch the desired value, making interactions with the android framework smooth and frictionless. To get started initialize kite (ideally inside your Application class) and pass to it the application context.

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Kite.fly(this)
    }
}

You're all set. You can now import the Kite object, select whichever resource category you want to access and fetch it using the resource id and the bracket notation [].

Beware: kite can not and will not save you from the mess that is dealing with Android Context. After all, kite is some cleverly placed syntactic sugar over those same android methods you are used to: kite itself holds a reference to Context. It will, however, unify and thoroughly uniform your experience with dealing with all android related resource extraction operations, which can turn to be extremely practical. It may also save you from typing again ContextCompat in your life. That's the precise reason kite was created.

Samples

// 🪁 Kite
fab.rippleColor =         Kite.color[R.color.md_light_lime]
fab.backgroundTintList =  Kite.colorStateList[R.color.md_lime]
fab.text =                Kite.string[R.string.unread_notifications, "69"]
fab.isVisible =           Kite.bools[R.bool.show_fab]

// Standard
fab.rippleColor =         ContextCompat.getColor(context, R.color.md_light_lime)
fab.backgroundTintList =  ColorStateList.valueOf(R.color.md_lime)
fab.text =                appContext.getString(R.string.unread_notifications, "69")
fab.isVisible =           resources.getBoolean(R.bool.show_fab)

Context Switching

One clear disadvantage to using kite with respect to doing things the old way is choosing which context to use. That's why Kite comes packed with extension functions for permanent change / temporary switch the in-use context, so that you have full control over which context is used to do what.

  • changeContext can be invoked on Kite and on any KiteFetcher, it is chainable and it permanently changes the context reference kite holds.
Kite.changeContext(this)
Kite.integer.changeContext(this)[R.integer.threads]
  • runWith can be invoked on any KiteFetcher, it is chainable and it temporarily runs the passed lambda in the desired context.
Kite.color.runWith(this) { color ->
    button.setBackground(
        color[R.color.colorAccent]
    )
}

Supported Resources

Kite delegates resource collection to KiteFetchers. Those classes contain a well defined implementation of the actual process of converting the given id to the output type.

Resource Type AAPT class Fetcher Input Output Implementation API Variants
Strings R.string Kite.string @StringRes string: Int String Context.getString() / formatArgs
Plurals R.plurals Kite.plural @PluralRes plural: Int, quantity: Int String Resources.getQuantityString() / formatArgs
Texts R.string Kite.text @StringRes text: Int CharSequence Context.getText() / /
Color R.color Kite.color @ColorRes color: Int @ColorInt Color ContextCompat.getColor() / /
ColorStateLists R.color Kite.colorStateList @ColorRes colorStateList: Int ColorStateList ContextCompat.getColorStateList() / /
Drawables R.drawable Kite.drawable @DrawableRes drawable: Int Drawable ContextCompat.getDrawable() / Resources.Theme?
Layouts R.layout Kite.layout @LayoutRes layout: Int XmlResourceParser Resources.getLayout() / /
Integer R.integer Kite.integer @IntegerRes integer: Int Int Resources.getInteger() / /
Booleans R.bool Kite.booleans @BoolRes boolean: Int Boolean Resources.getBoolean() / /
Dimensions R.dimen Kite.dimension @DimenRes dimensions: Int Float Resources.getDimensions() / /
Fractions R.fraction Kite.fraction @FractionRes fraction: Int, base: Int, pbase: Int Float Resources.getFraction() / /
Fonts R.font Kite.font @FontRes font: Int Typeface Resources.getFont() 26 /
Animations R.anim Kite.animation @AnimRes animation: Int Animation AnimationUtils.loadAnimation() / /
Interpolators R.interpolator Kite.interpolation @InterpolatorRes interpolator: Int Interpolator AnimationUtils.loadInterpolator() / /
IntArray R.array Kite.intArray @ArrayRes intArray: Int IntArray Resources.getIntArray() / /
StringArray R.array Kite.stringArray @ArrayRes stringArray: Int Array<out String> Resources.getStringArray() / /
TypedArray R.array Kite.typedArray @ArrayRes typedArray: Int TypedArray Resources.obtainTypedArray() / /
Identifiers R.id Kite.identifier name: String, defType: String, defPackage: String Int Resources.getIdentifier() / /
Xmls R.xml Kite.xml @XmlRes xml: Int XmlResourceParser Resources.getXml() / /
Raws R.raw Kite.raw @RawRes raw: Int InputStream Resources.openRawResource() / TypedValue

⚠️ Known Issues

  • Annotation checks over resource function parameters (functions which take as argument some annotated value, like @ColorRes, @StringRes) are not extensively performed by Android Studio, when using kotlin operator functions. I created a bug report @ google issue tracker here. Hope to see it fixed soon. By 2030 hopefully.

Kite Puns

  • A kite usually comes with different colors
  • A kite is flown and controlled with strings
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].