Added a shell script to generate multi-dpi css files for the mobile client.
This commit is contained in:
parent
1bb56e6581
commit
f87d98a6df
41
clients/flash/air-client/generate_css_dpi.sh
Normal file
41
clients/flash/air-client/generate_css_dpi.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Install bc binayr to use this command line tool `sudo apt-get install bc`
|
||||||
|
# Then install cssbeautify-cli node.js library `sudo npm install -g cssbeautify-cli`
|
||||||
|
# npm install -g perfectionist --save
|
||||||
|
# Resolution arrays declaration
|
||||||
|
declare -a files=("ldpi" "mdpi" "hdpi" "xxhdpi" "xxxhdpi")
|
||||||
|
declare -a resolutions=("120" "160" "240" "480" "640")
|
||||||
|
declare -a ratios=("0.375" "0.5" "0.75" "1.5" "2")
|
||||||
|
|
||||||
|
# Loop over reoslution array
|
||||||
|
for i in "${!files[@]}"
|
||||||
|
do
|
||||||
|
echo "Generating file ${files[$i]}.css with ${resolutions[$i]} dpi resolution"
|
||||||
|
# Delete the old file
|
||||||
|
rm src/css/tmp.css 2> /dev/null
|
||||||
|
while IFS='' read line || [[ -n "$line" ]]; do
|
||||||
|
regex="(.*):(\s*)([0-9]*);"
|
||||||
|
# Find any digit that matches the regex
|
||||||
|
if [[ $line =~ $regex ]]
|
||||||
|
then
|
||||||
|
# Replace the match
|
||||||
|
res_value=$(echo "scale=1; ${BASH_REMATCH[3]}*${ratios[$i]}" | bc -l)
|
||||||
|
echo $line | sed "s/${BASH_REMATCH[3]}/${res_value}/g" >> src/css/tmp.css
|
||||||
|
else
|
||||||
|
# Or write the line as it is
|
||||||
|
echo $line >> src/css/tmp.css
|
||||||
|
fi
|
||||||
|
# Always use xhdpi.css as base to geenrate css files
|
||||||
|
done < src/css/xhdpi.css
|
||||||
|
|
||||||
|
# Write the new resolution to the generated file
|
||||||
|
sed -ri "s/(application-dpi:\s*)[0-9]*/\1${resolutions[$i]}/g" src/css/tmp.css
|
||||||
|
echo "Running CSS beautifier on ${files[$i]}.css"
|
||||||
|
cssbeautify-cli -i4 -f "src/css/tmp.css" -w "src/css/output.css"
|
||||||
|
# Remove the first commented line
|
||||||
|
sed '1d' src/css/output.css > "src/css/${files[$i]}.css";
|
||||||
|
rm src/css/output.css
|
||||||
|
done
|
||||||
|
|
||||||
|
# Finally delete the temporary file
|
||||||
|
rm src/css/tmp.css
|
Loading…
Reference in New Issue
Block a user