Skip to content

Instantly share code, notes, and snippets.

@ksharma-xyz
ksharma-xyz / .zshrc
Last active June 3, 2024 10:04
android - adb commands with alias
## Read Blog - https://www.ksharma.xyz/android-adb-shortcuts-for-productivity
## A11y - Talkback
alias TalkbackOn="adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService"
alias TalkbackOff="adb shell settings put secure enabled_accessibility_services com.android.talkback/com.google.android.marvin.talkback.TalkBackService"
## A11y - FontSize
alias LargeFontSize="adb shell settings put system font_scale 2.0" # Largest font size for android devices
alias MediumFontSize="adb shell settings put system font_scale 1.5"
@ksharma-xyz
ksharma-xyz / TinkCryptoManager.kt
Last active May 24, 2024 11:16
Encryption and Decryption using Google Tink and managing keys using AndroidKeystore
import androidx.security.crypto.MasterKeys
import com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm
object TinkCryptoManager {
// Get / Create Keys using Android Keystore
private val aesKeystore =
AndroidKeystoreAesGcm(MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC))
fun encrypt(plainText: String): ByteArray =
@ksharma-xyz
ksharma-xyz / build.gradle.kts
Created May 24, 2024 09:10
Adding Google Tink dependency in Android project
dependencies {
implementation("com.google.crypto.tink:tink-android:1.13.0") // check latest version
}
@ksharma-xyz
ksharma-xyz / SecureScreen.kt
Last active May 13, 2024 01:00
Listen to changes in android Lifecycle in Composable and set and clear secure flag in onStart / onStop.
import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import android.view.WindowManager.LayoutParams.FLAG_SECURE
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@ksharma-xyz
ksharma-xyz / ComposableLifeCycleListener.kt
Created May 12, 2024 11:00
Listener for Composable Lifecycle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
@Composable
fun ComposableLifecycleListener(
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,