Skip to content

Instantly share code, notes, and snippets.

Avatar
🌈

Rebecca Franks riggaroo

🌈
View GitHub Profile
@riggaroo
riggaroo / export_strings.yml
Last active Dec 5, 2020
Github Action workflow that copies string translations from one repo into another and creates a PR.
View export_strings.yml
name: Translation Export to Android Repo
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
push_strings_to_over:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, 'Automated checkin')"
steps:
@riggaroo
riggaroo / tag_release.yml
Created Oct 4, 2020
Github Action workflow for tagging release on Github Release, copying release notes from CHANGELOG.md
View tag_release.yml
name: Tag Release
on:
push:
branches: [ main ]
jobs:
tag_release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
@riggaroo
riggaroo / create_release_branch.yml
Last active May 16, 2021
Github Action workflow for creating release branch, updating versionName and versionCode, copying strings.xml to another repo, submitting PRs as per GitFlow.
View create_release_branch.yml
name: Create Release Branch
on:
workflow_dispatch:
inputs:
versionName:
description: 'Name of version (ie 5.5.0)'
required: true
versionCode:
description: 'Version number (50500)'
required: true
@riggaroo
riggaroo / pull_screenshots.sh
Created Apr 30, 2020
pull_screenshots.sh script from Chiu-ki Chan's video on terminal tricks https://youtu.be/1N90lU1xn2w
View pull_screenshots.sh
#! /bin/bash
today=$(date +%Y%m%d)
for path in $(adb shell ls /sdcard/Pictures/Screenshots/*"${today}"*); do
name=$(basename "$path")
if [ ! -f "$name" ]; then
adb pull "$path"
fi
done
@riggaroo
riggaroo / InlineClasses.kt
Last active Mar 2, 2020
Have you heard about inline classes in Kotlin?
View InlineClasses.kt
// Why use inline classes? 🤔
// 🎯 Compile time safety
// 🎯 Less runtime overhead than a normal wrapper class as it "inlines" the data into its usages
// More info : https://kotlinlang.org/docs/reference/inline-classes.html
// Without inline classes 😞
data class Recipe(id: UUID)
data class Ingredient(id: UUID, recipeId: UUID)
@riggaroo
riggaroo / SpringAnimationVelocity.kt
Created Mar 28, 2019
Example setting start velocity of a spring animation.
View SpringAnimationVelocity.kt
SpringAnimation(this, floatPropertyAnimY, point.y).apply {
setStartVelocity(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5000f, resources.displayMetrics))
start()
}
@riggaroo
riggaroo / SpringAnimation.kt
Created Mar 28, 2019
Example using SpringAnimation to animate a custom view using FloatPropertyCompat properties.
View SpringAnimation.kt
private fun animateToPoint(point: Point) {
SpringAnimation(this, floatPropertyAnimX, point.x).apply {
spring.stiffness = SpringForce.STIFFNESS_MEDIUM
spring.dampingRatio = SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY
start()
}
SpringAnimation(this, floatPropertyAnimY, point.y).apply {
spring.stiffness = SpringForce.STIFFNESS_MEDIUM
@riggaroo
riggaroo / FloatPropertyCompatExamples.kt
Created Mar 28, 2019
Example of using FloatPropertyCompat for SpringAnimations.
View FloatPropertyCompatExamples.kt
private val floatPropertyAnimX = object : FloatPropertyCompat<ColorDropperView>(PROPERTY_X) {
override fun setValue(dropper: ColorDropperView?, value: Float) {
dropper?.setDropperX(value)
}
override fun getValue(dropper: ColorDropperView?): Float {
return dropper?.getDropperX() ?: 0f
}
}
@riggaroo
riggaroo / ValueAnimator.kt
Created Mar 28, 2019
Example showing how to use PropertyValuesHolder to animate a custom views properties.
View ValueAnimator.kt
private fun animateToPoint(point: Point) {
val propertyX = PropertyValuesHolder.ofFloat(ColorDropperView.PROPERTY_X, dropperPoint.x, point.x)
val propertyY = PropertyValuesHolder.ofFloat(ColorDropperView.PROPERTY_Y, dropperPoint.y, point.y)
val animator = ValueAnimator()
animator.setValues(propertyX, propertyY)
animator.interpolator = OvershootInterpolator()
animator.duration = 100
animator.addUpdateListener { animation ->
val animatedX = animation.getAnimatedValue(ColorDropperView.PROPERTY_X) as Float
@riggaroo
riggaroo / CustomView-Snippet6.kt
Created Mar 21, 2019
Using extension function to draw to canvas.
View CustomView-Snippet6.kt
canvas.withTranslate(200f, 300f) {
drawCircle(...)
}