diff --git a/Kotlin/.gitignore b/Kotlin/.gitignore index f5ed2b56..101f9f3e 100644 --- a/Kotlin/.gitignore +++ b/Kotlin/.gitignore @@ -1,40 +1,20 @@ -# Built application files -*.apk -*.ap_ - -# Files for the Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -bin/ -gen/ - -# Gradle files -.gradle/ -build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -proguard/ - -# Log Files -*.log - -.idea/.workspace - -# http://stackoverflow.com/questions/16736856/what-should-be-in-my-gitignore-for-an-android-studio-project +*.iml +.kotlin .gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build +**/build/ +xcuserdata +!src/**/build/ +local.properties .idea -**/*.iml -*.hprof -**/*.project +.DS_Store +captures +.externalNativeBuild +.cxx +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcodeproj/project.xcworkspace/ +!*.xcworkspace/contents.xcworkspacedata +**/xcshareddata/WorkspaceSettings.xcsettings +#So we don't accidentally commit our private keys +*.gpg diff --git a/Kotlin/build.gradle b/Kotlin/build.gradle deleted file mode 100644 index b971d828..00000000 --- a/Kotlin/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ - -buildscript { - - ext.kotlin_version = '1.3.72' - - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } - -} - -allprojects { - - repositories { - google() - jcenter() - } - -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/Kotlin/build.gradle.kts b/Kotlin/build.gradle.kts new file mode 100644 index 00000000..136f576a --- /dev/null +++ b/Kotlin/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + // this is necessary to avoid the plugins to be loaded multiple times + // in each subproject's classloader + alias(libs.plugins.androidApplication) apply false + alias(libs.plugins.androidLibrary) apply false + alias(libs.plugins.composeMultiplatform) apply false + alias(libs.plugins.composeCompiler) apply false + alias(libs.plugins.kotlinMultiplatform) apply false + +// alias(libs.plugins.vanniktech.mavenPublish) apply false +// alias(libs.plugins.ktlint) +} + +//subprojects { +// apply(plugin = "org.jlleitschuh.gradle.ktlint") // Version should be inherited from parent +// +// configure { +// debug.set(true) +// verbose.set(true) +// android.set(true) +// outputToConsole.set(true) +// outputColorName.set("RED") // Change terminal output color +// ignoreFailures.set(false) // Set to true to avoid build failures +// filter { +// exclude("**/generated/**") +// include("**/kotlin/**") +// } +// } +//} diff --git a/Kotlin/demo/build.gradle b/Kotlin/demo/build.gradle deleted file mode 100644 index 6ccb0378..00000000 --- a/Kotlin/demo/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - - compileSdkVersion 29 - - defaultConfig { - applicationId "com.wolt.blurhash" - minSdkVersion 14 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - -} - -dependencies { - implementation project(path: ':lib') - implementation 'androidx.appcompat:appcompat:1.1.0' -} diff --git a/Kotlin/demo/build.gradle.kts b/Kotlin/demo/build.gradle.kts new file mode 100644 index 00000000..219f5cac --- /dev/null +++ b/Kotlin/demo/build.gradle.kts @@ -0,0 +1,71 @@ +import org.jetbrains.compose.desktop.application.dsl.TargetFormat +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +plugins { + alias(libs.plugins.kotlinMultiplatform) + alias(libs.plugins.androidApplication) + alias(libs.plugins.composeMultiplatform) + alias(libs.plugins.composeCompiler) +} + +kotlin { + androidTarget { + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + jvmTarget.set(JvmTarget.JVM_11) + } + } + + sourceSets { + androidMain.dependencies { +// implementation(projects.library) + implementation(project(":library")) + implementation(compose.preview) + implementation(libs.androidx.activity.compose) + } + commonMain.dependencies { +// implementation(projects.library) + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material) + implementation(compose.ui) + implementation(compose.components.resources) + implementation(compose.components.uiToolingPreview) + implementation(libs.androidx.lifecycle.viewmodel) + implementation(libs.androidx.lifecycle.runtime.compose) + } + } +} + +android { + namespace = "com.wolt.blurhashapp" + compileSdk = libs.versions.android.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.wolt.blurhashapp" + minSdk = libs.versions.android.minSdk.get().toInt() + targetSdk = libs.versions.android.targetSdk.get().toInt() + versionCode = 1 + versionName = "1.0" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +dependencies { + debugImplementation(compose.uiTooling) +} + diff --git a/Kotlin/demo/proguard-rules.pro b/Kotlin/demo/proguard-rules.pro deleted file mode 100644 index f1b42451..00000000 --- a/Kotlin/demo/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/Kotlin/demo/src/main/AndroidManifest.xml b/Kotlin/demo/src/androidMain/AndroidManifest.xml similarity index 56% rename from Kotlin/demo/src/main/AndroidManifest.xml rename to Kotlin/demo/src/androidMain/AndroidManifest.xml index 3be7349e..c5db0b15 100644 --- a/Kotlin/demo/src/main/AndroidManifest.xml +++ b/Kotlin/demo/src/androidMain/AndroidManifest.xml @@ -1,6 +1,5 @@ - + - + android:theme="@android:style/Theme.Material.Light.NoActionBar"> + - + - + - + \ No newline at end of file diff --git a/Kotlin/demo/src/androidMain/kotlin/com/wolt/blurhashapp/App.kt b/Kotlin/demo/src/androidMain/kotlin/com/wolt/blurhashapp/App.kt new file mode 100644 index 00000000..dae01962 --- /dev/null +++ b/Kotlin/demo/src/androidMain/kotlin/com/wolt/blurhashapp/App.kt @@ -0,0 +1,104 @@ +package com.wolt.blurhashapp + +import android.graphics.Bitmap +import android.os.Bundle +import android.os.SystemClock +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.material.* +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.wolt.blurhashkt.BlurHashDecoder + +@Composable +@Preview +fun App() { + val defaultBlurHash = "LEHV6nWB2yk8pyo0adR*.7kCMdnj" + var blurHashInput by remember { mutableStateOf(defaultBlurHash) } + var bitmap by remember { mutableStateOf(null) } + var decodingTime by remember { mutableStateOf(0) } + + Column( + modifier = Modifier + .fillMaxSize() + .padding(24.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + // Input field for BlurHash + OutlinedTextField( + value = blurHashInput, + onValueChange = { blurHashInput = it }, + label = { Text("Enter BlurHash") }, + singleLine = true, + textStyle = TextStyle( + color = MaterialTheme.colors.primary, + textAlign = TextAlign.Center + ), + modifier = Modifier.fillMaxWidth() + ) + + // Decode button + Button( + onClick = { + bitmap = null // Clear current image + val time = timed { + bitmap = BlurHashDecoder.decode(blurHashInput, 20, 12) + } + decodingTime = time + }, + modifier = Modifier + .padding(top = 12.dp) + .height(48.dp), + colors = ButtonDefaults.buttonColors( + backgroundColor = MaterialTheme.colors.primary + ) + ) { + Text( + "DECODE", + color = MaterialTheme.colors.secondary, + fontSize = 16.sp + ) + } + + // Image result + bitmap?.let { + Image( + bitmap = it.asImageBitmap(), + contentDescription = "Decoded BlurHash Image", + modifier = Modifier + .padding(top = 24.dp) + .fillMaxWidth() + .aspectRatio(it.width.toFloat() / it.height.toFloat()) + ) + } + + // Time result + Text( + text = "Time: $decodingTime ms", + fontSize = 16.sp, + textAlign = TextAlign.Center, + modifier = Modifier + .padding(top = 8.dp) + .fillMaxWidth() + ) + } +} + +/** + * Executes a function and return the time spent in milliseconds. + */ +private inline fun timed(function: () -> Unit): Long { + val start = SystemClock.elapsedRealtime() + function() + return SystemClock.elapsedRealtime() - start +} diff --git a/Kotlin/demo/src/androidMain/kotlin/com/wolt/blurhashapp/MainActivity.kt b/Kotlin/demo/src/androidMain/kotlin/com/wolt/blurhashapp/MainActivity.kt new file mode 100644 index 00000000..823fe202 --- /dev/null +++ b/Kotlin/demo/src/androidMain/kotlin/com/wolt/blurhashapp/MainActivity.kt @@ -0,0 +1,23 @@ +package com.wolt.blurhashapp + +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 + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContent { + App() + } + } +} + +@Preview +@Composable +fun AppAndroidPreview() { + App() +} \ No newline at end of file diff --git a/Kotlin/demo/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml b/Kotlin/demo/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/Kotlin/demo/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Kotlin/demo/src/main/res/drawable/ic_launcher_background.xml b/Kotlin/demo/src/androidMain/res/drawable/ic_launcher_background.xml similarity index 51% rename from Kotlin/demo/src/main/res/drawable/ic_launcher_background.xml rename to Kotlin/demo/src/androidMain/res/drawable/ic_launcher_background.xml index 5713f34a..e93e11ad 100644 --- a/Kotlin/demo/src/main/res/drawable/ic_launcher_background.xml +++ b/Kotlin/demo/src/androidMain/res/drawable/ic_launcher_background.xml @@ -1,171 +1,170 @@ - + android:viewportWidth="108" + android:viewportHeight="108"> + android:fillColor="#3DDC84" + android:pathData="M0,0h108v108h-108z" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> - + android:strokeWidth="0.8" + android:strokeColor="#33FFFFFF" /> + \ No newline at end of file diff --git a/Kotlin/demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/Kotlin/demo/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 88% rename from Kotlin/demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to Kotlin/demo/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml index d378acd7..eca70cfe 100644 --- a/Kotlin/demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/Kotlin/demo/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - - - + + + \ No newline at end of file diff --git a/Kotlin/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/Kotlin/demo/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 88% rename from Kotlin/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to Kotlin/demo/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml index d378acd7..eca70cfe 100644 --- a/Kotlin/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/Kotlin/demo/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - - + + + \ No newline at end of file diff --git a/Kotlin/demo/src/androidMain/res/mipmap-hdpi/ic_launcher.png b/Kotlin/demo/src/androidMain/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..a571e600 Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-hdpi/ic_launcher.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png b/Kotlin/demo/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 00000000..61da551c Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-mdpi/ic_launcher.png b/Kotlin/demo/src/androidMain/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..c41dd285 Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-mdpi/ic_launcher.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png b/Kotlin/demo/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 00000000..db5080a7 Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-xhdpi/ic_launcher.png b/Kotlin/demo/src/androidMain/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..6dba46da Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png b/Kotlin/demo/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 00000000..da31a871 Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png b/Kotlin/demo/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..15ac6817 Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png b/Kotlin/demo/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..b216f2d3 Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png b/Kotlin/demo/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..f25a4197 Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/Kotlin/demo/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png b/Kotlin/demo/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..e96783cc Binary files /dev/null and b/Kotlin/demo/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/Kotlin/demo/src/androidMain/res/values/strings.xml b/Kotlin/demo/src/androidMain/res/values/strings.xml new file mode 100644 index 00000000..60b0bb8e --- /dev/null +++ b/Kotlin/demo/src/androidMain/res/values/strings.xml @@ -0,0 +1,3 @@ + + BlurHash + diff --git a/Kotlin/demo/src/main/java/com/wolt/blurhashapp/MainActivity.kt b/Kotlin/demo/src/main/java/com/wolt/blurhashapp/MainActivity.kt deleted file mode 100644 index 3d48edba..00000000 --- a/Kotlin/demo/src/main/java/com/wolt/blurhashapp/MainActivity.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.wolt.blurhashapp - -import android.graphics.Bitmap -import android.os.Bundle -import android.os.SystemClock -import androidx.appcompat.app.AppCompatActivity -import com.wolt.blurhashkt.BlurHashDecoder -import kotlinx.android.synthetic.main.activity_main.* - -class MainActivity : AppCompatActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - tvDecode.setOnClickListener { - var bitmap: Bitmap? = null - val time = timed { - bitmap = BlurHashDecoder.decode(etInput.text.toString(), 20, 12) - } - ivResult.setImageBitmap(bitmap) - ivResultTime.text = "Time: $time ms" - } - } - -} - -/** - * Executes a function and return the time spent in milliseconds. - */ -private inline fun timed(function: () -> Unit): Long { - val start = SystemClock.elapsedRealtime() - function() - return SystemClock.elapsedRealtime() - start -} - diff --git a/Kotlin/demo/src/main/res/drawable-v24/ic_launcher_foreground.xml b/Kotlin/demo/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index c3903edf..00000000 --- a/Kotlin/demo/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - diff --git a/Kotlin/demo/src/main/res/drawable/bg_blue_rounded_rect_8.xml b/Kotlin/demo/src/main/res/drawable/bg_blue_rounded_rect_8.xml deleted file mode 100644 index ac09c99e..00000000 --- a/Kotlin/demo/src/main/res/drawable/bg_blue_rounded_rect_8.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/Kotlin/demo/src/main/res/layout/activity_main.xml b/Kotlin/demo/src/main/res/layout/activity_main.xml deleted file mode 100644 index 3b22c57d..00000000 --- a/Kotlin/demo/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - diff --git a/Kotlin/demo/src/main/res/mipmap-hdpi/ic_launcher.png b/Kotlin/demo/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a2f59082..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png b/Kotlin/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 1b523998..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-mdpi/ic_launcher.png b/Kotlin/demo/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index ff10afd6..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png b/Kotlin/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index 115a4c76..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-xhdpi/ic_launcher.png b/Kotlin/demo/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index dcd3cd80..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/Kotlin/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 459ca609..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Kotlin/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 8ca12fe0..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/Kotlin/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index 8e19b410..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/Kotlin/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index b824ebdd..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/Kotlin/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index 4c19a13c..00000000 Binary files a/Kotlin/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/Kotlin/demo/src/main/res/values/colors.xml b/Kotlin/demo/src/main/res/values/colors.xml deleted file mode 100644 index aad209ea..00000000 --- a/Kotlin/demo/src/main/res/values/colors.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - #29b6f6 - #0086c3 - #444444 - - diff --git a/Kotlin/demo/src/main/res/values/strings.xml b/Kotlin/demo/src/main/res/values/strings.xml deleted file mode 100644 index 8b1e94e0..00000000 --- a/Kotlin/demo/src/main/res/values/strings.xml +++ /dev/null @@ -1,5 +0,0 @@ - - BlurHash - BlurHash string - Decode! - diff --git a/Kotlin/demo/src/main/res/values/styles.xml b/Kotlin/demo/src/main/res/values/styles.xml deleted file mode 100644 index c62b5531..00000000 --- a/Kotlin/demo/src/main/res/values/styles.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/Kotlin/gradle.properties b/Kotlin/gradle.properties index 8de50581..4f59299f 100644 --- a/Kotlin/gradle.properties +++ b/Kotlin/gradle.properties @@ -1,15 +1,12 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -android.enableJetifier=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx1536m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true +#Kotlin +kotlin.code.style=official +kotlin.daemon.jvmargs=-Xmx2048M + +#Gradle +org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 +org.gradle.caching=true +org.gradle.configuration-cache=true + +#Android +android.nonTransitiveRClass=true +android.useAndroidX=true \ No newline at end of file diff --git a/Kotlin/gradle/libs.versions.toml b/Kotlin/gradle/libs.versions.toml new file mode 100644 index 00000000..f9415ac7 --- /dev/null +++ b/Kotlin/gradle/libs.versions.toml @@ -0,0 +1,50 @@ +[versions] +agp = "8.9.1" +android-compileSdk = "35" +android-minSdk = "24" +android-targetSdk = "35" +androidx-activityCompose = "1.10.1" +androidx-appcompat = "1.7.0" +androidx-constraintlayout = "2.2.1" +androidx-core-ktx = "1.15.0" +androidx-espresso-core = "3.6.1" +androidx-lifecycle = "2.8.4" +androidx-material = "1.12.0" +androidx-test-junit = "1.2.1" +androidx-test-runner = "1.6.2" +compose-multiplatform = "1.7.3" +junit = "4.13.2" +kotlin = "2.1.20" +junitJupiter = "5.10.1" +kotlinxBenchmark = "0.4.13" +ktlint = "12.1.2" +kotlinxSerialization = "1.8.1" + +[libraries] +kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" } +androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-junit" } +androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidx-test-runner"} +androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-espresso-core" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } +androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" } +androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } +androidx-lifecycle-viewmodel = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-viewmodel", version.ref = "androidx-lifecycle" } +androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junitJupiter" } +kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } +kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinxBenchmark" } +kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinxSerialization" } + +[plugins] +androidApplication = { id = "com.android.application", version.ref = "agp" } +androidLibrary = { id = "com.android.library", version.ref = "agp" } +composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" } +composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +kotlinxBenchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "kotlinxBenchmark" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } +kotlinxSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +vanniktech-mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.29.0" } diff --git a/Kotlin/gradle/wrapper/gradle-wrapper.jar b/Kotlin/gradle/wrapper/gradle-wrapper.jar index 7a3265ee..2c352119 100644 Binary files a/Kotlin/gradle/wrapper/gradle-wrapper.jar and b/Kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Kotlin/gradle/wrapper/gradle-wrapper.properties b/Kotlin/gradle/wrapper/gradle-wrapper.properties index 032d0433..e2847c82 100644 --- a/Kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/Kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Mon Jul 01 10:02:38 EEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/Kotlin/gradlew b/Kotlin/gradlew index cccdd3d5..f5feea6d 100755 --- a/Kotlin/gradlew +++ b/Kotlin/gradlew @@ -1,78 +1,130 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/Kotlin/gradlew.bat b/Kotlin/gradlew.bat index e95643d6..9b42019c 100644 --- a/Kotlin/gradlew.bat +++ b/Kotlin/gradlew.bat @@ -1,4 +1,22 @@ -@if "%DEBUG%" == "" @echo off +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -9,25 +27,29 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -35,48 +57,36 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/Kotlin/lib/build.gradle b/Kotlin/lib/build.gradle deleted file mode 100644 index 35dd930e..00000000 --- a/Kotlin/lib/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'kotlin-android' - -android { - - compileSdkVersion 29 - - defaultConfig { - minSdkVersion 14 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - androidTestImplementation 'junit:junit:4.13' - androidTestImplementation 'androidx.test:runner:1.2.0' -} diff --git a/Kotlin/lib/proguard-rules.pro b/Kotlin/lib/proguard-rules.pro deleted file mode 100644 index f1b42451..00000000 --- a/Kotlin/lib/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# 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 diff --git a/Kotlin/lib/src/main/AndroidManifest.xml b/Kotlin/lib/src/main/AndroidManifest.xml deleted file mode 100644 index 058adf02..00000000 --- a/Kotlin/lib/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Kotlin/library/build.gradle.kts b/Kotlin/library/build.gradle.kts new file mode 100644 index 00000000..76182371 --- /dev/null +++ b/Kotlin/library/build.gradle.kts @@ -0,0 +1,147 @@ +import com.vanniktech.maven.publish.SonatypeHost +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +plugins { + kotlin("plugin.allopen") version libs.versions.kotlin + alias(libs.plugins.kotlinMultiplatform) + alias(libs.plugins.kotlinxBenchmark) + alias(libs.plugins.androidLibrary) + alias(libs.plugins.kotlinxSerialization) + alias(libs.plugins.vanniktech.mavenPublish) +} + +group = "com.wolt.blurhashkt" +version = "1.0.0" + +kotlin { + jvm() + androidTarget { + publishLibraryVariants("release", "debug") + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + jvmTarget.set(JvmTarget.JVM_11) + } + } + macosX64() + macosArm64() + iosX64() + iosArm64() + iosSimulatorArm64() +// mingwX64() + linuxX64() + linuxArm64() + + sourceSets { + val commonMain by getting { + dependencies { + implementation(libs.kotlinx.benchmark.runtime) + implementation(libs.kotlinx.serialization.core) + } + } + val commonTest by getting { + dependencies { + implementation(libs.kotlin.test) + } + } + val androidMain by getting { + dependencies { + implementation(libs.androidx.core.ktx) + } + } + val androidInstrumentedTest by getting { + dependencies { + implementation(libs.androidx.test.runner) + implementation(libs.androidx.test.junit) + } + } + } +} + +tasks.withType { + useJUnitPlatform() + + // Enable verbose output + testLogging { + events("passed", "skipped", "failed") + showExceptions = true + showStandardStreams = true + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL + } +} + +android { + namespace = "com.wolt.blurhashkt" + compileSdk = libs.versions.android.compileSdk.get().toInt() + defaultConfig { + minSdk = libs.versions.android.minSdk.get().toInt() + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +allOpen { + // Required to ensure benchmark classes and methods are open + annotation("org.openjdk.jmh.annotations.State") +} + +benchmark { + targets { + register("jvm") + register("android") + register("macosX64") + register("macosArm64") + register("iosX64") + register("iosArm64") + register("iosSimulatorArm64") + // register("mingwX64") + register("linuxX64") + register("linuxArm64") + } + configurations { + named("main") { + warmups = 1 + iterations = 1 + iterationTime = 1000 + iterationTimeUnit = "ms" + outputTimeUnit = "ms" + } + } // TODO: Finalize any missing changes +} + +mavenPublishing { + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + + signAllPublications() + + coordinates(group.toString(), "library", version.toString()) + + pom { + name = "Thumbhash Kotlin" + description = "A Kotlin implementation for Thumbhash." + inceptionYear = "2025" + url = "https://github.com/woltapp/blurhash" + licenses { + license { + name = "MIT" + url = "https://opensource.org/license/MIT/" + distribution = "repo" + } + } + developers { +// developer { +// id = "" +// name = "" +// url = "" +// } + } + scm { + url = "https://github.com/woltapp/blurhash" + connection = "https://github.com/woltapp/blurhash.git" + developerConnection = "https://github.com/woltapp/blurhash.git" + } + } +} diff --git a/Kotlin/lib/src/androidTest/java/com/wolt/blurhashkt/BlurHashDecoderTest.kt b/Kotlin/library/src/androidInstrumentedTest/kotlin/com/wolt/blurhashkt/BlurHashDecoderTest.kt similarity index 100% rename from Kotlin/lib/src/androidTest/java/com/wolt/blurhashkt/BlurHashDecoderTest.kt rename to Kotlin/library/src/androidInstrumentedTest/kotlin/com/wolt/blurhashkt/BlurHashDecoderTest.kt diff --git a/Kotlin/lib/src/main/java/com/wolt/blurhashkt/BlurHashDecoder.kt b/Kotlin/library/src/androidMain/kotlin/com/wolt/blurhashkt/BlurHashDecoder.kt similarity index 85% rename from Kotlin/lib/src/main/java/com/wolt/blurhashkt/BlurHashDecoder.kt rename to Kotlin/library/src/androidMain/kotlin/com/wolt/blurhashkt/BlurHashDecoder.kt index 3278868b..d53f44f2 100644 --- a/Kotlin/lib/src/main/java/com/wolt/blurhashkt/BlurHashDecoder.kt +++ b/Kotlin/library/src/androidMain/kotlin/com/wolt/blurhashkt/BlurHashDecoder.kt @@ -88,19 +88,19 @@ object BlurHashDecoder { val g = (value / 19) % 19 val b = value % 19 return floatArrayOf( - signedPow2((r - 9) / 9.0f) * maxAc, - signedPow2((g - 9) / 9.0f) * maxAc, - signedPow2((b - 9) / 9.0f) * maxAc + signedPow2((r - 9) / 9.0f) * maxAc, + signedPow2((g - 9) / 9.0f) * maxAc, + signedPow2((b - 9) / 9.0f) * maxAc ) } private fun signedPow2(value: Float) = value.pow(2f).withSign(value) private fun composeBitmap( - width: Int, height: Int, - numCompX: Int, numCompY: Int, - colors: Array, - useCache: Boolean + width: Int, height: Int, + numCompX: Int, numCompY: Int, + colors: Array, + useCache: Boolean ): Bitmap { // use an array for better performance when writing pixel colors val imageArray = IntArray(width * height) @@ -151,11 +151,11 @@ object BlurHashDecoder { } private fun DoubleArray.getCos( - calculate: Boolean, - x: Int, - numComp: Int, - y: Int, - size: Int + calculate: Boolean, + x: Int, + numComp: Int, + y: Int, + size: Int ): Double { if (calculate) { this[x + numComp * y] = cos(Math.PI * y * x / size) @@ -173,13 +173,13 @@ object BlurHashDecoder { } private val charMap = listOf( - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', - 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '#', '$', '%', '*', '+', ',', - '-', '.', ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~' + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '#', '$', '%', '*', '+', ',', + '-', '.', ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~' ) - .mapIndexed { i, c -> c to i } - .toMap() + .mapIndexed { i, c -> c to i } + .toMap() } diff --git a/Kotlin/settings.gradle b/Kotlin/settings.gradle deleted file mode 100644 index 42198e65..00000000 --- a/Kotlin/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':demo', ':lib' diff --git a/Kotlin/settings.gradle.kts b/Kotlin/settings.gradle.kts new file mode 100644 index 00000000..9a421c83 --- /dev/null +++ b/Kotlin/settings.gradle.kts @@ -0,0 +1,31 @@ +rootProject.name = "BlurHash" +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + +pluginManagement { + repositories { + google { + mavenContent { + includeGroupAndSubgroups("androidx") + includeGroupAndSubgroups("com.android") + includeGroupAndSubgroups("com.google") + } + } + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositories { + google { + mavenContent { + includeGroupAndSubgroups("androidx") + includeGroupAndSubgroups("com.android") + includeGroupAndSubgroups("com.google") + } + } + mavenCentral() + } +} + +include(":library", ":demo")