Java Code Examples for org.jetbrains.android.util.AndroidUtils

The following examples show how to use org.jetbrains.android.util.AndroidUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ADB-Duang   Source File: BaseAction.java    License: MIT License 5 votes vote down vote up
private static List<AndroidFacet> getApplicationFacets(Project project) {

        List<AndroidFacet> facets = Lists.newArrayList();
        for (AndroidFacet facet : AndroidUtils.getApplicationFacets(project)) {
            if (!isTestProject(facet)) {
                facets.add(facet);
            }
        }

        return facets;
    }
 
Example 2
/**
 * Converts the name of a Module, Application or User to a valid java package name segment.
 * Invalid characters are removed, and reserved Java language names are converted to valid values.
 */
@NotNull
private static String nameToJavaPackage(@NotNull String name) {
  String res = name.replace('-', '_');
  res = MODULE_NAME_GROUP.matcher(res).replaceAll("");
  res = DISALLOWED_IN_DOMAIN.matcher(res).replaceAll("").toLowerCase(Locale.US);
  if (!res.isEmpty() && AndroidUtils.isReservedKeyword(res) != null) {
    res = StringUtil.fixVariableNameDerivedFromPropertyName(res).toLowerCase(Locale.US);
  }
  return res;
}
 
Example 3
/**
 * Converts the name of a Module, Application or User to a valid java package name segment.
 * Invalid characters are removed, and reserved Java language names are converted to valid values.
 */
@NotNull
private static String nameToJavaPackage(@NotNull String name) {
  String res = name.replace('-', '_');
  res = MODULE_NAME_GROUP.matcher(res).replaceAll("");
  res = DISALLOWED_IN_DOMAIN.matcher(res).replaceAll("").toLowerCase(Locale.US);
  if (!res.isEmpty() && AndroidUtils.isReservedKeyword(res) != null) {
    res = StringUtil.fixVariableNameDerivedFromPropertyName(res).toLowerCase(Locale.US);
  }
  return res;
}
 
Example 4
Source Project: intellij   Source File: DefaultActivityLocatorCompat.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private static DefaultActivityLocatorCompat.ActivityWrapper findDefaultLauncher(
    @NotNull List<ActivityWrapper> launcherActivities) {
  for (ActivityWrapper activity : launcherActivities) {
    if (activity.hasCategory(AndroidUtils.DEFAULT_CATEGORY_NAME)) {
      return activity;
    }
  }

  return null;
}
 
Example 5
Source Project: ADBWIFI   Source File: AdbWifiConnect.java    License: Apache License 2.0 5 votes vote down vote up
private static List<AndroidFacet> getApplicationFacets(Project project) {

        List<AndroidFacet> facetList = AndroidUtils.getApplicationFacets(project);
        Module[] modules = ModuleManager.getInstance(project).getModules();
        for (Module module : modules) {
            AndroidFacet androidFacet = AndroidFacet.getInstance(module);
            if (androidFacet != null) {
                facetList.add(androidFacet);
            }
        }

        return facetList;
    }
 
Example 6
Source Project: intellij   Source File: DefaultActivityLocatorCompat.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean containsLauncherIntent(
    @NotNull DefaultActivityLocatorCompat.ActivityWrapper activity) {
  return activity.hasAction(AndroidUtils.LAUNCH_ACTION_NAME)
      && (activity.hasCategory(AndroidUtils.LAUNCH_CATEGORY_NAME)
          || activity.hasCategory(AndroidUtils.LEANBACK_LAUNCH_CATEGORY_NAME));
}
 
Example 7
BlazeAndroidBinaryRunConfigurationStateEditor(
    RunConfigurationStateEditor commonStateEditor,
    AndroidProfilersPanelCompat profilersPanelCompat,
    Project project) {
  this.commonStateEditor = commonStateEditor;
  this.profilersPanelCompat = profilersPanelCompat;
  setupUI(project);
  userIdField.setMinValue(0);

  activityField.addActionListener(
      new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          if (!project.isInitialized()) {
            return;
          }
          // We find all Activity classes in the module for the selected variant
          // (or any of its deps).
          final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
          PsiClass activityBaseClass =
              facade.findClass(
                  AndroidUtils.ACTIVITY_BASE_CLASS_NAME, ProjectScope.getAllScope(project));
          if (activityBaseClass == null) {
            Messages.showErrorDialog(
                mainContainer, AndroidBundle.message("cant.find.activity.class.error"));
            return;
          }
          GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project);
          PsiClass initialSelection =
              facade.findClass(activityField.getChildComponent().getText(), searchScope);
          TreeClassChooser chooser =
              TreeClassChooserFactory.getInstance(project)
                  .createInheritanceClassChooser(
                      "Select Activity Class",
                      searchScope,
                      activityBaseClass,
                      initialSelection,
                      null);
          chooser.showDialog();
          PsiClass selClass = chooser.getSelected();
          if (selClass != null) {
            // This must be done because Android represents
            // inner static class paths differently than java.
            String qualifiedActivityName =
                ActivityLocatorUtils.getQualifiedActivityName(selClass);
            activityField.getChildComponent().setText(qualifiedActivityName);
          }
        }
      });
  ActionListener listener = e -> updateEnabledState();
  launchCustomButton.addActionListener(listener);
  launchDefaultButton.addActionListener(listener);
  launchNothingButton.addActionListener(listener);

  useMobileInstallCheckBox.addActionListener(
      e -> PropertiesComponent.getInstance(project).setValue(MI_NEVER_ASK_AGAIN, true));

  useWorkProfileIfPresentCheckBox.addActionListener(listener);
}
 
Example 8
@Override
// Intellij 15.0.2
protected String getPreviousImplementation() {
    return Reflect.on(AndroidUtils.class).call("getDefaultLauncherActivityName", facet.getManifest()).get();
}