Skip to content

Commit

Permalink
Refactor: Modularized the app and introduced the authentication module
Browse files Browse the repository at this point in the history
- Extracted common data source code into a new module.
- Created a new module for authentication features.
- Updated dependencies to support the new modules.
- Refactored the code to use the new modules.
- Created new files for the authentication module.
- Added `GoogleSignInButton` and `GoogleSignInClient` to the authentication module.
- Updated `BooksRepositoryImpl` and `BookDetailsViewModel` to use the new `Logger` package.
- Updated `BooksRepositoryTest` to use the new `Logger` package.
- Updated the `Secrets` class and added it to `.gitignore`.
- Updated the `AboutVolume` component to use the new `formatHtmlToAnnotatedString` package.
- Updated `gradle-wrapper.properties` to use Gradle 8.10.2.
- Updated the `ColorGetters` to use the new `ColorPallet` package.
- Updated `NetworkModule` to use the new `Logger` and `LoggerImpl` packages.
- Updated `FakeBookUiState` to use the new `ColorPallet` package.
- Removed `SearchState` from `UseCases` and `BookDetailsViewModel`.
- Updated `BookDetailsUiState` to use the new `ColorPallet` package.
- Created new test classes for the common data source and authentication modules.
- Added proguard rules for the common data source and authentication modules.
- Added the common data source and authentication modules to `settings.gradle.kts`.
  • Loading branch information
donald-okara committed Jan 23, 2025
1 parent 398820f commit e73f702
Show file tree
Hide file tree
Showing 38 changed files with 340 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common-datasource/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
69 changes: 69 additions & 0 deletions common-datasource/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.hilt.android)
id("kotlin-kapt")
}

android {
namespace = "ke.don.common_datasource"
compileSdk = 35

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.material.icons.extended)
implementation(libs.kotlinx.coroutines.core)

//Dagger Hilt
implementation(libs.hilt.android)
implementation(libs.androidx.runtime.livedata)
kapt(libs.hilt.android.compiler)
implementation(libs.androidx.hilt.navigation.compose)

implementation(libs.material)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
Empty file.
21 changes: 21 additions & 0 deletions common-datasource/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ke.don.common_datasource

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("ke.don.common_datasource.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions common-datasource/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ke.don.common_datasource

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
4 changes: 3 additions & 1 deletion common-domain/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/build
/build
/src/main/java/ke.don.shared_domain/values/Secrets.kt
/src/main/java/ke/don/shared_domain/values/Secrets.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ke.don.shared_domain.screens.logger
package ke.don.shared_domain.logger

interface Logger {
fun logDebug(tag: String, message: String)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ke.don.shared_domain.screens.logger
package ke.don.shared_domain.logger

class LoggerImpl : Logger {
override fun logDebug(tag: String, message: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ke.don.shared_domain.screens.utils.color_utils
package ke.don.shared_domain.utils.color_utils

import okhttp3.OkHttpClient
import okhttp3.Request
import ke.don.shared_domain.screens.utils.color_utils.model.ColorPallet
import ke.don.shared_domain.utils.color_utils.model.ColorPallet
import java.io.InputStream
import androidx.palette.graphics.Palette
import android.graphics.BitmapFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ke.don.shared_domain.screens.utils.color_utils.model
package ke.don.shared_domain.utils.color_utils.model

import androidx.compose.ui.graphics.Color

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ke.don.shared_domain.screens.utils.formatting_utils
package ke.don.shared_domain.utils.formatting_utils

import android.text.Spanned
import android.text.style.CharacterStyle
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package ke.don.shared_domain.values

1 change: 1 addition & 0 deletions feature-authentication/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
75 changes: 75 additions & 0 deletions feature-authentication/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.hilt.android)
id("kotlin-kapt")
}

android {
namespace = "ke.don.feature_authentication"
compileSdk = 35

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.material.icons.extended)
implementation(libs.kotlinx.coroutines.core)

//Dagger Hilt
implementation(libs.hilt.android)
implementation(libs.androidx.runtime.livedata)
implementation(libs.googleid)
kapt(libs.hilt.android.compiler)
implementation(libs.androidx.hilt.navigation.compose)

//Credential Manager
implementation(libs.androidx.credentials)
implementation(libs.androidx.credentials.play.services.auth)


implementation(libs.material)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
Empty file.
21 changes: 21 additions & 0 deletions feature-authentication/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ke.don.feature_authentication

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("ke.don.feature_authentication.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions feature-authentication/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ke.don.feature_authentication.data

import android.content.Context
import com.google.android.libraries.identity.googleid.GetGoogleIdOption

class GoogleSignInClient(context: Context) {
val googleIdOption: GetGoogleIdOption = GetGoogleIdOption.Builder()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ke.don.feature_authentication.presentation

import android.service.autofill.OnClickAction
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable

@Composable
fun GoogleSignInButton(
onClickAction: () -> Unit
){
Button(
onClick = { /*TODO*/ }
) {
Text(text = "Sign in with Google")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ke.don.feature_authentication

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ke.don.feature_book_details.data.di

import ke.don.shared_domain.screens.logger.Logger
import ke.don.shared_domain.screens.logger.LoggerImpl
import ke.don.shared_domain.logger.Logger
import ke.don.shared_domain.logger.LoggerImpl
import ke.don.feature_book_details.network.GoogleBooksApi
import dagger.Module
import dagger.Provides
Expand Down
Loading

0 comments on commit e73f702

Please sign in to comment.