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

Demo app #54

Merged
merged 2 commits into from
Jul 11, 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 .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ trim_trailing_whitespace = true
# noinspection EditorConfigKeyCorrectness
[*.{kt,kts}]
ktlint_code_style = intellij_idea
ktlint_function_naming_ignore_when_annotated_with = Composable
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset
ktlint_standard_no-wildcard-imports = disabled
12 changes: 8 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
plugins {
id("com.diffplug.spotless") version "6.25.0"
id("com.github.ben-manes.versions") version "0.51.0"
alias(libs.plugins.android.application) apply false // Plugin does not allow being loaded multiple times
alias(libs.plugins.android.library) apply false // Plugin does not allow being loaded multiple times
alias(libs.plugins.kotlin.android) apply false // Plugin does not allow being loaded multiple times
alias(libs.plugins.kotlin.multiplatform) apply false // Plugin does not allow being loaded multiple times
alias(libs.plugins.spotless)
alias(libs.plugins.versions)
}

spotless {
Expand All @@ -10,10 +14,10 @@ spotless {
}
kotlin {
target("**/*.kt")
ktlint("1.3.0").setEditorConfigPath(".editorconfig")
ktlint("1.3.0").setEditorConfigPath("${project.rootDir}/.editorconfig")
}
kotlinGradle {
ktlint("1.3.0").setEditorConfigPath(".editorconfig")
ktlint("1.3.0").setEditorConfigPath("${project.rootDir}/.editorconfig")
}
}

Expand Down
113 changes: 113 additions & 0 deletions demo/compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.compose)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.multiplatform)
}

kotlin {
androidTarget()
jvm("desktop")
// @OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
// wasmJs {
// moduleName = "log4kDemo"
// browser {
// commonWebpackConfig {
// outputFileName = "log4kDemo.js"
// devServer = (devServer
// ?: org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.DevServer()).apply {
// static = (static ?: mutableListOf()).apply {
// add(project.projectDir.path)
// }
// }
// }
// }
// binaries.executable()
// }

listOf(
iosArm64(),
iosSimulatorArm64(),
iosX64(),
).forEach {
it.binaries.framework {
baseName = "Log4KDemo"
isStatic = true
}
}

applyDefaultHierarchyTemplate()

sourceSets {
val desktopMain by getting

androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
}
commonMain.dependencies {
implementation(project(":log4k"))
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
}
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
}
}
}

android {
namespace = "saschpe.log4k.demo"
compileSdk = libs.versions.android.compileSdk.get().toInt()

// sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
// sourceSets["main"].res.srcDirs("src/androidMain/res")
// sourceSets["main"].resources.srcDirs("src/commonMain/resources")

defaultConfig {
applicationId = "saschpe.log4k.demo"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
versionName = libs.versions.log4k.demo.get()
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
buildFeatures {
compose = true
}
compileOptions {
sourceCompatibility(libs.versions.java.get())
targetCompatibility(libs.versions.java.get())
}
dependencies {
debugImplementation(compose.uiTooling)
}
}

compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(
org.jetbrains.compose.desktop.application.dsl.TargetFormat.Deb,
org.jetbrains.compose.desktop.application.dsl.TargetFormat.Dmg,
org.jetbrains.compose.desktop.application.dsl.TargetFormat.Msi,
)
packageName = "saschpe.log4k.demo"
packageVersion = libs.versions.log4k.demo.get()
}
}
}
23 changes: 23 additions & 0 deletions demo/compose/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<activity
android:exported="true"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
7 changes: 7 additions & 0 deletions demo/compose/src/androidMain/kotlin/Platform.android.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import android.os.Build

class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}"
}

actual fun getPlatform(): Platform = AndroidPlatform()
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package saschpe.log4k.demo

import App
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import saschpe.log4k.FileLogger
import saschpe.log4k.FileLogger.Limit
import saschpe.log4k.FileLogger.Rotate
import saschpe.log4k.Log

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Move to application subclass in a real-world app:
Log.loggers += FileLogger(rotate = Rotate.Daily, limit = Limit.Files(max = 5))

Log.debug { "Android MainActivity.onCreate" }
setContent {
App()
}
}
}

@Preview
@Composable
fun AppAndroidPreview() {
App()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
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" />
</vector>
Loading
Loading