Skip to content

Instantly share code, notes, and snippets.

View runo280's full-sized avatar
🀨

runo280 runo280

🀨
  • ‍‍‍~
View GitHub Profile
@dmytrodanylyk
dmytrodanylyk / description.md
Last active June 20, 2022 15:00
Where this dependency comes from?

Did you ever have android build failed​ issue because of dependency resolution?

… or you were curious where all these old rxjava dependencies come from?

You can pretty easy track the module causing issues via following gradle command.

gradlew :root-module:dependencyInsight \
--configuration debugRuntimeClasspath \ // or debugCompileClasspath
--dependency io.reactivex:rxjava:1.1.0 > dependencies.txt // saves result to 'dependencies.txt' file
@alexjlockwood
alexjlockwood / CircleSquareView.kt
Created April 8, 2019 05:59
Inspired by @beesandbombs (twitter.com/beesandbombs)
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
@alexjlockwood
alexjlockwood / animated_cat.xml
Last active September 12, 2023 12:55
Android implementation of an animated cat loading spinner. Inspired by https://twitter.com/marcedwards/status/1109431862030524418
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
android:name="vector"
android:width="100dp"
android:height="100dp"
android:viewportWidth="100"
android:viewportHeight="100">
<group
@davidvavra
davidvavra / NonNullAssertionDetector.kt
Created March 22, 2019 17:06
Lint check for detecting non-null assertion (!!) in your code
import com.android.tools.lint.client.api.UElementHandler
import com.android.tools.lint.detector.api.*
import org.jetbrains.uast.UElement
import org.jetbrains.uast.UPostfixExpression
class NonNullAssertionDetector : Detector(), Detector.UastScanner {
override fun getApplicableUastTypes(): List<Class<out UElement>>? {
return listOf(UPostfixExpression::class.java)
}
@alexjlockwood
alexjlockwood / WaveSquare.kt
Created March 11, 2019 02:30
Kotlin implementation of a wave square animation, inspired by https://twitter.com/beesandbombs/status/1101169015299420163
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import android.util.AttributeSet
import android.view.View
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
@aramezx
aramezx / SymmetricKeyGenerationAndroidMRedesignedKeyStore.java
Created March 5, 2019 08:59
Here's how generating and retrieving a 256-bit AES key looks when using the new M APIs:
/*
* Android M officially introduces several new keystore features into the framework API,
* but the underlying work to support them has been going on for quite a while in the AOSP master branch.
* The most visible new feature is support for generating and using symmetric keys that
* are protected by the system keystore. Storing symmetric keys has been possible in previous versions too,
* but required using private (hidden) keystore APIs, and was thus not guaranteed to be portable across versions.
* Android M introduces a keystore-backed symmetric KeyGenerator, and adds support for the KeyStore.SecretKeyEntry JCA class,
* which allows storing and retrieving symmetric keys via the standard java.security.
* KeyStore JCA API. To support this, Android-specific key parameter classes and associated builders
* have been added to the Android SDK.
@aramezx
aramezx / keyExchangeImplementationUsingRSAOAEP.java
Created March 5, 2019 08:52
if you need to implement RSA key exchange, you can easily make use of OAEP padding like this:
/* if you need to implement RSA key exchange, you can easily make use of OAEP padding like this: */
ndroidRsaEngine rsa = new AndroidRsaEngine("key1", false);
Digest digest = new SHA512Digest();
Digest mgf1digest = new SHA512Digest();
OAEPEncoding oaep = new OAEPEncoding(rsa, digest, mgf1digest, null);
oaep.init(true, null);
byte[] cipherText = oaep.processBlock(plainBytes, 0, plainBytes.length);
@aramezx
aramezx / usingBouncyCastleForDigitalSignImplementation.java
Created March 5, 2019 08:50
How to use Android keystore and BouncyCastle for Sign Operation Implementation using RSA-PSS
/*
* If you use this primitive to implement, for example, Bouncy Castle's
* AsymmetricBlockCipher interface, you can use any signature algorithm available in the
* Bouncy Castle lightweight API (we actually use Spongy Castle to stay compatible
* with Android 2.x without too much hastle).
* For example, if you want to use a more modern (and provably secure)
* signature algorithm than Android's default PKCS#1.5
* implementation, such as RSA-PSS you can accomplish it with something
* like this (see sample project for AndroidRsaEngine):
*/
/*
* By using the IKeyStoreService directly you can store symmetric keys or other secret data
* in the system key store by using the put() method, which the current java.security.KeyStore implementation
* does not allow (it can only store PrivateKey's). Such data is only encrypted
* by the key store master key, and even the system key store is hardware-backed,
* data is not protected by hardware in any way.
*
* Accessing hidden services is not the only way to augment the system key store functionality.
* Since the sign() operation implements a 'raw' signature operation (RSASP1 in RFC 3447),
* key store-managed (including hardware-backed) keys can be used to
@aramezx
aramezx / generateKeyPairAndroidKeyStoreAPI18.java
Last active March 6, 2019 03:39
Basic Sample in keypair generation using android keystore in api level 18
/*
*
* The API is outlined in the 'Security' section of the 4.3 new API introduction page,
* and details can be found in the official SDK reference, so we will only review it briefly.
* Instead of introducing yet another Android-specific API, key store access is exposed via standard JCE APIs,
* namely KeyGenerator and KeyStore. Both are backed by a new Android JCE provider,
* AndroidKeyStoreProvider and are accessed by passing "AndroidKeyStore" as the type
* parameter of the respective factory methods (those APIs were actually available in 4.2 as well,
* but were not public). For a full sample detailing their usage,
* refer to the BasicAndroidKeyStore project in the Android SDK.