Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cioccarellia committed Nov 19, 2020
2 parents 6736db0 + f54c83c commit 8ade56b
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</p>

## TLDR
Fed up with typing ContextCompact, recources and context all over your apps to access your resources? Say no more.
Fed up with typing `ContextCompact`, `recources` and `context` all over your apps to access your resources? Say no more.
```gradle
implementation 'com.cioccarellia:kite:1.0.0-beta1'
```

- :kite: Access app resources with one contextless unified syntax
- :dna: Null safe layer between Android framework and your app
- :heart: Kotlin powered.
- :heart: Kotlin powered, 100%.

```kotlin
class App : Application() {
Expand All @@ -38,6 +38,8 @@ class App : Application() {
}
```

## Sample Usage

```kotlin
// Kite
fab.rippleColor = kite.color[R.color.md_light_lime]
Expand All @@ -51,21 +53,28 @@ fab.text = appContext.getString(R.string.ride)
```

## Supported Resources
- Strings
- Plurals
- Texts
- Color
- ColorStateLists
- Drawables
- Dimensions
- Animations
- Interpolators
- Layouts
- Booleans
- IntArray
- StringArray
- TypedArrays
- Identifiers
- Xmls
- Raws
- Fonts
| Resource Type | AAPT class | Namespace | 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?` |
| Dimensions | R.dimen | `Kite.dimension` | `@DimenRes dimensions: Int` | `Float` | `Resources.getDimensions()` | / | / |
| Animations | R.anim | `Kite.animation` | `@AnimRes animation: Int` | `Animation` | `AnimationUtils.loadAnimation()` | / | / |
| Interpolators | R.anim | `Kite.interpolation` | `@InterpolatorRes interpolator: Int` | `Interpolator` | `AnimationUtils.loadInterpolator()` | / | / |
| Layouts | R.layout | `Kite.layout` | `@LayoutRes layout: Int` | `XmlResourceParser` | `Resources.getlayout()` | / | / |
| Booleans | R.bool | `Kite.booleans` | `@BoolRes bolean: Int` | `Boolean` | `Resources.getBoolean()` | / | / |
| IntArray | R.array | `Kite.intArray` | `@ArrayRes intArray: Int` | `IntArray` | `Resources.getIntArray()` | / | / |
| StringArray | R.array | `Kite.stringArray` | `@ArrayRes stringArray: Int` | `Array<out String>` | `Resources.getStringArray()` | / | / |
| TypedArrays | 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` |
| Fonts | R.font | `Kite.font` | `@FontRes font: Int` | `Typeface` | `Resources.getFont()` | 26 | / |
| Integer | R.integer | `Kite.integer` | `@IntegerRes integer: Int` | `Int` | `Resources.getInteger()` | / | / |
| Fraction | R.fraction | `Kite.fraction` | `@FractionRes fraction: Int`, `base: Int`, `pbase: Int` | `Float` | `Resources.getFraction()` | / | / |

## Known Issues
- Annotation checks over resource 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 to google issuetracker [here](https://issuetracker.google.com/issues/173628041).

0 comments on commit 8ade56b

Please sign in to comment.