How about this for a draft working solution we could all try to comply with...
First an AttributionObject class:
package your.package.name;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.ShortName;
@Author("Joe Bloggs")
@ShortName("AttributionObject")
public class AttributionObject {
private String mHtml;
private String mLibraryName;
private String mPlaintext;
public AttributionObject(){
// default constructor
}
public AttributionObject(String[] pAttributionStrings){
mHtml=pAttributionStrings[2];
mLibraryName=pAttributionStrings[0];
mPlaintext=pAttributionStrings[1];
}
/**
* Get the licensing and attribution Strings as HTML.
*/
public String getHtml(){
return mHtml;
}
/**
* Get the name of the 3rd party library that this AttributionObject refers to.
*/
public String getLibraryName(){
return mLibraryName;
}
/**
* Get the licensing and attribution Strings as plain text.
*/
public String getPlainText(){
return mPlaintext;
}
}
Next a new library method that returns an Array of AttributionObjects to B4A:
/**
* Returns an Array of AttributionObjects.
*An AttributionObject contains licensing and attribution Strings relating to 3rd party libraries used in this B4A library.
*You are required to display some or all of these Strings in your application if you use related B4A library object(s).
*/
public AttributionObject[] GetAttributionObjects() {
Resources resources=BA.applicationContext.getResources();
int resourceId;
resourceId=resources.getIdentifier("attribution_object_names", "array", BA.packageName);
String[] attributionObjectNames=resources.getStringArray(resourceId);
String[] attributionValues;
int attributionObjectsCount=attributionObjectNames.length;
AttributionObject[] attributionObjects=new AttributionObject[attributionObjectsCount];
for (int i = 0; i < attributionObjectsCount; i++) {
resourceId=resources.getIdentifier(attributionObjectNames[i], "array", BA.packageName);
attributionValues=resources.getStringArray(resourceId);
attributionObjects[i]=new AttributionObject(attributionValues);
}
return attributionObjects;
}
Finally you can create and edit the attribution Strings in an XML file located
Objects/res/values, the XML filename can be whatever you desire and must be made
read-only:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="attribution_object_names">
<item>osm_droid</item>
<item>open_street_map</item>
<item>markers_balloon_overlay</item>
</string-array>
<string-array name="osm_droid">
<item>OSMDroid</item>
<item>OSMDroid is licensed under the terms and conditions of the GNU Lesser General Public Licence.</item>
<item><![CDATA[<a href="http://code.google.com/p/osmdroid/">OSMDroid</a> is licensed under the terms and conditions of the <a href="http://www.gnu.org/licenses/lgpl.html">GNU Lesser General Public Licence</a>.]]></item>
</string-array>
<string-array name="open_street_map">
<item>OpenStreetMap</item>
<item>OSMDroid displays map data provided by the OpenStreetMap project. This map data is licensed under the terms and conditions of the Creative Commons Attribution 3.0 Unported Licence.</item>
<item><![CDATA[OSMDroid displays map data provided by the <a href="http://www.openstreetmap.org/">OpenStreetMap</a> project.<br />This map data is licensed under the terms and conditions of the <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution 3.0 Unported Licence</a>.]]></item>
</string-array>
<string-array name="markers_balloon_overlay">
<item>MarkersBalloonOverlay</item>
<item>MarkersBalloonOverlay is a modification of the Android MapViewBalloons project. MapViewBalloons is licensed under the terms and conditions of the Apache License, Version 2.0.</item>
<item><![CDATA[MarkersBalloonOverlay is a modification of the Android <a href="https://github.com/jgilfelt/android-mapviewballoons">MapViewBalloons</a> project.<br />MapViewBalloons is licensed under the terms and conditions of the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.]]></item>
</string-array>
</resources>
Note that HTML contained in an item element must be contained by a CDATA section:
<item><![CDATA[ **HTML here** ]]></item>
The GetAttributionObjects method references the first XML string-array element named
attribution_object_names, which has items that name the other string-array elements that contain the actual attribution String values.
So
attribution_object_names is the only hardcoded value, you can add/edit/remove AttributionObjects by editing the XML - no need to recompile your library and no need for your library to become bloated with lots of Strings.
And finally (i think) you can create locale specific variations of your XML file.
Create folder
Objects/res/value-it and add an Italian version of your XML string-arrays for example.
What do you all think?
Sample B4A project, example libarary and Eclipse source attached.
Martin.