diff --git a/cardview-v7/.gitignore b/cardview-v7/.gitignore
new file mode 100644
index 00000000..796b96d1
--- /dev/null
+++ b/cardview-v7/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/cardview-v7/build.gradle b/cardview-v7/build.gradle
new file mode 100644
index 00000000..1f9f838a
--- /dev/null
+++ b/cardview-v7/build.gradle
@@ -0,0 +1,78 @@
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
+ *
+ * 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.
+ */
+
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 25
+ buildToolsVersion "25.0.2"
+
+ defaultConfig {
+ minSdkVersion 14
+ targetSdkVersion 25
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+task sourcesJar(type: Jar) {
+ from android.sourceSets.main.java.srcDirs
+ classifier = 'sources'
+}
+
+task javadoc(type: Javadoc) {
+ source = android.sourceSets.main.java.srcDirs
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+}
+
+afterEvaluate {
+ javadoc.classpath += files(android.libraryVariants.collect { variant ->
+ variant.javaCompile.classpath.files
+ })
+}
+
+task javadocJar(type: Jar, dependsOn: javadoc) {
+ classifier = 'javadoc'
+ from javadoc.destinationDir
+}
+
+artifacts {
+ archives javadocJar
+ archives sourcesJar
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ compile 'com.android.support:appcompat-v7:25.1.0'
+ testCompile 'junit:junit:4.12'
+ compile 'com.android.support:cardview-v7:25.1.0'
+ compile project(path: ':proteus-core')
+}
diff --git a/cardview-v7/proguard-rules.pro b/cardview-v7/proguard-rules.pro
new file mode 100644
index 00000000..fc826501
--- /dev/null
+++ b/cardview-v7/proguard-rules.pro
@@ -0,0 +1,33 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/aditya.sharat/Library/Android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+-dontobfuscate
+-printmapping out.map
+-keepparameternames
+-renamesourcefileattribute SourceFile
+-keepattributes Exceptions,InnerClasses,Signature,Deprecated
+
+# Preserve all annotations.
+
+-keepattributes *Annotation*
+
+# Preserve all public classes, and their public and protected fields and
+# methods.
+
+-keep public class * {
+ public protected *;
+}
\ No newline at end of file
diff --git a/cardview-v7/src/main/AndroidManifest.xml b/cardview-v7/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..6e61683c
--- /dev/null
+++ b/cardview-v7/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+
+
+
diff --git a/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/CardViewCollection.java b/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/CardViewCollection.java
new file mode 100644
index 00000000..b272ff69
--- /dev/null
+++ b/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/CardViewCollection.java
@@ -0,0 +1,44 @@
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
+ *
+ * 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.flipkart.android.proteus.support.v7;
+
+import com.flipkart.android.proteus.ProteusBuilder;
+import com.flipkart.android.proteus.support.v7.widget.CardViewParser;
+
+/**
+ * CardViewCollection
+ *
+ * @author adityasharat
+ */
+
+public class CardViewCollection implements ProteusBuilder.Collection {
+
+ private CardViewCollection() {
+ }
+
+ public static CardViewCollection create() {
+ return new CardViewCollection();
+ }
+
+ @Override
+ public void registerWith(ProteusBuilder builder) {
+ builder.register(new CardViewParser());
+ }
+}
diff --git a/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/widget/CardViewParser.java b/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/widget/CardViewParser.java
new file mode 100644
index 00000000..698bb915
--- /dev/null
+++ b/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/widget/CardViewParser.java
@@ -0,0 +1,165 @@
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
+ *
+ * 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.flipkart.android.proteus.support.v7.widget;
+
+import android.content.res.ColorStateList;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.widget.CardView;
+import android.view.ViewGroup;
+
+import com.flipkart.android.proteus.ProteusContext;
+import com.flipkart.android.proteus.ProteusView;
+import com.flipkart.android.proteus.ViewTypeParser;
+import com.flipkart.android.proteus.processor.BooleanAttributeProcessor;
+import com.flipkart.android.proteus.processor.ColorResourceProcessor;
+import com.flipkart.android.proteus.processor.DimensionAttributeProcessor;
+import com.flipkart.android.proteus.value.Layout;
+import com.flipkart.android.proteus.value.ObjectValue;
+
+/**
+ * CardViewParser
+ *
+ * @author adityasharat
+ */
+
+public class CardViewParser extends ViewTypeParser {
+
+ @NonNull
+ @Override
+ public String getType() {
+ return "CardView";
+ }
+
+ @Nullable
+ @Override
+ public String getParentType() {
+ return "FrameLayout";
+ }
+
+ @NonNull
+ @Override
+ public ProteusView createView(@NonNull ProteusContext context, @NonNull Layout layout, @NonNull ObjectValue data, @Nullable ViewGroup parent, int dataIndex) {
+ return new ProteusCardView(context);
+ }
+
+ @Override
+ protected void addAttributeProcessors() {
+
+ addAttributeProcessor("cardBackgroundColor", new ColorResourceProcessor() {
+ @Override
+ public void setColor(T view, int color) {
+ view.setCardBackgroundColor(color);
+ }
+
+ @Override
+ public void setColor(T view, ColorStateList colors) {
+ view.setCardBackgroundColor(colors);
+ }
+ });
+
+ addAttributeProcessor("cardCornerRadius", new DimensionAttributeProcessor() {
+ @Override
+ public void setDimension(T view, float dimension) {
+ view.setRadius(dimension);
+ }
+ });
+
+ addAttributeProcessor("cardElevation", new DimensionAttributeProcessor() {
+ @Override
+ public void setDimension(T view, float dimension) {
+ view.setCardElevation(dimension);
+ }
+ });
+
+ addAttributeProcessor("cardMaxElevation", new DimensionAttributeProcessor() {
+ @Override
+ public void setDimension(T view, float dimension) {
+ view.setMaxCardElevation(dimension);
+ }
+ });
+
+ addAttributeProcessor("cardPreventCornerOverlap", new BooleanAttributeProcessor() {
+ @Override
+ public void setBoolean(T view, boolean value) {
+ view.setPreventCornerOverlap(value);
+ }
+ });
+
+ addAttributeProcessor("cardUseCompatPadding", new BooleanAttributeProcessor() {
+ @Override
+ public void setBoolean(T view, boolean value) {
+ view.setUseCompatPadding(value);
+ }
+ });
+
+ addAttributeProcessor("contentPadding", new DimensionAttributeProcessor() {
+ @Override
+ public void setDimension(T view, float dimension) {
+ view.setContentPadding((int) dimension, (int) dimension, (int) dimension, (int) dimension);
+ }
+ });
+
+ addAttributeProcessor("contentPaddingBottom", new DimensionAttributeProcessor() {
+ @Override
+ public void setDimension(T view, float dimension) {
+ int t = view.getContentPaddingTop();
+ int r = view.getContentPaddingRight();
+ int l = view.getContentPaddingLeft();
+
+ view.setContentPadding(l, t, r, (int) dimension);
+ }
+ });
+
+ addAttributeProcessor("contentPaddingLeft", new DimensionAttributeProcessor() {
+ @Override
+ public void setDimension(T view, float dimension) {
+ int t = view.getContentPaddingTop();
+ int r = view.getContentPaddingRight();
+ int b = view.getContentPaddingBottom();
+
+ view.setContentPadding((int) dimension, t, r, b);
+ }
+ });
+
+ addAttributeProcessor("contentPaddingRight", new DimensionAttributeProcessor() {
+ @Override
+ public void setDimension(T view, float dimension) {
+ int t = view.getContentPaddingTop();
+ int b = view.getContentPaddingBottom();
+ int l = view.getContentPaddingLeft();
+
+ view.setContentPadding(l, t, (int) dimension, b);
+ }
+ });
+
+ addAttributeProcessor("contentPaddingTop", new DimensionAttributeProcessor() {
+ @Override
+ public void setDimension(T view, float dimension) {
+ int r = view.getContentPaddingRight();
+ int b = view.getContentPaddingBottom();
+ int l = view.getContentPaddingLeft();
+
+ view.setContentPadding(l, (int) dimension, r, b);
+ }
+ });
+
+ }
+}
diff --git a/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/widget/ProteusCardView.java b/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/widget/ProteusCardView.java
new file mode 100644
index 00000000..171e9338
--- /dev/null
+++ b/cardview-v7/src/main/java/com/flipkart/android/proteus/support/v7/widget/ProteusCardView.java
@@ -0,0 +1,56 @@
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * Copyright (c) 2017 Flipkart Internet Pvt. Ltd.
+ *
+ * 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.flipkart.android.proteus.support.v7.widget;
+
+import android.support.v7.widget.CardView;
+import android.view.View;
+
+import com.flipkart.android.proteus.ProteusContext;
+import com.flipkart.android.proteus.ProteusView;
+
+/**
+ * ProteusCardView
+ *
+ * @author adityasharat
+ */
+
+public class ProteusCardView extends CardView implements ProteusView {
+
+ private Manager manager;
+
+ public ProteusCardView(ProteusContext context) {
+ super(context);
+ }
+
+ @Override
+ public Manager getViewManager() {
+ return manager;
+ }
+
+ @Override
+ public void setViewManager(Manager manager) {
+ this.manager = manager;
+ }
+
+ @Override
+ public View getAsView() {
+ return this;
+ }
+}
diff --git a/cardview-v7/src/main/res/values/strings.xml b/cardview-v7/src/main/res/values/strings.xml
new file mode 100644
index 00000000..7b86f809
--- /dev/null
+++ b/cardview-v7/src/main/res/values/strings.xml
@@ -0,0 +1,22 @@
+
+
+
+ cardview-v7
+
diff --git a/data/layout.json b/data/layout.json
index 664c19b0..5d76f4a5 100644
--- a/data/layout.json
+++ b/data/layout.json
@@ -12,11 +12,13 @@
"background": "#efefef",
"children": [
{
- "type": "FrameLayout",
+ "type": "CardView",
"layout_width": "match_parent",
"layout_height": "wrap_content",
- "padding": "16dp",
- "paddingBottom": "0dp",
+ "contentPadding": "16dp",
+ "cardBackgroundColor": "#88ff99bb",
+ "cardElevation": "2dp",
+ "cardCornerRadius": "16dp",
"children": [
{
"type": "LinearLayout",
diff --git a/demo/build.gradle b/demo/build.gradle
index f8ce878b..13833933 100644
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -75,6 +75,7 @@ android {
compile project(':gson-adapter')
compile project(':support-v4')
compile project(':recyclerview-v7')
+ compile project(':cardview-v7')
}
}
diff --git a/demo/src/main/java/com/flipkart/android/proteus/demo/ProteusActivity.java b/demo/src/main/java/com/flipkart/android/proteus/demo/ProteusActivity.java
index 300df6b9..9764a0e9 100644
--- a/demo/src/main/java/com/flipkart/android/proteus/demo/ProteusActivity.java
+++ b/demo/src/main/java/com/flipkart/android/proteus/demo/ProteusActivity.java
@@ -50,6 +50,7 @@
import com.flipkart.android.proteus.gson.ProteusTypeAdapterFactory;
import com.flipkart.android.proteus.recyclerview.v7.RecyclerViewCollection;
import com.flipkart.android.proteus.support.v4.SupportV4Collection;
+import com.flipkart.android.proteus.support.v7.CardViewCollection;
import com.flipkart.android.proteus.toolbox.EventType;
import com.flipkart.android.proteus.value.DrawableValue;
import com.flipkart.android.proteus.value.Layout;
@@ -186,6 +187,7 @@ protected void onStart() {
Proteus proteus = new ProteusBuilder()
.register(SupportV4Collection.create())
.register(RecyclerViewCollection.create())
+ .register(CardViewCollection.create())
.register(new CircleViewParser())
.build();
diff --git a/settings.gradle b/settings.gradle
index 339430a8..b0b554bb 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -17,4 +17,4 @@
* specific language governing permissions and limitations under the License.
*/
-include ':demo', ':proteus-core', ':gson-adapter', ':support-v4', ':recyclerview-v7'
\ No newline at end of file
+include ':demo', ':proteus-core', ':gson-adapter', ':support-v4', ':recyclerview-v7', ':cardview-v7'
\ No newline at end of file