Skip to content

Instantly share code, notes, and snippets.

View es0329's full-sized avatar

Eric es0329

View GitHub Profile
@larryng
larryng / allure-kotlin-android-11.md
Created May 6, 2021 15:10
allure-kotlin on Android 11

re: android/android-test#743 (comment)

The workaround is to write to the app external cache instead:

/**
 * Basically [AllureAndroidJUnitRunner] except:
 *  - [Allure.lifecycle] is set to [BniAllureLifecycle]
 *  - without [ExternalStoragePermissionsListener] which doesn't work on Android 11
 */
@smokelaboratory
smokelaboratory / SecurityUtil.kt
Created April 29, 2021 18:00
Security Utility class
class SecurityUtil
@Inject
constructor() {
private val provider = "AndroidKeyStore"
private val cipher by lazy {
Cipher.getInstance("AES/GCM/NoPadding")
}
private val charset by lazy {
charset("UTF-8")
@zach-klippenstein
zach-klippenstein / SegmentedControl.kt
Last active December 26, 2024 23:13
iOS-style segmented control in Compose
import android.annotation.SuppressLint
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.forEachGesture
import androidx.compose.foundation.gestures.horizontalDrag
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.Box
@badsyntax
badsyntax / android_emulator_cli_ci.md
Last active May 28, 2025 12:31
start an android emulator with screen dimensions (specifically for use in CI)
# Install AVD files
yes | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-29;default;x86'
yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses

# Create emulator
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_API_29_AOSP -d pixel --package 'system-images;android-29;default;x86' --force

$ANDROID_HOME/emulator/emulator -list-avds
@vitorprado
vitorprado / RatingBar.kt
Created March 1, 2021 18:16
Jetpack Compose RatingBar (alpha12)
package com.components.ratingbar
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
@ThePredators
ThePredators / readme-mde.md
Last active June 29, 2026 15:04
Setup Mobile Development Environment

⭐ Setup Mobile Development Environment

⚠️ The following configuration has been tested on Intel, M1 & M2 Ships ⚠️

Pre-requisit :

If you have any issues with macOS, or need anything related to it check this documentation

Install Xcode Command Line tools :

@chriscoomber
chriscoomber / SingletonBase.kt
Last active November 7, 2024 11:09
Singletons with constructors in Kotlin
package com.example.app.utils
import org.jetbrains.annotations.TestOnly
/**
* Generic singleton implementation.
*
* # Usage
*
* First, defining your singleton:
@gmk57
gmk57 / 1 ViewBindingDelegates.kt
Last active June 29, 2025 07:54
Kotlin delegates for Android View Binding with usage examples
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.viewbinding.ViewBinding

A guide for working with Android Studio 4.1 on two or more personal Linux(Ubuntu) workstations.

  • More specifically, this is an offline plug and play approach for when you want to switch computers but your code is not hosted on the web

What you'll need:

  • A large capacity external drive (250gb or higher should be more than enough)

  • A base workstation to copy your AS (Android Studio) settings and data from

@3v1n0
3v1n0 / map-string-any-kotlin-serialization-tests.kt
Last active October 1, 2025 21:10
Kotlin Map<String, Any?> (andy Any type in general) (de)serialization tests with both Binary (CBOR) and JSON support
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.CompositeDecoder
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.*
import kotlin.reflect.KType
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.starProjectedType