-
Notifications
You must be signed in to change notification settings - Fork 7
/
configure.sh
executable file
·36 lines (31 loc) · 1.39 KB
/
configure.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
set -eu
GOOGLE_JSON=app/google-services.json
if [ ! -f "$GOOGLE_JSON" ]; then
echo "No $GOOGLE_JSON, copying dummy"
cp app/dummy-google-services.json "$GOOGLE_JSON"
fi
# merge settings files
INTEGRATION_PREFS="custom-vio/viotester-integration/android/preferences.xml"
INTEGRATION_ARRAYS="custom-vio/viotester-integration/android/arrays.xml"
ROOT_PREFS="app/src/main/res/xml/root_preferences.xml"
ROOT_ARRAYS="app/src/main/res/values/arrays.xml"
WARN_BANNER="<!--\n\n\n\n AUTO-GENERATED, DO NOT EDIT \n\n\n\n -->"
printf "$WARN_BANNER" > "$ROOT_PREFS"
printf "$WARN_BANNER" > "$ROOT_ARRAYS"
if [ -f "$INTEGRATION_PREFS" ]; then
echo "has $INTEGRATION_PREFS, merging settings XMLs"
# Every piece in Android Gradle Plugin and the XML settings mechanism seems to be
# actively working to prevent doing this any other way
sed "s_</PreferenceScreen>__g" < preferences.xml >> "$ROOT_PREFS"
sed "s_<PreferenceScreen>__g" < "$INTEGRATION_PREFS" | sed "s_</PreferenceScreen>__g" >> "$ROOT_PREFS"
sed "s_</resources>__g" < arrays.xml >> "$ROOT_ARRAYS"
sed "s_<resources>__g" < "$INTEGRATION_ARRAYS" >> "$ROOT_ARRAYS"
else
echo "no custom preferences using preferences as-is"
sed "s_</PreferenceScreen>__g" < preferences.xml >> "$ROOT_PREFS"
cat < arrays.xml >> "$ROOT_ARRAYS"
fi
cat < reset.xml >> "$ROOT_PREFS"
printf "$WARN_BANNER" >> "$ROOT_PREFS"
printf "$WARN_BANNER" >> "$ROOT_ARRAYS"