Skip to content

Instantly share code, notes, and snippets.

View michpohl's full-sized avatar
🏁
undefined

Michael Pohl michpohl

🏁
undefined
View GitHub Profile
@michpohl
michpohl / svg-to-xml.markdown
Last active September 18, 2024 19:51
How to easily batch convert many .svg files to Android Vector Drawables

How to easily batch convert many .svg files to Android Vector Drawables

Note that Android Studio claims to also be able to batch-import files starting version 3.4. Depending on how well that works and what you like, this solution might still be preferrable (it is for me)

We will need two tools:

  1. Prior to conversion we want to optimize our .svg files using SVGO. SVG Optimizer is a Node.js-based tool for optimizing SVG vector graphics files. Find it here: https://www.npmjs.com/package/svgo

  2. For conversion we will use vd-tool, a command line tool built from the actual converter inside Android Studio, so we know it will just do the same conversions. Here is a link: https://www.androiddesignpatterns.com/2018/11/android-studio-svg-to-vector-cli.html

@michpohl
michpohl / squashtop.sh
Last active December 20, 2021 15:25
Quickly squash n git commits into the n+1th
#!/bin/bash
# Script to quickly squash the last n commits in your current git branch into the n+1th.
# The n+1th commit message is re-used, the others are discarded
# user input
COUNT="$1"
if [[ -z $COUNT ]] ; then
printf "Usage: fixtop.sh [NUMBER]\nThis will squash the specified number of commits into the one right before.\n"
@michpohl
michpohl / build_vdtool.sh
Last active August 9, 2021 19:01
Bash script to build vd-tool from Android sources to batch convert SVG to VectorDrawables via terminal
#!/bin/bash
# inspiration for this script comes from here: https://www.androiddesignpatterns.com/2018/11/android-studio-svg-to-vector-cli.html
DESIRED_PATH="$1"
if [ -z "$1" ]
then
echo "No path provided.Please specify a path to clone the source files into."
echo -e "\nUsage: $ ./build_vdtool.sh [my-desired-path]\n"
echo "It is suggested to place these files outside of your app's source in order to not mess up the project files"
@michpohl
michpohl / sharedprefs.md
Last active January 25, 2021 15:20
How to find information from an installed Android app's SharedPreferences (if you have access to the keystore)

How to find information from an installed Android app's SharedPreferences (if you have access to the keystore)

Prerequisite: Yes, you can gain some nice insights following this How-To, but you can only get to the end of it if you're legitimized to do so (you need to have the app's keyStore and the passwords to it!)

You should also have the Android Debug Bridge (adb) installed as well as Android Studio.

1. Install the app on your phone

You might want to use it a bit and play around with it so all the data you might be looking for in sharedPreferences gets generated.

2. Find the app's package name

Go to the Play Store website, search for your app, and open the app's page. Now you can just copy the package name from the address bar

@michpohl
michpohl / JsonDataClass.kt
Last active December 28, 2019 07:41
JsonDataClass, enabling all sub (data) classes to be converted to Json and from Json unsing Moshi
/**
* All sub classes must be data classes!
*/
open class JsonDataClass {
fun toJsonString(): String {
return Moshi.Builder().build().adapter(this.javaClass).toJson(this)
}
companion object {
@michpohl
michpohl / how_to_font_scale_android.md
Last active May 6, 2019 16:09
how to override Accessibility fontScale setting in Android

Just check what sizing the fontScale is set to and change it to whatever we want. Then We have to reapply the configuration. This is an example method to put into an activity:

override fun attachBaseContext(newBase: Context?) {
        super.attachBaseContext(newBase)
        val conf = newBase!!.resources.configuration
        if (conf.fontScale > 1) {
            conf.fontScale = 1F
        applyOverrideConfiguration(conf)