Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean the project (#38) #42

Merged
merged 10 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- What is the objective? What is fixed/what feature is added/what was documented?
- How is the objective implemented? What classes/doc files/CI were changed?

# Details

Depends on the nature of the PR :
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
./gradlew check --parallel --build-cache

# Run connected tests on the emulator
- name: run tests
- name: Run Android tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
Expand All @@ -124,11 +124,6 @@ jobs:
- name: Generate coverage
run: ./gradlew jacocoTestReport

- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonar --info
# Upload the various reports to sonar
- name: Upload report to SonarCloud
env:
Expand Down
91 changes: 37 additions & 54 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ fun DependencyHandlerScope.globalTestImplementation(dep: Any) {
}

dependencies {
val composeBom = platform(libs.compose.bom)

// Dependencies
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
Expand All @@ -148,79 +151,48 @@ dependencies {
implementation(libs.androidx.navigation.runtime.ktx)
implementation(libs.androidx.navigation.common.ktx)
implementation(libs.androidx.navigation.testing)
testImplementation(libs.junit)
globalTestImplementation(libs.androidx.junit)
globalTestImplementation(libs.androidx.espresso.core)

// ------------- Jetpack Compose ------------------
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
globalTestImplementation(composeBom)

implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
// Material Design 3
implementation(libs.compose.material3)
// Integration with activities
implementation(libs.compose.activity)
// Integration with ViewModels
implementation(libs.compose.viewmodel)
// Android Studio Preview support
implementation(libs.compose.preview)
debugImplementation(libs.compose.tooling)
// UI Tests
globalTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)
implementation(platform(libs.firebase.bom))
implementation(libs.osmdroid)
implementation(libs.okhttp)

// --------- Kaspresso test framework ----------
// Global test dependencies
globalTestImplementation(libs.androidx.junit)
globalTestImplementation(libs.androidx.espresso.core)
globalTestImplementation(composeBom)
globalTestImplementation(libs.compose.test.junit)
globalTestImplementation(libs.kaspresso)
globalTestImplementation(libs.kaspresso.compose)

// ---------- Robolectric ------------
// Test dependencies
testImplementation(libs.junit)
testImplementation(libs.robolectric)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.android)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.compose.test.junit)
testImplementation(libs.compose.test.manifest)

// ---------- FireBase ------------
implementation(platform(libs.firebase.bom))

// ---------- OpenStreetMap ------------
implementation(libs.osmdroid)

// Adds a remote binary dependency only for local tests.

testImplementation (libs.mockito.inline)
testImplementation (libs.mockito.android)
testImplementation (libs.mockito.core)
testImplementation (libs.mockito.kotlin)
// Android test dependencies
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation (libs.ui.test.junit4)
androidTestImplementation (libs.mockito.mockito.kotlin)
debugImplementation (libs.ui.test.manifest)
// JUnit
testImplementation(libs.junit)
androidTestImplementation(libs.junit)

// AndroidX Test
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

// Compose UI Testing
androidTestImplementation(libs.ui.test.junit4)
androidTestImplementation(libs.junit)
androidTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)

// For both unit and instrumented tests
testImplementation(libs.compose.test.junit)
testImplementation(libs.compose.test.manifest)

// Mockito
testImplementation(libs.mockito.mockito.core.v3124)
testImplementation(libs.kotlin.mockito.kotlin.v320)
androidTestImplementation(libs.mockito.android.v3124)
androidTestImplementation(libs.mockito.kotlin)

implementation(libs.okhttp)
// Debug dependencies
debugImplementation(libs.compose.tooling)
debugImplementation(libs.compose.test.manifest)
debugImplementation(libs.ui.test.manifest)

// Robolectric (for unit tests that require Android framework)
testImplementation(libs.robolectric)
// To fix an issue with Firebase and the Protobuf library
configurations.configureEach {
exclude(group = "com.google.protobuf", module = "protobuf-lite")
Expand All @@ -238,6 +210,8 @@ tasks.withType<Test> {
}

tasks.register("jacocoTestReport", JacocoReport::class) {
description = "Generates Jacoco test reports"
group = "verification"
mustRunAfter("testDebugUnitTest", "connectedDebugAndroidTest")

reports {
Expand Down Expand Up @@ -266,4 +240,13 @@ tasks.register("jacocoTestReport", JacocoReport::class) {
include("outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec")
})

// This is a fix for a bug in the Jacoco plugin that causes it to generate invalid XML files
// This issue is caused by the Jetpack Compose compiler plugin, which is managed by Google.
// See : https://medium.com/@theilacker/fixing-sonarqube-line-out-of-range-issue-when-using-jetpack-compose-5ba4c1f361f1
// See : https://issuetracker.google.com/issues/231616123
doLast {
val reportFile = reports.xml.outputLocation.asFile.get()
val newContent = reportFile.readText().replace("<line[^>]+nr=\"65535\"[^>]*>".toRegex(), "")
reportFile.writeText(newContent)
}
}
14 changes: 0 additions & 14 deletions app/src/androidTest/java/ch/hikemate/app/screen/MainScreen.kt

This file was deleted.

12 changes: 4 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SampleApp"
tools:targetApi="31">
<activity
android:name=".SecondActivity"
android:exported="false"
android:label="@string/title_activity_second"
android:theme="@style/Theme.SampleApp" />
android:theme="@style/Theme.HikeMate"
tools:targetApi="31"
android:usesCleartextTraffic="false">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/title_activity_main"
android:theme="@style/Theme.SampleApp">
android:theme="@style/Theme.HikeMate">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ch/hikemate/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import ch.hikemate.app.ui.auth.SignInScreen
import ch.hikemate.app.ui.theme.SampleAppTheme
import ch.hikemate.app.ui.theme.HikeMateTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { SampleAppTheme { Surface(modifier = Modifier.fillMaxSize()) { SignInScreen() } } }
setContent { HikeMateTheme { Surface(modifier = Modifier.fillMaxSize()) { SignInScreen() } } }
}
}
43 changes: 0 additions & 43 deletions app/src/main/java/ch/hikemate/app/SecondActivity.kt

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/main/java/ch/hikemate/app/SimpleData.kt

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/main/java/ch/hikemate/app/resources/C.kt

This file was deleted.

9 changes: 4 additions & 5 deletions app/src/main/java/ch/hikemate/app/ui/auth/SignInScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import ch.hikemate.app.R
import ch.hikemate.app.ui.components.AppIcon
import ch.hikemate.app.ui.theme.kaushanTitleFontFamily
import ch.hikemate.app.ui.theme.primaryColor

/** A composable function to display the sign in screen */
@Composable
Expand Down Expand Up @@ -76,7 +76,7 @@ fun SignInScreen() {
style =
TextStyle(
color = Color.White,
fontFamily = FontFamily(Font(R.font.kaushan_script, FontWeight.Bold)),
fontFamily = kaushanTitleFontFamily,
fontSize = 60.sp,
fontWeight = FontWeight.Bold,
),
Expand Down Expand Up @@ -104,8 +104,7 @@ fun SignInWithGoogleButton(onSignInClick: () -> Unit) {
modifier =
Modifier.padding(8.dp)
.height(48.dp)
.border(
width = 3.dp, color = Color(0xFF3B9DE8), shape = RoundedCornerShape(size = 32.dp))
.border(width = 3.dp, color = primaryColor, shape = RoundedCornerShape(size = 32.dp))
.testTag("loginButton")) {
Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down
8 changes: 1 addition & 7 deletions app/src/main/java/ch/hikemate/app/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@ package ch.hikemate.app.ui.theme

import androidx.compose.ui.graphics.Color

val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val primaryColor = Color(0xFF3B9DE8)
26 changes: 3 additions & 23 deletions app/src/main/java/ch/hikemate/app/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,19 @@ import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

private val DarkColorScheme =
darkColorScheme(primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80)

private val LightColorScheme =
lightColorScheme(
primary = Purple40, secondary = PurpleGrey40, tertiary = Pink40

/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)
private val colorScheme = lightColorScheme(primary = primaryColor)

@Composable
fun SampleAppTheme(
fun HikeMateTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
Expand All @@ -46,14 +28,12 @@ fun SampleAppTheme(
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
else -> colorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
}
Expand Down
Loading