Skip to content

Commit

Permalink
Merge pull request #54 from wednesday-solutions/open-weather-api
Browse files Browse the repository at this point in the history
Gradle upgrade, Compose Dependencies and Switch Weather API
  • Loading branch information
shounak-mulay authored May 31, 2022
2 parents 56fa866 + b27389a commit f17b702
Show file tree
Hide file tree
Showing 137 changed files with 2,287 additions and 1,323 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup local.properties
env:
PROPS: ${{ secrets.LOCAL_PROPERTIES }}
run: echo -n "$PROPS" | base64 --decode > local.properties
- name: Build the Release APK
run: |
bash scripts/actions/build_file_according_to_flavour.sh
Expand Down
31 changes: 8 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ env:


jobs:
lint:
name: Lint
lint_test_build:
name: Lint, Test and Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
Expand All @@ -30,30 +29,16 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup local.properties
env:
PROPS: ${{ secrets.LOCAL_PROPERTIES }}
run: echo -n "$PROPS" | base64 --decode > local.properties
- name: Ktlint
run: ./gradlew ktlint
- name: Lint
run: ./gradlew lintRelease

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
run: ./gradlew lintDevRelease
- name: Unit tests
run: ./gradlew testDebugUnitTest
run: ./gradlew testDevDebugUnitTest
- name: Build the apk
run: ./gradlew assembleDevDebug

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
- Run the app by pressing the run button in android studio or by pressing `control + R`.
- Go through and setup the scripts in the [scripts](https://github.com/wednesday-solutions/android-template/tree/master/scripts) directory.

#### App Secrets
Sensitive information such as the api keys is managed via `local.properties` file. This file in not checked into version control to keep the sensitive information safe. If you want to run the project locally you need to add your own api keys.
Look at the [`local.skeleton.properties`](local.skeleton.properties) file for all the keys you need to include in your `local.properties` file.

You can get the Open Weather API key from [openweathermap.org](https://openweathermap.org/appid).

## Architecture
The architecture of the template facilitates separation of concerns and avoids tight coupling between it's various layers. The goal is to have the ability to make changes to individual layers without affecting the entire app. This architecture is an adaptation of concepts from [`The Clean Architecture`](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html).

Expand Down
29 changes: 20 additions & 9 deletions android.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,28 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
// coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
flavorDimensions "version"
productFlavors {
qa {
dimension "version"
}
prod {
dimension "version"
}
dev {
dimension "version"
}
}

Properties props = new Properties()
props.load(new FileInputStream(new File('local.properties')))

buildTypes {
release {}
debug {}
release {
buildConfigField 'String', 'OPEN_WEATHER_API_KEY', props['OPEN_WEATHER_API_KEY']
}
debug {
buildConfigField 'String', 'OPEN_WEATHER_API_KEY', props['DEBUG_OPEN_WEATHER_API_KEY']
}
}
}
53 changes: 31 additions & 22 deletions app/app.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,49 @@ plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
kotlin("android")
}

apply {
from("${rootProject.projectDir}/android.gradle")
from("${rootProject.projectDir}/lint.gradle")
}

android {

compileSdk = 31
buildToolsVersion = "30.0.3"

defaultConfig {
minSdk = 24
targetSdk = 31
applicationId = "com.wednesday.template"
versionCode = 7
versionName = "1.0"
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
}
flavorDimensions("version")

flavorDimensions += "version"
productFlavors {
create("qa") {
dimension("version")
dimension = "version"
applicationIdSuffix = ".qa"
versionNameSuffix = "-qa"
}
create("prod") {
dimension("version")
dimension = "version"
applicationIdSuffix = ".prod"
versionNameSuffix = "-prod"
}
create("dev") {
dimension("version")
dimension = "version"
applicationIdSuffix = ".dev"
versionNameSuffix = "-dev"
}
}

buildTypes {
getByName("release") {
minifyEnabled(false)
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"${project.rootDir}/tools/proguard-rules.pro"
Expand All @@ -46,16 +55,16 @@ android {
variant.outputs
.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
.forEach { output ->
val flavour = variant.flavorName
val builtType = variant.buildType.name
val versionName = variant.versionName
val vCode = variant.versionCode
output.outputFileName =
"app-${flavour}-${builtType}-${versionName}(${vCode}).apk".replace(
"-${flavour}",
""
)
}
val flavour = variant.flavorName
val builtType = variant.buildType.name
val versionName = variant.versionName
val vCode = variant.versionCode
output.outputFileName =
"app-${flavour}-${builtType}-${versionName}(${vCode}).apk".replace(
"-${flavour}",
""
)
}
}
}
}
Expand All @@ -70,14 +79,14 @@ dependencies {
implementation(project(":repo-di"))
implementation(project(":service-di"))

implementation(Dependencies.kotlinStdLib)
implementation(Dependencies.Kotlin.stdLib)

implementation(Dependencies.koinCore)
implementation(Dependencies.koinAndroid)
implementation(Dependencies.Koin.core)
implementation(Dependencies.Koin.android)

implementation(Dependencies.material)
implementation(Dependencies.Material.material)

implementation(Dependencies.loggingTimber)
implementation(Dependencies.Logging.timber)

implementation(Dependencies.androidSplashScreen)
implementation(Dependencies.Android.splashScreen)
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ class AndroidTemplateApplication : Application() {
)
}
}

}
39 changes: 0 additions & 39 deletions build.gradle

This file was deleted.

33 changes: 33 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath(Dependencies.Android.gradlePlugin)
classpath(Dependencies.Google.services)
classpath(Dependencies.Kotlin.gradlePlugin)
classpath(Dependencies.Kotlin.serializationPlugin)
classpath(Dependencies.Android.navigationSafeArgsPlugin)
}
}

allprojects {
repositories {
google()
mavenCentral()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
}
}

// TODO: Remove once ExperimentalCoroutinesApi: runTest is stable
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
}
Loading

0 comments on commit f17b702

Please sign in to comment.