xwords/xwords4/android/scripts/genPrefsWrapper.sh

46 lines
1,001 B
Bash
Raw Normal View History

#!/bin/bash
# Generate a java file providing the mapping of class name to xml file
# name that Android's system requires but doesn't provide. I hate
# leaving that sort of thing to chance.
mkClass() {
XMLFILE=$1
NAME=${XMLFILE/.xml/}
cat <<EOF
public static class ${NAME} extends BasePrefsFrag {
@Override
public int getResID() { return R.xml.${NAME}; }
}
EOF
}
cat <<EOF
/******************************************************************
* file generated by $0. Changes will be overwritten!!
******************************************************************/
package org.eehouse.android.xw4.gen;
import org.eehouse.android.xw4.PrefsActivity.BasePrefsFrag;
import org.eehouse.android.xw4.R;
public class PrefsWrappers {
EOF
IDS=""
while [ "$#" -gt 0 ]; do
FILE=$(basename $1)
mkClass $FILE
IDS="${IDS} R.xml.${FILE/.xml/}, "
shift
done
cat <<EOF
private static final int[] sIDS = {$IDS};
public static final int[] getPrefsResIDs() { return sIDS; }
}
EOF