Added CardView demo to SupportV7 demo app

Change-Id: Ie1b81426dc67c67766eb20fb8f1fc984d25a42cf
diff --git a/samples/Support7Demos/Android.mk b/samples/Support7Demos/Android.mk
index ca8310f..ef51640 100644
--- a/samples/Support7Demos/Android.mk
+++ b/samples/Support7Demos/Android.mk
@@ -27,13 +27,15 @@
         android-support-v7-appcompat \
         android-support-v7-gridlayout \
         android-support-v7-mediarouter \
-        android-support-v7-recyclerview
+        android-support-v7-recyclerview \
+        android-support-v7-cardview
 LOCAL_RESOURCE_DIR = \
         $(LOCAL_PATH)/res \
         frameworks/support/v7/appcompat/res \
         frameworks/support/v7/gridlayout/res \
-        frameworks/support/v7/mediarouter/res
+        frameworks/support/v7/mediarouter/res \
+        frameworks/support/v7/cardview/res
 LOCAL_AAPT_FLAGS := \
         --auto-add-overlay \
-        --extra-packages android.support.v7.appcompat:android.support.v7.gridlayout:android.support.v7.mediarouter
+        --extra-packages android.support.v7.cardview:android.support.v7.appcompat:android.support.v7.gridlayout:android.support.v7.mediarouter
 include $(BUILD_PACKAGE)
diff --git a/samples/Support7Demos/AndroidManifest.xml b/samples/Support7Demos/AndroidManifest.xml
index 6f9b237..3cbb359 100644
--- a/samples/Support7Demos/AndroidManifest.xml
+++ b/samples/Support7Demos/AndroidManifest.xml
@@ -201,5 +201,14 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".view.CardViewActivity"
+                  android:label="@string/card_view"
+                  android:theme="@style/Theme.AppCompat">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="com.example.android.supportv7.SAMPLE_CODE" />
+            </intent-filter>
+        </activity>
+
     </application>
 </manifest>
diff --git a/samples/Support7Demos/res/layout/activity_card_view.xml b/samples/Support7Demos/res/layout/activity_card_view.xml
new file mode 100644
index 0000000..f88daf7
--- /dev/null
+++ b/samples/Support7Demos/res/layout/activity_card_view.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              xmlns:card_view="http://schemas.android.com/apk/res-auto"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:background="#ffffffff"
+              android:orientation="vertical">
+    <RelativeLayout
+            android:layout_marginLeft="10dp"
+            android:layout_marginRight="10dp"
+            android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:id="@+id/radius_label"
+                android:layout_marginBottom="5dp"
+                android:text="@string/card_view_radius"/>
+        <SeekBar
+                android:id="@+id/corner_radius_seek_bar"
+                android:max="100"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_toRightOf="@id/radius_label"
+                android:layout_alignTop="@id/radius_label"/>
+        <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="5dp"
+                android:id="@+id/width_label"
+                android:text="@string/card_view_width"
+                android:layout_below="@id/radius_label"
+                android:layout_alignRight="@id/radius_label"/>
+        <SeekBar
+                android:id="@+id/width_seek_bar"
+                android:max="600"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_toRightOf="@id/width_label"
+                android:layout_alignTop="@id/width_label"/>
+        <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="5dp"
+                android:id="@+id/height_label"
+                android:text="@string/card_view_height"
+                android:layout_below="@id/width_label"
+                android:layout_alignRight="@id/width_label"/>
+        <SeekBar
+                android:id="@+id/height_seek_bar"
+                android:max="600"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_toRightOf="@id/height_label"
+                android:layout_alignTop="@id/height_label"/>
+
+    </RelativeLayout>
+    <android.support.v7.widget.CardView
+            android:id="@+id/card_view"
+            android:layout_gravity="center"
+            android:layout_width="200dp"
+            android:layout_height="200dp"
+            card_view:cardCornerRadius="4dp">
+        <TextView
+                android:id="@+id/info_text"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent" />
+    </android.support.v7.widget.CardView>
+</LinearLayout>
diff --git a/samples/Support7Demos/res/values/strings.xml b/samples/Support7Demos/res/values/strings.xml
index 7e4e03c..5a80295 100644
--- a/samples/Support7Demos/res/values/strings.xml
+++ b/samples/Support7Demos/res/values/strings.xml
@@ -109,4 +109,8 @@
     <string name="delete_add_item">D+A</string>
     <string name="d1a2d3">d1a2d3</string>
 
+    <string name="card_view">Card View</string>
+    <string name="card_view_radius">Radius</string>
+    <string name="card_view_width">Width</string>
+    <string name="card_view_height">Height</string>
 </resources>
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java
new file mode 100644
index 0000000..e680aaa
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2014 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.example.android.supportv7.view;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v7.widget.CardView;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.TextView;
+import com.example.android.supportv7.R;
+
+public class CardViewActivity extends Activity {
+
+    CardView mCardView;
+
+    TextView mInfoText;
+
+    SeekBar mCornerRadiusSeekBar;
+
+    SeekBar mWidthSeekBar;
+
+    SeekBar mHeightSeekBar;
+
+    private SeekBar.OnSeekBarChangeListener mOnSeekBarChangedListener
+            = new SeekBar.OnSeekBarChangeListener() {
+        @Override
+        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+            update();
+        }
+
+        @Override
+        public void onStartTrackingTouch(SeekBar seekBar) {
+
+        }
+
+        @Override
+        public void onStopTrackingTouch(SeekBar seekBar) {
+
+        }
+    };
+
+    private void update() {
+        mCardView.setRadius(mCornerRadiusSeekBar.getProgress());
+        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mCardView.getLayoutParams();
+        lp.width = mWidthSeekBar.getProgress();
+        lp.height = mHeightSeekBar.getProgress();
+        mCardView.setLayoutParams(lp);
+        mInfoText.setText("radius : " + mCornerRadiusSeekBar.getProgress()
+                + "\n w:" + lp.width + "\nh:" + lp.height);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_card_view);
+        mInfoText = (TextView) findViewById(R.id.info_text);
+        mCardView = (CardView) findViewById(R.id.card_view);
+        mCornerRadiusSeekBar = (SeekBar) findViewById(R.id.corner_radius_seek_bar);
+        mCornerRadiusSeekBar.setProgress((int) mCardView.getRadius());
+        mCornerRadiusSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener);
+
+        mWidthSeekBar = (SeekBar) findViewById(R.id.width_seek_bar);
+        mWidthSeekBar.setProgress(mCardView.getLayoutParams().width);
+
+        mWidthSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener);
+
+        mHeightSeekBar = (SeekBar) findViewById(R.id.height_seek_bar);
+        mHeightSeekBar.setProgress(mCardView.getLayoutParams().height);
+        mHeightSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangedListener);
+
+        update();
+        new Handler().postDelayed(new Runnable() {
+            @Override
+            public void run() {
+                View content = findViewById(android.R.id.content);
+                mWidthSeekBar.setMax(content.getWidth());
+                mHeightSeekBar.setMax(content.getHeight());
+            }
+        }, 100);
+    }
+
+}