├── .githooks └── pre-commit ├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle.kts ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── kotlin │ └── com │ │ └── molidev8 │ │ └── template │ │ ├── TemplateApplication.kt │ │ └── presentation │ │ ├── MainActivity.kt │ │ ├── MainViewModel.kt │ │ └── theme │ │ ├── Color.kt │ │ ├── Theme.kt │ │ └── Type.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-mdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xxhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xxxhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── values │ ├── colors.xml │ ├── strings.xml │ └── themes.xml │ └── xml │ ├── backup_rules.xml │ └── data_extraction_rules.xml ├── build.gradle.kts ├── buildSrc ├── .gitignore ├── build.gradle.kts └── src │ └── main │ └── java │ ├── AppConfig.kt │ └── ModuleDependencies.kt ├── config └── version │ ├── version.gradle.kts │ └── version.properties ├── core ├── .gitignore ├── build.gradle.kts ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ ├── data │ ├── datasource │ │ ├── api │ │ │ └── ServiceApi.kt │ │ └── database │ │ │ ├── Database.kt │ │ │ ├── DatabaseDao.kt │ │ │ ├── DatabaseDataSourceImpl.kt │ │ │ └── model │ │ │ └── EntityTemplate.kt │ └── repository │ │ ├── RepositoryImpl.kt │ │ └── mapper │ │ └── TemplateMapper.kt │ ├── di │ └── DataModule.kt │ └── domain │ ├── dataSource │ ├── ApiDataSource.kt │ └── DatabaseDataSource.kt │ ├── model │ └── Template.kt │ └── repository │ └── Repository.kt ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "--------------------------------------" 4 | echo "Running static analysis with Ktlint" 5 | echo "--------------------------------------" 6 | 7 | CMD="./gradlew ktlintFormat"; 8 | RESULT=$? 9 | 10 | # return 1 exit code if Ktlint fails 11 | $CMD 12 | RESULT=$? 13 | if [ $RESULT -ne 0 ]; then 14 | echo "--------------------------------------" 15 | echo " -------------------------------------- " 16 | echo 1>&2 "Ktlint found violations it could not fix" 17 | exit 1 18 | fi 19 | echo "Ktlint ran succesfully" 20 | exit 0 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle files 2 | .gradle/ 3 | build/ 4 | 5 | # Local configuration file (sdk path, etc) 6 | local.properties 7 | 8 | # Log/OS Files 9 | *.log 10 | 11 | # Android Studio generated files and folders 12 | captures/ 13 | .externalNativeBuild/ 14 | .cxx/ 15 | *.apk 16 | output.json 17 | 18 | # IntelliJ 19 | *.iml 20 | .idea/ 21 | misc.xml 22 | deploymentTargetDropDown.xml 23 | render.experimental.xml 24 | 25 | # Keystore files 26 | *.jks 27 | *.keystore 28 | 29 | # Google Services (e.g. APIs or Firebase) 30 | google-services.json 31 | 32 | # Android Profiling 33 | *.hprof -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | A Template Android project with lots of stuff already setup for you. 2 | You can check in detail what this repository comes with in this article https://medium.com/gitconnected/an-android-studio-template-project-for-your-android-apps-ca9ed9002f5 3 | 4 | # Config 5 | 6 | In order to run Ktlint with Git Hooks before a commit you need to set manually the hook path with this command: 7 | ```bash 8 | git config -local core.hooksPath .githooks 9 | ``` -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jlleitschuh.gradle.ktlint.KtlintExtension 2 | 3 | // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369 4 | @Suppress("DSL_SCOPE_VIOLATION") 5 | plugins { 6 | alias(libs.plugins.android.application) 7 | alias(libs.plugins.kotlin.android) 8 | alias(libs.plugins.kotlin.kapt) 9 | alias(libs.plugins.ktlint) 10 | } 11 | 12 | android { 13 | compileSdk = AppConfig.compileSdk 14 | buildToolsVersion = AppConfig.buildToolsVersion 15 | 16 | defaultConfig { 17 | applicationId = AppConfig.applicationId 18 | minSdk = AppConfig.minSdk 19 | targetSdk = AppConfig.targetSdk 20 | versionCode = AppConfig.readVersionCode(rootProject.projectDir.path) 21 | versionName = AppConfig.readVersionName(rootProject.projectDir.path) 22 | 23 | testInstrumentationRunner = AppConfig.androidTestInstrumentation 24 | } 25 | 26 | /*signingConfigs { 27 | create("release") { 28 | keyAlias = "" 29 | keyPassword = "" 30 | storeFile = file("") 31 | storePassword = "" 32 | } 33 | }*/ 34 | 35 | buildTypes { 36 | getByName("release") { 37 | isMinifyEnabled = true 38 | isShrinkResources = true 39 | proguardFiles( 40 | getDefaultProguardFile("proguard-android-optimize.txt"), 41 | "proguard-rules.pro" 42 | ) 43 | // signingConfig = signingConfigs.getByName("release") 44 | } 45 | } 46 | compileOptions { 47 | sourceCompatibility = JavaVersion.VERSION_11 48 | targetCompatibility = JavaVersion.VERSION_11 49 | } 50 | kotlinOptions { 51 | jvmTarget = "11" 52 | } 53 | buildFeatures { 54 | compose = true 55 | } 56 | composeOptions { 57 | kotlinCompilerExtensionVersion = "1.3.2" 58 | } 59 | packagingOptions { 60 | resources { 61 | excludes += "/META-INF/{AL2.0,LGPL2.1}" 62 | } 63 | } 64 | configurations { 65 | implementation.get().exclude(mapOf("group" to "org.jetbrains", "module" to "annotations")) 66 | } 67 | sourceSets { 68 | getByName("main") { 69 | java.srcDirs("src/main/kotlin") 70 | } 71 | } 72 | } 73 | 74 | dependencies { 75 | implementation(project(ModuleDependencies.coreModule)) 76 | } 77 | 78 | configure { 79 | android.set(true) 80 | } 81 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle.kts. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/molidev8/template/TemplateApplication.kt: -------------------------------------------------------------------------------- 1 | package com.molidev8.template 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class TemplateApplication : Application() 8 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/molidev8/template/presentation/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.molidev8.template.presentation 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import androidx.compose.foundation.layout.fillMaxSize 7 | import androidx.compose.material3.MaterialTheme 8 | import androidx.compose.material3.Surface 9 | import androidx.compose.material3.Text 10 | import androidx.compose.runtime.Composable 11 | import androidx.compose.ui.Modifier 12 | import androidx.compose.ui.tooling.preview.Preview 13 | import com.molidev8.template.presentation.theme.AndroidTemplateTheme 14 | import dagger.hilt.android.AndroidEntryPoint 15 | 16 | @AndroidEntryPoint 17 | class MainActivity : ComponentActivity() { 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | setContent { 21 | AndroidTemplateTheme { 22 | // A surface container using the 'background' color from the theme 23 | Surface( 24 | modifier = Modifier.fillMaxSize(), 25 | color = MaterialTheme.colorScheme.background 26 | ) { 27 | Greeting("Android") 28 | } 29 | } 30 | } 31 | } 32 | } 33 | 34 | @Composable 35 | fun Greeting(name: String) { 36 | Text(text = "Hello $name!") 37 | } 38 | 39 | @Preview(showBackground = true) 40 | @Composable 41 | fun DefaultPreview() { 42 | AndroidTemplateTheme { 43 | Greeting("Android") 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/molidev8/template/presentation/MainViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.molidev8.template.presentation 2 | 3 | import androidx.lifecycle.ViewModel 4 | import dagger.hilt.android.lifecycle.HiltViewModel 5 | 6 | @HiltViewModel 7 | class MainViewModel : ViewModel() 8 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/molidev8/template/presentation/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package com.molidev8.template.presentation.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val Purple80 = Color(0xFFD0BCFF) 6 | val PurpleGrey80 = Color(0xFFCCC2DC) 7 | val Pink80 = Color(0xFFEFB8C8) 8 | 9 | val Purple40 = Color(0xFF6650a4) 10 | val PurpleGrey40 = Color(0xFF625b71) 11 | val Pink40 = Color(0xFF7D5260) 12 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/molidev8/template/presentation/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package com.molidev8.template.presentation.theme 2 | 3 | import android.app.Activity 4 | import android.os.Build 5 | import androidx.compose.foundation.isSystemInDarkTheme 6 | import androidx.compose.material3.MaterialTheme 7 | import androidx.compose.material3.darkColorScheme 8 | import androidx.compose.material3.dynamicDarkColorScheme 9 | import androidx.compose.material3.dynamicLightColorScheme 10 | import androidx.compose.material3.lightColorScheme 11 | import androidx.compose.runtime.Composable 12 | import androidx.compose.runtime.SideEffect 13 | import androidx.compose.ui.graphics.toArgb 14 | import androidx.compose.ui.platform.LocalContext 15 | import androidx.compose.ui.platform.LocalView 16 | import androidx.core.view.WindowCompat 17 | 18 | private val DarkColorScheme = darkColorScheme( 19 | primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80 20 | ) 21 | 22 | private val LightColorScheme = lightColorScheme( 23 | primary = Purple40, secondary = PurpleGrey40, tertiary = Pink40 24 | 25 | /* Other default colors to override 26 | background = Color(0xFFFFFBFE), 27 | surface = Color(0xFFFFFBFE), 28 | onPrimary = Color.White, 29 | onSecondary = Color.White, 30 | onTertiary = Color.White, 31 | onBackground = Color(0xFF1C1B1F), 32 | onSurface = Color(0xFF1C1B1F), 33 | */ 34 | ) 35 | 36 | @Composable 37 | fun AndroidTemplateTheme( 38 | darkTheme: Boolean = isSystemInDarkTheme(), 39 | // Dynamic color is available on Android 12+ 40 | dynamicColor: Boolean = true, 41 | content: @Composable () -> Unit 42 | ) { 43 | val colorScheme = when { 44 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { 45 | val context = LocalContext.current 46 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) 47 | } 48 | 49 | darkTheme -> DarkColorScheme 50 | else -> LightColorScheme 51 | } 52 | val view = LocalView.current 53 | if (!view.isInEditMode) { 54 | SideEffect { 55 | (view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb() 56 | WindowCompat.getInsetsController( 57 | (view.context as Activity).window, view 58 | ).isAppearanceLightStatusBars = darkTheme 59 | } 60 | } 61 | 62 | MaterialTheme( 63 | colorScheme = colorScheme, typography = Typography, content = content 64 | ) 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/kotlin/com/molidev8/template/presentation/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package com.molidev8.template.presentation.theme 2 | 3 | import androidx.compose.material3.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.FontFamily 6 | import androidx.compose.ui.text.font.FontWeight 7 | import androidx.compose.ui.unit.sp 8 | 9 | // Set of Material typography styles to start with 10 | val Typography = Typography( 11 | bodyLarge = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp, 15 | lineHeight = 24.sp, 16 | letterSpacing = 0.5.sp 17 | ) 18 | /* Other default text styles to override 19 | titleLarge = TextStyle( 20 | fontFamily = FontFamily.Default, 21 | fontWeight = FontWeight.Normal, 22 | fontSize = 22.sp, 23 | lineHeight = 28.sp, 24 | letterSpacing = 0.sp 25 | ), 26 | labelSmall = TextStyle( 27 | fontFamily = FontFamily.Default, 28 | fontWeight = FontWeight.Medium, 29 | fontSize = 11.sp, 30 | lineHeight = 16.sp, 31 | letterSpacing = 0.5.sp 32 | ) 33 | */ 34 | ) 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/molidev8/android-template/3dd40fe2e8bc7d46201da4614f088c69c042a1e1/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Android Template 3 | Sample 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |