summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/aapt/Bundle.h4
-rw-r--r--tools/aapt/Main.cpp4
-rw-r--r--tools/aapt/ResourceTable.cpp31
-rw-r--r--tools/aapt2/Main.cpp2
-rw-r--r--tools/aapt2/integration-tests/AppOne/Android.mk2
-rw-r--r--tools/aapt2/integration-tests/AppOne/res/transition/transition_set.xml22
-rw-r--r--tools/aapt2/link/Link.cpp37
-rw-r--r--tools/aapt2/readme.md5
8 files changed, 105 insertions, 2 deletions
diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h
index 653c1b4d6f97..a93ee2e2b71d 100644
--- a/tools/aapt/Bundle.h
+++ b/tools/aapt/Bundle.h
@@ -55,6 +55,7 @@ public:
mCompressionMethod(0), mJunkPath(false), mOutputAPKFile(NULL),
mManifestPackageNameOverride(NULL), mInstrumentationPackageNameOverride(NULL),
mAutoAddOverlay(false), mGenDependencies(false), mNoVersionVectors(false),
+ mNoVersionTransitions(false),
mCrunchedOutputDir(NULL), mProguardFile(NULL), mMainDexProguardFile(NULL),
mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL),
@@ -219,6 +220,8 @@ public:
void setBuildAppAsSharedLibrary(bool val) { mBuildAppAsSharedLibrary = val; }
void setNoVersionVectors(bool val) { mNoVersionVectors = val; }
bool getNoVersionVectors() const { return mNoVersionVectors; }
+ void setNoVersionTransitions(bool val) { mNoVersionTransitions = val; }
+ bool getNoVersionTransitions() const { return mNoVersionTransitions; }
/*
* Set and get the file specification.
@@ -299,6 +302,7 @@ private:
bool mAutoAddOverlay;
bool mGenDependencies;
bool mNoVersionVectors;
+ bool mNoVersionTransitions;
const char* mCrunchedOutputDir;
const char* mProguardFile;
const char* mMainDexProguardFile;
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index 984d98e30f29..417b7ae087e1 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -223,6 +223,8 @@ void usage(void)
" localization\n"
" --no-version-vectors\n"
" Do not automatically generate versioned copies of vector XML resources.\n"
+ " --no-version-transitions\n"
+ " Do not automatically generate versioned copies of transition XML resources.\n"
" --private-symbols\n"
" Java package name to use when generating R.java for private resources.\n",
gDefaultIgnoreAssets);
@@ -704,6 +706,8 @@ int main(int argc, char* const argv[])
bundle.setPseudolocalize(PSEUDO_ACCENTED | PSEUDO_BIDI);
} else if (strcmp(cp, "-no-version-vectors") == 0) {
bundle.setNoVersionVectors(true);
+ } else if (strcmp(cp, "-no-version-transitions") == 0) {
+ bundle.setNoVersionTransitions(true);
} else if (strcmp(cp, "-private-symbols") == 0) {
argc--;
argv++;
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 661409e3d4bc..63498f7cef08 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -4730,6 +4730,32 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle) {
return NO_ERROR;
}
+const String16 kTransitionElements[] = {
+ String16("fade"),
+ String16("changeBounds"),
+ String16("slide"),
+ String16("explode"),
+ String16("changeImageTransform"),
+ String16("changeTransform"),
+ String16("changeClipBounds"),
+ String16("autoTransition"),
+ String16("recolor"),
+ String16("changeScroll"),
+ String16("transitionSet"),
+ String16("transition"),
+ String16("transitionManager"),
+};
+
+static bool IsTransitionElement(const String16& name) {
+ for (int i = 0, size = sizeof(kTransitionElements) / sizeof(kTransitionElements[0]);
+ i < size; ++i) {
+ if (name == kTransitionElements[i]) {
+ return true;
+ }
+ }
+ return false;
+}
+
status_t ResourceTable::modifyForCompat(const Bundle* bundle,
const String16& resourceName,
const sp<AaptFile>& target,
@@ -4766,6 +4792,11 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
continue;
}
+ if (bundle->getNoVersionTransitions() && (IsTransitionElement(node->getElementName()))) {
+ // We were told not to version transition tags, so skip the children here.
+ continue;
+ }
+
const Vector<XMLNode::attribute_entry>& attrs = node->getAttributes();
for (size_t i = 0; i < attrs.size(); i++) {
const XMLNode::attribute_entry& attr = attrs[i];
diff --git a/tools/aapt2/Main.cpp b/tools/aapt2/Main.cpp
index 74d40194e955..15d7e2e2241b 100644
--- a/tools/aapt2/Main.cpp
+++ b/tools/aapt2/Main.cpp
@@ -25,7 +25,7 @@ namespace aapt {
static const char* sMajorVersion = "2";
// Update minor version whenever a feature or flag is added.
-static const char* sMinorVersion = "4";
+static const char* sMinorVersion = "5";
int PrintVersion() {
std::cerr << "Android Asset Packaging Tool (aapt) " << sMajorVersion << "."
diff --git a/tools/aapt2/integration-tests/AppOne/Android.mk b/tools/aapt2/integration-tests/AppOne/Android.mk
index bc40a6269382..a6f32d4b9fdc 100644
--- a/tools/aapt2/integration-tests/AppOne/Android.mk
+++ b/tools/aapt2/integration-tests/AppOne/Android.mk
@@ -24,5 +24,5 @@ LOCAL_SRC_FILES := $(call all-java-files-under,src)
LOCAL_STATIC_ANDROID_LIBRARIES := \
AaptTestStaticLibOne \
AaptTestStaticLibTwo
-LOCAL_AAPT_FLAGS := --no-version-vectors
+LOCAL_AAPT_FLAGS := --no-version-vectors --no-version-transitions
include $(BUILD_PACKAGE)
diff --git a/tools/aapt2/integration-tests/AppOne/res/transition/transition_set.xml b/tools/aapt2/integration-tests/AppOne/res/transition/transition_set.xml
new file mode 100644
index 000000000000..e10e6c2f53da
--- /dev/null
+++ b/tools/aapt2/integration-tests/AppOne/res/transition/transition_set.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
+ android:transitionOrdering="sequential">
+ <fade android:fadingMode="fade_out" />
+ <changeBounds />
+ <fade android:fadingMode="fade_in" />
+</transitionSet>
diff --git a/tools/aapt2/link/Link.cpp b/tools/aapt2/link/Link.cpp
index c3ce0760f554..f7e0f8f55fd4 100644
--- a/tools/aapt2/link/Link.cpp
+++ b/tools/aapt2/link/Link.cpp
@@ -80,6 +80,7 @@ struct LinkOptions {
// Optimizations/features.
bool no_auto_version = false;
bool no_version_vectors = false;
+ bool no_version_transitions = false;
bool no_resource_deduping = false;
bool no_xml_namespaces = false;
bool do_not_compress_anything = false;
@@ -250,6 +251,7 @@ static std::unique_ptr<xml::XmlResource> LoadXml(const std::string& path,
struct ResourceFileFlattenerOptions {
bool no_auto_version = false;
bool no_version_vectors = false;
+ bool no_version_transitions = false;
bool no_xml_namespaces = false;
bool keep_raw_values = false;
bool do_not_compress_anything = false;
@@ -306,6 +308,23 @@ uint32_t ResourceFileFlattener::GetCompressionFlags(const StringPiece& str) {
return ArchiveEntry::kCompress;
}
+static bool IsTransitionElement(const std::string& name) {
+ return
+ name == "fade" ||
+ name == "changeBounds" ||
+ name == "slide" ||
+ name == "explode" ||
+ name == "changeImageTransform" ||
+ name == "changeTransform" ||
+ name == "changeClipBounds" ||
+ name == "autoTransition" ||
+ name == "recolor" ||
+ name == "changeScroll" ||
+ name == "transitionSet" ||
+ name == "transition" ||
+ name == "transitionManager";
+}
+
bool ResourceFileFlattener::LinkAndVersionXmlFile(
ResourceTable* table, FileOperation* file_op,
std::queue<FileOperation>* out_file_op_queue) {
@@ -345,6 +364,17 @@ bool ResourceFileFlattener::LinkAndVersionXmlFile(
}
}
}
+ if (options_.no_version_transitions) {
+ // Skip this if it is a transition resource.
+ xml::Element* el = xml::FindRootElement(doc);
+ if (el && el->namespace_uri.empty()) {
+ if (IsTransitionElement(el->name)) {
+ // We are NOT going to version this file.
+ file_op->skip_version = true;
+ return true;
+ }
+ }
+ }
const ConfigDescription& config = file_op->config;
@@ -1384,6 +1414,7 @@ class LinkCommand {
options_.extensions_to_not_compress;
file_flattener_options.no_auto_version = options_.no_auto_version;
file_flattener_options.no_version_vectors = options_.no_version_vectors;
+ file_flattener_options.no_version_transitions = options_.no_version_transitions;
file_flattener_options.no_xml_namespaces = options_.no_xml_namespaces;
file_flattener_options.update_proguard_spec =
static_cast<bool>(options_.generate_proguard_rules_path);
@@ -1863,6 +1894,11 @@ int Link(const std::vector<StringPiece>& args) {
"Use this only\n"
"when building with vector drawable support library",
&options.no_version_vectors)
+ .OptionalSwitch("--no-version-transitions",
+ "Disables automatic versioning of transition resources. "
+ "Use this only\n"
+ "when building with transition support library",
+ &options.no_version_transitions)
.OptionalSwitch("--no-resource-deduping",
"Disables automatic deduping of resources with\n"
"identical values across compatible configurations.",
@@ -2104,6 +2140,7 @@ int Link(const std::vector<StringPiece>& args) {
if (options.static_lib) {
options.no_auto_version = true;
options.no_version_vectors = true;
+ options.no_version_transitions = true;
}
LinkCommand cmd(&context, options);
diff --git a/tools/aapt2/readme.md b/tools/aapt2/readme.md
index 800103307e2b..e2a752e488ea 100644
--- a/tools/aapt2/readme.md
+++ b/tools/aapt2/readme.md
@@ -1,5 +1,10 @@
# Android Asset Packaging Tool 2.0 (AAPT2) release notes
+## Version 2.5
+### `aapt2 link ...`
+- Transition XML versioning: Adds a new flag `--no-version-transitions` to disable automatic
+ versioning of Transition XML resources.
+
## Version 2.4
### `aapt2 link ...`
- Supports `<meta-data>` tags in `<manifest>`.