use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class StringResourceViewPanel method hyperlinkUpdate.
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
StringBuilder sb = new StringBuilder("https://translate.google.com/manager/android_studio/");
// Application Version
sb.append("?asVer=");
ApplicationInfo ideInfo = ApplicationInfo.getInstance();
// @formatter:off
sb.append(ideInfo.getMajorVersion()).append('.').append(ideInfo.getMinorVersion()).append('.').append(ideInfo.getMicroVersion()).append('.').append(ideInfo.getPatchVersion());
// @formatter:on
// Package name
MergedManifest manifest = MergedManifest.get(myFacet);
String pkg = manifest.getPackage();
if (pkg != null) {
sb.append("&pkgName=");
sb.append(pkg.replace('.', '_'));
}
// Application ID
AndroidModuleInfo moduleInfo = AndroidModuleInfo.get(myFacet);
String appId = moduleInfo.getPackage();
if (appId != null) {
sb.append("&appId=");
sb.append(appId.replace('.', '_'));
}
// Version code
Integer versionCode = manifest.getVersionCode();
if (versionCode != null) {
sb.append("&apkVer=");
sb.append(versionCode.toString());
}
// If we support additional IDE languages, we can send the language used in the IDE here
//sb.append("&lang=en");
BrowserUtil.browse(sb.toString());
}
use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class ActionBarHandler method getActivityAttributes.
@Nullable
private ActivityAttributes getActivityAttributes() {
boolean token = RenderSecurityManager.enterSafeRegion(myCredential);
try {
MergedManifest manifest = MergedManifest.get(myRenderTask.getModule());
String activity = StringUtil.notNullize(myRenderTask.getConfiguration().getActivity());
return manifest.getActivityAttributes(activity);
} finally {
RenderSecurityManager.exitSafeRegion(token);
}
}
use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class OnClickEnumSupport method getAllValues.
@Override
@NotNull
public List<ValueWithDisplayString> getAllValues() {
Module module = myProperty.getModel().getModule();
Configuration configuration = myProperty.getModel().getConfiguration();
String activityClassName = configuration.getActivity();
JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
Collection<PsiClass> classes;
if (activityClassName != null) {
if (activityClassName.startsWith(".")) {
MergedManifest manifest = MergedManifest.get(module);
String pkg = StringUtil.notNullize(manifest.getPackage());
activityClassName = pkg + activityClassName;
}
PsiClass activityClass = facade.findClass(activityClassName, module.getModuleScope());
if (activityClass != null) {
classes = Collections.singletonList(activityClass);
} else {
classes = Collections.emptyList();
}
} else {
GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false);
PsiClass activityClass = facade.findClass(CLASS_ACTIVITY, scope);
if (activityClass != null) {
classes = ClassInheritorsSearch.search(activityClass, scope, true).findAll();
} else {
classes = Collections.emptyList();
}
}
List<ValueWithDisplayString> values = new ArrayList<>();
Set<String> found = new HashSet<>();
for (PsiClass psiClass : classes) {
for (PsiMethod method : psiClass.getAllMethods()) {
if (OnClickConverter.CONVERTER_FOR_LAYOUT.checkSignature(method) && found.add(method.getName()) && method instanceof PsiMethodImpl) {
values.add(new ValueWithDisplayString(method.getName(), method.getName(), psiClass.getName()));
}
}
}
return values;
}
use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class ManifestUtils method getActionLocation.
@NotNull
static SourceFilePosition getActionLocation(@NotNull Module module, @NotNull Actions.Record record) {
SourceFilePosition sourceFilePosition = record.getActionLocation();
SourceFile sourceFile = sourceFilePosition.getFile();
File file = sourceFile.getSourceFile();
SourcePosition sourcePosition = sourceFilePosition.getPosition();
if (file != null && !SourcePosition.UNKNOWN.equals(sourcePosition)) {
VirtualFile vFile = VfsUtil.findFileByIoFile(file, false);
assert vFile != null;
Module fileModule = ModuleUtilCore.findModuleForFile(vFile, module.getProject());
if (fileModule != null && !fileModule.equals(module)) {
MergedManifest manifest = MergedManifest.get(fileModule);
Document document = manifest.getDocument();
assert document != null;
Element root = document.getDocumentElement();
assert root != null;
int startLine = sourcePosition.getStartLine();
int startColumn = sourcePosition.getStartColumn();
Node node = PositionXmlParser.findNodeAtLineAndCol(document, startLine, startColumn);
if (node == null) {
Logger.getInstance(ManifestPanel.class).warn("Can not find node in " + fileModule + " for " + sourceFilePosition);
} else {
List<? extends Actions.Record> records = getRecords(manifest, node);
if (!records.isEmpty()) {
return getActionLocation(fileModule, records.get(0));
}
}
}
}
return sourceFilePosition;
}
use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class LaunchUtils method isWatchFeatureRequired.
/** Returns whether the watch hardware feature is required for the given facet. */
public static boolean isWatchFeatureRequired(@NotNull AndroidFacet facet) {
MergedManifest mergedManifest = MergedManifest.get(facet);
Element feature = mergedManifest.findUsedFeature(UsesFeature.HARDWARE_TYPE_WATCH);
return feature != null && isRequired(feature);
}
Aggregations