use of com.android.builder.model.SourceProvider in project android by JetBrains.
the class ConfigureTemplateParametersStep method validateAllParameters.
@Nullable
private String validateAllParameters() {
String message = null;
Collection<Parameter> parameters = getModel().getTemplateHandle().getMetadata().getParameters();
Module module = myFacet == null ? null : myFacet.getModule();
Project project = getModel().getProject().getValueOrNull();
SourceProvider sourceProvider = getModel().getSourceSet().get().toSourceProvider();
for (Parameter parameter : parameters) {
ObservableValue<?> property = myParameterRows.get(parameter).getProperty();
if (property == null) {
continue;
}
Set<Object> relatedValues = getRelatedValues(parameter);
message = parameter.validate(project, module, sourceProvider, myPackageName.get(), property.get(), relatedValues);
if (message != null) {
break;
}
}
return message;
}
use of com.android.builder.model.SourceProvider in project android by JetBrains.
the class LintIdeUtils method getResourceDirectories.
/** Returns the resource directories to use for the given module */
@NotNull
public static List<File> getResourceDirectories(@NotNull AndroidFacet facet) {
if (facet.requiresAndroidModel()) {
AndroidModel androidModel = facet.getAndroidModel();
if (androidModel != null) {
List<File> resDirectories = new ArrayList<File>();
List<SourceProvider> sourceProviders = androidModel.getActiveSourceProviders();
for (SourceProvider provider : sourceProviders) {
for (File file : provider.getResDirectories()) {
if (file.isDirectory()) {
resDirectories.add(file);
}
}
}
return resDirectories;
}
}
return new ArrayList<File>(facet.getMainSourceProvider().getResDirectories());
}
use of com.android.builder.model.SourceProvider in project android by JetBrains.
the class CreateResourceDialogUtils method updateSourceSetCombo.
public static void updateSourceSetCombo(@NotNull JComponent label, @NotNull JComboBox combo, @Nullable AndroidFacet facet) {
// we're in here, so we default to always including the source set combo (if it's a Gradle project that is.)
if (facet != null && facet.requiresAndroidModel() && facet.getAndroidModel() != null) {
List<SourceProvider> providers = IdeaSourceProvider.getAllSourceProviders(facet);
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (SourceProvider sourceProvider : providers) {
//noinspection unchecked
model.addElement(new ApiComboBoxItem(sourceProvider, sourceProvider.getName(), 0, 0));
}
combo.setModel(model);
label.setVisible(true);
combo.setVisible(true);
} else {
label.setVisible(false);
combo.setVisible(false);
}
}
use of com.android.builder.model.SourceProvider in project android by JetBrains.
the class AddAndroidActivityPath method init.
@Override
protected void init() {
Module module = getModule();
assert module != null;
AndroidFacet facet = AndroidFacet.getInstance(module);
assert facet != null;
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform != null) {
myState.put(KEY_BUILD_SDK, platform.getTarget().getVersion().getFeatureLevel());
}
AndroidModuleInfo moduleInfo = AndroidModuleInfo.get(facet);
AndroidVersion minSdkVersion = moduleInfo.getMinSdkVersion();
myState.put(KEY_MIN_SDK, minSdkVersion);
myState.put(KEY_TARGET_API, moduleInfo.getTargetSdkVersion());
myState.put(KEY_PACKAGE_NAME, getInitialPackageName(module, facet));
myState.put(KEY_OPEN_EDITORS, true);
if (myTemplate == null) {
FormFactor formFactor = getFormFactor(myTargetFolder);
myState.put(FormFactorUtils.getMinApiLevelKey(formFactor), minSdkVersion.getApiLevel());
myState.put(FormFactorUtils.getBuildApiLevelKey(formFactor), moduleInfo.getTargetSdkVersion().getApiLevel());
ActivityGalleryStep galleryStep = new ActivityGalleryStep(formFactor, false, KEY_SELECTED_TEMPLATE, module, myParentDisposable);
addStep(galleryStep);
} else {
TemplateMetadata templateMetadata = TemplateManager.getInstance().getTemplateMetadata(myTemplate);
assert templateMetadata != null;
myState.put(KEY_SELECTED_TEMPLATE, new TemplateEntry(myTemplate, templateMetadata));
}
SourceProvider[] sourceProviders = getSourceProviders(module, myTargetFolder);
boolean isInstantAppModule = facet.getProjectType() == PROJECT_TYPE_ATOM;
myState.put(IS_INSTANT_APP_KEY, isInstantAppModule);
myParameterStep = new TemplateParameterStep2(getFormFactor(myTargetFolder), ImmutableMap.of(), myParentDisposable, KEY_PACKAGE_NAME, sourceProviders, CUSTOMIZE_ACTIVITY_TITLE);
myAssetStudioStep = new IconStep(KEY_SELECTED_TEMPLATE, KEY_SOURCE_PROVIDER, myParentDisposable);
addStep(myParameterStep);
addStep(myAssetStudioStep);
}
use of com.android.builder.model.SourceProvider in project android by JetBrains.
the class TestArtifactSearchScopes method getSourceScope.
@NotNull
private FileRootSearchScope getSourceScope(@NotNull String artifactName) {
Set<File> roots = Collections.emptySet();
AndroidModuleModel androidModel = getAndroidModel();
if (androidModel != null) {
roots = new HashSet<>();
// TODO consider generated source
for (SourceProvider sourceProvider : androidModel.getTestSourceProviders(artifactName)) {
roots.addAll(getAllSourceFolders(sourceProvider));
}
}
return new FileRootSearchScope(myModule.getProject(), roots);
}
Aggregations