summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/SoftKeyboard/src/com/example/android/softkeyboard/ImePreferences.java5
-rw-r--r--samples/Support7Demos/AndroidManifest.xml56
-rw-r--r--samples/Support7Demos/res/layout/activity_card_view.xml58
-rw-r--r--samples/Support7Demos/res/layout/toolbar_display_options.xml85
-rw-r--r--samples/Support7Demos/res/layout/toolbar_fragment_pager.xml34
-rw-r--r--samples/Support7Demos/res/layout/toolbar_usage.xml40
-rw-r--r--samples/Support7Demos/res/menu/actions.xml11
-rw-r--r--samples/Support7Demos/res/values/colors.xml5
-rw-r--r--samples/Support7Demos/res/values/strings.xml5
-rw-r--r--samples/Support7Demos/res/values/styles.xml32
-rw-r--r--samples/Support7Demos/res/xml/searchable.xml22
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarDisplayOptions.java36
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarTabs.java3
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarUsage.java13
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/app/RecentSuggestionsProvider.java28
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/app/SearchActivity.java45
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarDisplayOptions.java129
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarFragmentPagerMenu.java171
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarUsage.java80
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java36
-rw-r--r--samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java2
-rw-r--r--tools/idegen/src/Configuration.java2
22 files changed, 864 insertions, 34 deletions
diff --git a/samples/SoftKeyboard/src/com/example/android/softkeyboard/ImePreferences.java b/samples/SoftKeyboard/src/com/example/android/softkeyboard/ImePreferences.java
index db6c1d984..14c67b70d 100644
--- a/samples/SoftKeyboard/src/com/example/android/softkeyboard/ImePreferences.java
+++ b/samples/SoftKeyboard/src/com/example/android/softkeyboard/ImePreferences.java
@@ -41,6 +41,11 @@ public class ImePreferences extends PreferenceActivity {
setTitle(R.string.settings_name);
}
+ @Override
+ protected boolean isValidFragment(final String fragmentName) {
+ return Settings.class.getName().equals(fragmentName);
+ }
+
public static class Settings extends InputMethodSettingsFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
diff --git a/samples/Support7Demos/AndroidManifest.xml b/samples/Support7Demos/AndroidManifest.xml
index 4077bb110..703d657d2 100644
--- a/samples/Support7Demos/AndroidManifest.xml
+++ b/samples/Support7Demos/AndroidManifest.xml
@@ -31,7 +31,7 @@
reading images from the media store from API v19+. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
- <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" />
+ <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="21" />
<!-- The smallest screen this app works on is a phone. The app will
scale its UI to larger screens but doesn't make good use of them
@@ -130,6 +130,16 @@
</intent-filter>
</activity>
+ <activity android:name=".app.SearchActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.SEARCH" />
+ </intent-filter>
+
+ <meta-data android:name="android.app.searchable"
+ android:resource="@xml/searchable" />
+
+ </activity>
+
<activity android:name=".app.ActionBarUsage"
android:label="@string/action_bar_usage"
android:theme="@style/Theme.AppCompat">
@@ -151,7 +161,7 @@
<activity android:name=".app.ActionBarTabs"
android:label="@string/action_bar_tabs"
- android:theme="@style/Theme.AppCompat">
+ android:theme="@style/Theme.Custom">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.example.android.supportv7.SAMPLE_CODE" />
@@ -160,7 +170,7 @@
<activity android:name=".app.ActionBarSettingsActionProviderActivity"
android:label="@string/action_bar_settings_action_provider"
- android:theme="@style/Theme.AppCompat">
+ android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.example.android.supportv7.SAMPLE_CODE" />
@@ -177,15 +187,49 @@
</activity>
<activity android:name=".app.ActionBarWithDrawerLayout"
- android:label="@string/action_bar_with_navigation_drawer"
- android:theme="@style/Theme.AppCompat"
- >
+ android:label="@string/action_bar_with_navigation_drawer"
+ 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>
+
+ <activity android:name=".app.ToolbarUsage"
+ android:label="@string/toolbar_usage"
+ android:theme="@style/Theme.Custom.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.example.android.supportv7.SAMPLE_CODE" />
</intent-filter>
+
+ <meta-data
+ android:name="android.app.default_searchable"
+ android:value=".app.SearchActivity" />
</activity>
+ <activity android:name=".app.ToolbarDisplayOptions"
+ android:label="@string/toolbar_display_options"
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.supportv7.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".app.ToolbarFragmentPagerMenu"
+ android:label="@string/toolbar_fragment_pager"
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.example.android.supportv7.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <provider android:name=".app.RecentSuggestionsProvider"
+ android:authorities="com.example.android.supportv7.RecentSuggestionsProvider" />
+
<!-- RecyclerView samples -->
<activity android:name=".widget.RecyclerViewActivity"
android:label="@string/recycler_view"
diff --git a/samples/Support7Demos/res/layout/activity_card_view.xml b/samples/Support7Demos/res/layout/activity_card_view.xml
index cfd307142..9b985f70e 100644
--- a/samples/Support7Demos/res/layout/activity_card_view.xml
+++ b/samples/Support7Demos/res/layout/activity_card_view.xml
@@ -123,14 +123,62 @@
android:layout_height="wrap_content"
android:layout_toRightOf="@id/alpha_label"
android:layout_alignTop="@id/alpha_label"/>
-
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="5dp"
+ android:id="@+id/color_label"
+ android:textColor="@android:color/black"
+ android:text="@string/card_view_bg_color"
+ android:layout_below="@id/alpha_label"
+ android:layout_alignRight="@id/alpha_label"/>
<RadioGroup
- android:id="@+id/select_target_radio"
+ android:id="@+id/select_bg_color_radio"
+ android:layout_toRightOf="@id/color_label"
+ android:layout_alignTop="@id/color_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/alpha_seek_bar">
<RadioButton
+ android:id="@+id/def"
+ android:layout_width="40dp"
+ android:layout_height="wrap_content"
+ android:background="@color/cardview_light_background"
+ android:checked="true"/>
+ <RadioButton
+ android:id="@+id/yellow"
+ android:layout_width="40dp"
+ android:layout_height="wrap_content"
+ android:background="@color/card_yellow"/>
+ <RadioButton
+ android:id="@+id/aquatic"
+ android:layout_width="40dp"
+ android:layout_height="wrap_content"
+ android:background="@color/card_aquatic"/>
+ <RadioButton
+ android:id="@+id/classic"
+ android:layout_width="40dp"
+ android:layout_height="wrap_content"
+ android:background="@color/card_classic"/>
+ <RadioButton
+ android:id="@+id/sunbrite"
+ android:layout_width="40dp"
+ android:layout_height="wrap_content"
+ android:background="@color/card_sunbrite"/>
+ <RadioButton
+ android:id="@+id/tropical"
+ android:layout_width="40dp"
+ android:layout_height="wrap_content"
+ android:background="@color/card_tropical"/>
+ </RadioGroup>
+ <RadioGroup
+ android:id="@+id/select_target_radio"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_below="@id/color_label">
+ <RadioButton
android:id="@+id/resize_card_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -144,7 +192,6 @@
android:textColor="@android:color/black"
android:text="@string/card_view_resize_content"/>
</RadioGroup>
-
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="match_parent">
@@ -155,9 +202,10 @@
card_view:cardElevation="10dp">
<TextView
android:id="@+id/info_text"
+ android:text="@string/card_view"
android:textColor="@android:color/black"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/card_view_sample_text"
diff --git a/samples/Support7Demos/res/layout/toolbar_display_options.xml b/samples/Support7Demos/res/layout/toolbar_display_options.xml
new file mode 100644
index 000000000..cc3e66c5a
--- /dev/null
+++ b/samples/Support7Demos/res/layout/toolbar_display_options.xml
@@ -0,0 +1,85 @@
+<?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:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:minHeight="?attr/actionBarSize"
+ android:background="?attr/colorPrimary" />
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <Button
+ android:id="@+id/toggle_home_as_up"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/toggle_home_as_up"/>
+
+ <Button
+ android:id="@+id/toggle_show_home"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/toggle_show_home"/>
+
+ <Button
+ android:id="@+id/toggle_use_logo"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/toggle_use_logo"/>
+
+ <Button
+ android:id="@+id/toggle_show_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/toggle_show_title"/>
+
+ <Button
+ android:id="@+id/toggle_show_custom"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/toggle_show_custom"/>
+
+ <Button
+ android:id="@+id/cycle_custom_gravity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/cycle_custom_gravity"/>
+
+ <Button
+ android:id="@+id/toggle_visibility"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/toggle_visibility"/>
+
+ </LinearLayout>
+
+ </ScrollView>
+
+</LinearLayout> \ No newline at end of file
diff --git a/samples/Support7Demos/res/layout/toolbar_fragment_pager.xml b/samples/Support7Demos/res/layout/toolbar_fragment_pager.xml
new file mode 100644
index 000000000..9f56f194b
--- /dev/null
+++ b/samples/Support7Demos/res/layout/toolbar_fragment_pager.xml
@@ -0,0 +1,34 @@
+<?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"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?actionBarSize"
+ android:background="?attr/colorPrimaryDark" />
+
+ <android.support.v4.view.ViewPager
+ android:id="@+id/viewpager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
+
+</LinearLayout> \ No newline at end of file
diff --git a/samples/Support7Demos/res/layout/toolbar_usage.xml b/samples/Support7Demos/res/layout/toolbar_usage.xml
new file mode 100644
index 000000000..b202e1f68
--- /dev/null
+++ b/samples/Support7Demos/res/layout/toolbar_usage.xml
@@ -0,0 +1,40 @@
+<?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:app="http://schemas.android.com/apk/res-auto"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:minHeight="?attr/actionBarSize"
+ android:background="?attr/colorPrimaryDark"
+ app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
+ app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="Your content"
+ android:gravity="center"
+ android:textAppearance="?android:attr/textAppearanceLarge"/>
+
+</LinearLayout> \ No newline at end of file
diff --git a/samples/Support7Demos/res/menu/actions.xml b/samples/Support7Demos/res/menu/actions.xml
index 38d291ebc..43605fd3c 100644
--- a/samples/Support7Demos/res/menu/actions.xml
+++ b/samples/Support7Demos/res/menu/actions.xml
@@ -16,9 +16,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_search"
- android:icon="@android:drawable/ic_menu_search"
android:title="@string/action_bar_search"
- app:showAsAction="ifRoom"
+ android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
+ app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView" />
<item android:id="@+id/action_add"
android:icon="@android:drawable/ic_menu_add"
@@ -30,6 +30,7 @@
<item android:id="@+id/action_share"
android:icon="@android:drawable/ic_menu_share"
android:title="@string/action_bar_share"
+ android:enabled="false"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_sort"
android:icon="@android:drawable/ic_menu_sort_by_size"
@@ -38,12 +39,10 @@
<menu>
<item android:id="@+id/action_sort_size"
android:icon="@android:drawable/ic_menu_sort_by_size"
- android:title="@string/action_bar_sort_size"
- android:onClick="onSort" />
+ android:title="@string/action_bar_sort_size" />
<item android:id="@+id/action_sort_alpha"
android:icon="@android:drawable/ic_menu_sort_alphabetically"
- android:title="@string/action_bar_sort_alpha"
- android:onClick="onSort" />
+ android:title="@string/action_bar_sort_alpha" />
</menu>
</item>
</menu>
diff --git a/samples/Support7Demos/res/values/colors.xml b/samples/Support7Demos/res/values/colors.xml
index b129b8de6..c8c67a0a2 100644
--- a/samples/Support7Demos/res/values/colors.xml
+++ b/samples/Support7Demos/res/values/colors.xml
@@ -16,4 +16,9 @@
<resources>
<drawable name="blue">#770000ff</drawable>
+ <color name="card_yellow">#FCF0AD</color>
+ <color name="card_aquatic">#FCF0AD</color>
+ <color name="card_classic">#BAB7A9</color>
+ <color name="card_sunbrite">#F9D6AC</color>
+ <color name="card_tropical">#56C4E8</color>
</resources>
diff --git a/samples/Support7Demos/res/values/strings.xml b/samples/Support7Demos/res/values/strings.xml
index 14569a53d..789e19ef8 100644
--- a/samples/Support7Demos/res/values/strings.xml
+++ b/samples/Support7Demos/res/values/strings.xml
@@ -121,6 +121,9 @@
necessary.
</string>
+ <string name="toolbar_usage">AppCompat/Toolbar/Toolbar as Action Bar</string>
+ <string name="toolbar_display_options">AppCompat/Toolbar/Toolbar Display Options</string>
+ <string name="toolbar_fragment_pager">AppCompat/Toolbar/Toolbar Fragment ViewPager</string>
<string name="sample_media_route_provider_remote">Remote Playback (Simulated)</string>
<string name="sample_media_route_activity_local">Local Playback</string>
@@ -147,6 +150,7 @@
<string name="card_view_radius">Radius</string>
<string name="card_view_width">Width</string>
<string name="card_view_height">Height</string>
+ <string name="card_view_bg_color">Background</string>
<string name="card_view_elevation">Elevation</string>
<string name="card_view_max_elevation">Max Elevation</string>
<string name="card_view_alpha">Alpha</string>
@@ -156,5 +160,6 @@
<string name="palette">Palette</string>
<string name="palette_all_colors">Full color palette</string>
+ <string name="search_hint">Search...</string>
</resources>
diff --git a/samples/Support7Demos/res/values/styles.xml b/samples/Support7Demos/res/values/styles.xml
new file mode 100644
index 000000000..f085fa5f0
--- /dev/null
+++ b/samples/Support7Demos/res/values/styles.xml
@@ -0,0 +1,32 @@
+<?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.
+-->
+
+<resources>
+
+ <style name="Theme.Custom" parent="Theme.AppCompat.Light.DarkActionBar">
+ <item name="colorPrimary">#ff00bcd4</item>
+ <item name="colorPrimaryDark">#00838f</item>
+ <item name="colorAccent">#ffff00</item>
+ </style>
+
+ <style name="Theme.Custom.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
+ <item name="colorPrimary">#ff00bcd4</item>
+ <item name="colorPrimaryDark">#00838f</item>
+ <item name="colorAccent">#ffff00</item>
+ </style>
+
+</resources> \ No newline at end of file
diff --git a/samples/Support7Demos/res/xml/searchable.xml b/samples/Support7Demos/res/xml/searchable.xml
new file mode 100644
index 000000000..7f0fa74d5
--- /dev/null
+++ b/samples/Support7Demos/res/xml/searchable.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+
+<searchable xmlns:android="http://schemas.android.com/apk/res/android"
+ android:label="@string/activity_sample_code"
+ android:hint="@string/search_hint"
+ android:searchSuggestAuthority="com.example.android.supportv7.RecentSuggestionsProvider"
+ android:searchSuggestSelection=" ?" /> \ No newline at end of file
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarDisplayOptions.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarDisplayOptions.java
index b7b25e8f8..ebda99905 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarDisplayOptions.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarDisplayOptions.java
@@ -15,6 +15,8 @@
*/
package com.example.android.supportv7.app;
+import com.example.android.supportv7.R;
+
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
@@ -24,8 +26,8 @@ import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
-
-import com.example.android.supportv7.R;
+import android.widget.ArrayAdapter;
+import android.widget.Toast;
/**
* This demo shows how various action bar display option flags can be combined and their effects.
@@ -59,6 +61,21 @@ public class ActionBarDisplayOptions extends ActionBarActivity
bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this));
bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this));
bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this));
+
+ final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(bar.getThemedContext(),
+ R.layout.support_simple_spinner_dropdown_item,
+ new String[] { "Item 1", "Item 2", "Item 3" });
+ bar.setListNavigationCallbacks(listAdapter, new ActionBar.OnNavigationListener() {
+ @Override
+ public boolean onNavigationItemSelected(int itemPosition, long itemId) {
+ Toast.makeText(ActionBarDisplayOptions.this,
+ listAdapter.getItem(itemPosition),
+ Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ });
+
+ bar.setLogo(R.drawable.ic_media_play);
}
@Override
@@ -94,10 +111,17 @@ public class ActionBarDisplayOptions extends ActionBarActivity
flags = ActionBar.DISPLAY_SHOW_CUSTOM;
break;
case R.id.toggle_navigation:
- bar.setNavigationMode(
- bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD
- ? ActionBar.NAVIGATION_MODE_TABS
- : ActionBar.NAVIGATION_MODE_STANDARD);
+ switch (bar.getNavigationMode()) {
+ case ActionBar.NAVIGATION_MODE_STANDARD:
+ bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ break;
+ case ActionBar.NAVIGATION_MODE_TABS:
+ bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+ break;
+ case ActionBar.NAVIGATION_MODE_LIST:
+ bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ break;
+ }
return;
case R.id.cycle_custom_gravity: {
ActionBar.LayoutParams lp = mCustomViewLayoutParams;
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarTabs.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarTabs.java
index aaa916cf3..4bfea5010 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarTabs.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarTabs.java
@@ -36,7 +36,6 @@ public class ActionBarTabs extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
setContentView(R.layout.action_bar_tabs);
}
@@ -61,10 +60,8 @@ public class ActionBarTabs extends ActionBarActivity {
if (bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_TABS) {
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
- bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
} else {
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
}
}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarUsage.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarUsage.java
index 6ed59fbbe..f8c29caed 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarUsage.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarUsage.java
@@ -67,14 +67,19 @@ public class ActionBarUsage extends ActionBarActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_sort_alpha:
+ case R.id.action_sort_size:
+ onSort(item);
+ break;
+ }
+
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
+
return true;
}
- // This method is specified as an onClick handler in the menu xml and will
- // take precedence over the Activity's onOptionsItemSelected method.
- // See res/menu/actions.xml for more info.
- public void onSort(MenuItem item) {
+ private void onSort(MenuItem item) {
mSortMode = item.getItemId();
// Request a call to onPrepareOptionsMenu so we can change the sort icon
supportInvalidateOptionsMenu();
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/RecentSuggestionsProvider.java b/samples/Support7Demos/src/com/example/android/supportv7/app/RecentSuggestionsProvider.java
new file mode 100644
index 000000000..8d6666d1a
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/RecentSuggestionsProvider.java
@@ -0,0 +1,28 @@
+/*
+ * 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.app;
+
+import android.content.SearchRecentSuggestionsProvider;
+
+public class RecentSuggestionsProvider extends SearchRecentSuggestionsProvider {
+ public final static String AUTHORITY = "com.example.android.supportv7.RecentSuggestionsProvider";
+ public final static int MODE = DATABASE_MODE_QUERIES;
+
+ public RecentSuggestionsProvider() {
+ setupSuggestions(AUTHORITY, MODE);
+ }
+} \ No newline at end of file
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/SearchActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/app/SearchActivity.java
new file mode 100644
index 000000000..622516f7a
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/SearchActivity.java
@@ -0,0 +1,45 @@
+/*
+ * 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.app;
+
+import android.app.Activity;
+import android.app.SearchManager;
+import android.content.Intent;
+import android.os.Bundle;
+import android.provider.SearchRecentSuggestions;
+
+/**
+ * An Activity which is only used for recieving ACTION_SEARCH intents, saving any queries
+ * to our SearchRecentSuggestions so that SearchView's can display suggestions.
+ */
+public class SearchActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Get the intent, verify the action and get the query
+ Intent intent = getIntent();
+ if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
+ String query = intent.getStringExtra(SearchManager.QUERY);
+ SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
+ RecentSuggestionsProvider.AUTHORITY, RecentSuggestionsProvider.MODE);
+ suggestions.saveRecentQuery(query, null);
+ finish();
+ }
+ }
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarDisplayOptions.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarDisplayOptions.java
new file mode 100644
index 000000000..f5c3d7587
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarDisplayOptions.java
@@ -0,0 +1,129 @@
+/*
+ * 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.app;
+
+import com.example.android.supportv7.R;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBar.Tab;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.Gravity;
+import android.view.Menu;
+import android.view.View;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.ArrayAdapter;
+import android.widget.Toast;
+
+/**
+ * This demo shows how various action bar display option flags can be combined and their effects
+ * when used on a Toolbar-provided Action Bar
+ */
+public class ToolbarDisplayOptions extends ActionBarActivity
+ implements View.OnClickListener {
+
+ private View mCustomView;
+ private ActionBar.LayoutParams mCustomViewLayoutParams;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.toolbar_display_options);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ findViewById(R.id.toggle_home_as_up).setOnClickListener(this);
+ findViewById(R.id.toggle_show_home).setOnClickListener(this);
+ findViewById(R.id.toggle_use_logo).setOnClickListener(this);
+ findViewById(R.id.toggle_show_title).setOnClickListener(this);
+ findViewById(R.id.toggle_show_custom).setOnClickListener(this);
+ findViewById(R.id.cycle_custom_gravity).setOnClickListener(this);
+ findViewById(R.id.toggle_visibility).setOnClickListener(this);
+
+ // Configure several action bar elements that will be toggled by display options.
+ mCustomView = getLayoutInflater().inflate(R.layout.action_bar_display_options_custom, null);
+ mCustomViewLayoutParams = new ActionBar.LayoutParams(
+ LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.display_options_actions, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onSupportNavigateUp() {
+ finish();
+ return true;
+ }
+
+ @Override
+ public void onClick(View v) {
+ final ActionBar bar = getSupportActionBar();
+ int flags = 0;
+ switch (v.getId()) {
+ case R.id.toggle_home_as_up:
+ flags = ActionBar.DISPLAY_HOME_AS_UP;
+ break;
+ case R.id.toggle_show_home:
+ flags = ActionBar.DISPLAY_SHOW_HOME;
+ break;
+ case R.id.toggle_use_logo:
+ flags = ActionBar.DISPLAY_USE_LOGO;
+ getSupportActionBar().setLogo(R.drawable.ic_media_play);
+ break;
+ case R.id.toggle_show_title:
+ flags = ActionBar.DISPLAY_SHOW_TITLE;
+ break;
+ case R.id.toggle_show_custom:
+ flags = ActionBar.DISPLAY_SHOW_CUSTOM;
+ break;
+ case R.id.cycle_custom_gravity: {
+ ActionBar.LayoutParams lp = mCustomViewLayoutParams;
+ int newGravity = 0;
+ switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
+ case Gravity.LEFT:
+ newGravity = Gravity.CENTER_HORIZONTAL;
+ break;
+ case Gravity.CENTER_HORIZONTAL:
+ newGravity = Gravity.RIGHT;
+ break;
+ case Gravity.RIGHT:
+ newGravity = Gravity.LEFT;
+ break;
+ }
+ lp.gravity = lp.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK | newGravity;
+ bar.setCustomView(mCustomView, lp);
+ return;
+ }
+ case R.id.toggle_visibility:
+ if (bar.isShowing()) {
+ bar.hide();
+ } else {
+ bar.show();
+ }
+ return;
+ }
+
+ int change = bar.getDisplayOptions() ^ flags;
+ bar.setDisplayOptions(change, flags);
+ }
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarFragmentPagerMenu.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarFragmentPagerMenu.java
new file mode 100644
index 000000000..9b579338c
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarFragmentPagerMenu.java
@@ -0,0 +1,171 @@
+/*
+ * 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.app;
+
+import com.example.android.supportv7.R;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Demonstrates how fragments can participate in the options menu from within a {@link ViewPager}.
+ */
+public class ToolbarFragmentPagerMenu extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.toolbar_fragment_pager);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ ViewPager vp = (ViewPager) findViewById(R.id.viewpager);
+ PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager(),
+ new MenuFragment(), new Menu2Fragment());
+ vp.setAdapter(adapter);
+ }
+
+ private static class PagerAdapter extends FragmentPagerAdapter {
+ private final List<Fragment> mFragments;
+
+ public PagerAdapter(FragmentManager fm, Fragment... fragments) {
+ super(fm);
+
+ mFragments = new ArrayList<Fragment>();
+ for (Fragment fragment : fragments) {
+ mFragments.add(fragment);
+ }
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ return mFragments.get(position);
+ }
+
+ @Override
+ public int getCount() {
+ return mFragments.size();
+ }
+ }
+
+ /**
+ * A fragment that displays a menu. This fragment happens to not
+ * have a UI (it does not implement onCreateView), but it could also
+ * have one if it wanted.
+ */
+ public static class MenuFragment extends Fragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ MenuItemCompat.setShowAsAction(menu.add("Menu 1a"), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+ MenuItemCompat.setShowAsAction(menu.add("Menu 1b"), MenuItemCompat.SHOW_AS_ACTION_NEVER);
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ TextView textView = new TextView(container.getContext());
+
+ textView.setText(getClass().getSimpleName());
+ textView.setGravity(Gravity.CENTER);
+ textView.setLayoutParams(new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+
+ return textView;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getTitle().equals("Menu 1a")) {
+ Toast.makeText(getActivity(), "Selected Menu 1a.", Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ if (item.getTitle().equals("Menu 1b")) {
+ Toast.makeText(getActivity(), "Selected Menu 1b.", Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ /**
+ * Second fragment with a menu.
+ */
+ public static class Menu2Fragment extends Fragment {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ MenuItemCompat.setShowAsAction(menu.add("Menu 2"), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ TextView textView = new TextView(container.getContext());
+
+ textView.setText(getClass().getSimpleName());
+ textView.setGravity(Gravity.CENTER);
+ textView.setLayoutParams(new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+
+ return textView;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getTitle().equals("Menu 2")) {
+ Toast.makeText(getActivity(), "Selected Menu 2.", Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarUsage.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarUsage.java
new file mode 100644
index 000000000..f5ac03b84
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarUsage.java
@@ -0,0 +1,80 @@
+/*
+ * 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.app;
+
+import com.example.android.supportv7.R;
+
+import android.app.SearchManager;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.view.ActionMode;
+import android.support.v7.widget.PopupMenu;
+import android.support.v7.widget.SearchView;
+import android.support.v7.widget.Toolbar;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * This demonstrates idiomatic usage of the Toolbar as the action bar.
+ */
+public class ToolbarUsage extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.toolbar_usage);
+
+ // Retrieve the Toolbar from our content view, and set it as the action bar
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.actions, menu);
+
+ // Retrieve the SearchView and plug it into SearchManager
+ final SearchView searchView = (SearchView) MenuItemCompat
+ .getActionView(menu.findItem(R.id.action_search));
+
+ SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
+ searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
+ return true;
+ }
+
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java b/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java
index ba4f0cb1d..ca0c08aac 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/view/CardViewActivity.java
@@ -16,6 +16,8 @@
package com.example.android.supportv7.view;
import android.app.Activity;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.ViewCompat;
@@ -25,8 +27,11 @@ import android.view.ViewGroup;
import android.widget.RadioGroup;
import android.widget.SeekBar;
import android.widget.TextView;
+
import com.example.android.supportv7.R;
+import java.lang.reflect.Field;
+
public class CardViewActivity extends Activity {
CardView mCardView;
@@ -84,7 +89,7 @@ public class CardViewActivity extends Activity {
lp = setViewBounds(mInfoText);
}
mInfoText.setText("radius: " + mCornerRadiusSeekBar.getProgress()
- +", alpha: " + mAlphaSeekBar.getProgress()
+ + ", alpha: " + mAlphaSeekBar.getProgress()
+ "\n w: " + lp.width + "\nh: " + lp.height
+ "\nelevation: " + mCardView.getCardElevation() + " of "
+ mCardView.getMaxCardElevation());
@@ -143,15 +148,42 @@ public class CardViewActivity extends Activity {
}
});
- update();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
View content = findViewById(android.R.id.content);
+ mWidthSeekBar.setProgress(mCardView.getWidth());
+ mHeightSeekBar.setProgress(mCardView.getHeight());
mWidthSeekBar.setMax(content.getWidth());
mHeightSeekBar.setMax(content.getHeight());
+ update();
}
}, 100);
+
+ ((RadioGroup) findViewById(R.id.select_bg_color_radio))
+ .setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ mCardView.setCardBackgroundColor(
+ getResources().getColor(getColorId(checkedId)));
+ }
+ });
}
+ private int getColorId(int id) {
+ switch (id) {
+ case R.id.yellow:
+ return R.color.card_yellow;
+ case R.id.aquatic:
+ return R.color.card_aquatic;
+ case R.id.classic:
+ return R.color.card_classic;
+ case R.id.sunbrite:
+ return R.color.card_sunbrite;
+ case R.id.tropical:
+ return R.color.card_tropical;
+ default:
+ return R.color.cardview_light_background;
+ }
+ }
}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java b/samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java
index 50fe1e1a8..b503bcf0e 100644
--- a/samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java
+++ b/samples/Support7Demos/src/com/example/android/supportv7/widget/AnimatedRecyclerView.java
@@ -480,7 +480,7 @@ public class AnimatedRecyclerView extends Activity {
}
public void selectItem(MyViewHolder holder, boolean selected) {
- mSelected.put((String) holder.textView.getText(), selected);
+ mSelected.put((String) holder.textView.getText().toString(), selected);
}
public void toggleExpanded(MyViewHolder holder) {
diff --git a/tools/idegen/src/Configuration.java b/tools/idegen/src/Configuration.java
index 2f800b11a..c09be1a40 100644
--- a/tools/idegen/src/Configuration.java
+++ b/tools/idegen/src/Configuration.java
@@ -132,7 +132,7 @@ public class Configuration {
String path = file.getPath().substring(2);
// Keep track of source roots for .java files.
- if (path.endsWith(".java")) {
+ if (path.endsWith(".java") && !file.isDirectory()) {
if (firstJavaFile) {
// Only parse one .java file per directory.
firstJavaFile = false;