use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class LaunchUtils method isWatchFaceApp.
/**
* Returns whether the given module corresponds to a watch face app.
* A module is considered to be a watch face app if there are no activities, and a single service with
* a specific intent filter. This definition is likely stricter than it needs to be to but we are only
* interested in matching the watch face template application.
*/
public static boolean isWatchFaceApp(@NotNull AndroidFacet facet) {
if (AndroidFacet.getInstance(facet.getModule()) == null) {
Logger.getInstance(LaunchUtils.class).warn("calling isWatchFaceApp when facet is not ready yet");
return false;
}
MergedManifest info = MergedManifest.get(facet);
if (!info.getActivities().isEmpty()) {
return false;
}
final List<Element> services = info.getServices();
if (services.size() != 1) {
return false;
}
Element service = services.get(0);
List<Element> filters = LintUtils.getChildren(service);
return filters.size() == 1 && ActivityLocatorUtils.containsAction(filters.get(0), AndroidUtils.WALLPAPER_SERVICE_ACTION_NAME) && ActivityLocatorUtils.containsCategory(filters.get(0), AndroidUtils.WATCHFACE_CATEGORY_NAME);
}
use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class ConfigurationManager method computePreferredTheme.
/**
* Returns the preferred theme
*/
@NotNull
public String computePreferredTheme(@NotNull Configuration configuration) {
MergedManifest manifest = MergedManifest.get(myModule);
// TODO: If we are rendering a layout in included context, pick the theme
// from the outer layout instead
String activity = configuration.getActivity();
if (activity != null) {
String activityFqcn = activity;
if (activity.startsWith(".")) {
String pkg = StringUtil.notNullize(manifest.getPackage());
activityFqcn = pkg + activity;
}
ActivityAttributes attributes = manifest.getActivityAttributes(activityFqcn);
if (attributes != null) {
String theme = attributes.getTheme();
// Check that the theme looks like a reference
if (theme != null && theme.startsWith(SdkConstants.PREFIX_RESOURCE_REF)) {
return theme;
}
}
// Try with the package name from the manifest.
attributes = manifest.getActivityAttributes(activity);
if (attributes != null) {
String theme = attributes.getTheme();
// Check that the theme looks like a reference
if (theme != null && theme.startsWith(SdkConstants.PREFIX_RESOURCE_REF)) {
return theme;
}
}
}
// in the manifest)
return manifest.getDefaultTheme(configuration.getTarget(), configuration.getScreenSize(), configuration.getDevice());
}
use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class ManifestConflictTest method getErrorHtml.
private String[] getErrorHtml() {
MergedManifest manifest = MergedManifest.get(myAndroidFacet);
manifest.clear();
ImmutableList<MergingReport.Record> records = manifest.getLoggingRecords();
String[] errors = new String[records.size()];
for (int c = 0; c < records.size(); c++) {
MergingReport.Record record = records.get(c);
errors[c] = ManifestPanel.getErrorHtml(myAndroidFacet, record.getMessage(), record.getSourceLocation(), myHtmlLinkManager, null);
}
return errors;
}
use of com.android.tools.idea.model.MergedManifest in project android by JetBrains.
the class NlProperties method currentActivityIfFoundIsDerivedFromAppCompatActivity.
private static boolean currentActivityIfFoundIsDerivedFromAppCompatActivity(@NotNull List<NlComponent> components) {
assert !components.isEmpty();
NlModel model = components.get(0).getModel();
Configuration configuration = model.getConfiguration();
String activityClassName = configuration.getActivity();
if (activityClassName == null) {
// Assume we are since this is how the default activities are created.
return true;
}
if (activityClassName.startsWith(".")) {
MergedManifest manifest = MergedManifest.get(model.getModule());
String pkg = StringUtil.notNullize(manifest.getPackage());
activityClassName = pkg + activityClassName;
}
JavaPsiFacade facade = JavaPsiFacade.getInstance(model.getProject());
PsiClass activityClass = facade.findClass(activityClassName, model.getModule().getModuleScope());
while (activityClass != null && !CLASS_APP_COMPAT_ACTIVITY.equals(activityClass.getQualifiedName())) {
activityClass = activityClass.getSuperClass();
}
return activityClass != null;
}
Aggregations