ADT #1825491: Provide default choices for <uses-library>
We currently hardcode a list in the PlatformTarget and propagate it to the UI via the AndroidTargetParser. This way we can later decide to actually get the info from some kind of manifest.
This commit is contained in:
@@ -29,6 +29,7 @@ import com.android.layoutlib.api.ILayoutBridge;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.android.sdklib.IAndroidTarget.IOptionalLibrary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -97,6 +98,7 @@ public class AndroidTargetData {
|
||||
|
||||
/**
|
||||
* Creates an AndroidTargetData object.
|
||||
* @param platformLibraries
|
||||
* @param optionalLibraries
|
||||
*/
|
||||
void setExtraData(IResourceRepository systemResourceRepository,
|
||||
@@ -110,6 +112,7 @@ public class AndroidTargetData {
|
||||
String[] broadcastIntentActionValues,
|
||||
String[] serviceIntentActionValues,
|
||||
String[] intentCategoryValues,
|
||||
String[] platformLibraries,
|
||||
IOptionalLibrary[] optionalLibraries,
|
||||
ProjectResources resources,
|
||||
LayoutBridge layoutBridge) {
|
||||
@@ -126,7 +129,7 @@ public class AndroidTargetData {
|
||||
setPermissions(permissionValues);
|
||||
setIntentFilterActionsAndCategories(activityIntentActionValues, broadcastIntentActionValues,
|
||||
serviceIntentActionValues, intentCategoryValues);
|
||||
setOptionalLibraries(optionalLibraries);
|
||||
setOptionalLibraries(platformLibraries, optionalLibraries);
|
||||
}
|
||||
|
||||
public DexWrapper getDexWrapper() {
|
||||
@@ -293,18 +296,23 @@ public class AndroidTargetData {
|
||||
setValues("(category,android:name)", intentCategoryValues); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private void setOptionalLibraries(IOptionalLibrary[] optionalLibraries) {
|
||||
String[] values;
|
||||
private void setOptionalLibraries(String[] platformLibraries,
|
||||
IOptionalLibrary[] optionalLibraries) {
|
||||
|
||||
if (optionalLibraries == null) {
|
||||
values = new String[0];
|
||||
} else {
|
||||
values = new String[optionalLibraries.length];
|
||||
ArrayList<String> libs = new ArrayList<String>();
|
||||
|
||||
if (platformLibraries != null) {
|
||||
for (String name : platformLibraries) {
|
||||
libs.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (optionalLibraries != null) {
|
||||
for (int i = 0; i < optionalLibraries.length; i++) {
|
||||
values[i] = optionalLibraries[i].getName();
|
||||
libs.add(optionalLibraries[i].getName());
|
||||
}
|
||||
}
|
||||
setValues("(uses-library,android:name)", values);
|
||||
setValues("(uses-library,android:name)", libs.toArray(new String[libs.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -267,6 +267,7 @@ public final class AndroidTargetParser {
|
||||
broadcast_actions.toArray(new String[broadcast_actions.size()]),
|
||||
service_actions.toArray(new String[service_actions.size()]),
|
||||
categories.toArray(new String[categories.size()]),
|
||||
mAndroidTarget.getPlatformLibraries(),
|
||||
mAndroidTarget.getOptionalLibraries(),
|
||||
resources,
|
||||
layoutBridge);
|
||||
|
||||
@@ -192,6 +192,15 @@ final class AddOnTarget implements IAndroidTarget {
|
||||
return mLibraries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of libraries of the underlying platform.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String[] getPlatformLibraries() {
|
||||
return mBasePlatform.getPlatformLibraries();
|
||||
}
|
||||
|
||||
public boolean isCompatibleBaseFor(IAndroidTarget target) {
|
||||
// basic test
|
||||
if (target == this) {
|
||||
|
||||
@@ -150,6 +150,13 @@ public interface IAndroidTarget extends Comparable<IAndroidTarget> {
|
||||
*/
|
||||
IOptionalLibrary[] getOptionalLibraries();
|
||||
|
||||
/**
|
||||
* Returns the list of libraries available for a given platform.
|
||||
*
|
||||
* @return an array of libraries provided by the platform or <code>null</code> if there is none.
|
||||
*/
|
||||
String[] getPlatformLibraries();
|
||||
|
||||
/**
|
||||
* Returns whether the given target is compatible with the receiver.
|
||||
* <p/>A target is considered compatible if applications developed for the receiver can run on
|
||||
|
||||
@@ -149,16 +149,26 @@ final class PlatformTarget implements IAndroidTarget {
|
||||
return "HVGA";
|
||||
}
|
||||
|
||||
/*
|
||||
* Always returns null, as a standard platforms have no optional libraries.
|
||||
/**
|
||||
* Always returns null, as a standard platform ha no optional libraries.
|
||||
*
|
||||
* (non-Javadoc)
|
||||
* {@inheritDoc}
|
||||
* @see com.android.sdklib.IAndroidTarget#getOptionalLibraries()
|
||||
*/
|
||||
public IOptionalLibrary[] getOptionalLibraries() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently always return a fixed list with "android.test.runner" in it.
|
||||
* <p/>
|
||||
* TODO change the fixed library list to be build-dependent later.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String[] getPlatformLibraries() {
|
||||
return new String[] { SdkConstants.ANDROID_TEST_RUNNER_LIB };
|
||||
}
|
||||
|
||||
public boolean isCompatibleBaseFor(IAndroidTarget target) {
|
||||
// basic test
|
||||
if (target == this) {
|
||||
|
||||
@@ -167,6 +167,9 @@ public final class SdkConstants {
|
||||
/** Namespace for the resource XML, i.e. "http://schemas.android.com/apk/res/android" */
|
||||
public final static String NS_RESOURCES = "http://schemas.android.com/apk/res/android";
|
||||
|
||||
/** The name of the uses-library that provides "android.test.runner" */
|
||||
public final static String ANDROID_TEST_RUNNER_LIB = "android.test.runner";
|
||||
|
||||
/* Folder path relative to the SDK root */
|
||||
/** Path of the documentation directory relative to the sdk folder.
|
||||
* This is an OS path, ending with a separator. */
|
||||
|
||||
Reference in New Issue
Block a user