Skip to content

Instantly share code, notes, and snippets.

View KaustubhPatange's full-sized avatar
🎯
Focusing

Kaustubh Patange KaustubhPatange

🎯
Focusing
View GitHub Profile
@granoeste
granoeste / EachDirectoryPath.md
Last active April 4, 2024 22:32
[Android] How to get the each directory path.

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

@zchee
zchee / actionlist.vim
Last active April 19, 2024 13:22
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@jemshit
jemshit / proguard-rules.pro
Last active April 27, 2024 08:54
Proguard Rules for Android libraries
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
### RxJava, RxAndroid (https://gist.github.com/kosiara/487868792fbd3214f9c9)
-keep class rx.schedulers.Schedulers {
public static <methods>;
@santaevpavel
santaevpavel / OutlineSpan.kt
Created July 9, 2018 06:25
Class for outlining text (TextView) on Android
class OutlineSpan(
@ColorInt private val strokeColor: Int,
@Dimension private val strokeWidth: Float
): ReplacementSpan() {
override fun getSize(
paint: Paint,
text: CharSequence,
start: Int,
end: Int,
@willyrh495
willyrh495 / EncryptionAES.kt
Created June 17, 2020 03:43
AES encryption using AndroidKeyStore
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import java.security.*
import javax.crypto.*
import javax.crypto.spec.GCMParameterSpec
import android.util.Base64
import androidx.annotation.VisibleForTesting
class EncryptionAES {
@manuelvicnt
manuelvicnt / AnAndroidApp.kt
Last active January 1, 2023 17:05
Hilt and AssistedInject working together in Hilt v2.28-alpha times - ViewModel version
// IMPORTANT! READ THIS FIRST
// Assisted Injection doesn't work with @HiltViewModel or @ViewModelInject
// Read more about the issue here: https://github.com/google/dagger/issues/2287
//
//
// AssistedInject and Hilt working together in v2.28-alpha times
// Example of a ViewModel using AssistedInject injected in a Fragment by Hilt
// As AssistedInject isn't part of Dagger yet, we cannot use in
// conjuction with @ViewModelInject
@truedem
truedem / ViewModelFactory.kt
Last active December 14, 2020 13:20
ViewModelFactory for Android Jetpack
class ViewModelFactory constructor(
private val baseRepository: BaseRepository, // your repository class to handle database, network, shared preferences, etc.
owner: SavedStateRegistryOwner,
defaultArgs: Bundle? = null
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) {
// usage in activity:
// val sharedVM by viewModels<MySharedViewModel> { ViewModelFactory(App.getRep(), this) }
// App.getRep() returns instance of BaseRepository, replace with your actual logic
@jpmcosta
jpmcosta / adb_wifi.bat
Created September 2, 2020 13:12
ADB over WiFi Batch Script
@echo off
setlocal
rem Change to suit your configuration.
set netmask=192.168
rem Set adb.
if [%1] == [] (
set adb=%ANDROID_HOME%\platform-tools\adb.exe
) else (
@cedrickring
cedrickring / ColoredShadow.kt
Last active April 18, 2024 10:29
Draw a colored shadow in Android Jetpack Compose
/*
Copyright 2020 Cedric Kring.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@bmc08gt
bmc08gt / AutoSizeText.kt
Last active February 16, 2024 10:58
Autosizing Text in Jetpack Compose
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle