Skip to content
Open
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
56 changes: 18 additions & 38 deletions Kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -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
29 changes: 0 additions & 29 deletions Kotlin/build.gradle

This file was deleted.

29 changes: 29 additions & 0 deletions Kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
// 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/**")
// }
// }
//}
29 changes: 0 additions & 29 deletions Kotlin/demo/build.gradle

This file was deleted.

71 changes: 71 additions & 0 deletions Kotlin/demo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}

21 changes: 0 additions & 21 deletions Kotlin/demo/proguard-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wolt.blurhashapp">
<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="@style/AppTheme">
<activity android:name="com.wolt.blurhashapp.MainActivity">
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"/>
<action android:name="android.intent.action.MAIN" />

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

</manifest>
</manifest>
104 changes: 104 additions & 0 deletions Kotlin/demo/src/androidMain/kotlin/com/wolt/blurhashapp/App.kt
Original file line number Diff line number Diff line change
@@ -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<Bitmap?>(null) }
var decodingTime by remember { mutableStateOf<Long>(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
}
Loading