use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class PlatformComponentsPanel method updatePlatformItems.
private void updatePlatformItems() {
myPlatformDetailsRootNode.removeAllChildren();
myPlatformSummaryRootNode.removeAllChildren();
myStates.clear();
List<AndroidVersion> versions = Lists.newArrayList(myCurrentPackages.keySet());
versions = Lists.reverse(versions);
for (AndroidVersion version : versions) {
Set<UpdaterTreeNode> versionNodes = Sets.newHashSet();
UpdaterTreeNode marker = new ParentTreeNode(version);
myPlatformDetailsRootNode.add(marker);
boolean obsolete = false;
for (UpdatablePackage info : myCurrentPackages.get(version)) {
RepoPackage pkg = info.getRepresentative();
PackageNodeModel model = new PackageNodeModel(info);
myStates.add(model);
UpdaterTreeNode node = new DetailsTreeNode(model, myModificationListener, myConfigurable);
marker.add(node);
versionNodes.add(node);
if (pkg.obsolete() && pkg.getTypeDetails() instanceof DetailsTypes.PlatformDetailsType) {
obsolete = true;
}
}
if (!obsolete) {
SummaryTreeNode node = SummaryTreeNode.createNode(version, versionNodes);
if (node != null) {
myPlatformSummaryRootNode.add(node);
}
}
}
refreshModified();
SdkUpdaterConfigPanel.resizeColumnsToFit(myPlatformDetailTable);
SdkUpdaterConfigPanel.resizeColumnsToFit(myPlatformSummaryTable);
myPlatformDetailTable.updateUI();
myPlatformSummaryTable.updateUI();
TreeUtil.expandAll(myPlatformDetailTable.getTree());
TreeUtil.expandAll(myPlatformSummaryTable.getTree());
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class InstantRunPositionManager method getPsiFileByLocation.
/**
* Returns the PSI file corresponding to the given JDI location.
* This method is overridden so that we may provide an API specific version of the sources for platform (android.jar) classes.
*
* TODO: This method is implemented as part of InstantRunPositionManager, although it has nothing to do with instant run.
* The issue is that the position manager extension API is a little odd: the position manager that was added last is the one that gets
* used, and luckily for us, the instant run position manager is being added last. Ideally, we should move just the code that identifies
* the Psi File given a location to a separate extension mechanism. See b.android.com/208140
*/
@Nullable
@Override
protected PsiFile getPsiFileByLocation(Project project, Location location) {
PsiFile file = super.getPsiFileByLocation(project, location);
if (file == null) {
return null;
}
if (!DebuggerSettings.getInstance().SHOW_ALTERNATIVE_SOURCE) {
return file;
}
// we only care about providing an alternate source for files inside the platform.
if (!AndroidFacet.isInAndroidSdk(file)) {
return file;
}
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session == null) {
return file;
}
String relPath = getRelPathFromSourceRoot(project, file);
if (relPath == null) {
return file;
}
AndroidVersion version = session.getDebugProcess().getProcessHandler().getUserData(AndroidSessionInfo.ANDROID_DEVICE_API_LEVEL);
if (version == null) {
return file;
}
PsiFile source = getSourceForApiLevel(project, version, relPath);
return source == null ? file : source;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class TemplateParameterStep2 method validate.
@Override
public boolean validate() {
setErrorHtml(null);
AndroidVersion minApi = myState.get(AddAndroidActivityPath.KEY_MIN_SDK);
Integer buildApi = myState.get(AddAndroidActivityPath.KEY_BUILD_SDK);
TemplateEntry templateEntry = myState.get(AddAndroidActivityPath.KEY_SELECTED_TEMPLATE);
if (templateEntry == null) {
return false;
}
for (Parameter param : templateEntry.getParameters()) {
if (param != null) {
Object value = getStateParameterValue(param);
String error = param.validate(getProject(), getModule(), myState.get(AddAndroidActivityPath.KEY_SOURCE_PROVIDER), myState.get(myPackageNameKey), value != null ? value : "", getRelatedValues(param));
if (error != null) {
// Highlight?
setErrorHtml(error);
return false;
}
// Check to see that the selection's constraints are met if this is a combo box
if (value instanceof ApiComboBoxItem) {
ApiComboBoxItem selectedItem = (ApiComboBoxItem) value;
if (minApi == null || buildApi == null) {
return false;
}
String message = selectedItem.validate(minApi.getFeatureLevel(), buildApi);
if (message != null) {
setErrorHtml(message);
return false;
}
}
}
}
return true;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AddAndroidActivityPath method getDirectories.
private Map<String, Object> getDirectories() {
Map<String, Object> templateParameters = Maps.newHashMap();
Module module = getModule();
assert module != null;
AndroidFacet facet = AndroidFacet.getInstance(module);
assert facet != null;
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform != null) {
templateParameters.put(ATTR_BUILD_API, platform.getTarget().getVersion().getFeatureLevel());
templateParameters.put(ATTR_BUILD_API_STRING, getBuildApiString(platform.getTarget().getVersion()));
}
// Read minSdkVersion and package from manifest and/or build.gradle files
AndroidModuleInfo moduleInfo = AndroidModuleInfo.get(facet);
AndroidModel androidModel = facet.getAndroidModel();
SourceProvider sourceProvider1 = myState.get(KEY_SOURCE_PROVIDER);
if (sourceProvider1 != null && androidModel != null) {
String packageName = myState.get(KEY_PACKAGE_NAME);
assert packageName != null;
templateParameters.putAll(selectSourceProvider(sourceProvider1, androidModel, module, packageName));
}
AndroidVersion minSdkVersion = moduleInfo.getMinSdkVersion();
String minSdkName = minSdkVersion.getApiString();
templateParameters.put(ATTR_MIN_API, minSdkName);
templateParameters.put(ATTR_TARGET_API, moduleInfo.getTargetSdkVersion().getApiLevel());
templateParameters.put(ATTR_MIN_API_LEVEL, minSdkVersion.getFeatureLevel());
templateParameters.put(ATTR_IS_LIBRARY_MODULE, facet.isLibraryProject());
try {
templateParameters.put(ATTR_DEBUG_KEYSTORE_SHA1, KeystoreUtils.sha1(getDebugKeystore(facet)));
} catch (Exception e) {
LOG.info("Could not compute SHA1 hash of debug keystore.", e);
templateParameters.put(ATTR_DEBUG_KEYSTORE_SHA1, "");
}
@SuppressWarnings("deprecation") String projectLocation = NewModuleWizardState.ATTR_PROJECT_LOCATION;
Project project = getProject();
assert project != null;
templateParameters.put(projectLocation, project.getBasePath());
// We're really interested in the directory name on disk, not the module name. These will be different if you give a module the same
// name as its containing project.
String moduleName = new File(module.getModuleFilePath()).getParentFile().getName();
templateParameters.put(FormFactorUtils.ATTR_MODULE_NAME, moduleName);
return templateParameters;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AndroidSdkUtils method findBestTarget.
@Nullable
private static IAndroidTarget findBestTarget(@NotNull IAndroidTarget[] targets) {
IAndroidTarget bestTarget = null;
int maxApiLevel = -1;
for (IAndroidTarget target : targets) {
AndroidVersion version = target.getVersion();
if (target.isPlatform() && !version.isPreview() && version.getApiLevel() > maxApiLevel) {
bestTarget = target;
maxApiLevel = version.getApiLevel();
}
}
return bestTarget;
}
Aggregations