Skip to content

Commit 49aa64e

Browse files
author
jwjiang
committed
initial lewa patchrom
1 parent e22d14b commit 49aa64e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+6470
-0
lines changed

README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a place holder, please fill in real text when you add stuff.

ResValuesModify/jar/ResValuesModify

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
java -jar $PORT_ROOT/tools/ResValuesModify/jar/ResValuesModify.jar $*
4+
5+
8.34 KB
Binary file not shown.

ResValuesModify/jar/config

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# NOTE:
2+
# default operation is replace dest node with src node if the dest node exist or
3+
# append src node to the file if dest node doesn't exist
4+
#
5+
# - type [name]
6+
# explicitly declare don't merge this kind of nodes
7+
#
8+
# + type [name]
9+
# explicitly declare that merge this kind of nodes
10+
#
11+
# I array-type [name]
12+
# explicitly declare that to insert new 'items' for 'array' type instead of default replacement
13+
# insert new items to the head of array
14+
# priority of "+" and "I" is higher then "-"
15+
16+
- add-resource
17+
18+
I string-array config_statusBarIcons

ResValuesModify/src/Log.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class Log {
2+
public static void i(String info){
3+
System.out.println(info);
4+
}
5+
6+
public static void i(String tag, String info){
7+
System.out.println( String.format("INFO[%s]: %s", tag, info));
8+
}
9+
10+
public static void e(String tag, String err){
11+
System.err.println( String.format("ERROR[%s]: %s", tag, err));
12+
}
13+
14+
public static void w(String tag, String err){
15+
System.err.println( String.format("WARING[%s]: %s", tag, err));
16+
}
17+
18+
public static void e(String err){
19+
System.err.println(err);
20+
}
21+
}
+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import java.io.File;
2+
import java.util.ArrayList;
3+
4+
public class ResValuesModify {
5+
private ArrayList<File> mSrcFiles = new ArrayList<File>();
6+
private ArrayList<File> mDestFiles = new ArrayList<File>();
7+
private ArrayList<File> mConfigFiles = new ArrayList<File>();
8+
private static final String LOG_TAG = "CHECK";
9+
10+
public static void main(String[] args) {
11+
ResValuesModify resVM = new ResValuesModify();
12+
if (!resVM.checkArgs(args) || !resVM.checkPath(args)) {
13+
resVM.usage();
14+
return;
15+
}
16+
resVM.mergeXML();
17+
}
18+
19+
private boolean checkArgs(String[] args) {
20+
boolean ret = true;
21+
if (args.length < 2) {
22+
Log.e(LOG_TAG, "invalid argument count");
23+
return false;
24+
}
25+
26+
if (args[0].equals(args[1])) {
27+
Log.e(LOG_TAG, "src dir is the same with dest dir");
28+
ret = false;
29+
}
30+
31+
for (int i = 2; i < args.length; i++) {
32+
File f = new File(args[i]);
33+
if (f.exists() && f.isFile()) {
34+
mConfigFiles.add(f);
35+
} else {
36+
Log.i(LOG_TAG, "ignore config file:" + f.getName());
37+
}
38+
}
39+
return ret;
40+
}
41+
42+
private boolean checkPath(String[] args) {
43+
return perpareXmlFiles(args[0], mSrcFiles) && perpareXmlFiles(args[1], mDestFiles);
44+
}
45+
46+
private void mergeXML() {
47+
(new XMLMerge(mSrcFiles, mDestFiles, mConfigFiles)).merge();
48+
}
49+
50+
private void usage() {
51+
Log.i("USAGE: ");
52+
Log.i("ResValuesModify src-values-dir dest-values-dir [config-files ...]");
53+
Log.i(" config-files: config file that explicitly declare merge-rule");
54+
Log.i("");
55+
}
56+
57+
private boolean perpareXmlFiles(String path, ArrayList<File> xmlFiles) {
58+
File dir = new File(path);
59+
if (!dir.isDirectory()) {
60+
Log.w(LOG_TAG, path + " : no such directory");
61+
return false;
62+
}
63+
64+
File[] files = dir.listFiles();
65+
for (File f : files) {
66+
if (f.isFile()) {
67+
if (f.getName().endsWith(".xml") || f.getName().endsWith(".xml.part")) {
68+
xmlFiles.add(f);
69+
}
70+
}
71+
}
72+
73+
if (0 == xmlFiles.size()) {
74+
Log.w(LOG_TAG, "No xml file in " + path);
75+
return false;
76+
}
77+
return true;
78+
}
79+
}

0 commit comments

Comments
 (0)