use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.
the class RenderErrorContributor method reportRtlNotEnabled.
private void reportRtlNotEnabled(@NotNull RenderLogger logger, @Nullable RenderTask task) {
ApplicationManager.getApplication().runReadAction(() -> {
Project project = logger.getProject();
if (project == null || project.isDisposed()) {
return;
}
Module module = logger.getModule();
if (module == null) {
return;
}
AndroidFacet facet = AndroidFacet.getInstance(module);
Manifest manifest = facet != null ? facet.getManifest() : null;
Application application = manifest != null ? manifest.getApplication() : null;
if (application == null) {
return;
}
final XmlTag applicationTag = application.getXmlTag();
if (applicationTag == null) {
return;
}
HtmlBuilder builder = new HtmlBuilder();
builder.add("(").addLink("Add android:supportsRtl=\"true\" to the manifest", logger.getLinkManager().createRunnableLink(() -> {
new SetAttributeFix(project, applicationTag, AndroidManifest.ATTRIBUTE_SUPPORTS_RTL, ANDROID_URI, VALUE_TRUE).execute();
EditorDesignSurface surface = task != null ? task.getDesignSurface() : null;
if (surface != null) {
surface.requestRender(true);
}
})).add(")");
addIssue().setSeverity(HighlightSeverity.ERROR).setSummary("RTL support requires android:supportsRtl=\"true\" in the manifest").setHtmlContent(builder).build();
});
}
use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.
the class SpecificActivityLocator method doesPackageContainMavenProperty.
private static boolean doesPackageContainMavenProperty(@NotNull AndroidFacet facet) {
final Manifest manifest = facet.getManifest();
if (manifest == null) {
return false;
}
final String aPackage = manifest.getPackage().getStringValue();
return aPackage != null && aPackage.contains("${");
}
use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.
the class PackageClassConverter method getManifestPackage.
@Nullable
private String getManifestPackage(@NotNull ConvertContext context) {
DomElement domElement = context.getInvocationElement();
Manifest manifest = domElement.getParentOfType(Manifest.class, true);
String manifestPackage = manifest != null ? manifest.getPackage().getValue() : null;
if (manifestPackage == null && myUseManifestBasePackage) {
Module module = context.getModule();
if (module != null) {
manifestPackage = MergedManifest.get(module).getPackage();
}
}
return manifestPackage;
}
use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.
the class ManifestInnerClass method getFields.
@NotNull
@Override
public PsiField[] getFields() {
if (myFieldsCache == null) {
myFieldsCache = CachedValuesManager.getManager(getProject()).createCachedValue(new CachedValueProvider<PsiField[]>() {
@Override
public Result<PsiField[]> compute() {
final Manifest manifest = myFacet.getManifest();
if (manifest == null) {
return Result.create(PsiField.EMPTY_ARRAY, PsiModificationTracker.MODIFICATION_COUNT);
}
final List<Pair<String, String>> pairs = doGetFields(manifest);
final PsiField[] result = new PsiField[pairs.size()];
final PsiClassType stringType = PsiType.getJavaLangString(myManager, GlobalSearchScope.allScope(getProject()));
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
int i = 0;
for (Pair<String, String> pair : pairs) {
final AndroidLightField field = new AndroidLightField(pair.getFirst(), ManifestInnerClass.this, stringType, true, pair.getSecond());
field.setInitializer(factory.createExpressionFromText("\"" + pair.getSecond() + "\"", field));
result[i++] = field;
}
final XmlElement xmlElement = manifest.getXmlElement();
final PsiFile psiManifestFile = xmlElement != null ? xmlElement.getContainingFile() : null;
return Result.create(result, psiManifestFile != null ? psiManifestFile : PsiModificationTracker.MODIFICATION_COUNT);
}
});
}
return myFieldsCache.getValue();
}
use of org.jetbrains.android.dom.manifest.Manifest in project android by JetBrains.
the class AndroidGotoDeclarationHandler method collectManifestElements.
private static void collectManifestElements(@NotNull String nestedClassName, @NotNull String fieldName, @NotNull AndroidFacet facet, @NotNull List<PsiElement> result) {
final Manifest manifest = facet.getManifest();
if (manifest == null) {
return;
}
List<? extends ManifestElementWithRequiredName> list;
if ("permission".equals(nestedClassName)) {
list = manifest.getPermissions();
} else if ("permission_group".equals(nestedClassName)) {
list = manifest.getPermissionGroups();
} else {
return;
}
for (ManifestElementWithRequiredName domElement : list) {
final AndroidAttributeValue<String> nameAttribute = domElement.getName();
final String name = nameAttribute.getValue();
if (AndroidUtils.equal(name, fieldName, false)) {
final XmlElement psiElement = nameAttribute.getXmlAttributeValue();
if (psiElement != null) {
result.add(psiElement);
}
}
}
}
Aggregations