UI updates for Done Bar sample
Change-Id: I590b873550d57857448930794c23887978b287ad
(cherry picked from commit 7e2bb894bbb3d41126b9c064a414dbd64b684b07)
diff --git a/ui/actionbar/DoneBar/AndroidManifest.xml b/ui/actionbar/DoneBar/AndroidManifest.xml
index 5536a9b..cce4d5e 100755
--- a/ui/actionbar/DoneBar/AndroidManifest.xml
+++ b/ui/actionbar/DoneBar/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:theme="@style/Theme.Sample"
android:allowBackup="true">
- <activity android:name=".MainActivity"
+ <activity android:name=".SampleDashboardActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/ui/actionbar/DoneBar/res/drawable-xhdpi/sample_dashboard_item_background.9.png b/ui/actionbar/DoneBar/res/drawable-xhdpi/sample_dashboard_item_background.9.png
new file mode 100644
index 0000000..1358628
--- /dev/null
+++ b/ui/actionbar/DoneBar/res/drawable-xhdpi/sample_dashboard_item_background.9.png
Binary files differ
diff --git a/ui/actionbar/DoneBar/res/layout/activity_main.xml b/ui/actionbar/DoneBar/res/layout/activity_main.xml
index e342ca3..88cdb80 100755
--- a/ui/actionbar/DoneBar/res/layout/activity_main.xml
+++ b/ui/actionbar/DoneBar/res/layout/activity_main.xml
@@ -14,45 +14,28 @@
limitations under the License.
-->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
- <LinearLayout style="@style/Widget.SampleContentContainer"
+ <TextView style="@style/Widget.SampleMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical">
+ android:layout_marginLeft="@dimen/horizontal_page_margin"
+ android:layout_marginRight="@dimen/horizontal_page_margin"
+ android:layout_marginTop="@dimen/vertical_page_margin"
+ android:layout_marginBottom="@dimen/vertical_page_margin"
+ android:text="@string/intro_message" />
- <TextView style="@style/Widget.SampleMessage"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/intro_message" />
+ <GridView android:id="@android:id/list"
+ style="@style/Widget.SampleDashboard.Grid"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:paddingLeft="@dimen/horizontal_page_margin"
+ android:paddingRight="@dimen/horizontal_page_margin"
+ android:paddingBottom="@dimen/vertical_page_margin"
+ android:scrollbarStyle="outsideOverlay" />
- <Button style="@style/Widget.SampleButton"
- android:id="@+id/done_bar_link"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/margin_large"
- android:layout_marginBottom="@dimen/margin_small"
- android:text="@string/done_bar_title" />
-
- <TextView style="@style/Widget.SampleMessage"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/done_bar_description" />
-
- <Button style="@style/Widget.SampleButton"
- android:id="@+id/done_button_link"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/margin_large"
- android:layout_marginBottom="@dimen/margin_small"
- android:text="@string/done_button_title" />
-
- <TextView style="@style/Widget.SampleMessage"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/done_button_description" />
-
- </LinearLayout>
-</ScrollView>
+</LinearLayout>
diff --git a/ui/actionbar/DoneBar/res/layout/sample_dashboard_item.xml b/ui/actionbar/DoneBar/res/layout/sample_dashboard_item.xml
new file mode 100644
index 0000000..38987ee
--- /dev/null
+++ b/ui/actionbar/DoneBar/res/layout/sample_dashboard_item.xml
@@ -0,0 +1,32 @@
+<!--
+ Copyright 2013 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"
+ style="@style/Widget.SampleDashboard.Item"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView android:id="@android:id/text1"
+ style="@style/Widget.SampleDashboard.Item.Title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView android:id="@android:id/text2"
+ style="@style/Widget.SampleDashboard.Item.Description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+</LinearLayout>
diff --git a/ui/actionbar/DoneBar/res/values-sw600dp/dimens.xml b/ui/actionbar/DoneBar/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..22074a2
--- /dev/null
+++ b/ui/actionbar/DoneBar/res/values-sw600dp/dimens.xml
@@ -0,0 +1,24 @@
+<!--
+ Copyright 2013 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.
+ -->
+
+<resources>
+
+ <!-- Semantic definitions -->
+
+ <dimen name="horizontal_page_margin">@dimen/margin_huge</dimen>
+ <dimen name="vertical_page_margin">@dimen/margin_medium</dimen>
+
+</resources>
diff --git a/ui/actionbar/DoneBar/res/values-sw600dp/styles.xml b/ui/actionbar/DoneBar/res/values-sw600dp/styles.xml
index 8b7fa45..401e7aa 100644
--- a/ui/actionbar/DoneBar/res/values-sw600dp/styles.xml
+++ b/ui/actionbar/DoneBar/res/values-sw600dp/styles.xml
@@ -16,24 +16,9 @@
<resources>
- <style name="Widget.SampleContentContainer">
- <item name="android:paddingTop">@dimen/margin_medium</item>
- <item name="android:paddingBottom">@dimen/margin_medium</item>
- <item name="android:paddingLeft">@dimen/margin_huge</item>
- <item name="android:paddingRight">@dimen/margin_huge</item>
- </style>
-
<style name="Widget.SampleMessage">
<item name="android:textAppearance">?android:textAppearanceLarge</item>
<item name="android:lineSpacingMultiplier">1.2</item>
</style>
- <style name="Widget.SampleButton" parent="android:Widget.Holo.Light.Button">
- <item name="android:textAppearance">?android:textAppearanceLarge</item>
- <item name="android:paddingTop">@dimen/margin_medium</item>
- <item name="android:paddingBottom">@dimen/margin_medium</item>
- <item name="android:paddingLeft">@dimen/margin_large</item>
- <item name="android:paddingRight">@dimen/margin_large</item>
- </style>
-
</resources>
diff --git a/ui/actionbar/DoneBar/res/values/dimens.xml b/ui/actionbar/DoneBar/res/values/dimens.xml
index 952c220..39e710b 100644
--- a/ui/actionbar/DoneBar/res/values/dimens.xml
+++ b/ui/actionbar/DoneBar/res/values/dimens.xml
@@ -24,4 +24,9 @@
<dimen name="margin_large">32dp</dimen>
<dimen name="margin_huge">64dp</dimen>
+ <!-- Semantic definitions -->
+
+ <dimen name="horizontal_page_margin">@dimen/margin_medium</dimen>
+ <dimen name="vertical_page_margin">@dimen/margin_medium</dimen>
+
</resources>
diff --git a/ui/actionbar/DoneBar/res/values/styles.xml b/ui/actionbar/DoneBar/res/values/styles.xml
index 80895ef..f3841bd 100644
--- a/ui/actionbar/DoneBar/res/values/styles.xml
+++ b/ui/actionbar/DoneBar/res/values/styles.xml
@@ -27,7 +27,10 @@
<style name="Widget" />
<style name="Widget.SampleContentContainer">
- <item name="android:padding">@dimen/margin_medium</item>
+ <item name="android:paddingTop">@dimen/vertical_page_margin</item>
+ <item name="android:paddingBottom">@dimen/vertical_page_margin</item>
+ <item name="android:paddingLeft">@dimen/horizontal_page_margin</item>
+ <item name="android:paddingRight">@dimen/horizontal_page_margin</item>
</style>
<style name="Widget.SampleMessage">
@@ -35,8 +38,34 @@
<item name="android:lineSpacingMultiplier">1.1</item>
</style>
- <style name="Widget.SampleButton" parent="android:Widget.Holo.Light.Button">
- <item name="android:textAppearance">?android:textAppearanceMedium</item>
+ <style name="Widget.SampleDashboard.Grid" parent="Widget">
+ <item name="android:stretchMode">columnWidth</item>
+ <item name="android:columnWidth">200dp</item>
+ <item name="android:numColumns">auto_fit</item>
+ <item name="android:drawSelectorOnTop">true</item>
+ <item name="android:horizontalSpacing">@dimen/margin_medium</item>
+ <item name="android:verticalSpacing">@dimen/margin_medium</item>
+ </style>
+
+ <style name="Widget.SampleDashboard.Item" parent="Widget">
+ <item name="android:background">@drawable/sample_dashboard_item_background</item>
+ <item name="android:paddingTop">@dimen/margin_small</item>
+ <item name="android:paddingLeft">@dimen/margin_medium</item>
+ <item name="android:paddingRight">@dimen/margin_medium</item>
+ <item name="android:paddingBottom">@dimen/margin_medium</item>
+ </style>
+
+ <style name="Widget.SampleDashboard.Item.Title" parent="Widget">
+ <item name="android:layout_marginBottom">@dimen/margin_tiny</item>
+ <item name="android:textAppearance">?android:textAppearanceLarge</item>
+ <item name="android:textColor">#09c</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">24sp</item>
+ </style>
+
+ <style name="Widget.SampleDashboard.Item.Description" parent="Widget">
+ <item name="android:textAppearance">?android:textAppearanceSmall</item>
+ <item name="android:fontFamily">sans-serif-light</item>
</style>
</resources>
diff --git a/ui/actionbar/DoneBar/src/com/example/android/donebar/DoneBarActivity.java b/ui/actionbar/DoneBar/src/com/example/android/donebar/DoneBarActivity.java
old mode 100644
new mode 100755
diff --git a/ui/actionbar/DoneBar/src/com/example/android/donebar/DoneButtonActivity.java b/ui/actionbar/DoneBar/src/com/example/android/donebar/DoneButtonActivity.java
old mode 100644
new mode 100755
diff --git a/ui/actionbar/DoneBar/src/com/example/android/donebar/SampleDashboardActivity.java b/ui/actionbar/DoneBar/src/com/example/android/donebar/SampleDashboardActivity.java
new file mode 100755
index 0000000..690a0ed
--- /dev/null
+++ b/ui/actionbar/DoneBar/src/com/example/android/donebar/SampleDashboardActivity.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2013 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.donebar;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.GridView;
+import android.widget.TextView;
+
+/**
+ * A simple launcher activity offering access to the individual samples in this project.
+ */
+public class SampleDashboardActivity extends Activity implements AdapterView.OnItemClickListener {
+ private Sample[] mSamples;
+ private GridView mGridView;
+
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ // Prepare list of samples in this dashboard.
+ mSamples = new Sample[]{
+ new Sample(R.string.done_bar_title, R.string.done_bar_description,
+ DoneBarActivity.class),
+ new Sample(R.string.done_button_title, R.string.done_button_description,
+ DoneButtonActivity.class),
+ };
+
+ // Prepare the GridView
+ mGridView = (GridView) findViewById(android.R.id.list);
+ mGridView.setAdapter(new SampleAdapter());
+ mGridView.setOnItemClickListener(this);
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> container, View view, int position, long id) {
+ startActivity(mSamples[position].intent);
+ }
+
+ private class SampleAdapter extends BaseAdapter {
+ @Override
+ public int getCount() {
+ return mSamples.length;
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mSamples[position];
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return mSamples[position].hashCode();
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup container) {
+ if (convertView == null) {
+ convertView = getLayoutInflater().inflate(R.layout.sample_dashboard_item,
+ container, false);
+ }
+
+ ((TextView) convertView.findViewById(android.R.id.text1)).setText(
+ mSamples[position].titleResId);
+ ((TextView) convertView.findViewById(android.R.id.text2)).setText(
+ mSamples[position].descriptionResId);
+ return convertView;
+ }
+ }
+
+ private class Sample {
+ int titleResId;
+ int descriptionResId;
+ Intent intent;
+
+ private Sample(int titleResId, int descriptionResId, Intent intent) {
+ this.intent = intent;
+ this.titleResId = titleResId;
+ this.descriptionResId = descriptionResId;
+ }
+
+ private Sample(int titleResId, int descriptionResId,
+ Class<? extends Activity> activityClass) {
+ this(titleResId, descriptionResId,
+ new Intent(SampleDashboardActivity.this, activityClass));
+ }
+ }
+}