android-trinity is tiny proactive framework with much of the scaffolding code required to start a new Android Application.

Overview

android-trinity

This is tiny framework with much of the scaffolding code (with some nice utilities and prepared source code) required to start a new Android Application.

Background 📦

Yes, android studio might create a project for you, but there are missing parts, which I ALWAYS end up adding to every single project I create. This tiny Framework (I would say still scaffolding code) aims to solve this by making easy and fast to create an android project with the fundamental building blocks. Check the TODO section below for more information on the evolution and progress.

What does android-trinity provide? 🎨

Freedom. It uses standard tools but organized in such a way that facilitates android development. You can refactor or change anything but the idea is to have a robust starting point. All the wiring is done for you with the flexibility of being modified according to your needs.

What does android-trinity NOT INCLUDE? (likely to change if necessary in future versions)

  • DI. You should choose your Dependency Injection Framework.
  • NO Navigation Framework.
  • NO LiveData and ViewModel libraries since some Engineers might use other approaches at UI level like MVI, MVP, etc.
  • NO Kotlin Flow.
  • NO UI Layouts for Tablet or Android TV support.

Pre-defined Gradle Tasks

  • ./gradlew runStaticAnalysis
  • ./gradlew runTestCoverage
  • ./gradlew runUnitTests
  • ./gradlew runAcceptanceTests
  • ./gradlew compileApp
  • ./gradlew runApp

How to use it 👣

At the time being there are a couple of manual steps involved since we are at a very early stage. But we believe in sofware evolution right? So stay tuned and check both the How to Contribute and TODO List sections.

  • STEP 1: Click on Use this template to create a new repo.
  • STEP 2: Import the project in Android Studio
  • STEP 3: Rename packages according to your needs. com.fernandocejas.sample by default.

Using Test Helpers

Let's say you want to write tests (and you should ALWAYS do), As mentioned there are 3 classes which come into play and here examples of their usage:

  • UnitTest.kt: Unit Test base class which setup mocks for you (You only use the @Mockk annotation)
class FeatureFlagTest : UnitTest() {

    @Mockk prival val yourMock

    @Test
    fun `given a feature flag, when it is activated, then executes given logic block`() {
        val activeFlag = ActiveFeatureFlag()
        val fakeNavigator = mockk<Navigator>(relaxed = true)

        activeFlag whenActivated {
            fakeNavigator.doSomething()
            fakeNavigator.navigateToActiveFeature()
            fakeNavigator.doSomething()
        }

        verify(exactly = 1) { fakeNavigator.navigateToActiveFeature() }
        verify(exactly = 2) { fakeNavigator.doSomething() }
    }
  • AndroidTest.kt: Integration Test base class which setup mocks for you (You only use the @Mockk annotation). You might use this classes when they are Android Components involved. It is backed up by Robolectric.
class YourTestClass : AndroidTest() {

    @Mockk prival val yourMock

    @Test
    fun `given something, when something happens, then do something`() {
        TODO()
    }
  • AcceptanceTest.kt: UI Test base class which setup Espresso for you
class MainActivityTest: AcceptanceTest(MainActivity::class.java) {

    @Test
    fun checkToolBarTest() {
        onView(withId(R.id.toolbar)).check(matches(isDisplayed()))
    }
}

Feature Flags

Android-trinity includes a simple offline feature flags framework with a very simple api generated at compile time. If you want more information, refer to the introduced pull request. (TODO: Add more documentation)

Example of its usage:

Flag.Hello whenActivated { displayGreeting(R.string.hello) }

Quality Reports: Static Analysis

Quality Reports: Code Coverage

  • The tool chosen here is Jacoco due to its nature and popularity in the community.
  • The gradlew task and its configuration could be found inside quality.gradle.kts file.

TODO List

  • Gradle Tasks for Publishing to Google Play: App Bundles.
  • Automate the process from How to Use section: Idea: ./gradlew setupProject
  • Local Feature Flags.
  • Rename default packages to io.android-trinity or io.android.trinity.
  • ???
  • ???

How to Contribute

Nothing is set in stone here and things can change and evolve based on the community work and requirements. So if you want to contribute, feel free to open an issue and label it properly: Bug, Enhancement, etc.. or send a PR. Please both with a good descriptions of the intention, in order to facilitate review

License

Copyright 2021 Fernando Cejas

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

http://www.fernandocejas.com

Buy Me A Coffee

You might also like...
An android app will start when boot and exit after 1s. Develop for Redmi K40 to enable DC dimming automatically.
An android app will start when boot and exit after 1s. Develop for Redmi K40 to enable DC dimming automatically.

An android app will start when boot and exit after 1s. Develop for Redmi K40 to enable DC dimming automatically.

Android Package Inspector - dynamic analysis with api hooks, start unexported activities and more. (Xposed Module)
Android Package Inspector - dynamic analysis with api hooks, start unexported activities and more. (Xposed Module)

Inspeckage - Android Package Inspector Inspeckage is a tool developed to offer dynamic analysis of Android applications. By applying hooks to function

⌨️ A tool that gives you a massive head start when building Compose based apps. It saves you from time-consuming setup and configuration
⌨️ A tool that gives you a massive head start when building Compose based apps. It saves you from time-consuming setup and configuration

⌨️ A tool that gives you a massive head start when building Compose based apps. It saves you from time-consuming setup and configuration

weiV(pronounced the same as wave), a new declarative UI development framework based on the Android View system.

weiV(pronounced the same as wave) 简体中文 if ("weiV" == "View".reversed()) { Log.d( "weiV", "It means Inversion of Control, you shoul

Is a new version of code for my (Social media app) with Clean Architecture

Is a new version of code for my Social media app with Clean Architecture. I used most of Clean code tips with android, SOLID principles and design-patterns..

Todo List Application is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item
Todo List Application is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item

Todo List Application is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item

This Android application demonstrates new splash screen API launched by Google last year.
This Android application demonstrates new splash screen API launched by Google last year.

This Android application demonstrates new splash screen API launched by Google last year.

Simple application with some famous graph algorithm implemented by Jetpack Compose framework
Simple application with some famous graph algorithm implemented by Jetpack Compose framework

GraphAlgorithm This Application was implemented by Jetpack Compose framework. The dagger-hilt library was used for dependency injection and Room libra

A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Comments
  • Feature Flags Compact Offline Framework

    Feature Flags Compact Offline Framework

    This PR aims to Introduce a first version, which will let to define Feature Flags at compile time.

    API Usage:

            Flag.ExampleFeature whenActivated {
                doSomething()
            } otherwise {
                //do something else
            }
    

    Flags are defined at compile time per Product Flavor:

    File: FeatureFlags.kt

    /**
     * Defines a map for activated flags per product flavor.
     */
    object FeatureFlags {
        val activated = mapOf(
    
            //Enabled Features for DEV Product Flavor
            ProductFlavors.DEV to setOf(
                Features.FEATURE_HELLO,
                Features.FEATURE_BYE),
    
            //Enabled Features for INTERNAL Product Flavor
            ProductFlavors.INTERNAL to setOf(
                Features.FEATURE_BYE),
    
            //Enabled Features for PUBLIC Product Flavor
            ProductFlavors.PUBLIC to setOf(
                Features.FEATURE_HELLO))
    
    

    Compile time flags values should be assigned to Flag class for usage at code level:

    /**
     * Feature flags states (activated/deactivated) can be used as conditionals.
     *
     * ### Example:
     *
     * ```Flag.Conversations whenActivated { fn } otherwise { fn }```
     */
    internal sealed class Flag(enabled: Boolean) : FeatureFlag(enabled) {
    
        /**
         * Defined Feature Flags.
         * @see "FeatureFlags.kt" file for compile-time feature definition.
         */
        object Search : Flag(BuildConfig.FEATURE_HELLO)
        object Conversations : Flag(BuildConfig.FEATURE_BYE)
    }
    
    enhancement 
    opened by android10 0
Owner
Fernando Cejas
Head of Engineering @TIGNUM. Former Director at @wireapp. Former @soundcloud Core Engineering. Ex @IBM. Curious learner. Geek. OPEN SOURCE Advocate.
Fernando Cejas
Task Timer - An android app that helps you to keep a track of how much time you spend on each task

Task Timer - An android app that helps you to keep a track of how much time you spend on each task

Hassan Al-Shammari 1 Feb 24, 2022
Episodie is a TV show time tracker app with unusual design written in kotlin and clean architecture approach. Get to know how much time you spent watching tv shows.

Episodie Episodie is a TV show time tracker app with unusual design. Get to know how much time you spent watching tv shows. Track easily overall progr

Przemek 126 Dec 7, 2022
This representation of Clean Architecture tries to stick to the recommendations of the philosophy as much as possible

Android Clean Architecture Google - Rebuilding our guide to app architecture Ple

Martin Cazares 8 Sep 9, 2022
A tiny Android app that can receive WhatsApp group message export files and parse message history stats.

A tiny Android app that can receive WhatsApp group message export files and parse message history stats.

Zac Sweers 2 May 3, 2022
Clipeus - Tiny app to clean clipboard

Clipeus Clipboard cleaner. Tiny app to clean clipboard. No UI. Click on the app

lucky 30 Dec 18, 2022
A Kotlin binding to webview, a tiny cross-platform webview library, supports Java and Native.

webviewko provides a Kotlin/JVM and a Kotlin/Native(experimental) binding to webview, a tiny cross-platform webview library to build modern cross-platform GUIs using WebView2, WebKit and WebKitGTK.

Winterreisender 17 Dec 30, 2022
Tiny app to monitor permission changes.

Catcher Permission monitor. Tiny app to monitor permission changes. If any app will get INTERNET permission after an update you will get a notificatio

lucky 9 Oct 9, 2022
Quick start with the Google Maps Android API

Please note: This repository is not currently maintained, and is kept for historical purpose only. You can find an up to date tutorial here: https://g

Google Archive 234 Nov 14, 2022
Start android project

android-skeleton Start android project Global configuration Use of catalog versions file libs.versions.toml Centralize common module configuration in

Fabien Boismoreau 9 Jun 12, 2022
Android Clean Architecture Kick Start project with MVVM, Coroutine, DI, Caching, Networking.

Android Clean Architecture Kick Start project with MVVM, Coroutine, DI, Caching, Networking Stacks: Clean Architecture MVVVM Local Caching (StoreX) Ne

Romman Sabbir 3 Jun 18, 2022