com.android.ide.common.resources.configuration.ResourceQualifier Java Examples

The following examples show how to use com.android.ide.common.resources.configuration.ResourceQualifier. 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: IdGeneratingResourceFile.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the resource value associated with this whole file as a layout resource
 * @param file the file handler that represents this file
 * @param folder the folder this file is under
 * @return a resource value associated with this layout
 */
private ResourceValue getFileValue(IAbstractFile file, ResourceFolder folder) {
    // test if there's a density qualifier associated with the resource
    DensityQualifier qualifier = folder.getConfiguration().getDensityQualifier();

    ResourceValue value;
    if (!ResourceQualifier.isValid(qualifier)) {
        value =
                new ResourceValueImpl(
                        new ResourceReference(mFileType, mFileName, isFramework()),
                        file.getOsLocation());
    } else {
        value =
                new DensityBasedResourceValueImpl(
                        new ResourceReference(mFileType, mFileName, isFramework()),
                        file.getOsLocation(),
                        qualifier.getValue());
    }
    return value;
}
 
Example #2
Source File: GeneratedResourceClassifier.java    From intellij with Apache License 2.0 6 votes vote down vote up
private static boolean mayHaveNonStringTranslations(String dirName) {
  // String translations only sit in the values-xx-rYY directories, so we can rule out other
  // directories quickly.
  if (!dirName.contains(SdkConstants.RES_QUALIFIER_SEP)) {
    return true;
  }
  if (ResourceFolderType.getFolderType(dirName) != ResourceFolderType.VALUES) {
    return true;
  }
  FolderConfiguration config = FolderConfiguration.getConfigForFolder(dirName);
  // Conservatively say it's interesting if there is an unrecognized configuration.
  if (config == null) {
    return true;
  }
  // If this is a translation mixed with something else, consider it a translation directory.
  boolean hasTranslation = false;
  for (ResourceQualifier qualifier : config.getQualifiers()) {
    if (qualifier instanceof LocaleQualifier) {
      hasTranslation = true;
    }
  }
  return !hasTranslation;
}
 
Example #3
Source File: SingleResourceFile.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public SingleResourceFile(IAbstractFile file, ResourceFolder folder) {
    super(file, folder);

    // we need to infer the type of the resource from the folder type.
    // This is easy since this is a single Resource file.
    List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(folder.getType());
    mType = types.get(0);

    // compute the resource name
    mResourceName = getResourceName(mType);

    // test if there's a density qualifier associated with the resource
    DensityQualifier qualifier = folder.getConfiguration().getDensityQualifier();

    if (!ResourceQualifier.isValid(qualifier)) {
        mValue =
                new ResourceValueImpl(
                        new ResourceReference(mType, getResourceName(mType), isFramework()),
                        file.getOsLocation());
    } else {
        mValue =
                new DensityBasedResourceValueImpl(
                        new ResourceReference(mType, getResourceName(mType), isFramework()),
                        file.getOsLocation(),
                        qualifier.getValue());
    }
}
 
Example #4
Source File: FullyQualifiedName.java    From bazel with Apache License 2.0 4 votes vote down vote up
private static void addIfNotNull(
    ResourceQualifier qualifier, ImmutableList.Builder<String> builder) {
  if (qualifier != null) {
    builder.add(qualifier.getFolderSegment());
  }
}