Affogato is a multipurpose library for Android, Jetpack Compose and Kotlin.

Overview

Version Kotlin API License MIT

affogato_img

Affogato

Affogato is a multipurpose library for Jetpack Compose, Android and Kotlin.

Core-ktx

Core-ktx is a Kotlin library that provides a set of Kotlin extensions. Like collections, operations, string, math, random, date time, color, block scope and try-catch functions. Also, TimeAgo is my favorite extension for times πŸ˜„ .

TimeAgo.format(now()) // a moment ago
now().timeAgo(locale = TimeAgo.Locale.EN) // a moment ago

Coroutines

Coroutines module contains suspended try-catch from Core-ktx and DispatchersProvider for handling coroutines context in main and test source.

// Normal way
suspend fun foo() = withContext(Dispatchers.Default) {
  return try {
    // do something return value
  } catch (_: Exception) {
    null
  }
}

// Affogato way
suspend fun foo() = suspendedTryCatchNull {
  // do something return value
}

Logger

Logger module contains a simple logger for Android. It's a wrapper for Log andLogger with some extensions.

// Setup
Logger.tag = "MyApp"

Logger.isDebug = BuildConfig.DEBUG // if debug mode false onRelease will be called.
Logger.onRealease = { tag, message, throwable ->
  // do something
}

// Extension
logcat { "Hello Affogato" }
logcat(tag = "TAG") { "Hello Affogato" }
logcat(LogLevel.INFO) { "Hello Affogato" }
try {
  // do something
} catch (e: Exception) {
  logcat(throwable = e) { "Hello Affogato" }
}

Metrica-ktx

This module adds Yandex Metrica to your project. You can use it for crashlytics and reporting events and push notifications.

yandexMetrica("api-key") {
  // configuration
}

@Serializable
data class Foo(val bar: String)
YandexMetricaX.reportEvent("event_name", Foo("bar"))

Okhttp

Okhttp builder is part of this module. You can use it for building okhttp client with a simple syntax. Also, you can track download and upload progress with DownloadStreamResponseBody and UploadStreamRequestBody.

val client = okHttp {
  addInterceptor(HttpLoggingInterceptor())
  cache(Cache(cacheDir, cacheSize))
}

Structure

This module contains useful structure class like DataState and EntityMapper. Also, it contains SingletonHolder for creating singleton classes or ObjectPool for creating heavy objects to save time. You can use checker class for validate phone, email and password.

class SharedPref private constructor(private val context: Context) {
  // ...
  companion object : SingletonHolder<SharedPref, Context>(::SharedPref)
}

StringPool["key"] = "token"
StringPool["key"] // token

Phone("09123456789").isValid() // true
Phone("09123456789").format("IR") // +98 912 345 6789

Compose Unit Size

The unit is one of the Jetpack Compose modules of this library, which can support relative screen sizes in sdp, ssp and custom create with @Dimen. Also, we can use rememberWindowSize() to know in which device we are (Compact, Medium, Expanded) or use postureState to build adaptive and responsive UIs in Foldables.

@Dimen(type = "dp", values = ["320:70", "480:80", "600:180", "720:180"])
val icon = 80.dp

dimen.icon // 80.dp in device with width 480.dp

Links

Affogato is currently available for maven/gradle builds at Jitpack ( read Getting started).

Download

Gradle Setup

Step 1. Add the JitPack repository to your build.gradle file

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.ghasemdev.affogato:AFFOGATO_MODULE:AFFOGATO_VERSION'
}

Maven Setup

Step 1. Add the JitPack repository to your build.gradle file

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Step 2. Add the dependency

<dependency>
    <groupId>com.github.ghasemdev.affogato</groupId>
    <artifactId>AFFOGATO_MODULE</artifactId>
    <version>AFFOGATO_VERSION</version>
</dependency>

License

The MIT License (MIT)

Copyright (c) 2022 ghasemdev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You might also like...
Math Your Brain is a math game built using Jetpack Compose and Modern MVVM Architecture
Math Your Brain is a math game built using Jetpack Compose and Modern MVVM Architecture

Math Your Brain is a math game built using Jetpack Compose and Modern MVVM Architecture. I built this so that programmers learning Jetpack Compose Can use this repository as a learning material for Jetpack Compose.

Android & iPhone payments apps built w/ SwiftUI & Jetpack Compose
Android & iPhone payments apps built w/ SwiftUI & Jetpack Compose

Android & iPhone payments apps built w/ SwiftUI & Jetpack Compose, the apps persist data locally w/ SQLDelight and Remote w/ Firebase., Payments w/ Stripe and are architected to emphasize code sharing

Add Bubble Navigation Bar in Android Jetpack Compose.
Add Bubble Navigation Bar in Android Jetpack Compose.

BubbleNavigationBarCompose How it looks Setup Open the file settings.gradle (it looks like that) dependencyResolutionManagement { repositoriesMode

Spinwheel for Android using Jetpack Compose.
Spinwheel for Android using Jetpack Compose.

SpinwheelCompose SpinWheel in Android using Jetpack Compose. How it looks Usage val textList by remember { mutableStateOf( listOf("Pie 1"

PhotoSearch is an Android TV app using Jetpack Compose.
PhotoSearch is an Android TV app using Jetpack Compose.

PhotoSearch What's PhotoSearch? πŸš€ PhotoSearch is an Android TV app using Jetpack Compose UI. The purpose of this project is to try new Android techno

AnKunv2 is an Android application built with Jetpack Compose to stream anime on demand.
AnKunv2 is an Android application built with Jetpack Compose to stream anime on demand.

AnKunv2 AnKunv2 is an app a bit similar to YouTube but to stream anime. Updated from AnKun using Jetpack Compose. Tech Stack Kotlin AndroidX UI - Jetp

Add Expandable Horizontal Pager in Android Jetpack Compose.
Add Expandable Horizontal Pager in Android Jetpack Compose.

ExpandableHorizontalPagerCompose Add Expandable Horizontal Pager in Android Jetpack Compose. How it looks Usage BoxWithConstraints( modifier = Mod

Add Ios Swipe Search TextField Component in Android Jetpack Compose.
Add Ios Swipe Search TextField Component in Android Jetpack Compose.

IosSwipeSearchCompose Add Ios Swipe Search TextField Component in Android Jetpack Compose. How it looks Usage val text = remember { mutableStateOf("")

New style for app design Online Sunglasses Shop App UI made in Jetpack Compose.πŸ˜‰πŸ˜Ž
New style for app design Online Sunglasses Shop App UI made in Jetpack Compose.πŸ˜‰πŸ˜Ž

JetSunglassUI-Android New style for app design Online Sunglasses Shop App UI made in Jetpack Compose. πŸ˜‰ 😎 (Navigation Components, Dagger-Hilt, Mater

Comments
  • [Feature Request] Allow TimeAgo.format to not add prefix or suffix

    [Feature Request] Allow TimeAgo.format to not add prefix or suffix

    Is your feature request related to a problem? Please describe.

    Allow TimeAgo.format to not add prefix or suffix

    The function of displaying duration can be realized by hiding prefix or suffix.

    Describe the solution you'd like

    fun format(
        date: Long,
        locale: String = default,
        clock: Long = nowInMilliseconds(),
        minCutOff: DateLimitation = None,
        isWeekFormatEnabled: Boolean = false,
        allowFromNow: Boolean = false,
    +    appendPrefix: Boolean = true,
    +    appendSuffix: Boolean = true
    ): String
    
    opened by ShirasawaSama 0
Releases(1.5.2)
  • 1.5.0(Aug 22, 2022)

    πŸš€ Features

    • Add okhttp-android module
      • okhttp builder extension okhttp {} , Response.new {} and OkHttpClient.new {}.
      • download and upload progress listener DownloadStreamResponseBody, UploadStreamRequestBody.
    • Add logger-android module
      • LogLevel enum.
      • logcat extension.
      • Singleton Logger.

    πŸ’₯ Breaking Changes

    • Rename checker class from structure module.
    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Aug 21, 2022)

    πŸš€ Features

    • Add New Structure Class.
      • lazy singleton object
      • object pool pattern
      • validator class EmailChecker, PasswordChecker, PhoneChecker and IRPhoneChecker
    • Add Metrica Module.
      • metrica builder yandexMetrica("api-key") {}, yandexMetricaConfig("api-key") {} , withLogs(isDebugMode), withSessionTimeout(duration)
      • metrica reporter for serialized class YandexMetricaX.reportEvent("key", data-class)
      • metrica profile builder metricaProfile {}, withValue(Int)

    πŸ’₯ Breaking Changes

    • Remove additional classes from affogato-coroutines-android

    πŸ’­ Other

    • rename block -> runBlock
    • rename isNotNullOrEmpty -> isNotNullNotEmpty, isNotNullOrBlank -> isNotNullNotBlank
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Aug 18, 2022)

    πŸš€ Features

    • Add local const val to TimeAgo class instead of used invalid locale strings.
    • New structure module with below features:
      • EntityMapper - Convert entity to domain model and vice versa.
      • DataState - Contains three different state -> Loading, Error and Success.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Aug 16, 2022)

  • 1.1.2(Aug 15, 2022)

  • 1.1.1(Aug 14, 2022)

    πŸ’₯ Breaking Changes

    • Rename date parameter in LookupMessages to dateInMillis
    • Rename toString -> format in all datetime extensions

    πŸ› Fixes

    • Fix duplicated $ sign in ar and fa TimeAgo Messages
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Aug 13, 2022)

    πŸš€ Features

    • Collections Function (built-in and get functions based on Range and Progression, sorting map, rotate, head, tail and ...)
    • Operations Function (collection operation add, sub, mul, div and rem, string times and some boolean operator)
    • String Function (formatting and get functions based on Range and Progression, format, removeDecimalPart, rotate and ... )
    • Math Function (math for collection like median, std, variance and more, BD and BI, round with digit, infix pow and degree to radian, ... )
    • Random Function (choice, choices and nextInt-long based on Progression)
    • Date Time Function (convert all type of date time to each other :), now functions and time ago)
    • Color Converter (rgb to hex, hex to rgb)
    • Block Scope Function
    • Try-Catch Functions and Counter
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Jul 27, 2022)

    πŸš€ Features

    • sdp and ssp unit
    • Dimen tag for create auto dimensions
    • Window Size, Global Window Size, rememberWindowSize()
    • Window Orientation, isLandscape
    • Posture, postureState, postureFlow, ...
    • Hinge Size, hingeWidthDp, hingeHeightDp, ...
    • Window Layout Info, windowLayoutInfoState, windowLayoutInfo, ...
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-beta05(Jul 26, 2022)

  • 1.0.0-beta04(Jul 16, 2022)

  • 1.0.0-beta03(Jul 16, 2022)

  • 1.0.0-beta02(Jul 16, 2022)

  • 1.0.0-beta01(Jul 15, 2022)

  • 1.0.0-alpha05(Jul 14, 2022)

  • 1.0.0-alpha04(Jul 13, 2022)

  • 1.0.0-alpha03(Jul 13, 2022)

Owner
Ghasem Shirdel
Android Developer with Kotlin
Ghasem Shirdel
Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

JetBrains 10k Jan 7, 2023
Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

Mohammadali Rezaei 7 Nov 28, 2022
Clean Android multi-module offline-first scalable app in 2022. Including Jetpack Compose, MVI, Kotlin coroutines/Flow, Kotlin serialization, Hilt and Room.

Android Kotlin starter project - 2022 edition Android starter project, described precisely in this article. Purpose To show good practices using Kotli

Krzysztof DΔ…browski 176 Jan 3, 2023
FirestoreCleanArchitectureApp is an app built with Kotlin and Firestore that displays data in real-time using the MVVM Architecture Pattern. For the UI it uses Jetpack Compose, Android's modern toolkit for building native UI.

FirestoreCleanArchitectureApp FirestoreCleanArchitectureApp is an app built with Kotlin and Cloud Firestore that displays data in real-time using Andr

Alex 66 Dec 15, 2022
A ksp library to automatically generate navigation functions for jetpack compose.

Compose/Navigation/Generator ⚠️ This library is still under development and not considered stable! Content Introduction Usage Example: Single destinat

Steffen Eckardt 4 Sep 13, 2022
Ejemplo de App Android con Kotlin, Jetpack Compose, Retrofit y consumo de la API REST de PokΓ©mon

PokΓ©mon Jetpack Compose Ejemplo de App Android con Kotlin, Jetpack Compose, Retrofit y consumo de la API REST de PokΓ©mon Jetpack Compose Retrofit PokΓ©

Brais Moure 70 Jan 31, 2023
Build with Jetpack Compose & all modern techniques and architecture of android app development

IMDB Movie App Build with Jetpack Compose & all modern techniques and architecture of android app development ScreenShots ?? Built With ?? Kotlin - Fi

Jayant Kumar 7 Dec 17, 2022
Counterpart of onTouchEvent for Jetpack Compose and transform gesture with specific number of pointers

Counterpart of onTouchEvent for Jetpack Compose and transform gestures notify when last pointer is up number of pointer that are down or list of pointers that can be used to get details of events when gesture is on

Smart Tool Factory 19 Nov 19, 2022