Java Code Examples for com.android.SdkConstants

The following examples show how to use com.android.SdkConstants. 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: intellij   Source File: KotlinResourcePsiElementFinder.java    License: Apache License 2.0 6 votes vote down vote up
/** Checks if `expression` matches an expected R.abc.xyz pattern. */
private static boolean isResourceExpression(PsiElement expression) {
  if (!(expression instanceof KtQualifiedExpression)) {
    return false;
  }

  KtQualifiedExpression qualifiedExpression = (KtQualifiedExpression) expression;
  // qualifier should be `R.abc` which is also a `KtQualifiedExpression`
  PsiElement qualifier = qualifiedExpression.getReceiverExpression();
  if (!(qualifier instanceof KtQualifiedExpression)) {
    return false;
  }

  KtQualifiedExpression qualifierExpression = (KtQualifiedExpression) qualifier;
  // rClassExpression should be `R`
  PsiElement rClassExpression = qualifierExpression.getReceiverExpression();
  // rTypeExpression should be `abc`
  PsiElement rTypeExpression = qualifierExpression.getSelectorExpression();

  return rTypeExpression != null
      && SdkConstants.R_CLASS.equals(rClassExpression.getText())
      && ResourceType.fromClassName(rTypeExpression.getText()) != null;
}
 
Example 2
Source Project: java-n-IDE-for-Android   Source File: LocalDirInfo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new immutable {@link LocalDirInfo}.
 *
 * @param fileOp The {@link FileOp} to use for all file-based interactions.
 * @param dir The platform/addon directory of the target. It should be a directory.
 */
public LocalDirInfo(@NonNull IFileOp fileOp, @NonNull File dir) {
    mFileOp = fileOp;
    mDir = dir;
    mDirModifiedTS = mFileOp.lastModified(dir);

    // Capture some info about the source.properties file if it exists.
    // We use propsModifiedTS == 0 to mean there is no props file.
    long propsChecksum = 0;
    long propsModifiedTS = 0;
    File props = new File(dir, SdkConstants.FN_SOURCE_PROP);
    if (mFileOp.isFile(props)) {
        propsModifiedTS = mFileOp.lastModified(props);
        propsChecksum = getFileChecksum(props);
    }
    mPropsModifiedTS = propsModifiedTS;
    mPropsChecksum = propsChecksum;
    mDirChecksum = getDirChecksum(mDir);
}
 
Example 3
Source Project: bazel   Source File: RClassGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private String writeInnerClassHeader(
    String fullyQualifiedOuterClass, String innerClass, ClassWriter innerClassWriter) {
  String fullyQualifiedInnerClass = fullyQualifiedOuterClass + "$" + innerClass;
  innerClassWriter.visit(
      JAVA_VERSION,
      Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_SUPER,
      fullyQualifiedInnerClass,
      null, /* signature */
      SUPER_CLASS,
      null /* interfaces */);
  innerClassWriter.visitSource(SdkConstants.FN_RESOURCE_CLASS, null);
  writeConstructor(innerClassWriter);
  innerClassWriter.visitInnerClass(
      fullyQualifiedInnerClass,
      fullyQualifiedOuterClass,
      innerClass,
      Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL | Opcodes.ACC_STATIC);
  return fullyQualifiedInnerClass;
}
 
Example 4
Source Project: javaide   Source File: FolderConfiguration.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the name of a folder with the configuration.
 */
@NonNull
public String getFolderName(@NonNull ResourceFolderType folder) {
    StringBuilder result = new StringBuilder(folder.getName());

    for (ResourceQualifier qualifier : mQualifiers) {
        if (qualifier != null) {
            String segment = qualifier.getFolderSegment();
            if (segment != null && !segment.isEmpty()) {
                result.append(SdkConstants.RES_QUALIFIER_SEP);
                result.append(segment);
            }
        }
    }

    return result.toString();
}
 
Example 5
Source Project: NBANDROID-V2   Source File: AndroidManifestParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Processes the instrumentation node.
 *
 * @param attributes the attributes for the instrumentation node.
 */
private void processInstrumentationNode(Attributes attributes) {
    // lets get the class name, and check it if required.
    String instrumentationName = getAttributeValue(attributes,
            AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (instrumentationName != null) {
        String instrClassName
                = combinePackageAndClassName(mManifestData.mPackage, instrumentationName);
        String targetPackage = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_TARGET_PACKAGE,
                true /* hasNamespace */);
        mManifestData.mInstrumentations.add(
                new Instrumentation(instrClassName, targetPackage));
        mManifestData.mKeepClasses.add(
                new ManifestData.KeepClass(
                        instrClassName, null, AndroidManifest.NODE_INSTRUMENTATION));
        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, instrClassName,
                    SdkConstants.CLASS_INSTRUMENTATION, true /* testVisibility */);
        }
    }
}
 
Example 6
Source Project: intellij   Source File: AarLibrary.java    License: Apache License 2.0 6 votes vote down vote up
/** Get path to res folder according to CLASSES root of modifiable model */
@Nullable
public PathString getResFolder(Project project) {
  Library aarLibrary =
      ProjectLibraryTable.getInstance(project)
          .getLibraryByName(this.key.getIntelliJLibraryName());
  if (aarLibrary != null) {
    VirtualFile[] files = aarLibrary.getFiles(OrderRootType.CLASSES);
    for (VirtualFile file : files) {
      if (file.isDirectory() && SdkConstants.FD_RES.equals(file.getName())) {
        return new PathString(file.getPath());
      }
    }
  }
  return null;
}
 
Example 7
Source Project: javaide   Source File: LocalDirInfo.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new immutable {@link LocalDirInfo}.
 *
 * @param fileOp The {@link FileOp} to use for all file-based interactions.
 * @param dir The platform/addon directory of the target. It should be a directory.
 */
public LocalDirInfo(@NonNull IFileOp fileOp, @NonNull File dir) {
    mFileOp = fileOp;
    mDir = dir;
    mDirModifiedTS = mFileOp.lastModified(dir);

    // Capture some info about the source.properties file if it exists.
    // We use propsModifiedTS == 0 to mean there is no props file.
    long propsChecksum = 0;
    long propsModifiedTS = 0;
    File props = new File(dir, SdkConstants.FN_SOURCE_PROP);
    if (mFileOp.isFile(props)) {
        propsModifiedTS = mFileOp.lastModified(props);
        propsChecksum = getFileChecksum(props);
    }
    mPropsModifiedTS = propsModifiedTS;
    mPropsChecksum = propsChecksum;
    mDirChecksum = getDirChecksum(mDir);
}
 
Example 8
Source Project: java-n-IDE-for-Android   Source File: PlatformTarget.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public File getDefaultSkin() {
    // only one skin? easy.
    if (mSkins.length == 1) {
        return mSkins[0];
    }

    // look for the skin name in the platform props
    String skinName = mProperties.get(SdkConstants.PROP_SDK_DEFAULT_SKIN);
    if (skinName == null) {
        // otherwise try to find a good default.
        if (mVersion.getApiLevel() >= 4) {
            // at this time, this is the default skin for all older platforms that had 2+ skins.
            skinName = "WVGA800";                                       //$NON-NLS-1$
        } else {
            skinName = "HVGA"; // this is for 1.5 and earlier.          //$NON-NLS-1$
        }
    }

    return new File(getFile(IAndroidTarget.SKINS), skinName);
}
 
Example 9
Source Project: javaide   Source File: LintClient.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns true if this project is a Gradle-based Android project
 *
 * @param project the project to check
 * @return true if this is a Gradle-based project
 */
public boolean isGradleProject(Project project) {
    // This is not an accurate test; specific LintClient implementations (e.g.
    // IDEs or a gradle-integration of lint) have more context and can perform a more accurate
    // check
    if (new File(project.getDir(), SdkConstants.FN_BUILD_GRADLE).exists()) {
        return true;
    }

    File parent = project.getDir().getParentFile();
    if (parent != null && parent.getName().equals(SdkConstants.FD_SOURCES)) {
        File root = parent.getParentFile();
        if (root != null && new File(root, SdkConstants.FN_BUILD_GRADLE).exists()) {
            return true;
        }
    }

    return false;
}
 
Example 10
Source Project: javaide   Source File: FolderConfiguration.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the folder configuration as a unique key
 */
@NonNull
public String getUniqueKey() {
  StringBuilder result = new StringBuilder(100);

  for (ResourceQualifier qualifier : mQualifiers) {
    if (qualifier != null) {
      String segment = qualifier.getFolderSegment();
      if (segment != null && !segment.isEmpty()) {
        result.append(SdkConstants.RES_QUALIFIER_SEP);
        result.append(segment);
      }
    }
  }

  return result.toString();
}
 
Example 11
Source Project: javaide   Source File: LocalSdk.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Try to find a docs package at the given location.
 * Returns null if not found.
 */
private LocalDocPkgInfo scanDoc(File docFolder) {
    // Can we find some properties?
    Properties props = parseProperties(new File(docFolder, SdkConstants.FN_SOURCE_PROP));
    MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION);
    if (rev == null) {
        return null;
    }

    try {
        AndroidVersion vers = new AndroidVersion(props);
        LocalDocPkgInfo info = new LocalDocPkgInfo(this, docFolder, props, vers, rev);

        // To start with, a doc folder should have an "index.html" to be acceptable.
        // We don't actually check the content of the file.
        if (!mFileOp.isFile(new File(docFolder, "index.html"))) {
            info.appendLoadError("Missing index.html");
        }
        return info;

    } catch (AndroidVersionException e) {
        return null; // skip invalid or missing android version.
    }
}
 
Example 12
Source Project: javaide   Source File: DeviceManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
private boolean isDevicesExtra(@NonNull File item) {
    File properties = new File(item, SdkConstants.FN_SOURCE_PROP);
    try {
        BufferedReader propertiesReader = new BufferedReader(new FileReader(properties));
        try {
            String line;
            while ((line = propertiesReader.readLine()) != null) {
                Matcher m = PATH_PROPERTY_PATTERN.matcher(line);
                if (m.matches()) {
                    return true;
                }
            }
        } finally {
            propertiesReader.close();
        }
    } catch (IOException ignore) {
    }
    return false;
}
 
Example 13
Source Project: javaide   Source File: PlatformPackage.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Computes a potential installation folder if an archive of this package were
 * to be installed right away in the given SDK root.
 * <p/>
 * A platform package is typically installed in SDK/platforms/android-"version".
 * However if we can find a different directory under SDK/platform that already
 * has this platform version installed, we'll use that one.
 *
 * @param osSdkRoot The OS path of the SDK root folder.
 * @param sdkManager An existing SDK manager to list current platforms and addons.
 * @return A new {@link File} corresponding to the directory to use to install this package.
 */
@Override
public File getInstallFolder(String osSdkRoot, SdkManager sdkManager) {

    // First find if this platform is already installed. If so, reuse the same directory.
    for (IAndroidTarget target : sdkManager.getTargets()) {
        if (target.isPlatform() && target.getVersion().equals(mVersion)) {
            return new File(target.getLocation());
        }
    }

    File platforms = new File(osSdkRoot, SdkConstants.FD_PLATFORMS);
    File folder = new File(platforms,
            String.format("android-%s", getAndroidVersion().getApiString())); //$NON-NLS-1$

    return folder;
}
 
Example 14
public void build(@NonNull CommandLineLauncher launcher)
        throws IOException, InterruptedException {

    // get the env var
    Map<String, String> env = Maps.newHashMap();
    if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) {
        env.put("DYLD_LIBRARY_PATH", mBuildToolInfo.getLocation().getAbsolutePath());
    } else if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_LINUX) {
        env.put("LD_LIBRARY_PATH", mBuildToolInfo.getLocation().getAbsolutePath());
    }

    doMainCompilation(launcher, env);

    if (mSupportMode) {
        createSupportFiles(launcher, env);
    }
}
 
Example 15
Source Project: atlas   Source File: AwbApkPackageTask.java    License: Apache License 2.0 6 votes vote down vote up
static File copyJavaResourcesOnly(File destinationFolder, File zip64File) throws IOException {
    File cacheDir = new File(destinationFolder, ZIP_64_COPY_DIR);
    File copiedZip = new File(cacheDir, zip64File.getName());
    FileUtils.mkdirs(copiedZip.getParentFile());

    try (ZipFile inFile = new ZipFile(zip64File);
         ZipOutputStream outFile =
                 new ZipOutputStream(
                         new BufferedOutputStream(new FileOutputStream(copiedZip)))) {

        Enumeration<? extends ZipEntry> entries = inFile.entries();
        while (entries.hasMoreElements()) {
            ZipEntry zipEntry = entries.nextElement();
            if (!zipEntry.getName().endsWith(SdkConstants.DOT_CLASS)) {
                outFile.putNextEntry(new ZipEntry(zipEntry.getName()));
                try {
                    ByteStreams.copy(
                            new BufferedInputStream(inFile.getInputStream(zipEntry)), outFile);
                } finally {
                    outFile.closeEntry();
                }
            }
        }
    }
    return copiedZip;
}
 
Example 16
Source Project: java-n-IDE-for-Android   Source File: DeviceManager.java    License: Apache License 2.0 6 votes vote down vote up
private boolean isDevicesExtra(@NonNull File item) {
    File properties = new File(item, SdkConstants.FN_SOURCE_PROP);
    try {
        BufferedReader propertiesReader = new BufferedReader(new FileReader(properties));
        try {
            String line;
            while ((line = propertiesReader.readLine()) != null) {
                Matcher m = PATH_PROPERTY_PATTERN.matcher(line);
                if (m.matches()) {
                    return true;
                }
            }
        } finally {
            propertiesReader.close();
        }
    } catch (IOException ignore) {
    }
    return false;
}
 
Example 17
Source Project: javaide   Source File: PreValidator.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Validate an xml declaration with 'tools:node="removeAll" annotation. There should not
 * be any other attribute declaration on this element.
 */
private static void validateRemoveAllOperation(MergingReport.Builder mergingReport,
        XmlElement element) {

    NamedNodeMap attributes = element.getXml().getAttributes();
    if (attributes.getLength() > 1) {
        List<String> extraAttributeNames = new ArrayList<String>();
        for (int i = 0; i < attributes.getLength(); i++) {
            Node item = attributes.item(i);
            if (!(SdkConstants.TOOLS_URI.equals(item.getNamespaceURI()) &&
                    NodeOperationType.NODE_LOCAL_NAME.equals(item.getLocalName()))) {
                extraAttributeNames.add(item.getNodeName());
            }
        }
        String message = String.format(
                "Element %1$s at %2$s annotated with 'tools:node=\"removeAll\"' cannot "
                        + "have other attributes : %3$s",
                element.getId(),
                element.printPosition(),
                Joiner.on(',').join(extraAttributeNames)
        );
        element.addMessage(mergingReport, ERROR, message);
    }
}
 
Example 18
Source Project: java-n-IDE-for-Android   Source File: OrphanXmlElement.java    License: Apache License 2.0 6 votes vote down vote up
public OrphanXmlElement(@NonNull Element xml) {

        mXml = Preconditions.checkNotNull(xml);
        NodeTypes nodeType;
        String elementName = mXml.getNodeName();
        // this is bit more complicated than it should be. Look first if there is a namespace
        // prefix in the name, most elements don't. If they do, however, strip it off if it is the
        // android prefix, but if it's custom namespace prefix, classify the node as CUSTOM.
        int indexOfColon = elementName.indexOf(':');
        if (indexOfColon != -1) {
            String androidPrefix = XmlUtils.lookupNamespacePrefix(xml, SdkConstants.ANDROID_URI);
            if (androidPrefix.equals(elementName.substring(0, indexOfColon))) {
                nodeType = NodeTypes.fromXmlSimpleName(elementName.substring(indexOfColon + 1));
            } else {
                nodeType = NodeTypes.CUSTOM;
            }
        } else {
            nodeType = NodeTypes.fromXmlSimpleName(elementName);
        }
        mType = nodeType;
    }
 
Example 19
/**
 * Processes the instrumentation node.
 * @param attributes the attributes for the instrumentation node.
 */
private void processInstrumentationNode(Attributes attributes) {
    // lets get the class name, and check it if required.
    String instrumentationName = getAttributeValue(attributes,
            AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (instrumentationName != null) {
        String instrClassName = AndroidManifest.combinePackageAndClassName(
                mManifestData.mPackage, instrumentationName);
        String targetPackage = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_TARGET_PACKAGE,
                true /* hasNamespace */);
        mManifestData.mInstrumentations.add(
                new Instrumentation(instrClassName, targetPackage));
        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, instrClassName,
                    SdkConstants.CLASS_INSTRUMENTATION, true /* testVisibility */);
        }
    }
}
 
Example 20
/**
 * Returns the folder configuration as a unique key
 */
@NonNull
public String getUniqueKey() {
  StringBuilder result = new StringBuilder(100);

  for (ResourceQualifier qualifier : mQualifiers) {
    if (qualifier != null) {
      String segment = qualifier.getFolderSegment();
      if (segment != null && !segment.isEmpty()) {
        result.append(SdkConstants.RES_QUALIFIER_SEP);
        result.append(segment);
      }
    }
  }

  return result.toString();
}
 
Example 21
Source Project: java-n-IDE-for-Android   Source File: ResourceRepository.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Processes a folder and adds it to the list of existing folders.
 * @param folder the folder to process
 * @return the ResourceFolder created from this folder, or null if the process failed.
 */
@Nullable
public ResourceFolder processFolder(@NonNull IAbstractFolder folder) {
    ensureInitialized();

    // split the name of the folder in segments.
    String[] folderSegments = folder.getName().split(SdkConstants.RES_QUALIFIER_SEP);

    // get the enum for the resource type.
    ResourceFolderType type = ResourceFolderType.getTypeByName(folderSegments[0]);

    if (type != null) {
        // get the folder configuration.
        FolderConfiguration config = FolderConfiguration.getConfig(folderSegments);

        if (config != null) {
            return add(type, config, folder);
        }
    }

    return null;
}
 
Example 22
Source Project: javaide   Source File: LocalSdk.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void scanSources(File collectionDir, Collection<LocalPkgInfo> outCollection) {
    // The build-tool root folder contains a list of per-revision folders.
    for (File platformDir : mFileOp.listFiles(collectionDir)) {
        if (!shouldVisitDir(PkgType.PKG_SOURCE, platformDir)) {
            continue;
        }

        Properties props = parseProperties(new File(platformDir, SdkConstants.FN_SOURCE_PROP));
        MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION);
        if (rev == null) {
            continue; // skip, no revision
        }

        try {
            AndroidVersion vers = new AndroidVersion(props);

            LocalSourcePkgInfo pkgInfo =
                    new LocalSourcePkgInfo(this, platformDir, props, vers, rev);
            outCollection.add(pkgInfo);
        } catch (AndroidVersionException e) {
            continue; // skip invalid or missing android version.
        }
    }
}
 
Example 23
Source Project: javaide   Source File: PlatformLoader.java    License: GNU General Public License v3.0 6 votes vote down vote up
private synchronized void init(@NonNull ILogger logger) {
    if (mSdkInfo == null) {
        String host;
        if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) {
            host = "darwin-x86";
        } else if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_LINUX) {
            host = "linux-x86";
        } else {
            throw new IllegalStateException(
                    "Windows is not supported for platform development");
        }

        mSdkInfo = new SdkInfo(
                new File(mTreeLocation, "out/host/" + host + "/framework/annotations.jar")  );
    }
}
 
Example 24
/** Look through binary/unknown files looking for resource URLs */
private void tokenizeUnknownBinary(@NonNull File file) {
    try {
        if (sAndroidResBytes == null) {
            sAndroidResBytes = ANDROID_RES.getBytes(SdkConstants.UTF_8);
        }
        byte[] bytes = Files.toByteArray(file);
        int index = 0;
        while (index != -1) {
            index = indexOf(bytes, sAndroidResBytes, index);
            if (index != -1) {
                index += sAndroidResBytes.length;

                // Find the end of the URL
                int begin = index;
                int end = begin;
                for (; end < bytes.length; end++) {
                    byte c = bytes[end];
                    if (c != '/' && !Character.isJavaIdentifierPart((char)c)) {
                        // android_res/raw/my_drawable.png => @raw/my_drawable
                        String url = "@" + new String(bytes, begin, end - begin, UTF_8);
                        markReachable(getResourceFromUrl(url));
                        break;
                    }
                }
            }
        }
    } catch (IOException e) {
        // Ignore
    }
}
 
Example 25
Source Project: Folivora   Source File: FolivoraAttrProcessing.java    License: Apache License 2.0 5 votes vote down vote up
private static void registerAttribute(
  AttributeDefinition attrDef,
  String parentStyleableName,
  String namespaceKey,
  DomElement element,
  AttributeProcessingUtil.AttributeProcessor callback) {
  String name = attrDef.getName();
  if (!SdkConstants.ANDROID_URI.equals(namespaceKey) && name.startsWith(SdkConstants.ANDROID_NS_NAME_PREFIX)) {
    name = name.substring(SdkConstants.ANDROID_NS_NAME_PREFIX.length());
    namespaceKey = SdkConstants.ANDROID_URI;
  }

  XmlName xmlName = new XmlName(name, namespaceKey);
  DomExtension extension = callback.processAttribute(xmlName, attrDef, parentStyleableName);
  if (extension != null) {
    Converter converter = AndroidDomUtil.getSpecificConverter(xmlName, element);
    if ("drawableName".equals(name)) {
      converter = DRAWABLE_CLASS_CONVERTER;
    }
    if ("drawableId".equals(name)) {
      converter = DRAWABLE_ID_CONVERTER;
    }
    if (converter == null) {
      if (SdkConstants.TOOLS_URI.equals(namespaceKey)) {
        converter = ToolsAttributeUtil.getConverter(attrDef);
      } else {
        converter = AndroidDomUtil.getConverter(attrDef);
      }
    }

    if (converter != null) {
      extension.setConverter(converter, mustBeSoft(converter, attrDef.getFormats()));
    }
  }
}
 
Example 26
Source Project: Stark   Source File: MonitorVisitor.java    License: Apache License 2.0 5 votes vote down vote up
static boolean isClassEligibleForStark(@NonNull File inputFile) {
    if (inputFile.getPath().endsWith(SdkConstants.DOT_CLASS)) {
        return isClassEligibleForStark(inputFile.getName());
    } else {
        return false;
    }
}
 
Example 27
Source Project: Stark   Source File: MonitorVisitor.java    License: Apache License 2.0 5 votes vote down vote up
static boolean isClassEligibleForStark(@NonNull String name) {
    if (name.endsWith(SdkConstants.DOT_CLASS)) {
        return !name.equals("R" + SdkConstants.DOT_CLASS) && !name.startsWith("R$");
    } else {
        return false;
    }
}
 
Example 28
Source Project: javaide   Source File: AndroidProGuardTask.java    License: GNU General Public License v3.0 5 votes vote down vote up
private File getDefaultProguardFile(String name) {
    File sdkDir = scope.getGlobalScope().getSdkHandler().getAndCheckSdkFolder();
    return new File(sdkDir,
            SdkConstants.FD_TOOLS + File.separatorChar
                    + SdkConstants.FD_PROGUARD + File.separatorChar
                    + name);
}
 
Example 29
/**
 * Parses the skin folder and builds the skin list.
 * @param skinRootFolder The path to the skin root folder.
 */
@NonNull
protected List<File> parseSkinFolder(@NonNull File skinRootFolder) {
    IFileOp fileOp = getLocalSdk().getFileOp();

    if (fileOp.isDirectory(skinRootFolder)) {
        ArrayList<File> skinList = new ArrayList<File>();

        File[] files = fileOp.listFiles(skinRootFolder);

        for (File skinFolder : files) {
            if (fileOp.isDirectory(skinFolder)) {
                // check for layout file
                File layout = new File(skinFolder, SdkConstants.FN_SKIN_LAYOUT);

                if (fileOp.isFile(layout)) {
                    // for now we don't parse the content of the layout and
                    // simply add the directory to the list.
                    skinList.add(skinFolder);
                }
            }
        }

        Collections.sort(skinList);
        return skinList;
    }

    return Collections.emptyList();
}
 
Example 30
Source Project: javaide   Source File: ProjectCreator.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Installs a new file from the gradle wrapper template.
 *
 * @param templateName the name of the template file
 * @param projectFolder the path to the project folder
 * @throws ProjectCreateException
 */
public void installGradleWrapperFile(String templateName, File projectFolder)
        throws ProjectCreateException {
    String templateFolder = mSdkFolder + File.separator +
            SdkConstants.OS_SDK_TOOLS_TEMPLATES_GRADLE_WRAPPER_FOLDER;

    installBinaryFile(new File(templateFolder, templateName),
            new File(projectFolder, templateName));
}