mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
309fcece03
I balked at writing code consisting of a bunch of classes there only to provide a mapping to resource file IDs, instead opting to generate them. (The right move might have been to generate everything from the old xwprefs.xml, but it's too late for that. :-)
45 lines
1,001 B
Bash
Executable file
45 lines
1,001 B
Bash
Executable file
#!/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
|