diff --git a/.gitignore b/.gitignore index 1bc29aa..aa724b7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ /.idea/workspace.xml /.idea/navEditor.xml /.idea/assetWizardSettings.xml -/.idea .DS_Store /build /captures diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml new file mode 100644 index 0000000..4a53bee --- /dev/null +++ b/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index b589d56..b86273d 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 0897082..97f0a8e 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,9 +1,9 @@ - diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..c224ad5 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..14b7baf --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 8978d23..74dd639 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,7 @@ + - + diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 288b36b..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,7 +1,6 @@ - - + \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 0d16f77..0000000 --- a/README.md +++ /dev/null @@ -1,324 +0,0 @@ -# GitHub CI-SonarCloud Erklärung ->:warning: Eine funktionierende CI mit den Konfigurationen unten beschrieben kann in diesem Repository gefunden werden :warning: -## Account Einrichtungen und erste Projekterstellungen -Kurze Erklärungsschritte für zukünftige CIs in diese Richtung. Zum Ausgeben der Metriken wird Sonarcloud verwendet - -1. Erstellung einer neuen **GitHub Organisation** -2. Erstellung eines **Repositorys** in dieser GitHub Organisation -3. Erstellung eines **SonarCloud** Accounts: https://sonarcloud.io/projects -4. Verbindung der Organisation mit SonarCloud -5. Selektion der mit SonarCloud zu analysierenden Repositories in dieser Organisation -6. Bei SonarCloud dann auf **+** klicken und **"Analyze new project"**. Hier wird die Organisation ausgewählt und dann die Repositorys, die von SonarCloud getrackt werden sollen -7. Nach der Erstellung und dem erstmaligen Scannen muss unter ``Administration -> Analysis Method "Automatic Analysis"`` **deaktiviert** werden - -## Analyse via GitHub CI -- Unter **Analysis Methods** bei SonarCloud muss nun **With GitHub Actions** ausgewählt werden -- Danach muss der SonarCloud **Secret-Key** im GitHub Repository hinterlegt werden - - In diesem Fall: https://github.com/uni-aau/github-ci/settings/secrets/actions -- Ins Feld **Name** kommt ``SONAR_TOKEN`` und bei **Value** der ``Key`` von SonarCloud - -## Gradle Project Änderungen -- **Projekt-Spezifikationen**: - - **Gradle Version** 8.0 - - **Android Gradle Plugin Version** 8.3.0 - - **SDK Version (target)** 34 - - **SDK Version (min)** 29 - - **Groovy DSL** -- Im Hauptordner wird ein **.github/workflows** Ordner hinzugefügt -- In diesen wird eine **build.yml** Datei erstellt. Diese kann via ``Administration -> Analysis Method -> Github Actions -> Gradle -> build.yml`` kopiert werden: -```yml name: SonarCloud -name: SonarCloud -on: - push: - branches: - - master # CHECK IF MAIN BRANCH NAME IS CORRECT - pull_request: - types: [opened, synchronize, reopened] -jobs: - build: - name: Build and analyze - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: 'zulu' # Alternative distribution options are available - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Gradle packages - uses: actions/cache@v3 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew build sonar --info -``` -**Hinweis**: Auf den korrekten **Branch-Namen** muss geachtet werden -- Weiters muss die **app/build.gradle** Datei erweitert werden. Da diese (hier in SE2) ebenso um Jacoco erweitert wird, muss dies ebenfalls noch beachtet werden -- Im Folgenden File werden die Änderungen mit Kommentaren markiert -```gradle -plugins { - alias(libs.plugins.androidApplication) - // --Beide ids hinzufügen-- Auf sonarqube Version achten (Siehe Sonarcloud -> Gradle) - id 'jacoco' - id 'org.sonarqube' version '4.4.1.3373' -} - -android { - // Werte müssen mit diesen aus der eigenen App übernommen werden - namespace 'net.jamnig.testapp' - compileSdk 34 - - defaultConfig { - applicationId "net.jamnig.testapp" - minSdk 29 - targetSdk 34 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - // --Hinzufügen-- - testOptions { - unitTests.all { - useJUnitPlatform() - finalizedBy jacocoTestReport - } - } -} -// --Hinzufügen-- + Überprüfen, ob xml.destination Path korrekt ist -tasks.register('jacocoTestReport', JacocoReport) { - dependsOn 'testDebugUnitTest' - - reports { - xml.required = true - xml.destination file("${project.projectDir}/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml") - } - - def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*'] - def debugTree = fileTree(dir: "${project.layout.buildDirectory.get().asFile}/intermediates/javac/debug", excludes: fileFilter) - def mainSrc = "${project.projectDir}/src/main/java" - - sourceDirectories.from = files([mainSrc]) - classDirectories.from = files([debugTree]) - executionData.from = files("${project.layout.buildDirectory.get().asFile}/jacoco/testDebugUnitTest.exec") -} - -// Sonarqube-Werte müssen von Sonarcloud unter Gradle kopiert werden. Diese sind individuell -// --Hinweis-- Darauf achten, dass Jacoco mitkopiert wird -sonar { - properties { - property "sonar.projectKey", "uni-aau_github-ci" - property "sonar.organization", "uni-aau" - property "sonar.host.url", "https://sonarcloud.io" - property "sonar.java.coveragePlugin", "jacoco" - property "sonar.coverage.jacoco.xmlReportPaths", "${project.projectDir}/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" - } -} - - -// Überprüfen, ob Dependencies korrekt (wahrscheinlich höher) sind und ggf. anpassen -// Dependency-Versionen sind unter **gradle/libs.version.toml** -// --Hinweis-- Mit JUnit 5 wird gearbeitet (für jacoco) -dependencies { - implementation libs.activity - implementation libs.appcompat - implementation libs.material - implementation libs.constraintlayout - testImplementation libs.junit - testImplementation libs.junit.jupiter.api - testRuntimeOnly libs.junit.jupiter.engine - androidTestImplementation libs.ext.junit - androidTestImplementation libs.espresso.core -} -``` -Nun kann die CI entweder mittels **GitHub CI** bei jedem Commit getriggered werden (Ist im Repository unter Actions) oder per Konsole mit dem Befehl **./gradlew build sonar --info** - -**WICHTIG:** Da die App mit einer leeren Aktivität mit Android Studio erstellt wurde, wird automatisch ein Testfall hinzugefügt: - >**Android:** Unter ``app/src/test/.../ExampleUnitTest.java`` muss dieser (gemeinsam mit @RunWith) **entfernt** werden, da der Testfall noch mit JUnit 4 läuft. JUnit 5 hat anderen Import (``org.junit.jupiter.api.*``). - -## Maven Project Änderungen -- **Projekt-Spezifikationen**: - - **Java Version** 17 -- Im Hauptordner wird ein **.github/workflows** Ordner hinzugefügt -- In diesen wird eine **build.yml** Datei erstellt. Diese kann via ``Administration -> Analysis Method -> Github Actions -> Maven -> build.yml`` kopiert werden: -```yml name: SonarCloud -name: SonarCloud -on: - push: - branches: - - main # CHECK IF MAIN BRANCH NAME IS CORRECT - pull_request: - types: [opened, synchronize, reopened] -jobs: - build: - name: Build and analyze - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: 'zulu' # Alternative distribution options are available. - - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=AAU-SE2_WebSocketDemo-Server -``` -**Hinweis**: Auf den korrekten **Branch-Namen** muss geachtet werden -- Weiters muss die **pom.xml** Datei erweitert werden. -- Die pom.xml entspricht einer (via IntelliJ) neu generierten pom.xml mit **Jacoco & SonarCloud** Ergänzungen, sowie die zusätzlichen Änderungen für den Software-Engineering II Server: -```xml - - - 4.0.0 - - - - org.springframework.boot - spring-boot-starter-parent - 3.2.3 - - - - - net.jamnig - server - 1.0-SNAPSHOT - - - 17 - 17 - UTF-8 - - 17 - **COPY_FROM_SONAR_CLOUD** - https://sonarcloud.io - - ${project.build.directory}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml - - - - - - - org.junit.jupiter - junit-jupiter-api - 5.10.2 - test - - - - - org.junit.jupiter - junit-jupiter-engine - 5.10.2 - test - - - - - - org.springframework.boot - spring-boot-starter-websocket - 3.2.3 - - - - - org.springframework.boot - spring-boot-starter-test - 3.2.3 - test - - - - - org.projectlombok - lombok - 1.18.30 - provided - - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.11 - - - - prepare-agent - - - - report - test - - report - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - -``` - -## Troubleshooting -- **./gradlew Permission denied** - - Rechte müssen vergeben werden: ``chmod +x gradlew`` - - Oder auch ``git update-index --chmod=+x gradlew`` im Git-Ordner - - -Bei Fehlern bitte Issue erstellen! \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index d287568..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,77 +0,0 @@ -plugins { - alias(libs.plugins.androidApplication) - id 'jacoco' - id "org.sonarqube" version "4.4.1.3373" -} - -android { - namespace 'net.jamnig.testapp' - compileSdk 34 - - defaultConfig { - applicationId "net.jamnig.testapp" - minSdk 29 - targetSdk 34 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - testOptions { - unitTests.all { - useJUnitPlatform() - finalizedBy jacocoTestReport - } - } -} - -tasks.register('jacocoTestReport', JacocoReport) { - dependsOn 'testDebugUnitTest' - - reports { - xml.required = true - xml.destination file("${project.projectDir}/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml") - } - - def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*'] - def debugTree = fileTree(dir: "${project.layout.buildDirectory.get().asFile}/intermediates/javac/debug", excludes: fileFilter) - def mainSrc = "${project.projectDir}/src/main/java" - - sourceDirectories.from = files([mainSrc]) - classDirectories.from = files([debugTree]) - executionData.from = files("${project.layout.buildDirectory.get().asFile}/jacoco/testDebugUnitTest.exec") -} - -sonar { - properties { - property "sonar.projectKey", "uni-aau_github-ci" - property "sonar.organization", "uni-aau" - property "sonar.host.url", "https://sonarcloud.io" - property "sonar.java.coveragePlugin", "jacoco" - property "sonar.coverage.jacoco.xmlReportPaths", "${project.projectDir}/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" - } -} - -dependencies { - implementation libs.activity - implementation libs.appcompat - implementation libs.material - implementation libs.constraintlayout - testImplementation libs.junit - testImplementation libs.junit.jupiter.api - testRuntimeOnly libs.junit.jupiter.engine - androidTestImplementation libs.ext.junit - androidTestImplementation libs.espresso.core -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..fc0d945 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,59 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) +} + +android { + namespace = "net.jamnig.testapp" + compileSdk = 35 + + defaultConfig { + applicationId = "net.jamnig.testapp" + minSdk = 30 + targetSdk = 35 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + 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 + } +} + +dependencies { + + implementation(libs.androidx.core.ktx) + 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) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) +} \ No newline at end of file diff --git a/app/src/androidTest/java/net/jamnig/testapp/ExampleInstrumentedTest.java b/app/src/androidTest/java/net/jamnig/testapp/ExampleInstrumentedTest.java deleted file mode 100644 index 87d8e8f..0000000 --- a/app/src/androidTest/java/net/jamnig/testapp/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.jamnig.testapp; - -import android.content.Context; - -import androidx.test.platform.app.InstrumentationRegistry; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -//@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("net.jamnig.testapp", appContext.getPackageName()); - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/net/jamnig/testapp/ExampleInstrumentedTest.kt b/app/src/androidTest/java/net/jamnig/testapp/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..e149f55 --- /dev/null +++ b/app/src/androidTest/java/net/jamnig/testapp/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package net.jamnig.testapp + +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("net.jamnig.testapp", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a042090..c02cea4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,20 +1,22 @@ + xmlns:tools="http://schemas.android.com/tools"> + android:allowBackup="true" + android:dataExtractionRules="@xml/data_extraction_rules" + android:fullBackupContent="@xml/backup_rules" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/Theme.TestApp" + tools:targetApi="31"> + android:name=".MainActivity" + android:exported="true" + android:label="@string/app_name" + android:theme="@style/Theme.TestApp"> diff --git a/app/src/main/java/net/jamnig/testapp/MainActivity.java b/app/src/main/java/net/jamnig/testapp/MainActivity.java deleted file mode 100644 index 2ddf583..0000000 --- a/app/src/main/java/net/jamnig/testapp/MainActivity.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.jamnig.testapp; - -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; -import android.util.Log; - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Log.d("TAG", "Hello World!"); - } -} \ No newline at end of file diff --git a/app/src/main/java/net/jamnig/testapp/MainActivity.kt b/app/src/main/java/net/jamnig/testapp/MainActivity.kt new file mode 100644 index 0000000..7542ece --- /dev/null +++ b/app/src/main/java/net/jamnig/testapp/MainActivity.kt @@ -0,0 +1,47 @@ +package net.jamnig.testapp + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import net.jamnig.testapp.ui.theme.TestAppTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + TestAppTheme { + Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> + Greeting( + name = "Android", + modifier = Modifier.padding(innerPadding) + ) + } + } + } + } +} + +@Composable +fun Greeting(name: String, modifier: Modifier = Modifier) { + Text( + text = "Hello $name!", + modifier = modifier + ) +} + +@Preview(showBackground = true) +@Composable +fun GreetingPreview() { + TestAppTheme { + Greeting("Android") + } +} \ No newline at end of file diff --git a/app/src/main/java/net/jamnig/testapp/ui/theme/Color.kt b/app/src/main/java/net/jamnig/testapp/ui/theme/Color.kt new file mode 100644 index 0000000..7ad0a7e --- /dev/null +++ b/app/src/main/java/net/jamnig/testapp/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package net.jamnig.testapp.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) \ No newline at end of file diff --git a/app/src/main/java/net/jamnig/testapp/ui/theme/Theme.kt b/app/src/main/java/net/jamnig/testapp/ui/theme/Theme.kt new file mode 100644 index 0000000..cc08215 --- /dev/null +++ b/app/src/main/java/net/jamnig/testapp/ui/theme/Theme.kt @@ -0,0 +1,58 @@ +package net.jamnig.testapp.ui.theme + +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.ui.platform.LocalContext + +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), + */ +) + +@Composable +fun TestAppTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/app/src/main/java/net/jamnig/testapp/ui/theme/Type.kt b/app/src/main/java/net/jamnig/testapp/ui/theme/Type.kt new file mode 100644 index 0000000..8d2cd0f --- /dev/null +++ b/app/src/main/java/net/jamnig/testapp/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package net.jamnig.testapp.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml index e4a5389..07d5da9 100644 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -1,170 +1,170 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:width="108dp" + android:height="108dp" + android:viewportWidth="108" + android:viewportHeight="108"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml index 8a2bdbf..2b068d1 100644 --- a/app/src/main/res/drawable/ic_launcher_foreground.xml +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -1,30 +1,30 @@ + xmlns:aapt="http://schemas.android.com/aapt" + android:width="108dp" + android:height="108dp" + android:viewportWidth="108" + android:viewportHeight="108"> + android:endX="85.84757" + android:endY="92.4963" + android:startX="42.9492" + android:startY="49.59793" + android:type="linear"> + android:color="#44000000" + android:offset="0.0" /> + android:color="#00000000" + android:offset="1.0" /> + android:fillColor="#FFFFFF" + android:fillType="nonZero" + android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" + android:strokeWidth="1" + android:strokeColor="#00000000" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 895f007..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml deleted file mode 100644 index 43bf1ff..0000000 --- a/app/src/main/res/values-night/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 0c7ca4f..2814b87 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,16 +1,5 @@ - - - + + + +