Skip to content

Instantly share code, notes, and snippets.

@nhtzr
Created December 29, 2019 22:27
Show Gist options
  • Save nhtzr/e4933858804da5f08613f95ee102b4fa to your computer and use it in GitHub Desktop.
Save nhtzr/e4933858804da5f08613f95ee102b4fa to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Not actually executable, but a reminder for myself
# see https://lunaticgeek.com/whatsapp-stickers/
# see https://gist.github.com/patrickhammond/4ddbe49a67e5eb1b9c03#gistcomment-2903816
TMP="$(mktemp -d)"
wget https://dl.stickershop.line.naver.jp/products/0/0/1/3962468/iphone/[email protected] --no-check-certificate
# unzip, folder is stickers@2x
cd 'stickers@2x'
convert [email protected] -gravity center -background none -extent 96x96 tray.png
mogrify -resize 512x512 -gravity center -background none -extent 512x512 -format webp *.png
for i in *.webp; do mv "${i}" "${i/@2x/}"; done
( for i in *.webp; do jq -nc '.image_file=$i' --arg i "$i" ; done ) | jq -nSM '[inputs]' > $TMP/asset_hashes.json
cd -
git clone --depth=1 [email protected]:WhatsApp/stickers.git
cd stickers/Android
brew cask install android-sdk
brew cask install homebrew/cask-versions/adoptopenjdk8
brew cask uninstall java
jenv local 1.8
unset JAVA_OPTS
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
touch ~/.android/repositories.cfg
sdkmanager --update
sdkmanager "platform-tools" "platforms;android-28"
vi app/build.gradle
# apply plugin: 'com.android.application'
#
# android {
# + lintOptions {
# + abortOnError false
# + }
# //the compression of webp file during build causes problem with FileDescriptor in ContentProvider.
# aaptOptions {
# noCompress "webp"
# }
# compileSdkVersion 29
# defaultConfig {
# - applicationId "com.example.samplestickerapp"
# + applicationId "xyz.nhtzr.sampleStickers"
# minSdkVersion 15
# targetSdkVersion 29
# versionCode 1
jq '.sticker_packs[0]|=(.+{$stickers, $name, $tray_image_file})' app/src/main/assets/contents.json --argfile stickers $TMP/asset_hashes.json --arg name "${NAME?}" --arg tray_image_file "${TRAY_IMAGE_FILE?}" | sponge app/src/main/assets/contents.json
./gradlew build
./gradlew :app:assembleDebug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment