Skip to content

Instantly share code, notes, and snippets.

View G00fY2's full-sized avatar

Thomas Wirth G00fY2

View GitHub Profile
@G00fY2
G00fY2 / CircleTransformation.kt
Last active March 10, 2020 01:48
Circle image transformation for Picasso 3 which handles API 26+ hardware bitmaps
import android.graphics.Bitmap
import android.graphics.Bitmap.Config
import android.graphics.BitmapShader
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Shader
import android.os.Build.VERSION
import android.os.Build.VERSION_CODES
import com.squareup.picasso3.RequestHandler
import com.squareup.picasso3.Transformation
@G00fY2
G00fY2 / privacy_policy_template.md
Last active December 14, 2020 07:42
Basic privacy policy template for open source apps that do not collect any personal information

Privacy Policy

[author] built the app [app_name] as an open source app for use as is.

Your Privacy

I take your privacy seriously! That's why this app does NOT collect or share any personal information.

The app also does NOT use third party services that collect information used to identify you.

@G00fY2
G00fY2 / CustomRxJava2CallAdapterFactory.java
Last active November 3, 2022 13:08
CustomRxJava2CallAdapterFactory to transform HttpExceptions to custom error
import com.google.gson.Gson;
import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.Maybe;
import io.reactivex.MaybeSource;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.Scheduler;
import io.reactivex.Single;
import java.lang.annotation.Annotation;
@G00fY2
G00fY2 / .gitignore
Last active July 3, 2021 11:33
A current reference template to use for Android development collected from the official github and gitignore.io templates. The template contains OS specific files (macOS, Linux, Windows) as well as files regarding the IDE (IntelliJ IDEA/Android Studio), Gradle, Java, Kotlin, proguard, build artifacts, common plugins and many more.
# Reference gitignore https://gist.github.com/G00fY2/81c0aa67943cca021e915840bf73ee1b
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
@G00fY2
G00fY2 / gist:ce88eb2dc2ee68f25b4a292571321f97
Created November 16, 2020 21:25
Android DeviceDefault AccentColor
var accentColor = Color.WHITE
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
context.obtainStyledAttributes(
android.R.style.ThemeOverlay_DeviceDefault_Accent_DayNight,
intArrayOf(android.R.attr.colorAccent)
).also {
accentColor = it.getColor(0, accentColor)
}.recycle()
}
org.gradle.jvmargs=-Xmx3g -XX:+UseParallelGC
org.gradle.daemon=true
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand=false
org.gradle.vfs.watch=true
@G00fY2
G00fY2 / gist:c8daab6115c07d78d8851565bf703375
Created April 14, 2021 22:25
kotlin conventional commit
val conventionalCommitRegex = Regex("^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\(\\w+\\))?(!)?(: (.*\\s*)*))|(Merge (.*\\s*)*)|(Initial commit\$)")
val maxSubjectLineLength = 72
val test = "fix(dagger): fix bad injection"
conventionalCommitRegex.matches(test) && test.lines().first().length <= maxSubjectLineLength
@G00fY2
G00fY2 / gist:6d19efffabfa1f64b0a56232a985d636
Created April 29, 2021 23:06
If you have a local clone, you can update it by running:
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
@G00fY2
G00fY2 / GitHookPlugin.kt
Last active January 20, 2023 12:46
Gradle task to generate a git commit hook
package buildplugins
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.model.ObjectFactory
import org.gradle.api.plugins.HelpTasksPlugin.HELP_GROUP
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
@G00fY2
G00fY2 / r8.md
Last active September 28, 2022 05:52
R8 Shrinker tweaks

Gradle task that prints the currently used R8 version

tasks.register("printR8Version") {
  try {
    println("R8 version: ${com.android.tools.r8.Version.getVersionString()}")
  } catch (ignored: Exception) {
    println("R8 version: unknown")
  }
}