org.jetbrains.android.util.AndroidUtils Java Examples

The following examples show how to use org.jetbrains.android.util.AndroidUtils. 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 File: BaseAction.java    From ADB-Duang with 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
Source File: DomainToPackageExpression.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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
Source File: DomainToPackageExpression.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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 File: DefaultActivityLocatorCompat.java    From intellij with 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 File: AdbWifiConnect.java    From ADBWIFI with 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 File: DefaultActivityLocatorCompat.java    From intellij with 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
Source File: BlazeAndroidBinaryRunConfigurationStateEditor.java    From intellij with Apache License 2.0 4 votes vote down vote up
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
Source File: GetDefaultLauncherActivityNameCompatBefore2_1.java    From ADBWIFI with Apache License 2.0 4 votes vote down vote up
@Override
// Intellij 15.0.2
protected String getPreviousImplementation() {
    return Reflect.on(AndroidUtils.class).call("getDefaultLauncherActivityName", facet.getManifest()).get();
}