summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/aapt/AaptAssets.cpp27
-rw-r--r--tools/aapt/AaptAssets.h2
-rw-r--r--tools/aapt/tests/AaptConfig_test.cpp2
-rw-r--r--tools/layoutlib/bridge/src/android/view/BridgeInflater.java6
-rw-r--r--tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java129
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java6
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java5
-rw-r--r--tools/split-select/Grouper.cpp9
-rw-r--r--tools/split-select/Grouper_test.cpp9
9 files changed, 103 insertions, 92 deletions
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index 871e04f..d346731 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -367,33 +367,6 @@ int AaptLocaleValue::initFromDirName(const Vector<String8>& parts, const int sta
return currentIndex;
}
-
-String8 AaptLocaleValue::toDirName() const {
- String8 dirName("");
- if (language[0]) {
- dirName += language;
- } else {
- return dirName;
- }
-
- if (script[0]) {
- dirName += "-s";
- dirName += script;
- }
-
- if (region[0]) {
- dirName += "-r";
- dirName += region;
- }
-
- if (variant[0]) {
- dirName += "-v";
- dirName += variant;
- }
-
- return dirName;
-}
-
void AaptLocaleValue::initFromResTable(const ResTable_config& config) {
config.unpackLanguage(language);
config.unpackRegion(region);
diff --git a/tools/aapt/AaptAssets.h b/tools/aapt/AaptAssets.h
index 7ae5368..4fdc964 100644
--- a/tools/aapt/AaptAssets.h
+++ b/tools/aapt/AaptAssets.h
@@ -78,8 +78,6 @@ struct AaptLocaleValue {
void writeTo(ResTable_config* out) const;
- String8 toDirName() const;
-
int compare(const AaptLocaleValue& other) const {
return memcmp(this, &other, sizeof(AaptLocaleValue));
}
diff --git a/tools/aapt/tests/AaptConfig_test.cpp b/tools/aapt/tests/AaptConfig_test.cpp
index ef3860c..7618974 100644
--- a/tools/aapt/tests/AaptConfig_test.cpp
+++ b/tools/aapt/tests/AaptConfig_test.cpp
@@ -65,7 +65,7 @@ TEST(AaptConfigTest, ParseBasicQualifiers) {
TEST(AaptConfigTest, ParseLocales) {
ConfigDescription config;
EXPECT_TRUE(TestParse("en-rUS", &config));
- EXPECT_EQ(String8("en-US"), config.toString());
+ EXPECT_EQ(String8("en-rUS"), config.toString());
}
TEST(AaptConfigTest, ParseQualifierAddedInApi13) {
diff --git a/tools/layoutlib/bridge/src/android/view/BridgeInflater.java b/tools/layoutlib/bridge/src/android/view/BridgeInflater.java
index 4acbd1c..80036e5 100644
--- a/tools/layoutlib/bridge/src/android/view/BridgeInflater.java
+++ b/tools/layoutlib/bridge/src/android/view/BridgeInflater.java
@@ -131,11 +131,11 @@ public final class BridgeInflater extends LayoutInflater {
}
@Override
- public View createViewFromTag(View parent, String name, AttributeSet attrs,
- boolean inheritContext) {
+ public View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
+ boolean ignoreThemeAttrs) {
View view;
try {
- view = super.createViewFromTag(parent, name, attrs, inheritContext);
+ view = super.createViewFromTag(parent, name, context, attrs, ignoreThemeAttrs);
} catch (InflateException e) {
// try to load the class from using the custom view loader
try {
diff --git a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
index 7a73fae..7f1e977 100644
--- a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
@@ -21,9 +21,11 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
+import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
+import android.util.TypedValue;
import android.util.Xml;
import java.io.IOException;
@@ -36,9 +38,13 @@ import java.io.IOException;
*
*/
public class LayoutInflater_Delegate {
-
private static final String TAG_MERGE = "merge";
+ private static final String ATTR_LAYOUT = "layout";
+
+ private static final int[] ATTRS_THEME = new int[] {
+ com.android.internal.R.attr.theme };
+
public static boolean sIsInInclude = false;
/**
@@ -49,7 +55,7 @@ public class LayoutInflater_Delegate {
*/
@LayoutlibDelegate
/* package */ static void rInflate(LayoutInflater thisInflater, XmlPullParser parser,
- View parent, final AttributeSet attrs, boolean finishInflate, boolean inheritContext)
+ View parent, Context context, AttributeSet attrs, boolean finishInflate)
throws XmlPullParserException, IOException {
if (finishInflate == false) {
@@ -61,7 +67,7 @@ public class LayoutInflater_Delegate {
// ---- START DEFAULT IMPLEMENTATION.
- thisInflater.rInflate_Original(parser, parent, attrs, finishInflate, inheritContext);
+ thisInflater.rInflate_Original(parser, parent, context, attrs, finishInflate);
// ---- END DEFAULT IMPLEMENTATION.
@@ -74,15 +80,50 @@ public class LayoutInflater_Delegate {
}
@LayoutlibDelegate
- public static void parseInclude(LayoutInflater thisInflater, XmlPullParser parser, View parent,
- AttributeSet attrs, boolean inheritContext) throws XmlPullParserException, IOException {
-
+ public static void parseInclude(LayoutInflater thisInflater, XmlPullParser parser,
+ Context context, View parent, AttributeSet attrs)
+ throws XmlPullParserException, IOException {
int type;
if (parent instanceof ViewGroup) {
- final int layout = attrs.getAttributeResourceValue(null, "layout", 0);
+ // Apply a theme wrapper, if requested. This is sort of a weird
+ // edge case, since developers think the <include> overwrites
+ // values in the AttributeSet of the included View. So, if the
+ // included View has a theme attribute, we'll need to ignore it.
+ final TypedArray ta = context.obtainStyledAttributes(attrs, ATTRS_THEME);
+ final int themeResId = ta.getResourceId(0, 0);
+ final boolean hasThemeOverride = themeResId != 0;
+ if (hasThemeOverride) {
+ context = new ContextThemeWrapper(context, themeResId);
+ }
+ ta.recycle();
+
+ // If the layout is pointing to a theme attribute, we have to
+ // massage the value to get a resource identifier out of it.
+ int layout = attrs.getAttributeResourceValue(null, ATTR_LAYOUT, 0);
if (layout == 0) {
- final String value = attrs.getAttributeValue(null, "layout");
+ final String value = attrs.getAttributeValue(null, ATTR_LAYOUT);
+ if (value == null || value.length() <= 0) {
+ throw new InflateException("You must specify a layout in the"
+ + " include tag: <include layout=\"@layout/layoutID\" />");
+ }
+
+ // Attempt to resolve the "?attr/name" string to an identifier.
+ layout = context.getResources().getIdentifier(value.substring(1), null, null);
+ }
+
+ // The layout might be referencing a theme attribute.
+ // ---- START CHANGES
+ if (layout != 0) {
+ final TypedValue tempValue = new TypedValue();
+ if (context.getTheme().resolveAttribute(layout, tempValue, true)) {
+ layout = tempValue.resourceId;
+ }
+ }
+ // ---- END CHANGES
+
+ if (layout == 0) {
+ final String value = attrs.getAttributeValue(null, ATTR_LAYOUT);
if (value == null) {
throw new InflateException("You must specifiy a layout in the"
+ " include tag: <include layout=\"@layout/layoutID\" />");
@@ -111,13 +152,24 @@ public class LayoutInflater_Delegate {
if (TAG_MERGE.equals(childName)) {
// Inflate all children.
- thisInflater.rInflate(childParser, parent, childAttrs, false,
- inheritContext);
+ thisInflater.rInflate(childParser, parent, context, childAttrs, false);
} else {
final View view = thisInflater.createViewFromTag(parent, childName,
- childAttrs, inheritContext);
+ context, childAttrs, hasThemeOverride);
final ViewGroup group = (ViewGroup) parent;
+ final TypedArray a = context.obtainStyledAttributes(
+ attrs, com.android.internal.R.styleable.Include);
+ final int id = a.getResourceId(
+ com.android.internal.R.styleable.Include_id, View.NO_ID);
+ final int visibility = a.getInt(
+ com.android.internal.R.styleable.Include_visibility, -1);
+ final boolean hasWidth = a.hasValue(
+ com.android.internal.R.styleable.Include_layout_width);
+ final boolean hasHeight = a.hasValue(
+ com.android.internal.R.styleable.Include_layout_height);
+ a.recycle();
+
// We try to load the layout params set in the <include /> tag. If
// they don't exist, we will rely on the layout params set in the
// included XML file.
@@ -127,40 +179,27 @@ public class LayoutInflater_Delegate {
// successfully loaded layout params from the <include /> tag,
// false means we need to rely on the included layout params.
ViewGroup.LayoutParams params = null;
- try {
- // ---- START CHANGES
- sIsInInclude = true;
- // ---- END CHANGES
-
- params = group.generateLayoutParams(attrs);
-
- } catch (RuntimeException e) {
- // ---- START CHANGES
- sIsInInclude = false;
- // ---- END CHANGES
-
- params = group.generateLayoutParams(childAttrs);
- } finally {
- // ---- START CHANGES
- sIsInInclude = false;
- // ---- END CHANGES
-
- if (params != null) {
- view.setLayoutParams(params);
+ if (hasWidth && hasHeight) {
+ try {
+ // ---- START CHANGES
+ sIsInInclude = true;
+ // ---- END CHANGES
+
+ params = group.generateLayoutParams(attrs);
+
+ } finally {
+ // ---- START CHANGES
+ sIsInInclude = false;
+ // ---- END CHANGES
}
}
+ if (params == null) {
+ params = group.generateLayoutParams(childAttrs);
+ }
+ view.setLayoutParams(params);
// Inflate all children.
- thisInflater.rInflate(childParser, view, childAttrs, true, true);
-
- // Attempt to override the included layout's android:id with the
- // one set on the <include /> tag itself.
- TypedArray a = thisInflater.mContext.obtainStyledAttributes(attrs,
- com.android.internal.R.styleable.View, 0, 0);
- int id = a.getResourceId(com.android.internal.R.styleable.View_id, View.NO_ID);
- // While we're at it, let's try to override android:visibility.
- int visibility = a.getInt(com.android.internal.R.styleable.View_visibility, -1);
- a.recycle();
+ thisInflater.rInflateChildren(childParser, view, childAttrs, true);
if (id != View.NO_ID) {
view.setId(id);
@@ -188,12 +227,6 @@ public class LayoutInflater_Delegate {
throw new InflateException("<include /> can only be used inside of a ViewGroup");
}
- final int currentDepth = parser.getDepth();
- while (((type = parser.next()) != XmlPullParser.END_TAG ||
- parser.getDepth() > currentDepth) && type != XmlPullParser.END_DOCUMENT) {
- // Empty
- }
+ LayoutInflater.consumeChildElements(parser);
}
-
-
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index e1c58fd..8e74ce1 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -1010,6 +1010,12 @@ public final class BridgeContext extends Context {
}
@Override
+ public int checkSelfPermission(String arg0) {
+ // pass
+ return 0;
+ }
+
+ @Override
public int checkPermission(String arg0, int arg1, int arg2, IBinder arg3) {
// pass
return 0;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
index 39ebdfc..6282fe5 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -145,4 +145,9 @@ public class BridgePowerManager implements IPowerManager {
public void boostScreenBrightness(long time) throws RemoteException {
// pass for now.
}
+
+ @Override
+ public boolean isDeviceIdleMode() throws RemoteException {
+ return false;
+ }
}
diff --git a/tools/split-select/Grouper.cpp b/tools/split-select/Grouper.cpp
index 22685cd..55e52fc 100644
--- a/tools/split-select/Grouper.cpp
+++ b/tools/split-select/Grouper.cpp
@@ -34,7 +34,6 @@ groupByMutualExclusivity(const Vector<SplitDescription>& splits) {
// Find mutually exclusive splits and group them.
KeyedVector<SplitDescription, SortedVector<SplitDescription> > densityGroups;
KeyedVector<SplitDescription, SortedVector<SplitDescription> > abiGroups;
- KeyedVector<SplitDescription, SortedVector<SplitDescription> > localeGroups;
const size_t splitCount = splits.size();
for (size_t i = 0; i < splitCount; i++) {
const SplitDescription& split = splits[i];
@@ -47,10 +46,6 @@ groupByMutualExclusivity(const Vector<SplitDescription>& splits) {
SplitDescription key(split);
key.abi = abi::Variant_none;
appendValue(abiGroups, key, split);
- } else if (split.config.locale != 0) {
- SplitDescription key(split);
- key.config.clearLocale();
- appendValue(localeGroups, key, split);
} else {
groups.add();
groups.editTop().add(split);
@@ -67,10 +62,6 @@ groupByMutualExclusivity(const Vector<SplitDescription>& splits) {
groups.add(abiGroups[i]);
}
- const size_t localeCount = localeGroups.size();
- for (size_t i = 0; i < localeCount; i++) {
- groups.add(localeGroups[i]);
- }
return groups;
}
diff --git a/tools/split-select/Grouper_test.cpp b/tools/split-select/Grouper_test.cpp
index a5f9c5a..7294a86 100644
--- a/tools/split-select/Grouper_test.cpp
+++ b/tools/split-select/Grouper_test.cpp
@@ -37,6 +37,8 @@ protected:
addSplit(splits, "en-rUS-sw300dp-xhdpi");
addSplit(splits, "large");
addSplit(splits, "pl-rPL");
+ addSplit(splits, "fr-rCA");
+ addSplit(splits, "fr");
addSplit(splits, "xlarge");
addSplit(splits, "en-rUS-sw600dp-xhdpi");
addSplit(splits, "en-rUS-sw300dp-hdpi");
@@ -64,7 +66,7 @@ protected:
};
TEST_F(GrouperTest, shouldHaveCorrectNumberOfGroups) {
- EXPECT_EQ(12u, mGroups.size());
+ EXPECT_EQ(15u, mGroups.size());
}
TEST_F(GrouperTest, shouldGroupDensities) {
@@ -79,7 +81,10 @@ TEST_F(GrouperTest, shouldGroupAbi) {
}
TEST_F(GrouperTest, shouldGroupLocale) {
- expectHasGroupWithSplits("pl-rPL", "de-rDE");
+ expectHasGroupWithSplits("pl-rPL");
+ expectHasGroupWithSplits("de-rDE");
+ expectHasGroupWithSplits("fr");
+ expectHasGroupWithSplits("fr-rCA");
}
TEST_F(GrouperTest, shouldGroupEachSplitIntoItsOwnGroup) {