This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI Lint with ktlint All gradle files now use kotlin for configuring. Change libraries for Jetpack Compose Change main activity to Jetpack Compose Fix build error
- Loading branch information
Showing
25 changed files
with
400 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[*{kt,kts}] | ||
ktlint_function_naming_ignore_when_annotated_with=Composable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Enable KVM | ||
run: | | ||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | ||
sudo udevadm control --reload-rules | ||
sudo udevadm trigger --name-match=kvm | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '21' | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
- name: Build with Gradle | ||
run: ./gradlew build | ||
- name: Test (local) | ||
run: ./gradlew test | ||
- name: Test (emulator) | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 29 | ||
script: ./gradlew connectedCheck | ||
- name: Android Test Report | ||
uses: asadmansr/android-test-report-action@v1.2.0 | ||
if: ${{ always() }} # IMPORTANT: run Android Test Report regardless | ||
- name: Lint | ||
run: | | ||
./gradlew lint | ||
./gradlew ktlintCheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
id("org.jlleitschuh.gradle.ktlint") version "12.1.0" | ||
} | ||
|
||
android { | ||
namespace = "dk.scheduling.schedulingfrontend" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "dk.scheduling.schedulingfrontend" | ||
minSdk = 28 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro", | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
|
||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.11" | ||
} | ||
|
||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation("androidx.core:core-ktx:1.12.0") | ||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") | ||
implementation("androidx.activity:activity-compose:1.8.2") | ||
implementation(platform("androidx.compose:compose-bom:2024.04.00")) | ||
implementation("androidx.compose.ui:ui") | ||
implementation("androidx.compose.ui:ui-graphics") | ||
implementation("androidx.compose.ui:ui-tooling-preview") | ||
implementation("androidx.compose.material3:material3") | ||
implementation("androidx.compose.material:material-icons-core") | ||
implementation("androidx.compose.material:material-icons-extended") | ||
implementation("org.apache.commons:commons-lang3:3.14.0") | ||
implementation("com.squareup.retrofit2:retrofit:2.9.0") | ||
implementation("com.squareup.retrofit2:converter-gson:2.9.0") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
androidTestImplementation(platform("androidx.compose:compose-bom:2024.04.00")) | ||
androidTestImplementation("androidx.compose.ui:ui-test-junit4") | ||
debugImplementation("androidx.compose.ui:ui-tooling") | ||
debugImplementation("androidx.compose.ui:ui-test-manifest") | ||
} | ||
|
||
ktlint { | ||
dependencies { | ||
ktlintRuleset("com.twitter.compose.rules:ktlint:0.0.26") | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 42 additions & 25 deletions
67
app/src/main/java/dk/scheduling/schedulingfrontend/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,56 @@ | ||
package dk.scheduling.schedulingfrontend | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.util.Log.ERROR | ||
import android.widget.Button | ||
import dk.scheduling.schedulingfrontend.API.ApiClient | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Text | ||
import dk.scheduling.schedulingfrontend.api.ApiClient | ||
import dk.scheduling.schedulingfrontend.ui.theme.SchedulingFrontendTheme | ||
import retrofit2.Call | ||
import retrofit2.Callback | ||
import retrofit2.Response | ||
class MainActivity : AppCompatActivity() { | ||
|
||
class MainActivity : ComponentActivity() { | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
val button = findViewById<Button>(R.id.button) | ||
button.setOnClickListener { | ||
val call = ApiClient.apiService.test() | ||
setContent { | ||
SchedulingFrontendTheme { | ||
Button(onClick = { | ||
val call = ApiClient.apiService.test() | ||
|
||
call.enqueue(object : Callback<String>{ | ||
override fun onResponse(call: Call<String>, response: Response<String>) { | ||
if (response.isSuccessful) { | ||
//val post = response.body() | ||
println("we got a response") | ||
// Handle the retrieved post data | ||
} else { | ||
println("we did not get a successful response") | ||
// Handle error | ||
} | ||
} | ||
call.enqueue( | ||
object : Callback<String> { | ||
override fun onResponse( | ||
call: Call<String>, | ||
response: Response<String>, | ||
) { | ||
if (response.isSuccessful) { | ||
// val post = response.body() | ||
Log.i("testAPI", "we got a response") | ||
// Handle the retrieved post data | ||
} else { | ||
Log.w("testAPI", "we did not get a successful response") | ||
// Handle error | ||
} | ||
} | ||
|
||
override fun onFailure(call: Call<String>, t: Throwable) { | ||
// Handle failure | ||
Log.e("error message", "could not get a response") | ||
override fun onFailure( | ||
call: Call<String>, | ||
t: Throwable, | ||
) { | ||
// Handle failure | ||
Log.e("testAPI", "could not get a response") | ||
} | ||
}, | ||
) | ||
}) { | ||
Text("Test API") | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ling/schedulingfrontend/API/ApiService.kt → ...ling/schedulingfrontend/api/ApiService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package dk.scheduling.schedulingfrontend.API | ||
package dk.scheduling.schedulingfrontend.api | ||
import retrofit2.Call | ||
import retrofit2.http.GET | ||
|
||
interface ApiService { | ||
@GET("test") | ||
fun test() : Call<String> | ||
} | ||
fun test(): Call<String> | ||
} |
Oops, something went wrong.