Skip to content

Commit

Permalink
Added provider declaration to paste in the manifest.
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD committed Apr 15, 2014
1 parent 663a141 commit 0bd3311
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/org/jraf/androidcontentprovidergenerator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void validateConfig() {
throw new IllegalArgumentException("Could not find 'toolVersion' field in _config.json, which is mandatory and must be equals to '"
+ Constants.VERSION + "'.");
}
if (!configVersion.equals(Constants.VERSION)) {
if (!Constants.VERSION.startsWith(configVersion)) {
throw new IllegalArgumentException("Invalid 'toolVersion' value in _config.json: found '" + configVersion + "' but expected '" + Constants.VERSION
+ "'.");
}
Expand Down Expand Up @@ -375,6 +375,20 @@ private void generateSqliteUpgradeHelper(Arguments arguments) throws IOException
template.process(root, out);
}

private void printManifest(Arguments arguments) throws IOException, JSONException, TemplateException {
Template template = getFreeMarkerConfig().getTemplate("manifest.ftl");
JSONObject config = getConfig(arguments.inputDir);
Writer out = new OutputStreamWriter(System.out);

Map<String, Object> root = new HashMap<String, Object>();
root.put("config", config);
root.put("model", Model.get());
root.put("header", Model.get().getHeader());

System.out.println("\nProvider declaration to paste in the AndroidManifest.xml file: ");
template.process(root, out);
}

private void go(String[] args) throws IOException, JSONException, TemplateException {
Arguments arguments = new Arguments();
JCommander jCommander = new JCommander(arguments, args);
Expand All @@ -393,6 +407,8 @@ private void go(String[] args) throws IOException, JSONException, TemplateExcept
generateContentProvider(arguments);
generateSqliteOpenHelper(arguments);
generateSqliteUpgradeHelper(arguments);

printManifest(arguments);
}

public static void main(String[] args) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


<provider
android:name="${config.providerJavaPackage}.${config.providerClassName}"
android:authorities="${config.authority}"
android:exported="false" />

0 comments on commit 0bd3311

Please sign in to comment.