Merge "Add PropertiesMap and ability to get entire map of properties" into studio-master-dev
diff --git a/layoutlib-api/src/main/java/com/android/ide/common/rendering/api/RenderSession.java b/layoutlib-api/src/main/java/com/android/ide/common/rendering/api/RenderSession.java
index 38ed896..55073d4 100644
--- a/layoutlib-api/src/main/java/com/android/ide/common/rendering/api/RenderSession.java
+++ b/layoutlib-api/src/main/java/com/android/ide/common/rendering/api/RenderSession.java
@@ -19,6 +19,7 @@
import static com.android.ide.common.rendering.api.Result.Status.NOT_IMPLEMENTED;
import com.android.ide.common.rendering.api.Result.Status;
+import com.android.util.PropertiesMap;
import java.awt.image.BufferedImage;
import java.util.List;
@@ -107,12 +108,22 @@
* values, for the given view Object.
* @param viewObject the view object.
* @return a map of the default property values or null.
+ * @deprecated use {@link #getDefaultProperties()}
*/
+ @Deprecated
public Map<String, String> getDefaultProperties(Object viewObject) {
return null;
}
/**
+ * Returns the map of View Cookie -> properties (attribute name, attribute value) for all the
+ * views that have a view cookie.
+ */
+ public Map<Object, PropertiesMap> getDefaultProperties() {
+ return null;
+ }
+
+ /**
* Re-renders the layout as-is.
* In case of success, this should be followed by calls to {@link #getRootViews()} and
* {@link #getImage()} to access the result of the rendering.
diff --git a/layoutlib-api/src/main/java/com/android/util/PropertiesMap.java b/layoutlib-api/src/main/java/com/android/util/PropertiesMap.java
new file mode 100644
index 0000000..ab77e51
--- /dev/null
+++ b/layoutlib-api/src/main/java/com/android/util/PropertiesMap.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package com.android.util;
+
+
+import java.util.HashMap;
+
+/**
+ * LayoutLib can return properties that a View asked for at the time of inflation. This map is from
+ * the property name (XML attribute name) to the value - both pre and post resolution.
+ */
+public class PropertiesMap extends HashMap<String, PropertiesMap.Property> {
+
+ public static class Property {
+
+ /** Pre-resolution resource value */
+ public final String resource;
+ /** Post-resolution value */
+ public final String value;
+
+ public Property(String resource, String value) {
+ this.resource = resource;
+ this.value = value;
+ }
+ }
+}