Created
July 24, 2023 16:32
-
-
Save NedaTop/5c3b72cda4c6450df3670eb6300db4e4 to your computer and use it in GitHub Desktop.
Tiles to ProtoLayout migration script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run this script in your projects dir to migrate from Tiles to ProtoLayout by changing the imports. | |
path="" | |
# Should be the full path to the folder with Java classes. | |
while getopts p:w: flag | |
do | |
case "${flag}" in | |
p) path=${OPTARG};; | |
esac | |
done | |
if [[ $path != "" ]] then | |
cd "$path" | |
fi | |
# Rename material packages | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|androidx.wear.tiles.material|androidx.wear.protolayout.material|g" {} + | |
# Rename builder packages | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|androidx.wear.tiles|androidx.wear.protolayout|g" {} + | |
# Re-rename real tiles classes | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|androidx.wear.protolayout.EventBuilders|androidx.wear.tiles.EventBuilders|g" {} + | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|androidx.wear.protolayout.RequestBuilders|androidx.wear.tiles.RequestBuilders|g" {} + | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|androidx.wear.protolayout.TileBuilders|androidx.wear.tiles.TileBuilders|g" {} + | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|androidx.wear.protolayout.TileService|androidx.wear.tiles.TileService|g" {} + | |
# Rename updated methods | |
# Note that etXXXX is intentional as there are both setter and getter. | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|etTimeline|etTileTimeline|g" {} + | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|onResourcesRequest|onTileResourcesRequest|g" {} + | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|etDeviceParameters|etDeviceConfiguration|g" {} + | |
find . -type f -name "*.(java|kt)" -exec sed -i "s|etState|etCurrentState|g" {} + | |
cd - > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment