[Android Themes] AChep:
### Description:

I think that almost all themers gets tired when they needs to make resources-redirections file (at /res/xml/ folder).

### How to use it?

- Put themed icons to /acHelper/themed/ folder

- Run /acHelper/run.bat (If you're Linux user - launch achelper.jar by hands)

- Type icons prefix

- Enjoy ;)

### Sources:

import java.io.File;
import java.io.IOException;
import java.io.FileWriter;

import java.util.Scanner;
import java.util.Date;

public class ThemeHelper {

private static final String VERSION_NAME = "0.1";
private static final String FOLDER_THEMED_NAME = "themed";

private static File mRootFolder = null;

public static void main(String[] args) {
try {
mRootFolder = new File(ThemeHelper.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile();
} catch (Exception ex) { return; }

logln(3);
logln("Program:");
logln(" acHelper "+VERSION_NAME);
logln("Contact:");
logln(" 2012 (C) AChep@xda");
logln(" <artemchep@gmail.com>");
logln(1);
log("Type resources prefix: ");

Scanner input = new Scanner(System.in);
String prefix = input.nextLine();
input.close();

logln("- - - - - - - - - - - - - - - - - -");
long beginTime = new Date().getTime();

createResourceRedirectionsFile(mRootFolder.getPath()+"/"+FOLDER_THEMED_NAME, prefix);

logln("- - - - - - - - - - - - - - - - - -");
logln(" Elapsed time: "+(new Date().getTime()-beginTime)+"ms.");
}

private static void createResourceRedirectionsFile(String directory, String patch){
int i, i2;

log(" - Building list of files... ");
final File[] files = new File(directory).listFiles(); logln("Successfully.");

log(" - Parcing files... ");
int length = files.length; String[] names = new String[length]; int ctrl = 0;
for (i = 0; i<length; i++) {
names[i+ctrl] = files[i].getName();
int nameLength = names[i+ctrl].length();
for (i2 = 0; i2 < nameLength; i2++)
if (names[i+ctrl].charAt(i2)=='.')
break;
if (i2 == nameLength) ctrl--;
else names[i+ctrl]=names[i+ctrl].substring(0, i2);
}
length = length+ctrl; logln(ctrl==0 ? "Successfully." : "Has warnings!");

try {
log(" - Opening output file... ");
File file = new File(mRootFolder
, patch.substring(0, patch.length()-1)+".xml");
file.delete();
FileWriter writer = new FileWriter(file); logln("Successfully.");

log(" - Parcing and writing values... ");
int patchLength = patch.length();
for (i = 0; i < length; i++){
if (names[i].length()>patchLength && names[i].substring(0, patchLength).equals(patch))
writer.append("<item name=\"drawable/"+names[i].substring(patchLength, names[i].length())+"\">@drawable/"+names[i]+"</item>\n");
}

writer.flush();
writer.close();
logln("Successfully.");
} catch (Exception ex) {
logln("Error!");
}
}

/**
* Short named analog of System.out.print(String msg);
*/
private static void log(String str){
System.out.print(str);
}

/**
* Recursive dividers
*/
private static void logln(int number){
if (number>1) logln(number-1);
logln("");
}

/**
* Short named analog of System.out.println(String msg);
*/
private static void logln(String str){
System.out.println(str);
}
}

acHelper Tool. 2012 © AChep

If you want copy it, let me know about it and make a link to my profile and thread.

Regards, AChep.​