Skip to content

Instantly share code, notes, and snippets.

echo "# arguments called with ----> ${@} "
echo "# \$1 ----------------------> $1 "
echo "# \$2 ----------------------> $2 "
echo "# path to me ---------------> ${0} "
echo "# parent path --------------> ${0%/*} "
echo "# my name ------------------> ${0##*/} "
@idanatz
idanatz / proguard-rules.pro
Last active March 29, 2020 15:00
Kotlin Obfuscation Blog Post
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
public static void checkExpressionValueIsNotNull(java.lang.Object, java.lang.String);
public static void checkFieldIsNotNull(java.lang.Object, java.lang.String);
public static void checkFieldIsNotNull(java.lang.Object, java.lang.String, java.lang.String);
public static void checkNotNull(java.lang.Object);
public static void checkNotNull(java.lang.Object, java.lang.String);
public static void checkNotNullExpressionValue(java.lang.Object, java.lang.String);
public static void checkNotNullParameter(java.lang.Object, java.lang.String);
public static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
public static void checkReturnedValueIsNotNull(java.lang.Object, java.lang.String);
@idanatz
idanatz / apk_teardown.java
Created February 17, 2020 18:12
Kotlin Obfuscation Blog Post
public final class a {
public String a;
public final String a() {
String var1 = this.a;
if (var1 == null) {
b.b("importantVar");
}
return var1;
}
@idanatz
idanatz / java_decompiled_class.java
Last active February 22, 2020 19:43
Kotlin Obfuscation Blog Post
// removed some of the irrelevant code for simplicity
public final class SomeClass {
@NotNull public String importantVar;
@NotNull
public final String getImportantVar() {
String var10000 = this.importantVar;
if (var10000 == null) {
Intrinsics.throwUninitializedPropertyAccessException("importantVar");
}
@idanatz
idanatz / example.kt
Last active February 17, 2020 17:42
Kotlin Obfuscation Blog Post
// note: this code is for example purposes, i know its not the right why to do things :)
class SomeClass {
lateinit var importantVar: String
fun funcWithParams(importantString: String, importantList: List<Int>) {
}
fun String.importantExtensionFunc() {
}
}
@idanatz
idanatz / LocaleSafeWebView.kt
Last active March 29, 2020 15:00
Runtime Locale Changing Blog Post
class LocaleSafeWebView : WebView {
constructor(context: Context) : super(context) {
overrideLocale()
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
overrideLocale()
}
@idanatz
idanatz / RuntimeLocaleChanger.kt
Last active March 29, 2020 15:00
Runtime Locale Changing Blog Post
object RuntimeLocaleChanger {
fun wrapContext(context: Context): Context { ... }
fun overrideLocale(context: Context) {
val savedLocale = createLocaleFromSavedLanguage() // load the user picked language from persistence (e.g SharedPreferences)
?: return // nothing to do in this case
// as part of creating a new context that contains the new locale we also need to override the default locale.
@idanatz
idanatz / App.kt
Last active March 29, 2020 15:00
Runtime Locale Changing Blog Post
class App : Application() {
override fun attachBaseContext(base: Context) { ... }
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
RuntimeLocaleChanger.overrideLocale(this)
}
}
@idanatz
idanatz / App.kt
Last active March 29, 2020 15:00
Runtime Locale Changing Blog Post
class App : Application() {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(RuntimeLocaleChanger.wrapContext(base))
}
}
@idanatz
idanatz / RuntimeLocaleChanger.kt
Last active March 29, 2020 15:01
Runtime Locale Changing Blog Post
object RuntimeLocaleChanger {
fun wrapContext(context: Context): Context {
val savedLocale = createLocaleFromSavedLanguage() // load the user picked language from persistence (e.g SharedPreferences)
?: return context // else return the original untouched context
// as part of creating a new context that contains the new locale we also need to override the default locale.
Locale.setDefault(savedLocale)