Skip to content

Commit

Permalink
refactor: rewrite whole application in jetpack compose (1/2) (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Garg committed Dec 13, 2022
2 parents 81a2103 + 50c37d9 commit 19fa50f
Show file tree
Hide file tree
Showing 133 changed files with 1,510 additions and 2,643 deletions.
73 changes: 64 additions & 9 deletions .github/workflows/pr_ci.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,86 @@
name: Android CI
name: Android CI (PR)

on: push
on:
pull_request:

concurrency:
group: ${{ github.sha }}
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
file-changes:
runs-on: ubuntu-latest
outputs:
any: ${{ steps.changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v34.5.3
with:
files: |
.github/workflows/pr_ci.yml
gradle/libs.versions.toml
**/*.kt
**/*.kts
**/*.xml
check-codestyle:
needs: [ file-changes ]
runs-on: ubuntu-latest
if: needs.file-changes.outputs.any == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
with:
fetch-depth: 0

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Set up JDK
uses: actions/setup-java@v3.6.0
uses: actions/setup-java@v3.8.0
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"

- name: Check codestyle
uses: gradle/gradle-build-action@v2.3.2
uses: gradle/gradle-build-action@v2.3.3
with:
arguments: spotlessCheck
gradle-home-cache-cleanup: true

build-apks:
needs: [ check-codestyle ]
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
if: needs.file-changes.outputs.any == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3.8.0
with:
distribution: "zulu"
java-version: "11"
cache: "gradle"

- name: Build debug APKs
uses: gradle/gradle-build-action@v2.3.3
with:
arguments: assembleDebug
gradle-home-cache-cleanup: true
env:
GITHUB_CI: true
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}

- name: Upload debug APKs
uses: actions/upload-artifact@v3
with:
name: Debug APKs
path: app/build/outputs/apk/debug/*.apk
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/*
/.idea/
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
.envrc
5 changes: 3 additions & 2 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build
/release
*.properties
*.jks
*.apk
release/
key.properties
129 changes: 79 additions & 50 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,49 +1,33 @@
@file:Suppress("UnstableApiUsage")
@file:Suppress("UnstableApiUsage", "DSL_SCOPE_VIOLATION")

import java.util.*

val isGithubCi = System.getenv("GITHUB_CI") != null

plugins {
id("com.android.application")
kotlin("android")
kotlin("kapt")
id("dagger.hilt.android.plugin")
id("androidx.navigation.safeargs.kotlin")
id("kotlin-parcelize")
}

android {
namespace = "dev.yash.keymanager"
compileSdk = 33
buildToolsVersion = "31.0.0"

defaultConfig {
applicationId = "dev.yash.keymanager"
minSdk = 26
targetSdk = 33
versionCode = 5
versionName = "2.2"
versionCode = 6
versionName = "v3.0"
multiDexEnabled = true

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders["appAuthRedirectScheme"] = "dev.yash.keymanager"
}
setProperty("archivesBaseName", "${defaultConfig.applicationId}-$versionName")

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() }

buildFeatures { viewBinding = true }

packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
excludes += "/META-INF/*.kotlin_module"
excludes += "**/kotlin/**"
excludes += "**/*.txt"
excludes += "**/*.xml"
excludes += "**/*.properties"
}
vectorDrawables { useSupportLibrary = true }
}

kapt { correctErrorTypes = true }
Expand All @@ -65,43 +49,88 @@ android {
}

buildTypes {
getByName("release") {
isMinifyEnabled = true
release {
isShrinkResources = true
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
isMinifyEnabled = true
versionNameSuffix = "-release"
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}

if (isGithubCi) {
configureEach {
buildConfigField("String", "CLIENT_ID", "\"${System.getenv("CLIENT_ID")}\"")
buildConfigField("String", "CLIENT_SECRET", "\"${System.getenv("CLIENT_SECRET")}\"")
}
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() }

buildFeatures {
compose = true
buildConfig = true
}

composeOptions {
kotlinCompilerExtensionVersion =
libs.compose.compiler.get().versionConstraint.requiredVersion
}

packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
excludes += "/META-INF/*.kotlin_module"
excludes += "**/kotlin/**"
excludes += "**/*.txt"
excludes += "**/*.xml"
excludes += "**/*.properties"
}
}
}

dependencies {
implementation(libs.androidx.activity)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.fragment)
implementation(libs.androidx.legacy)
implementation(libs.androidx.lifecycle.livedata)
implementation(libs.androidx.lifecycle.viewmodel)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.ui)
implementation(libs.androidx.paging.runtime)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.lifecycle.ktx)
implementation(libs.androidx.paging)
implementation(libs.androidx.security.crypto)
implementation(libs.androidx.security.identity)

debugImplementation(libs.chucker.library)
releaseImplementation(libs.chucker.no.op)

implementation(libs.google.dagger)
kapt(libs.google.dagger.compiler)
implementation(libs.google.material)
implementation(libs.compose.activity)
implementation(platform(libs.compose.bom))
implementation(libs.compose.constraintlayout)
implementation(libs.compose.material)
implementation(libs.compose.material.icons)
implementation(libs.compose.material3)
implementation(libs.compose.navigation)
implementation(libs.compose.navigation.hilt)
implementation(libs.compose.paging)
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.ui.tooling.preview)
debugImplementation(libs.compose.ui.tooling)
debugImplementation(libs.compose.ui.test.manifest)

implementation(libs.square.moshi)
implementation(libs.square.moshi.converter)
implementation(libs.moshi.metadata.reflect)
implementation(libs.square.moshi.metadata.reflect)
implementation(libs.square.okhttp.logging)
debugImplementation(libs.square.leakcanary)

implementation(libs.google.accompanist.systemuicontroller)
implementation(libs.google.dagger.hilt)
kapt(libs.google.dagger.hilt.compiler)

debugImplementation(libs.leakcanary)
implementation(libs.lottie)
implementation(libs.openid.appauth)
implementation(libs.timber)
implementation(libs.appauth)
debugImplementation(libs.chucker)
releaseImplementation(libs.chucker.no.op)
testImplementation(libs.junit)
}
Binary file added app/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 46 additions & 22 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontwarn com.google.errorprone.annotations.Immutable
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
Expand All @@ -28,4 +7,49 @@
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
-dontwarn org.openjsse.net.ssl.OpenJSSE
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod

# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations

# Keep annotation default values (e.g., retrofit2.http.Field.encoded).
-keepattributes AnnotationDefault

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

# Keep inherited services.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface * extends <1>

# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response

# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
Loading

0 comments on commit 19fa50f

Please sign in to comment.