Skip to content

Instantly share code, notes, and snippets.

View alvindizon's full-sized avatar
🎯
Focusing

alvindizon

🎯
Focusing
View GitHub Profile
@JunkFood02
JunkFood02 / Motion.kt
Last active July 19, 2024 11:57
A music player demo made with Jetpack Compose animation APIs, including shared element transition, list animations, animated content, etc.
package com.example.compose_debug
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.FastOutLinearInEasing
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.PathEasing
@rynkowsg
rynkowsg / SharedPreferencesUtils.kt
Created March 6, 2024 16:03
Get EncryptedSharedPreferences
//
// Get EncryptedSharedPreferences and handle restore of accidentallly
// backuped file that we can no longer decrypt. If the master key provided
// is not able to decrypt the shared preferences, the file will be recreated.
//
// Tested with "androidx.security:security-crypto:1.1.0-alpha06"
//
package pl.rynkowski.platform_utils
@mxalbert1996
mxalbert1996 / AutoShrinkText.kt
Created April 6, 2023 07:24
Auto Size (Auto Shrink) Text
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.LocalContentColor
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
@rain-1
rain-1 / LLM.md
Last active November 2, 2024 12:14
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

import android.annotation.SuppressLint
import androidx.compose.animation.animateColor
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
import androidx.compose.foundation.Image
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.fillMaxSize
@NicolaVerbeeck
NicolaVerbeeck / EncryptedFileStorage.kt
Last active April 18, 2024 21:12
Encrypted file storage for data store
package com.a.b
import android.content.Context
import androidx.annotation.GuardedBy
import androidx.datastore.core.ReadScope
import androidx.datastore.core.Serializer
import androidx.datastore.core.Storage
import androidx.datastore.core.StorageConnection
import androidx.datastore.core.WriteScope
import androidx.datastore.core.use
@KONFeature
KONFeature / ComposeOverlayViewService.kt
Created June 28, 2022 21:34
Service ready to display complete view (with the right context to access the window manager and layout inflater if needed, but also access to a saved state registry and a view model store owner). Then a compose overlay service, that use the first one to push a compose view as system overlay, and also proposing a simple draggable box that can be …
import android.content.Intent
import android.graphics.PixelFormat
import android.os.IBinder
import android.view.Gravity
import android.view.WindowManager
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@zivkesten
zivkesten / BottomSheetUtils.kt
Last active June 3, 2024 14:36
Extension functions to display a Jetpack Compose bottom sheet over Android view
// Extension for Activity
fun Activity.showAsBottomSheet(content: @Composable (() -> Unit) -> Unit) {
val viewGroup = this.findViewById(android.R.id.content) as ViewGroup
addContentToView(viewGroup, content)
}
// Extension for Fragment
fun Fragment.showAsBottomSheet(content: @Composable (() -> Unit) -> Unit) {
val viewGroup = requireActivity().findViewById(android.R.id.content) as ViewGroup
addContentToView(viewGroup, content)
@apkelly
apkelly / Results.md
Last active August 6, 2024 06:58
Annotated String resources in Kotlin and for Jetpack Compose UI

The code below renders the following text in both Android Views and in Jetpack Compose UI.

Contact our team on 555 555 555 Opt 3 to activate.

@MachFour
MachFour / ActionMenu.kt
Last active January 22, 2024 14:39
Jetpack Compose Material3 ActionMenu
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Call
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem