Skip to content

Instantly share code, notes, and snippets.

View tkuenneth's full-sized avatar

Thomas Künneth tkuenneth

View GitHub Profile
@tkuenneth
tkuenneth / DragAndDropDemo.kt
Created December 13, 2024 15:10
This demo shows how to achieve automatic scrolling of pages in a HorizontalPager upon drag and drop operations of children of pages.
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.grid.GridCells
@tkuenneth
tkuenneth / MainActivity.kt
Last active November 12, 2024 02:08
Jetpack Compose LazyColumn with animated header
package de.thomaskuenneth.animatedheaderdemo
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
@tkuenneth
tkuenneth / MainActivity.kt
Created May 29, 2021 10:07
How to display an adaptive icon in Jetpack Compose
package com.thomaskuenneth.sandbox
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
@tkuenneth
tkuenneth / MainActivity.kt
Created April 9, 2021 14:35
Short demo for OnReceiveContentListener
package com.thomaskuenneth.sandbox
import android.os.Bundle
import android.widget.EditText
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
@tkuenneth
tkuenneth / Better.kt
Created January 8, 2021 14:09
A short demo using coroutines
package com.thomaskuenneth
import androidx.compose.desktop.Window
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import kotlinx.coroutines.GlobalScope
@tkuenneth
tkuenneth / Bad.kt
Created January 8, 2021 14:08
A short demo deliberately showing bad coding style
import androidx.compose.desktop.Window
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
fun main() = Window {
Box(contentAlignment = Alignment.Center,
@tkuenneth
tkuenneth / BlinkingTitleBarDemo.kt
Created December 31, 2020 13:49
A Java Swing window with a blinking title bar
package com.thomaskuenneth
import kotlinx.coroutines.*
import java.awt.*
import java.awt.event.*
import javax.swing.*
import javax.swing.UIManager.*
import javax.swing.plaf.*
import java.lang.System.*
@tkuenneth
tkuenneth / ChristmasTreeActivity.kt
Created December 20, 2020 16:00
A Christmas tree in Jetpack Compose
package com.thomaskuenneth.christmastreecompose
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@tkuenneth
tkuenneth / AlertDialogDemo.kt
Created December 18, 2020 12:00
A Compose for Desktop example showing an AlertDialog
package com.thomaskuenneth
import androidx.compose.desktop.AppManager
import androidx.compose.desktop.Window
import androidx.compose.material.AlertDialog
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.window.Menu
@tkuenneth
tkuenneth / DexAnalyzer.java
Created November 10, 2020 15:39
Determines and visualizes dependencies between classes belonging to an Android app
/*
* DexAnalyzer.java
* Copyright 2016 Thomas Kuenneth
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of