use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class NewVectorAssetAction method createWizard.
@Nullable
@Override
protected ModelWizard createWizard(@NotNull AndroidFacet facet) {
Module module = facet.getModule();
Project project = module.getProject();
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
if (androidModel != null) {
AndroidVersion minSdkVersion = androidModel.getMinSdkVersion();
String version = androidModel.getAndroidProject().getModelVersion();
GradleVersion revision = GradleVersion.parse(version);
if (revision.compareIgnoringQualifiers(VECTOR_ASSET_GENERATION_REVISION) < 0 && (minSdkVersion == null || minSdkVersion.getApiLevel() < VECTOR_DRAWABLE_API_LEVEL)) {
Messages.showErrorDialog(project, ERROR_MESSAGE, ERROR_TITLE);
return null;
}
}
ModelWizard.Builder wizardBuilder = new ModelWizard.Builder();
wizardBuilder.addStep(new NewVectorAssetStep(new GenerateVectorIconModel(facet), facet));
return wizardBuilder.build();
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class InstallPlatformHyperlink method execute.
@Override
protected void execute(@NotNull Project project) {
List<String> requested = Lists.newArrayList();
for (AndroidVersion version : myAndroidVersions) {
requested.add(DetailsTypes.getPlatformPath(version));
}
ModelWizardDialog dialog = SdkQuickfixUtils.createDialogForPaths(project, requested);
if (dialog != null && dialog.showAndGet()) {
GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
}
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class TemplateUtils method getKnownVersions.
/**
* Returns a list of known API names
*
* @return a list of string API names, starting from 1 and up through the
* maximum known versions (with no gaps)
*/
@NotNull
public static String[] getKnownVersions() {
final AndroidSdkData sdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
assert sdkData != null;
int max = SdkVersionInfo.HIGHEST_KNOWN_STABLE_API;
IAndroidTarget[] targets = sdkData.getTargets();
SparseArray<IAndroidTarget> apiTargets = null;
for (IAndroidTarget target : targets) {
if (target.isPlatform()) {
AndroidVersion version = target.getVersion();
if (!version.isPreview()) {
int apiLevel = version.getApiLevel();
max = Math.max(max, apiLevel);
if (apiLevel > SdkVersionInfo.HIGHEST_KNOWN_API) {
if (apiTargets == null) {
apiTargets = new SparseArray<IAndroidTarget>();
}
apiTargets.put(apiLevel, target);
}
}
}
}
String[] versions = new String[max];
for (int api = 1; api <= max; api++) {
String name = SdkVersionInfo.getAndroidName(api);
// noinspection ConstantConditions
if (name == null) {
if (apiTargets != null) {
IAndroidTarget target = apiTargets.get(api);
if (target != null) {
name = AndroidSdkUtils.getTargetLabel(target);
}
}
if (name == null) {
name = String.format("API %1$d", api);
}
}
versions[api - 1] = name;
}
return versions;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class HotswapAction method doUpdate.
@Override
protected void doUpdate(@NotNull AnActionEvent e, @NotNull Project project) {
Presentation presentation = e.getPresentation();
presentation.setEnabled(false);
if (!InstantRunSettings.isInstantRunEnabled()) {
presentation.setText("Apply Changes: Instant Run has been disabled");
return;
}
RunnerAndConfigurationSettings settings = RunManager.getInstance(project).getSelectedConfiguration();
if (settings == null) {
presentation.setText("Apply Changes: No run configuration selected");
return;
}
AndroidSessionInfo session = getAndroidSessionInfo(project, settings);
if (session == null) {
presentation.setText(String.format("Apply Changes: No active '%1$s' launch", settings.getName()));
return;
}
ProcessHandler processHandler = getActiveProcessHandler(project, settings);
if (processHandler == null) {
presentation.setText(String.format("Apply Changes: No active '%1$s' launch", settings.getName()));
return;
}
RunConfiguration configuration = settings.getConfiguration();
if (!(configuration instanceof ModuleBasedConfiguration)) {
presentation.setText(String.format("Apply Changes: '%1$s' is not a module based configuration", settings.getName()));
return;
}
Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
if (module == null) {
presentation.setText(String.format("Apply Changes: No module specified in '%1$s'", settings.getName()));
return;
}
if (!(configuration instanceof AndroidRunConfigurationBase)) {
presentation.setText(String.format("Apply Changes: '%1$s' is not an Android launch configuration", settings.getName()));
return;
}
if (!((AndroidRunConfigurationBase) configuration).supportsInstantRun()) {
presentation.setText(String.format("Apply Changes: Configuration '%1$s' does not support instant run", settings.getName()));
return;
}
AndroidVersion androidVersion = InstantRunManager.getMinDeviceApiLevel(processHandler);
if (androidVersion == null) {
presentation.setText(String.format("Apply Changes: Cannot locate device from '%1$s'", settings.getName()));
return;
}
if (!InstantRunManager.isInstantRunCapableDeviceVersion(androidVersion)) {
presentation.setText(String.format("Apply Changes: Target device API level (%1$s) too low for Instant Run", androidVersion));
return;
}
InstantRunGradleSupport status = InstantRunGradleUtils.getIrSupportStatus(InstantRunGradleUtils.getAppModel(module), androidVersion);
if (status != SUPPORTED) {
String notification = status.getUserNotification();
if (notification == null) {
notification = status.toString();
}
presentation.setText("Apply Changes: " + notification);
return;
}
presentation.setText("Apply Changes" + getShortcutText());
presentation.setEnabled(true);
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class InstantRunPositionManager method createSourcesByApiLevel.
private static Map<AndroidVersion, VirtualFile> createSourcesByApiLevel() {
Collection<? extends LocalPackage> sourcePackages = getAllPlatformSourcePackages();
Map<AndroidVersion, VirtualFile> sourcesByApi = Maps.newHashMap();
for (LocalPackage sourcePackage : sourcePackages) {
TypeDetails typeDetails = sourcePackage.getTypeDetails();
if (!(typeDetails instanceof DetailsTypes.ApiDetailsType)) {
Logger.getInstance(InstantRunPositionManager.class).warn("Unable to get type details for source package @ " + sourcePackage.getLocation().getPath());
continue;
}
DetailsTypes.ApiDetailsType details = (DetailsTypes.ApiDetailsType) typeDetails;
AndroidVersion version = details.getAndroidVersion();
VirtualFile sourceFolder = VfsUtil.findFileByIoFile(sourcePackage.getLocation(), true);
if (sourceFolder != null && sourceFolder.isValid()) {
sourcesByApi.put(version, sourceFolder);
}
}
return ImmutableMap.copyOf(sourcesByApi);
}
Aggregations