use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AppResourceRepository method isPrivate.
/**
* Returns true if the given resource is private
*
* @param type the type of the resource
* @param name the name of the resource
* @return true if the given resource is private
*/
public boolean isPrivate(@NotNull ResourceType type, @NotNull String name) {
if (myResourceVisibility == null) {
ResourceVisibilityLookup.Provider provider = getResourceVisibilityProvider();
if (provider == null) {
return false;
}
// TODO: b/23032391
AndroidModuleModel androidModel = AndroidModuleModel.get(myFacet);
if (androidModel == null) {
// but can be triggered during a sync (b/22523040)
return false;
}
myResourceVisibility = provider.get(androidModel.getAndroidProject(), androidModel.getSelectedVariant());
}
return myResourceVisibility.isPrivate(type, name);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AppResourceRepository method findAarLibraries.
@NotNull
private static Map<File, String> findAarLibraries(@NotNull AndroidFacet facet, @NotNull List<AndroidFacet> dependentFacets) {
// Use the gradle model if available, but if not, fall back to using plain IntelliJ library dependencies
// which have been persisted since the most recent sync
AndroidModuleModel androidModuleModel = AndroidModuleModel.get(facet);
if (androidModuleModel != null) {
List<AndroidLibrary> libraries = Lists.newArrayList();
addGradleLibraries(libraries, androidModuleModel);
for (AndroidFacet dependentFacet : dependentFacets) {
AndroidModuleModel dependentGradleModel = AndroidModuleModel.get(dependentFacet);
if (dependentGradleModel != null) {
addGradleLibraries(libraries, dependentGradleModel);
}
}
return findAarLibrariesFromGradle(androidModuleModel.getModelVersion(), dependentFacets, libraries);
}
return findAarLibrariesFromIntelliJ(facet, dependentFacets);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class LintIdeClient method getBuildTools.
@Override
@Nullable
public BuildToolInfo getBuildTools(@NonNull com.android.tools.lint.detector.api.Project project) {
if (project.isGradleProject()) {
Module module = getModule();
if (module != null) {
AndroidModuleModel model = AndroidModuleModel.get(module);
if (model != null) {
GradleVersion version = model.getModelVersion();
if (version != null && version.isAtLeast(2, 1, 0)) {
String buildToolsVersion = model.getAndroidProject().getBuildToolsVersion();
AndroidSdkHandler sdk = getSdk();
if (sdk != null) {
try {
Revision revision = Revision.parseRevision(buildToolsVersion);
BuildToolInfo buildToolInfo = sdk.getBuildToolInfo(revision, getRepositoryLogger());
if (buildToolInfo != null) {
return buildToolInfo;
}
} catch (NumberFormatException ignore) {
// Fall through and use the latest
}
}
}
}
}
}
return super.getBuildTools(project);
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class MoveToDebugManifestQuickFix method apply.
@Override
public void apply(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.Context context) {
final XmlAttribute attribute = PsiTreeUtil.getParentOfType(startElement, XmlAttribute.class);
if (attribute != null) {
XmlTag parent = attribute.getParent();
if (parent != null && parent.getName().equals(TAG_USES_PERMISSION)) {
Module module = getModule(parent);
assert MOCK_LOCATION_PERMISSION.equals(parent.getAttributeValue(ATTR_NAME, ANDROID_URI));
parent.delete();
if (module != null) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
VirtualFile mainManifest = facet.getMainIdeaSourceProvider().getManifestFile();
// TODO: b/22928250
AndroidModuleModel androidModel = AndroidModuleModel.get(facet);
if (androidModel != null && mainManifest != null && mainManifest.getParent() != null && mainManifest.getParent().getParent() != null) {
final VirtualFile src = mainManifest.getParent().getParent();
for (BuildTypeContainer container : androidModel.getAndroidProject().getBuildTypes()) {
BuildType buildType = container.getBuildType();
if (buildType.isDebuggable()) {
addManifest(module, src, buildType.getName());
return;
}
}
Messages.showErrorDialog(module.getProject(), "Did not find a debug build type", "Move Permission");
}
}
}
}
}
}
use of com.android.tools.idea.gradle.project.model.AndroidModuleModel in project android by JetBrains.
the class AndroidRunConfigurationEditor method updateLinkState.
private void updateLinkState() {
Module module = getModuleSelector().getModule();
if (module == null) {
myOldVersionLabel.setVisible(false);
return;
}
AndroidModuleModel model = AndroidModuleModel.get(module);
if (model == null || InstantRunGradleUtils.modelSupportsInstantRun(model)) {
myOldVersionLabel.setVisible(false);
return;
}
myOldVersionLabel.setVisible(true);
}
Aggregations