2020-06-06 11:07:56 +03:00
|
|
|
#!/bin/bash
|
|
|
|
# Convert app to a different package with different icon and name,
|
|
|
|
# to allow multiple installations on the same device.
|
|
|
|
|
|
|
|
mydir="$(dirname "$(realpath "$0")")"
|
|
|
|
|
2021-05-09 15:40:33 +03:00
|
|
|
if [ "$1" = "--name-replace" ]; then
|
|
|
|
replace_name=1
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
replace_name=0
|
|
|
|
fi
|
|
|
|
package_add="$1"
|
|
|
|
if ((replace_name)); then
|
|
|
|
name_replace="$2"
|
|
|
|
else
|
|
|
|
name_add="$2"
|
|
|
|
name_replace="SchildiChat.$name_add"
|
|
|
|
fi
|
|
|
|
|
2020-11-05 18:11:32 +03:00
|
|
|
source "$mydir/merge_helpers.sh"
|
|
|
|
|
2021-05-09 15:40:33 +03:00
|
|
|
if [ -z "$package_add" ] || [ -z "$name_replace" ]; then
|
|
|
|
echo "Usage: $0 [--name-replace] <package_add> <name_add/replace>"
|
2020-06-06 11:07:56 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-11-05 18:11:32 +03:00
|
|
|
require_clean_git
|
|
|
|
|
2020-09-02 14:15:16 +03:00
|
|
|
build_gradle="$mydir/vector/build.gradle"
|
|
|
|
src_dir="$mydir/vector/src"
|
|
|
|
fastlane_dir="$mydir/fastlane"
|
|
|
|
|
|
|
|
if grep -q "de.spiritcroc.riotx.$package_add" "$build_gradle"; then
|
|
|
|
echo "Abort, $package_add already active"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-06-06 11:07:56 +03:00
|
|
|
logo_replace_color() {
|
2020-07-18 16:03:15 +03:00
|
|
|
local file="$1"
|
|
|
|
local color_shell="$2"
|
|
|
|
local color_shell_dark="$3"
|
2020-07-24 13:09:07 +03:00
|
|
|
local color_bg="$4"
|
2020-07-18 16:03:15 +03:00
|
|
|
# shell color
|
2020-07-19 17:33:52 +03:00
|
|
|
sed -i "s|#8BC34A|$color_shell|gi" "$file"
|
|
|
|
sed -i "s|#33691E|$color_shell_dark|gi" "$file"
|
2020-07-24 13:09:07 +03:00
|
|
|
# bg color
|
|
|
|
sed -i "s|#e2f0d2|$color_bg|gi" "$file"
|
2020-06-06 11:07:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
logo_alternative() {
|
2020-07-18 16:03:15 +03:00
|
|
|
logo_replace_color "$mydir/graphics/ic_launcher_foreground_sc.svg" "$@"
|
|
|
|
logo_replace_color "$mydir/graphics/ic_launcher_sc.svg" "$@"
|
2020-07-24 13:09:07 +03:00
|
|
|
logo_replace_color "$mydir/graphics/feature_image.svg" "$@"
|
|
|
|
logo_replace_color "$mydir/graphics/store_icon.svg" "$@"
|
2022-04-04 13:34:15 +03:00
|
|
|
logo_replace_color "$mydir/vector/src/release/res/drawable/ic_launcher_background_sc.xml" "$@"
|
2020-06-06 11:07:56 +03:00
|
|
|
"$mydir/graphics/icon_gen.sh"
|
|
|
|
}
|
|
|
|
|
2020-12-29 13:58:13 +03:00
|
|
|
logo_beta() {
|
|
|
|
cp "$mydir/graphics/beta/"* "$mydir/graphics/"
|
|
|
|
"$mydir/graphics/icon_gen.sh"
|
|
|
|
}
|
|
|
|
|
2020-06-06 11:07:56 +03:00
|
|
|
case "$package_add" in
|
|
|
|
"a")
|
2020-11-02 14:42:09 +03:00
|
|
|
# blue
|
|
|
|
logo_alternative "#2196F3" "#0D47A1" "#BBDEFB"
|
2020-06-06 11:07:56 +03:00
|
|
|
;;
|
|
|
|
"b")
|
2020-07-19 10:42:48 +03:00
|
|
|
# orange: 900 color recuded in value
|
2020-07-24 13:09:07 +03:00
|
|
|
logo_alternative "#FB8C00" "#7f2c00" "#FFE0B2"
|
2020-06-06 11:07:56 +03:00
|
|
|
;;
|
|
|
|
"c")
|
2020-11-02 14:42:09 +03:00
|
|
|
# red: 900 color reduced in value
|
|
|
|
logo_alternative "#E53935" "#4c0b0b" "#FFCDD2"
|
|
|
|
;;
|
|
|
|
"d")
|
2020-06-06 11:07:56 +03:00
|
|
|
# purple
|
2020-07-24 13:09:07 +03:00
|
|
|
logo_alternative "#5E35B1" "#311B92" "#D1C4E9"
|
2020-06-06 11:07:56 +03:00
|
|
|
;;
|
2020-11-02 14:42:09 +03:00
|
|
|
"e")
|
|
|
|
# pink
|
|
|
|
logo_alternative "#D81B60" "#880E4F" "#F8BBD0"
|
2020-06-06 11:07:56 +03:00
|
|
|
;;
|
2021-05-09 15:40:33 +03:00
|
|
|
"sf")
|
|
|
|
# green with different background
|
|
|
|
logo_alternative "#8BC34A" "#33691E" "#f2e4ae"
|
|
|
|
;;
|
2020-08-10 12:39:15 +03:00
|
|
|
"x")
|
2020-11-02 14:42:09 +03:00
|
|
|
# cyan
|
|
|
|
logo_alternative "#00ACC1" "#006064" "#B2EBF2"
|
|
|
|
;;
|
|
|
|
"z")
|
|
|
|
# white
|
2020-08-10 12:39:15 +03:00
|
|
|
logo_alternative "#ffffff" "#000000" "#eeeeee"
|
|
|
|
;;
|
2020-06-06 11:07:56 +03:00
|
|
|
esac
|
|
|
|
|
2021-09-30 10:48:50 +03:00
|
|
|
sed -i "s|\"SchildiChat|\"$name_replace|g" "$build_gradle"
|
2020-08-10 12:39:15 +03:00
|
|
|
sed -i "s|de.spiritcroc.riotx|de.spiritcroc.riotx.$package_add|g" "$build_gradle" `find "$src_dir" -name google-services.json`
|
2021-05-09 15:40:33 +03:00
|
|
|
sed -i "s|SchildiChat|$name_replace|g" `find "$fastlane_dir/metadata/android" -name "title.txt"`
|
2020-11-05 18:11:32 +03:00
|
|
|
|
2020-12-20 15:01:27 +03:00
|
|
|
|
|
|
|
if [ "$package_add" = "testing.foss" ]; then
|
2021-08-21 11:02:33 +03:00
|
|
|
find "$fastlane_dir" -name full_description.txt -exec cp "$fastlane_dir/../fastlane_alternatives/testing_foss_full_description.txt" '{}' \;
|
|
|
|
find "$fastlane_dir" -name short_description.txt -exec cp "$fastlane_dir/../fastlane_alternatives/testing_foss_short_description.txt" '{}' \;
|
2020-12-29 13:58:13 +03:00
|
|
|
logo_beta
|
2020-12-20 15:01:27 +03:00
|
|
|
elif [ "$package_add" = "testing.fcm" ]; then
|
2021-08-21 11:02:33 +03:00
|
|
|
find "$fastlane_dir" -name full_description.txt -exec cp "$fastlane_dir/../fastlane_alternatives/testing_fcm_full_description.txt" '{}' \;
|
|
|
|
find "$fastlane_dir" -name short_description.txt -exec cp "$fastlane_dir/../fastlane_alternatives/testing_fcm_short_description.txt" '{}' \;
|
2020-12-29 13:58:13 +03:00
|
|
|
logo_beta
|
2021-08-21 11:02:33 +03:00
|
|
|
elif [ "$package_add" = "foss" ]; then
|
|
|
|
find "$fastlane_dir" -name full_description.txt -exec cp "$fastlane_dir/../fastlane_alternatives/foss_full_description.txt" '{}' \;
|
|
|
|
find "$fastlane_dir" -name short_description.txt -exec cp "$fastlane_dir/../fastlane_alternatives/foss_short_description.txt" '{}' \;
|
|
|
|
elif [ "$package_add" = "fcm" ]; then
|
|
|
|
find "$fastlane_dir" -name full_description.txt -exec cp "$fastlane_dir/../fastlane_alternatives/fcm_full_description.txt" '{}' \;
|
|
|
|
find "$fastlane_dir" -name short_description.txt -exec cp "$fastlane_dir/../fastlane_alternatives/fcm_short_description.txt" '{}' \;
|
2020-12-20 15:01:27 +03:00
|
|
|
fi
|
|
|
|
|
2020-11-05 18:11:32 +03:00
|
|
|
git add -A
|
2021-05-09 15:40:33 +03:00
|
|
|
git commit -m "Switch to alternative $name_replace ($package_add)"
|